akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.lang.Math.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int W = sc.nextInt();
		long[][] dp = new long[N + 1][W + 1];
		int[] wList = new int[N];
		long[] vList = new long[N];
		for (int i = 0; i < N; i++) {
			wList[i] = sc.nextInt();
			vList[i] = sc.nextInt();
		}
		for (int i = 0; i < N + 1; i++) {
			dp[0][i] = 0;
		}

		for (int i = 1; i < N + 1; i++) {
			for (int j = 0; j < W + 1; j++) {
				if (j - wList[i - 1] >= 0) {
					dp[i][j] = Math.max(dp[i - 1][j], dp[i - 1][j - wList[i - 1]] + vList[i - 1]);
				} else {
					dp[i][j] = dp[i - 1][j];
				}
			}
		}

		System.out.println(dp[N][W]);
	}

}

Measured memory_bytes: 124116
#include<stdio.h>
#include<math.h>
long long num[200000+50];
typedef long long ll;
int main()
{
	ll n;
	while(scanf("%lld",&n)!=EOF)
	{
		ll i,sn=0;
		ll k;
		for(i=0;i<n;i++)
		{
			scanf("%lld",&num[i]);
			sn+=num[i];
		}
		k=fabs(sn-2*num[0]);
		for(i=0;i<n-1;i++)
		{
			sn-=2*num[i];
			if(k>fabs(sn))
			k=fabs(sn);
		}
		if(k<0)
		k*=-1;
		printf("%lld\n",k);
	}
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int counter = 0;
		while (scanner.hasNext()) {

			if (counter == 0) {
				counter = scanner.nextInt();
				if (counter == 0) {
					break;
				}
			}

			int sum = 0;
			int max = -1;
			int min = 1001;
			for (int i = 0; i < counter; i++) {

				int point = scanner.nextInt();

				sum = sum + point;

				if (max < point) {
					max = point;
				}
				if (min > point) {
					min = point;
				}
			}
			System.out.println((sum - max - min) / (counter - 2));

			counter = 0;
		}

		scanner.close();
	}
}



Measured memory_bytes: 28488
#include <iostream>
#include<iomanip>
#include <cmath>
#include <climits>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
#include <tuple>
#include <map>
#include <list>
#include <string>
#include <numeric>
#include <utility>
#include <cfloat>

using namespace std;

//bool verified[200000];
//map <char, int> last_index;
//int next_same_char[200000];
int p[10];
int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> p[i];
    }
    int tmp = 0;
    int max_p = *max_element(p, p + N);
    cout << accumulate(p, p + N, tmp) - max_p / 2 << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x)  (long long)(x).size()
#define sqr(x) (x)*(x)
#define sof sizeof
#define ins insert
#define lowerB lower_bound
#define upperB upper_bound
#define mkp make_pair
#define mod 1000000007
#define mod1 998244353
#define N 100003
#define inf 1e18
#define minf -1e18
#define min3(a,b,c) min(a,min(b,c));
#define max3(a,b,c) max(a,max(b,c));
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::floatfield );std::cout.precision(15)
#define PI M_PI
#define fi first
#define se second
#define here cout<<"RSSB"<<endl
#define showzero cout<<std::showpoint
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define br "\n"
using namespace  std ;
typedef double db;
typedef long long ll ;
typedef vector<int>vi ;
//typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
typedef vector<pll>vpll;
typedef vector<string>vstr;
typedef vector<bool>vbool ;
/*vbool isprime(N,true);
vll spf(N,0);
vll prime;
void sieve()
{
    isprime[0] = isprime[1] = false;
    for(ll i = 2 ; i<N ; i++)
    {
        if(isprime[i])
        {
            for(ll j=2*i ; j<N ; j+=i)
            {
                isprime[j] = false;
                if(spf[j]==0)
                {
                    spf[j] = i;
                }
            }
            prime.pb(i);
        }
    }
}*/
/*ll nck(ll n , ll k ,ll m=1e18+7)
{
    ll i , j,b=1,c=1 ;
    if(n-k<k)
    {
        k = n-k ;
    }
    while(k)
    {
        b*=n ;
        c*=k ;
        ll g = __gcd(b,c) ;
        b/=g ;
        c/=g ;
        n--;
        k-- ;
    }
    return(b) ;
}
long long power(long long k , long long n , long long m=mod)
{
    long long res = 1;
    while(n)
    {
        if(n%2!=0)
        {
            res = (res*k)%m ;
        }
        k = (k*k)%m ;
        n = n/2 ;
    }
    return(res) ;
}
void READ(vll &v, ll n)
{
    ll a ;
    for(ll i=0 ; i<n ; i=i+1)
    {
        cin>>a ;
        v.pb(a) ;
    }
}
void PRINT(vll &v , ll a = 0)
{
    //ll a ;
    for(ll i=a ; i<v.size() ; i=i+1)
    {
        v[i] = max((ll)0,v[i]);
        cout<<v[i]<<" " ;
    }
    cout<<"\n" ;
}*/
//ll n,m,k;
//bool ok = true;
int main()
{
    FastIO ;
    PRECISION ;
  	ll n;
    //double p,q,r,u,w ;
    //char ch,chr ;
    //string str,st,str2,str3;
    //ll a1=0,a2=0,b1=0,b2=0,c1=0 ;
    //cin>>str>>str1;
    cin>>n;
    showzero;
    cout<<(db)2*PI*n;
}

Measured memory_bytes: 3800
// Problem : A - Rainy Season
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	string s; cin >> s;
	if (s == "RRR") cout << 3 << endl;
	else {
		if (s == "RRS" || s == "SRR") {
			cout << 2 << endl;
		} else {
			if (s == "SSS") {
				cout << 0 << endl;
			} else {
				cout << 1 << endl;
			}
		}
	}
	return 0;
}
 


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;

int t[100005], x[100005], y[100005];
int n;

int main()
{
	scanf("%d", &n); n++;
	for (int i = 1;i < n;i++) scanf("%d%d%d", t+i, x+i, y+i);
	for (int i = 1;i < n;i++)
	{
		int d = abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
		if (d > t[i]-t[i-1] || (d^(t[i]-t[i-1]))%2)
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {
  
  ll n, k, q;
  cin >> n >> k >> q;
  vec1 c(n, k);
  
  for(int i = 0; i < q; i++) {
    int a;
    cin >> a;
    c.at(a-1)++;
  }
  for(int i = 0; i < n; i++) {
    c.at(i) = c.at(i) - q;
    if(c.at(i) > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int H,W; //H...updown,W...rightleft
    cin >> H;
    cin >> W;
    int kumo[H][W] = {0};
    for(int i = 0;i < H;i++){
        char yoko[W+3] = {0};
        cin >> yoko;
        int k = -1;
        for(int j = 0;j < W;j++){
            if(yoko[j] == 'c'){
                k = 0;
                kumo[i][j] = k;
            }
            else if(k == -1){
                kumo[i][j] = k;
            }
            else{
                k++;
                kumo[i][j] = k;
            }
        }
    }
    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            cout << kumo[i][j];
            if(j != W-1){
                cout << ' ';
            }
        }
        cout << endl;
    }
    return 0;
}
/*AOJ?????????*/

Measured memory_bytes: 3120
import sys
import collections


try:
    sys.stdin = open(sys.path[0] + '/input.txt', 'r')
    sys.stdout = open(sys.path[0] + '/output.txt', 'w')
except FileNotFoundError:
    pass


hmap = collections.defaultdict(int)

for i in range(int(input())):
    s = input()
    hmap[s] += 1


for term in ('AC', 'WA', 'TLE', 'RE'):
    print('{} x {}'.format(term, hmap[term]))


Measured memory_bytes: 9416
#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;


signed main(){
  ll a,b,c;
  cin>>a>>b>>c;
  ll h = pow((a+b+c)*(a-b+c)*(a+b-c)*(c+b-a)/16,0.5);
  cout << h;
  return 0;
}
  

Measured memory_bytes: 256
import math

N,D = (int(i) for i in input().split())
X =[]
for i in range(N):
    X.append([int(j) for j in input().split()])
count = 0

for i in range(N-1):
    for j in range(i+1,N):
        dist = 0
        for k in range(D):
            dist += (X[i][k]- X[j][k])**2
        dist = math.sqrt(dist)
        if dist % 1 == 0 :
            count += 1

print(count)


Measured memory_bytes: 38384
#include<stdio.h>
#include<math.h>


int main(void){


  int i ,j;
  int a[100] = {};
  int n;
  int count = 0;
  int tmp;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }

  for(j = 0; j < n -1; j++){
    for(i = n-1; i > j; i--){
      if(a[i] < a[i - 1]){
        tmp = a[i];
        a[i] = a[i - 1];
        a[i - 1] = tmp;
        count++;
      }
    }
  }

  for(i = 0; i < n-1; i++){
    printf("%d ", a[i]);
  }
  printf("%d\n", a[i]);
  printf("%d\n", count);

  return 0;
}




Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;

int main(){
    
    // 1. 入力情報.
    int H, W, N;
    scanf("%d %d %d", &H, &W, &N);
    
    // 2. ペイント操作の回数.
    int X = max(H, W);
    int ans = N / X;
    if(N % X != 0) ans++;
    
    // 3. 出力.
    printf("%d\n", ans);
    return 0;
    
}

Measured memory_bytes: 256
sum_num = int(input())
result = 0
for num in range(1, sum_num + 1):
	if not ((num % 3 == 0 and num % 5 == 0) or num % 3 == 0 or num % 5 == 0):
		result = result + num
	else:
		continue
print(str(result))


Measured memory_bytes: 9168
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main(int argc , char *argv[]) {
    int n,a, best = 0, gap;

    cin >> n;

    vector<int> list1, list2;
    for(int i=0 ; i<n ; i++) {
        cin >> a; 
        list1.push_back(a);
    } 
     for(int i=0 ; i<n ; i++) {
        cin >> a; 
        list2.push_back(a);
    }  

    for(int i=0 ; i<n ; i++) {
        gap = list1[i] - list2[i];
        best = (best+gap > best) ? best+gap : best;
    }
 
    cout << best;




    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  if(s.at(0)==t.at(2)&&s.at(1)==t.at(1)&&s.at(2)==t.at(0)){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
import sys
from collections import Counter, deque, defaultdict
from math import factorial
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n,m = MAP()
E = [[(0,0,0)]for i in range(m)]
for i in range(m):
    a,b,cost = MAP()
    E[i] = (a-1, b-1, -1*cost)

d = [INF]*n
d[0] = 0
for i in range(n-1):
    for e in E:
        if d[e[0]] != INF and d[e[0]]+e[2] < d[e[1]]:
            d[e[1]] = d[e[0]]+e[2]
res =  d[n-1]

for e in E:
    if d[e[0]] != INF and d[e[0]]+e[2] < d[e[1]]:
            d[e[1]] = d[e[0]]+e[2]




if  res != d[n-1]:
    print('inf')
else:
    print(res*-1)


Measured memory_bytes: 41584
using System;
using System.Collections.Generic;
using System.Linq;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;
using TextReader = System.IO.TextReader;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            var N = consoleReader.Int;
            var a = consoleReader.Split.Int;
            Array.Sort(a);
            return a.Last() - a.First();
        }


        #region いつもの
        private readonly ConsoleReader consoleReader;
        public Program(ConsoleReader consoleReader) { this.consoleReader = consoleReader; }
        static void Main() => Console.WriteLine(new Program(new ConsoleReader(Console.In)).Calc()); static string AllLines<T>(IEnumerable<T> source) => string.Join("\n", source);
        #endregion
    }

#pragma warning disable
    public class ConsoleReader
    {
        private string[] line = Array.Empty<string>();
        private int linePosition;
        private TextReader textReader;
        public ConsoleReader(TextReader tr) { textReader = tr; }
        public int Int => int.Parse(String);
        public long Long => long.Parse(String);
        public double Double => double.Parse(String);
        public string String
        {
            get
            {
                if (linePosition >= line.Length)
                {
                    linePosition = 0;
                    line = textReader.ReadLine().Split();
                }
                return line[linePosition++];
            }
        }
        public class SplitLine
        {
            private string[] splited;
            public SplitLine(ConsoleReader cr) { splited = cr.textReader.ReadLine().Split(); }
            public int[] Int => String.Select(x => int.Parse(x)).ToArray();
            public long[] Long => String.Select(x => long.Parse(x)).ToArray();
            public double[] Double => String.Select(x => double.Parse(x)).ToArray();
            public string[] String => splited;
        }
        public SplitLine Split => new SplitLine(this);
        public class RepeatReader
        {
            ConsoleReader cr; int count;
            public RepeatReader(ConsoleReader cr, int count) { this.cr = cr; this.count = count; }
            public IEnumerable<T> Select<T>(Func<ConsoleReader, T> func) { for (int i = 0; i < count; i++) yield return func(cr); }
            public IEnumerable<string> String { get { for (int i = 0; i < count; i++) yield return cr.String; } }
            public IEnumerable<int> Int { get { for (int i = 0; i < count; i++) yield return cr.Int; } }
            public IEnumerable<double> Double { get { for (int i = 0; i < count; i++) yield return cr.Double; } }
        }
        public RepeatReader Repeat(int count) => new RepeatReader(this, count);
    }
}

Measured memory_bytes: 13396
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<bits/stdc++.h>
using namespace std;

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

//Degree <-> Radian
double toRad(double d){ double rad; rad=d*PI/180; return rad; }
double toDegree(double rad){ double d; d=rad*180/PI; return d; }
//The least common multiple : lcm
ll lcm(int a,int b){ return a*b/__gcd(a,b); }
//素数判定
bool isPrime(int n){
    int i; 
    if(n<2) return 0;
    else if(n==2) return 1;
    if(n%2==0) return 0;
    for(i=3;i*i<=n;i+=2) if(n%i==0) return 0;
    return 1;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s,t,u;
    int a,b;
    cin >> s >> t >> a >> b >> u;
    if(s==u)cout << (a-1) << " " << b ENDL;
    else cout << a << " " << (b-1) ENDL;
    
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int mxN = 2e5 + 5;
const ll INF = 1e18;
int N, M, ls[mxN], rs[mxN];
ll a[mxN], dp[mxN], tree[4 * mxN], lz[4 * mxN];
vector<int> st[mxN], en[mxN];

inline void add(ll* arr, int v, ll val) {
    arr[v] += val;
}

void lazy(int node) {
    add(lz, 2 * node, lz[node]);
    add(tree, 2 * node, lz[node]);
    add(lz, 2 * node + 1, lz[node]);
    add(tree, 2 * node + 1, lz[node]);
    lz[node] = 0;
}

void update(int l, int r, int ql, int qr, ll val, int node) {
    if (ql > qr) {
        return;
    }
    if (ql > r || qr < l) {
        return;
    }
    if (ql <= l && qr >= r) {
        add(tree, node, val);
        add(lz, node, val);
        return;
    }
    lazy(node);
    int mid = l + (r - l) / 2;
    update(l, mid, ql, qr, val, 2 * node);
    update(mid + 1, r, ql, qr, val, 2 * node + 1);
    tree[node] = max(tree[2 * node], tree[2 * node + 1]);
}

ll query(int l, int r, int ql, int qr, int node) {
    if (ql > qr) {
        return -INF;
    }
    if (ql > r || qr < l) {
        return -INF;
    }
    if (ql <= l && qr >= r) {
        return tree[node];
    }
    lazy(node);
    int mid = l + (r - l) / 2;
    return max(query(l, mid, ql, qr, 2 * node), query(mid + 1, r, ql, qr, 2 * node + 1));
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> ls[i] >> rs[i] >> a[i];
        st[ls[i]].push_back(i);
        en[rs[i]].push_back(i);
    }
    ll ans = 0;
    dp[0] = 0;
    for (int i = 1; i <= N; i++) {
        for (int idx : st[i]) {
            update(0, N, 0, i - 1, a[idx], 1);
        }
        dp[i] = query(0, N, 0, i - 1, 1);
        ans = max(ans, dp[i]);
        update(0, N, i, i, dp[i], 1);
        for (int idx : en[i]) {
            update(0, N, 0, ls[idx] - 1, -a[idx], 1);
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 38364
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll gcd(ll a, ll b);
ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int bit(int a, int i){
  return (a >> i) & 1;
}

int main(void){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i];

  int l = 0, r = 0;
  int b = 0;
  ll res = 0;
  while (l < n){
    while (r < n){
      int ok = 1;
      for (int i = 0; i < 20; i++){
        if (bit(b, i) == bit(a[r], i) && bit(a[r], i) == 1){
          ok = 0;
        }
      }
      if (ok){
        b ^= a[r];
        r++;
      }
      else {
        break;
      }
    }
    res += r - l;
    b ^= a[l];
    l++;
  }

  cout << res << endl;

  return 0;
}

ll gcd(ll a, ll b){
  if (a < b)
    return gcd(b, a);
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	ll S;
	scan(S);
	ll absmin=INF;
	while(S>=100){
		absmin=min(absmin,abs(S%1000-753));
		S/=10;
	}
	prin(absmin);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >>n;
  while(n!=0){
    int na=0;
    int zeroc=0;
    int k[n];
    for(int i=0;i<n;i++){
      cin>>k[i];
    }
    for(int i=0;i<n;i++){
      if(k[i]>=2){
        na++;
      }
      if(k[i]==0) zeroc++;
    }
    if(na==0){
      cout <<"NA"<<endl;
    }else{
      cout <<n+1-zeroc<<endl;
    }
  cin >>n;
}
  return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int x, a, b; cin >> x >> a >> b;

    int ans = (x - a) / b;

    cout << (x - a - ans*b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<long long> L) {
  sort(L.begin(), L.end());
  if( accumulate(L.begin(), L.begin() + L.size() - 1, 0) > L.back() ){
    cout << YES << endl;
  }else{
    cout << NO << endl;
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> L(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &L[i]);
  }
  solve(N, std::move(L));
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  char str[11];
  scanf("%s",&str);
  
  int len;
  while(str[++len]!='\0');
  int ans=1;
  
  if(str[0]!='A')
  ans=0;
  
  int i;
  int c=0;
  for(i=1;i<len;i++)
  {
    if(2<=i&&i<=len-2&&str[i]=='C')
        c++;
    
    if(str[i]>='A'&&str[i]<='Z'&&str[i]!='C')
      ans=0;
  }
  
  if(c!=1)
    ans=0;
  
  if(ans)
    printf("AC");
  else
    printf("WA");  
  return 0;

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define w(t) int t;cin>>t;while(t--)
#define pb push_back
#define mk make_pair
#define ascSort(v) sort(v.begin(), v.end())
#define descSort(v) sort(v.begin(), v.end(), greater<int>())
#define ff first
#define ss second
#define pi pair<int,int>
#define vi vector<int>
#define umapi unordered_map<int,int>
#define INF 1000000007
const int mod=1e9+7;
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>PBDS;

void FIO(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	
}
vi visited;
vector<vi>adj;
void dfs(int node, int& cnt){
	visited[node]=1;
	cnt++;
	for(auto nbr:adj[node]){
		if(!visited[nbr	])
			dfs(nbr,cnt);
	}
}
int32_t main(){
	
	//FIO();
	
		int n,m;cin>>n>>m;
		adj=vector<vi>(n);
		visited=vi(n);
		set<pi> s;
		for(int i=0; i<m; i++){
			int x,y;cin>>x>>y;
			x--;y--;
			if(s.find({x,y})==s.end()){
				adj[x].pb(y);adj[y].pb(x);
				s.insert({x,y});s.insert({y,x});
			}
			else
				continue;
		}
		vi ans;
		for(int i=0; i<n; i++){
			if(!visited[i]){
				int cnt=0;
				dfs(i,cnt);
				ans.pb(cnt);
			}
		}
		int mx=ans[0];
		for(int i=0; i<(int)ans.size(); i++){
			mx=max(mx,ans[i]);
		}
		cout<<mx;
	
	


	

	return 0;
		
}





Measured memory_bytes: 46912
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;
const ll mod=1000000007;

int main(){
  int n; cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  sort(ALL(a));
  int ans=a[n-1]-a[0];
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
  int n, m;
  cin >> n >> m;

  vector<int> a(n);

  int sum = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    sum += a[i];
  }

  int ok = 0;
  for(int i = 0; i < n; i++){
    if((double)sum / (4.0 * m) <= a[i]){
      ok++;
    }
    if(ok >= m){
      cout << "Yes";
      return 0;
    }
  }

  cout << "No";

  return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 0x3f3f3f3f;
typedef vector<ll> vll;
typedef pair<ll, ll> Pll;

ll N;

int main() {
    ll N, M;
    cin >> N >> M;
    ll x = (N - M) * 100 + M * 1900;
    ll ans = x * (1 << M);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);

   int K, S;
   cin >> K >> S;
   int pattern = 0;
   for (int x = 0; x <= K; x++) {
      for (int y = 0; y <= K; y++) {
         if (S - (x + y) <= K && S - (x + y) >= 0) pattern++;
      }
   }
   cout << pattern << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits>

using namespace std;
typedef long long ll;

vector<ll> a;
vector<ll> cs;
vector<vector<ll>> dp;

ll calc(ll left, ll right){
    if(left == right){
        return 0;
    }
    if(dp.at(left).at(right) != -1){
        return dp.at(left).at(right);
    }

    ll ans = numeric_limits<ll>::max();
    for(ll x = left + 1; x <= right; ++x){
        ans = min(
            ans,
            cs.at(right + 1) - cs.at(left) + calc(left, x - 1) + calc(x, right)
        );
    }
    dp.at(left).at(right) = ans;
    return ans;
}

int main(){
    ll n;
    cin >> n;
    a.resize(n);
    for(int i = 0; i < n; ++i){
        cin >> a.at(i);
    }

    cs.resize(n + 1, 0);
    for(int i = 1; i <= n; ++i){
        cs.at(i) = cs.at(i - 1) + a.at(i - 1);
    }

    dp.resize(n, vector<ll>(n, -1));
    cout << calc(0, n - 1) << endl; 
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head, const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int h,w;
    while(1){
        scanf("%d %d",&h,&w);
        if(h==0&&w==0)break;
        rep(y,h){
            rep(x,w){
                if((x+y)%2==0)putchar('#');
                else putchar('.');
            }
            putchar('\n');
        }
        putchar('\n');
    }
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#define int long long
int unx(){int x=0,n=0; char c=getchar(); for(;!isdigit(c);c=getchar()) n=(c=='-'); for(;isdigit(c);c=getchar())x=x*10+c-'0'; return (n)?-x:x;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){}
#define in unx()
#define fasty ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define forinc(a,b,c) for(int a=b, _c=c; a<=_c; ++a)
#define fordec(a,b,c) for(int a=b, _c=c; a>=_c; --a)
#define forv(a,b) for(auto &a:b)
#define ii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define mt make_tuple
#define bit(x,i) (x>>(i-1)&1ll)
#define onbit(x,i) (x|(1ll<<(i-1)))
#define offbit(x,i) (x&~(1ll<<(i-1)))

const int N=2e5+5;
int n,m,a[N],dd[N];
vector<int> ad[N];
main(){
  fasty;

  cin>>n>>m;
  forinc(i,1,n) cin>>a[i];
  forinc(i,1,m){
    int u,v;
    cin>>u>>v;
    ad[u].pb(v); ad[v].pb(u);
  }
  int ans=0;
  forinc(i,1,n){
    if(!ad[i].size()) dd[i]=1,ans++;
  }
  forinc(i,1,n){
    forv(v,ad[i]){
      if(a[i]<=a[v]){
        dd[i]=1;
        break;
      }
    }
  }
  ans+=count(dd+1,dd+n+1,0);
  cout<<ans;
}


Measured memory_bytes: 13380
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{

int N, C;
	cin >> N >> C;
	int D[30][30];
	int c[500][500];
	fx(C) {
		fy(C)
		cin >> D[x][y];
	}
	vector<map<int,int>> K(3);
	fx(N) {
		fy(N) {
			cin >> c[x][y];
			K[(x + y + 2) % 3][c[x][y]]++;
		}
	}

	ll ans = LLONG_MAX;
	fx(C) {
		fy(C) {
			if (x == y){ continue; }
			fz(C) {
				if (z == x || z == y) { continue; }
				ll sum = 0;
				fw(C) {
					sum += K[0][w + 1] * D[w][x];
				}
				fw(C) {
					sum += K[1][w + 1] * D[w][y];
				}
				fw(C) {
					sum += K[2][w + 1] * D[w][z];
				}
				ans = min(ans, sum);
			}
		}
	}

	ce(ans)

    return 0;
}



Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;

int main() {
    int a,b;
    cin>>a>>b;
    if(a==1&&b==2) cout<<"3"<<endl;
    else if(a==1&&b==3) cout<<"2"<<endl;
    else if(a==2&&b==1) cout<<"3"<<endl;
    else if(a==2&&b==3) cout<<"1"<<endl;
    else if(a==3&&b==1) cout<<"2"<<endl;
    else if(a==3&&b==2) cout<<"1"<<endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) { 
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = 0;
		try {
			n = Integer.parseInt(br.readLine());
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		for (int i = 1; i <= 9; i++) {
			for (int j = 1; j <= 9; j++) {
				if (i * j == n) {
					System.out.println("Yes");
					System.exit(0);
				}				
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N + 2];
long double pi = 3.14159265;

void solve()
{
	double n;
	cin >> n;
	cout << fixed << setprecision(12) << 2 * pi*n << endl;

}

int32_t main()
{
	ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);






	int test = 1;

	while (test--)solve();


}





Measured memory_bytes: 3804
a = int(input())
b = list(map(int, input().split()))
flag = True
for i in range(len(b)):
  if b[i]%2==0:
    if b[i]%3!=0 and b[i]%5!=0:
      flag = False
      
if flag == True:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3064
N,M = map(int,input().split())
a_list=[]
pass_1= []
for i in range(M):
    a = list(map(int,input().split()))
    if(a[0]==1):
        pass_1.append(a[1])
    elif(a[1]==N):
        a_list.append(a[0])
    
if list(set(pass_1) & set(a_list)):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 115800
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 100;

int n, d[N][5], c[N][5];
int main ()
{
	cin >>n;
	for (int i = 1; i<=n; i++)
	{
		cin >>c[i][1] >>c[i][2] >>c[i][3];
		d[i][1] = max(d[i - 1][2], d[i - 1][3]) + c[i][1];
		d[i][2] = max(d[i - 1][1], d[i - 1][3]) + c[i][2];
		d[i][3] = max(d[i - 1][2], d[i - 1][1]) + c[i][3];
	}
	cout <<max(max(d[n][1], d[n][2]), d[n][3]);
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
	int N;
	vector<pair<int, int>> P;

	cin >> N;
	for(int i = 0; i < N; i++) {
		int A;
		cin >> A;
		P.push_back(make_pair(A, i));
	}
	sort(P.begin(), P.end());

	int ma = -1;
	int cnt = 1;
	for(int i = 1; i < N; i++) {
		if(P[i - 1].second < P[i].second) {
			cnt++;
		} else {
			ma = max(ma, cnt);
			cnt = 1;
		}
	}
	if(cnt == N) cout << '0' << endl;
	else cout << (N - ma) << endl;

	return 0;
}



Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int R;

    cin >> R;

    if(R < 1200){
        cout << "ABC" << endl;
    }
    else if(R < 2800){
        cout << "ARC" << endl;
    }
    else{
        cout << "AGC" << endl;
    }

}


Measured memory_bytes: 256
n = int(input())
s = set()
s.add(n)
i = 1
while True:
  i += 1
  if n % 2 == 0:
    n = n / 2
  else:
    n = 3 * n + 1
  if n in s:
    print(i)
    break
  s.add(n)


Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
using namespace std;

int main() {
    char ch;
    int count[26] = {};
    
    while(cin >> ch) {
        ch = tolower(ch);
        if (isalpha(ch)) {
            count[ch - 'a']++;
        }
    }
    for (int i = 0; i < 26; i++) {
        printf("%c : %d\n", i + 'a' ,count[i]);
    }
    return 0;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i = 0; i < (n); i++)

typedef pair<int, int> P;

struct Edge {int to, id;};

vector<vector<Edge>> g;
vector<int> ans;

void dfs(int v, int c = -1, int p = -1){
    int k = 1;
    rep(i,g[v].size()){
        int u = g[v][i].to, ei = g[v][i].id;
        if(u == p) continue;
        if(k == c) ++k;
        ans[ei] = k; ++k;
        dfs(u,ans[ei], v); 
    }
}

int main() {
    int n;
    cin >> n;

    g.resize(n);
    ans = vector<int>(n-1);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        --a; --b;
        g[a].push_back((Edge){b,(int)i});
        g[b].push_back((Edge){a,(int)i});
    }
    dfs(0);
    int mx = 0;
    rep(i,n) mx = max(mx, int(g[i].size()));
    cout << mx << endl;
    rep(i,n-1){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2")

using namespace std;

#define int long long
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int total = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        total += a[i];
    }
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (total <= 4 * m * a[i]) cnt++;
    }
    if (cnt >= m) cout << "Yes\n";
    else cout << "No\n";
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int t;
//    cin >> t;
t = 1;
    while (t--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	set<string> s;
	for(int i=0;i<n;i++)
	{
		string letters;
		cin>>letters;
		s.insert(letters);
	}
	cout<<s.size();
	
	return 0;
}

Measured memory_bytes: 19228
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <stack>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#define F first
#define S second
#define PII pair<int, int>
typedef long long LL;


using namespace std;

const int N = 1e5 + 10;
const LL INF = 1e16;
vector<LL> v;
LL n, a[N], r[N], ans;
map<int, bool> mp;

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i % 2)
      mp[a[i]] = true;
    r[i] = a[i];
  }
  sort(r, r + n);
  for (int i = 0; i < n; i++) {
    if (i % 2 && !mp[r[i]])
      ans++;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;

int t[101]={0};

int main(){
    int n, m;
    cin >> n;
    for(int i=0;i<n;++i)cin >> t[i];
    cin >> m;
    vector<pair<int, int> > d;
    for(int i=0;i<m;++i){
        int p, x;
        cin >> p >> x;
        d.push_back(pair<int, int>(p-1, x));
    }

    for(int i=0;i<m;++i){
        int sum = 0;
        for(int j=0;j<n;++j){
            if(d[i].first == j)sum += d[i].second;
            else sum += t[j];
        }
        cout << sum << endl;
    }

    return 0;
}


Measured memory_bytes: 256
using System.Collections.Generic;
using static System.Console;

class Program {
	static void Main() {
		var a = NextInt();
		var b = NextInt();

		var ans = 0;
		for (var i = 1; i < b - a; i++) {
			ans += i;
		}
		ans -= a;
		WriteLine(ans);
	}

	static int NextInt() {
		return int.Parse(NextString());
	}

	static string NextString() {
		var result = new List<char>();
		while (true) {
			int next = Read();
			if (next < 0)
				break;
			var nextChar = (char)next;
			if (!char.IsWhiteSpace(nextChar))
				result.Add(nextChar);
			else if (nextChar != '\r')
				break;
		}
		return string.Join("", result);
	}
}

Measured memory_bytes: 13268
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()
const int INF = 1e9;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
//typedef pair<int, int> P;

/* struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
}; */


/** 幾何ライブラリ **/
// to do : 1183

#include <complex>

#define X real()
#define Y imag()

const double EPS = 1e-11;

typedef double D;
typedef complex<D> P; // Point

struct L { // Line
	P a, b;
	L(){}
	L(P aa, P bb) : a(aa), b(bb){}
};

// 共役複素数 conj(a);

// 符号
int sig(D a, D b=0) { return a < b - EPS ? -1 : (a > b + EPS ? 1 : 0); }

// 内積
D dot(P a, P b) { return (conj(a)*b).real(); }

// 外積
D cross(P a, P b) { return (conj(a)*b).imag(); }

// 線分abに対する点cの位置
enum CCW{LEFT=1, RIGHT=-1, BACK=2, FRONT=-2, ON=0};
int ccw(P a, P b, P c)
{
	b -= a, c -= a;
	D s = sig(cross(b, c));
	if (s) return s>0 ? LEFT : RIGHT;
	if (sig(dot(b, c))<0) return BACK;
	if (sig(abs(c), abs(b))>0) return FRONT;
	return ON;
}

// 直線abと点cの距離
D distLP(L l, P c)
{
	return abs(cross(l.b-l.a, c-l.a))/abs(l.b-l.a);
}

// 線分abと点cの距離
D distSP(L l, P c)
{
	if (sig(dot(l.b-l.a, c-l.a))<0) return abs(c-l.a);
	if (sig(dot(l.a-l.b, c-l.b))<0) return abs(c-l.b);
	return abs(cross(l.b-l.a, c-l.a))/abs(l.b-l.a);
}

// 線分と線分の交差判定
bool iSS(L s, L t)
{
	return (ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0)
			&& (ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0);
}

// 線分と線分の交点 (公差していることが前提)
P cSS(L s, L t)
{
	D d1 = distLP(t, s.a);
	D d2 = distLP(t, s.b);
	D tmp = d1 / (d1 + d2);
	return s.a + (s.b-s.a)*tmp;
}

// 直線と直線の交差判定
bool iLL(L s, L t)
{
	return sig(cross(s.b-s.a, t.b-t.a))!=0;
}

/** Problem CGL_2-A : Parallel/Orthogonal **/
 int main()
 {
	L s, t;
	int q; cin>>q;
	rep(i, q) {
		cin>>s.a.X>>s.a.Y>>s.b.X>>s.b.Y;
		cin>>t.a.X>>t.a.Y>>t.b.X>>t.b.Y;
		
		cout << fixed << setprecision(15);
		if (sig(cross(s.a-s.b, t.a-t.b))==0) cout << 2 << endl;
		else if (sig(dot(s.a-s.b, t.a-t.b))==0) cout << 1 << endl;
		else cout << 0 << endl;
	}
 }

Measured memory_bytes: 1240
/*
 */

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// std::ios::sync_with_stdio(false);

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
    int N,Y;
    while (cin >> N >> Y) {
        int ans[] = {-1,-1,-1};
        FOR(i,0,N+1) FOR(j,0,N+1) if (i+j <= N) {
            const int k = N-i-j;
            const int a = 10000*i;
            const int b = 5000*j;
            const int c = 1000*k;
            if (a+b+c == Y) {
                ans[0] = i; ans[1] = j; ans[2] = k;
                break;
            }
        }
        FOR(i,0,3)
            cout << ans[i] << ' ';
        cout << endl;

    }
    return 0;
}


Measured memory_bytes: 256
def check(i):
	tot=k
	pw=0
	while(tot%i==0):
		tot//=i
		pw+=1
	if(tot%i==1):
		other = tot//i
		if(pw==0 and other>=2 and other<=k):
			setl.add(other)
		setl.add(i)

import math
k=int(input())
if(k==2):
	print(1)
	exit()
setl = set()
setl.add(k); setl.add(k-1)
for x in range(2,int(math.sqrt(k))+1):
	check(x)
	# check(k//x)
print(len(setl))

Measured memory_bytes: 3064
#include <bits/stdc++.h>

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  vector<int> a;
  Solver(LL n) : n(n), a(n){};

  void solve() {
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    int lb = 0, ub = n;
    while (ub - lb > 1) {
      int mid = (lb + ub) / 2;
      if (check(mid)) {
        ub = mid;
      } else {
        lb = mid;
      }
    }
    cout << ub << endl;
  }
  bool check(int x) {
    DBG(x)
    vector<pair<int, int>> str;
    int len = a[0];
    for (int i = 1; i < n; ++i) {
      if (a[i] > len) {
        len = a[i];
        continue;
      } else {
        len = a[i];
        while (str.size() > 0 && str.back().first > a[i]) {
          str.pop_back();
        }
        if (!nextstr(str, len, x)) {
          return false;
        }
      }
      DBG(str)
    }
    return true;
  }
  int nextstr(vector<pair<int, int>>& str, int l, int types) {
    int p = l;
    while (p > 0 && str.size() > 0 && str.back().first == p && str.back().second == types) {
      str.pop_back();
      p--;
    }
    if (p == 0) {
      return 0;
    }
    if (str.size() == 0 || str.back().first < p) {
      if (types == 1) return 0;
      str.emplace_back(p, 2);
      return 1;
    }
    str.back().second++;
    return 1;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#define NIL -1

struct Node { int p, l, r; };
struct Node T[1000];

void preorder(int u) {
  if (u == NIL) return;
  printf(" %d", u);
  preorder(T[u].l);
  preorder(T[u].r);
}

void inorder(int u) {
  if (u == NIL) return;
  inorder(T[u].l);
  printf(" %d", u);
  inorder(T[u].r);
}

void postorder(int u) {
  if (u == NIL) return;
  postorder(T[u].l);
  postorder(T[u].r);
  printf(" %d", u);
}

int main() {
  int n, v, r, l, root;

  scanf("%d", &n);

  for ( int i = 0; i < n; i++) {
    T[i].p = NIL;
  }

  for ( int i = 0; i < n; i++) {
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if (l != NIL) T[l].p = l;
    if (r != NIL) T[r].p = r;
  }

  for (int i = 0; i < n; i++) {
    if ( T[i].p == NIL ) root = i;
  }

  printf("Preorder\n");
  preorder(root);
  printf("\n");
  printf("Inorder\n");
  inorder(root);
  printf("\n");
  printf("Postorder\n");
  postorder(root);
  printf("\n");

  return 0;
}


Measured memory_bytes: 2712