akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}



signed main() {
	int a, b, t;
	cin >> a >> b >> t;
	cout << t / a * b << endl;
}


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

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(int _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(int _##i = (t), i = (f); i <  _##i; i++)
#define downto(f, t, i)  for(int _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(int _##i = (t), i = (f); i >  _##i; i--)
typedef long double LD;
#define long long long

#if defined(EBUG) && !defined(ONLINE_JUDGE)
#define debug true
#define ln << endl
#else
#define debug false
#define ln << '\n'
#endif
#define tb << '\t'
#define sp << ' '



signed main() { // long: 64bit
    if(!debug) {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }

    int N, M, R; cin >> N >> M >> R;

    vector<int> T(R); times(R, i) { cin >> T[i]; --T[i]; }

    vector<vector<long>> dist(N, vector<long>(N, 1e14));
    times(M, i) {
        int A, B, C; cin >> A >> B >> C; --A; --B;
        dist[A][B] = dist[B][A] = C;
    }

    times(N, k) times(N, i) times(N, j) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }

    vector<int> order(R); iota(order.begin(), order.end(), 0);
    long ans = 1e18;
    do {
        long d = 0;
        times(R - 1, i) {
            d += dist[T[order[i]]][T[order[i + 1]]];
        }
        ans = min(ans, d);
    } while(next_permutation(order.begin(), order.end()));

    cout << ans;

    return 0;
}


Measured memory_bytes: 640
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}


n,m,k = map(int,input().split())
uf = UnionFind(n)
friends = [0]*n
blocks = [0]*n

for i in range(m):
    a,b = map(int,input().split())
    uf.union(a-1,b-1)
    friends[a-1] += 1
    friends[b-1] += 1

for i in range(k):
    c,d = map(int,input().split())
    if uf.same(c-1,d-1):
        blocks[c-1] += 1
        blocks[d - 1] += 1

print(' '.join([str(uf.size(i) - friends[i] - blocks[i] - 1) for i in range(n)]))


Measured memory_bytes: 15556
if __name__ == '__main__':
    N=int(input())
    F=[]
    P=[]
    m=-10**10
    for i in range(N):
        temp=input().split()
        F.append(temp)
    for i in range(N):
        temp = list(map(int, input().split()))
        P.append(temp)

    for i in range(1,2**10):
        binary=i
        profit=0
        for j in range(N):
            f_binary=int(''.join(F[j]),2)
            number=binary&f_binary
            count=0
            while number>0:
                number&=number-1
                count+=1
            profit+=P[j][count]
        m=max(m,profit)
    print(m)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	string s, t; cin >> s >> t;
	int table[26][26];
	for(int i = 0; i < 26; i++) {
		for(int j = 0; j < 26; j++) {
			table[i][j] = 0;
		}
	}
	for(int i = 0; i < s.size(); i++) {
		table[s[i] - 'a'][t[i] - 'a']++;
	}
	for(int i = 0; i < 26; i++) {
		bool flag = false;
		for(int j = 0; j < 26; j++) {
			if(!flag && table[i][j] != 0) {
				flag = true;
				continue;
			}
			if(flag && table[i][j] != 0) {
				cout << "No" << endl;
				return 0;
			}
		}
		flag = false;
		for(int j = 0; j < 26; j++) {
			if(!flag && table[j][i] != 0) {
				flag = true;
				continue;
			}
			if(flag && table[j][i] != 0) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
				
	return 0;                                              
}
	


Measured memory_bytes: 916
p1,p2,p3 = 380,550,850
q1,q2,q3 = 200,300,500
d1,d2,d3 = 5,4,3
r1,r2,r3 = 0.2,0.15,0.12
arr = []
for tot in range(500,5001,100):
    lst = 1000000000
    for i in range(0,int(tot/q1)+1):
        for j in range(0,int(tot/q2)+1):
            for k in range(0,int(tot/q3)+1):
                if i*q1+j*q2+k*q3 == tot:
                    tmp = i*p1+j*p2+k*p3 - int(i/d1)*d1*p1*r1 - int(j/d2)*d2*p2*r2 - int(k/d3)*d3*p3*r3
                    lst = min(tmp,lst)
    arr.append([tot,int(lst)])
dic = dict(arr)
while(True):
    n = int(input())
    if n == 0:
        break
    print(dic[n])


Measured memory_bytes: 5628
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> v(n);
  long long res = 0;
  for(int i = 0; i < n; i++){
    cin >> v[i];
    res += v[i];
  }
  sort(v.begin(), v.end());
  for(int i = 0; i < n; i++){
    if(res%10 == 0) res -= v[i];
    if(res%10 != 0){
      cout << res << endl;
      return 0;
    }
    res += v[i];
  }
  cout << 0 << endl;
  return 0;
}
    

Measured memory_bytes: 256
#include "bits/stdc++.h"

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)
typedef long long ll;

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);
int gcd(int a, int b);

int calc(int n, int m, vector<int> x) {
    if(n > m) {
        return 0;
    }

    sort(x.begin(), x.end());
    vector<int> diff(m-1);
    for(int i=0; i<diff.size(); i++) {
        diff[i] = x[i+1] - x[i]; 
    }

    sort(diff.begin(), diff.end());
    int sum = 0; 
    for(int i=0; i<diff.size() - n + 1; i++) {
        sum += diff[i];
    }
    return sum;
}
int main() {
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for(int i=0; i<m; i++) cin >> x[i];

    cout << calc(n, m, x) << endl;
    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

int sum_digits(int num) {
    int rtn = 0;
    while(num != 0) {
        int tmp = num % 10; 
        rtn += tmp;
        num /= 10; 
    }   
    return rtn;
}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}

// ユークリウッドの互除法
int gcd(int a, int b) {
    if(b==0) return a;
    else return gcd(b, a % b);
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/

const int mx=100010;
const ll mod=1e9+7;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; }
    mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { mint res(*this); return res+=a; }
    mint operator-(const mint a) const { mint res(*this); return res-=a; }
    mint operator*(const mint a) const { mint res(*this); return res*=a; }
    mint pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; }
    // for prime mod
    mint inv() const { return pow(mod-2); }
    mint& operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const { mint res(*this); return res/=a; }
};

vector<int> v[mx];
int n,k;
mint ans = 1;

void dfs(int x, int p){
  ll col = (p==-1 ? k-1 : k-2);
  for(auto to:v[x]){
    if(to==p) continue;
    ans *= col;
    col--;
    dfs(to,x);
  }
}

int main(){  
  cin >> n >> k;
  rep(i,n-1){
    int a,b; cin >> a >> b; a--; b--;
    v[a].emplace_back(b);
    v[b].emplace_back(a);
  }
  dfs(0,-1);
  ans *= k;
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 11008
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int s = nextInt();

		long ans = 1;
		long[] a = new long[1000000];
		Arrays.fill(a, -1);
		a[0]=s;
		int k=1;
		boolean flg=true;
		while(flg){
			if(a[k-1]%2==0){
				a[k]=a[k-1]/2;
			}else{
				a[k]=a[k-1]*3+1;

			}
			for(int i=0;i<k;i++){
				if(a[k]==a[i]){
					flg=false;
					break;
				}
			}
			k++;
		}
		System.out.println(k);
	}

	public static boolean isExpN(long a,int base){
		int x=1;
		while((int)Math.pow(x, 2) <= a){
			if((int)Math.pow(x, 2) == a){
				return true;
			}
			x*=base;
		}
		return false;
	}
	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 29652
local mod = 1000000007
local function badd(x, y) return (x + y) % mod end
local mfl = math.floor

local function bmul(x, y)
  local x1, y1 = mfl(x / 31623), mfl(y / 31623)
  local x0, y0 = x - x1 * 31623, y - y1 * 31623
  return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod
end

local function modpow(src, pow)
  local res = 1
  while 0 < pow do
    if pow % 2 == 1 then
      res = bmul(res, src)
      pow = pow - 1
    end
    src = bmul(src, src)
    pow = mfl(pow / 2)
  end
  return res
end

local function modinv(src)
  return modpow(src, mod - 2)
end

local n = io.read("*n", "*l")
local _u = io.read()
local slen = #_u
local dp1, dp2 = {}, {}
dp1[1] = 1
for i = 1, n do
  local src = i % 2 == 1 and dp1 or dp2
  local dst = i % 2 == 1 and dp2 or dp1
  for j = 1, i + 1 do
    dst[j] = 0
  end
  dst[1] = src[1]
  dst[2] = badd(dst[2], src[1] + src[1])
  for j = 2, i do
    dst[j - 1] = badd(dst[j - 1], src[j])
    dst[j + 1] = badd(dst[j + 1], src[j] + src[j])
  end
end

local tbl = n % 2 == 0 and dp1 or dp2
local ret = tbl[1 + slen]
local denom = modinv(modpow(2, slen))
print(bmul(ret, denom))


Measured memory_bytes: 2816
#include <iostream>
#include <algorithm>
#include <list>

using namespace std;

const int MAX = 1e5 + 9;
const long long INF = 1e18 + 9;

bool cmp(const pair<long long, int> &a, const pair<long long, int> &b) {
	return a.first > b.first;
}

pair<long long, int> a[MAX];
int kind[MAX];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i].second >> a[i].first;
	}
	sort(a, a + n, cmp);
	/*
	for (int i = 0; i < n; i++) {
		auto sushi = a[i];
		cerr << sushi.first << ' ' << sushi.second << '\n';
	}
	cerr << '\n';
	*/
	list<pair<long, long>> s, b;
	int cnt = 0;
	long long sum = 0;
	for (int i = 0; i < k; i++) {
		if (!kind[a[i].second]) {
			cnt++;
			s.push_back(make_pair(INF, a[i].second));
		} else {
			s.push_front(a[i]);
		}
		kind[a[i].second]++;
		sum += a[i].first * 1LL;
	}
	for (int i = k; i < n; i++) {
		b.push_back(make_pair(a[i].first, a[i].second));
	}
//	cerr << cnt << ' ' << sum << '\n';
	long long ret = cnt * cnt * 1LL + sum * 1LL;
	while (!b.empty() && s.front().first != INF) {
		if (!kind[(*b.begin()).second]) {
			sum -= s.front().first * 1LL;
			sum += b.front().first * 1LL;
			kind[s.front().second]--;
			kind[b.front().second]++;
			s.pop_front();
			cnt++;
			s.push_back(make_pair(INF, (*b.begin()).second));
			ret = max(ret, cnt * cnt * 1LL + sum * 1LL) * 1LL;
			/*
			for (auto sushi : s) {
				cerr << sushi.first << ' ' << sushi.second << '\n';
			}
			cerr << '\n';
			*/
		}
		b.pop_front();
	}
	//cerr << cnt << ' ' << sum << '\n';
	cout << ret << '\n';
	
	return 0;
}


Measured memory_bytes: 6912
#include<stdio.h>

int ab(int a){
	if(a<0)return -a;
	return a;
}

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

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



int main(void){
    // Your code here!
  
    string t;
    cin>>t;
    
    int maxv = -1, cnt=0;
    
    for(int i=0;i<t.size();i++) if(t[i]=='?') t[i]='D';
    
    cout<<t<<endl;
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;

#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pi acos(-1.0)

#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pf(a) printf("%lld\n",a)

#define stll(a) stoll(a,nullptr,10)
#define all(a) a.begin(),a.end()
#define PII pair<ll,ll>
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define EL printf("\n")
#define ff first
#define ss second
#define rev(a) reverse(all(a))


#define mem(ar,val) memset(ar,val,sizeof(ar))
#define ssort(ar) sort(ar.begin(),ar.end())
#define csort(ar,comp) sort(ar.begin(),ar.end(),comp)

#define bug1(a) cerr<<"test "<<a<<endl;
#define bug2(a,b) cerr<<"test "<<a<<" "<<b<<endl;
#define bug3(a,b,c) cerr<<"test "<<a<<" "<<b<<" "<<c<<endl;
#define bug4(a,b,c,d) cerr<<"test "<<a<<" "<<b<<" "<<c<<" "<<d<<endl;

#define fout freopen("output.txt","w",stdout)
#define fin  freopen("input.txt","r",stdin)

/// unordered_map<int,int>mp;
/// mp.reserve(1024);
/// mp.max_load_factor(0.25);

/// pbds
/// *find_by_order(k) - return k th largest element.. 0 based
/// order_of_key(k) - number of items strictly smaller than k

///  priority_queue <ll, vector<ll>, greater<ll> >

/*
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
*/

typedef long long ll;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;


int main()
{
    string st,tt="";
    cin>>st;
    ll n = st.length();
    for(int i=0;i<n;i++)
    {
        if(st[i]=='d')
        {
            if(i+5<n && st[i+5]=='e')
            {
                if(i+7<n && st[i+7]=='a')
                    tt+="dream",i+=4;
                else tt+="dreamer",i+=6;
            }
            else tt+="dream",i+=4;
        }
        else
        {
            if(i+5<n && st[i+5]=='r')
                tt+="eraser",i+=5;
            else tt+="erase",i+=4;
        }
    }
    if(st==tt)
        cout<<"YES\n";
    else cout<<"NO\n";
}












Measured memory_bytes: 3700
N = int(input())
A = list(map(int, input().split()))

dic = {}
dup = set()
for a in A:
    if a in dic:
        dic[a] += 1
        dup.add(a)
    else:
        dic[a] = 1

A_max = max(A)
A.sort()
A_set = set(dic.keys())

cnt = 0
for a in A:
    if a not in A_set:
        continue

    cnt1 = 2
    x = a * cnt1

    while x <= A_max:
        if x in A_set:
            A_set.remove(x)

        cnt1 += 1
        x = a * cnt1


A_set = A_set - dup

print(len(A_set))


Measured memory_bytes: 50516
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

const int mod = 998244353;

int main() {
    ll n, k;
    cin >> n >> k;
    if(n < 2*k-1){
        cout << -1 << endl;
        return 0;
    }

    vector<int> x(n), y(n), z(n);

    for(int i = 0; i < n; i++){
        if(i&1){
            x[i] = k + ((n+1)/2) + i/2;
            y[i] = k + n + i/2;
        }else{
            x[i] = k + i/2;
            y[i] = k + n + n/2 + i/2;
        }
        z[i] = k + 2*n + i;
    }
    for(int i = 0; i < n; i++){
        printf("%d %d %d\n", x[i], y[i], z[i]);
    }
}


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

int main(){
	int a, b;
  	cin >> a >> b;
  	
  	int ans;
	
  	rep(i, 4){
    	if(i == a || i == b) continue;
      	ans = i;
    }
  
  	cout << ans << endl;
}

Measured memory_bytes: 256
def words(n):
    if n==1:return "357"
    A=[]
    for i in "357":
        for j in words(n-1):
            A.append(i+j)
    return A


n=int(input())
m=len(str(n))

cnt=0
for j in range(3,m+1):
    for i in words(j):
        if n>=int(i) and ("3" in i and "5" in i and "7" in i):
            cnt +=1

print(cnt)

Measured memory_bytes: 4852
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};


llong pow(int x, int n){
    llong ans = x;
    if (n == 0) return 1;

    for(int i = 0; i < n - 1; i++) {
        ans *= x;
    }

    return ans;
}


void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}


string toUpper(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = toupper(s[i]);
    }
    return t;
}

string toLower(string s) {
    string t = s;
    REP(i, s.size()) {
        t[i] = tolower(s[i]);
    }
    return t;
}


int main() {
    string s;
    cin >> s;
    cout << s.replace(0, 4, "2018") << endl;

    return 0;
}

Measured memory_bytes: 500
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int,int *> P;
typedef pair<long long,int>PP;
int main(){
  int n,k;
  cin>>n;
  int l=0;
  map<int,int>mp;
  while(mp[n]==0){
    l++;
    mp[n]=1;
    if(n%2==0){
      n=n/2;
    }else{
      n=n*3+1;
    }
  }
  cout<<l+1<<endl;
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <time.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = k; i < n; i++){
        if(a[i] > a[i - k]) cout << "Yes" << "\n";
        else cout << "No" << "\n";
    }
}

Measured memory_bytes: 4836
/* ex3-4
   Sagzar1993  */


#include <stdio.h>

int main(void) {
    int num;

    //入力を受け取る
    scanf("%d", &num);

    //numが各数字で割り切れ、かつその商が１から９の間であるとき、Yesを表示
    if(num % 1 == 0 && num / 1 <= 9){
        printf("Yes\n");
    }else if(num % 2 == 0 && num / 2 <= 9){
        printf("Yes\n");
    }else if(num % 3 == 0 && num / 3 <= 9){
        printf("Yes\n");
    }else if(num % 4 == 0 && num / 4 <= 9){
        printf("Yes\n");
    }else if(num % 5 == 0 && num / 5 <= 9){
        printf("Yes\n");
    }else if(num % 6 == 0 && num / 6 <= 9){
        printf("Yes\n");
    }else if(num % 7 == 0 && num / 7 <= 9){
        printf("Yes\n");
    }else if(num % 8 == 0 && num / 8 <= 9){
        printf("Yes\n");
    }else if(num % 9 == 0 && num / 9 <= 9){
        printf("Yes\n");
    }else{
        printf("No\n"); //どれにも当てはまらなかった場合はNoを表示
    }
    return 0;
}

Measured memory_bytes: 128
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
//--
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<cstdio>
#include<cstring>
#include<sstream>
#include<complex>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()

#define re real()
#define im imag()

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef complex<double> pt;
typedef pair<pt,pt> line; //sX+tY

double dot(pt a,pt b){return (conj(a)*b).real();}
double cros(pt a,pt b){return (conj(a)*b).imag();}
pt proj(pt a,pt to){
  return dot(a,to)/norm(to)*to;
}

pt refle(pt a,pt mirror){
  return pt(2)*proj(a,mirror)-a;
}

int pt3(pt a,pt b,pt c){
  pt p=b-a,q=c-a;
  double tmp;
  tmp=cros(p,q);
  if(tmp>0){
    return 0;
  }else if(tmp<0){
    return 1;
  }else if(norm(p+q)<max(norm(p),norm(q))){
    return 2;//back
  }else if(norm(q)>norm(p)){
    return 3;//front
  }else if(norm(q)<norm(p)){
    return 4;
  }
  return 5;
}

pt dir(line a){return a.Y-a.X;}

int line2(line a,line b){
  if(dot(dir(a),dir(b))==0)
    return 1;//直交
  if(cros(dir(a),dir(b))==0)
    return 2;//平行
  return 0;
}

int intersect(line a,line b){
  if(line2(a,b)==2)
    return pt3(a.X,a.Y,b.X)>3 || pt3(a.X,a.Y,b.Y)>3
      || pt3(b.X,b.Y,a.X)>3 || pt3(b.X,b.Y,a.Y)>3;
  return cros(dir(a),b.X-a.X)*cros(dir(a),b.Y-a.X)<=0
    && cros(dir(b),a.X-b.X)*cros(dir(b),a.Y-b.X)<=0;
}

int main(){
  int i,j,k,n,re;
  line s1,s2;
  double a[8];
  cin>>n;
  rep(i,n){
    rep(j,8)
      cin>>a[j];
    s1.X=pt(a[0],a[1]);
    s1.Y=pt(a[2],a[3]);
    s2.X=pt(a[0+4],a[1+4]);
    s2.Y=pt(a[2+4],a[4+3]);
    cout<<intersect(s1,s2)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
void solve(){
    int n,a[210];
    string s;
    cin>>n;
    rep(i,n)cin>>a[i];
    cin>>s;
    vector<int>base;
    for(int i=n-1;i>=0;i--){
        int x=a[i];
        sort(all(base),greater<int>());
        for(int y:base){
            chmin(x,x^y);
        }
        if(x){
            if(s[i]=='0')base.pb(x);
            else{
                puts("1");
                return;
            }
        }
    }
    puts("0");
}
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int t;cin>>t;while(t--)solve();
    return 0;
}

Measured memory_bytes: 3540
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    double T, A;
    cin >> T >> A;
    double tmp;
    double H, d;
    double min_t = 100000;
    int min_i = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> H;
        tmp = T - H * 0.006;
        d = abs(A - tmp);
        if (d < min_t)
        {
            min_t = d;
            min_i = i + 1;
        }

    }

    cout << min_i << endl;
    
    return 0;
}

Measured memory_bytes: 888
#include <iostream>

using namespace std;

signed main()
{
    int k, a, b;

    cin >> k >> a >> b;

    for (int i = a; i <= b; ++i)
    {
        if (i % k == 0)
        {
            cout << "OK"
                 << "\n";
            return 0;
        }
    }
    cout << "NG"
         << "\n";

    return 0;
}


Measured memory_bytes: 3080
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int ans = 0;
		int now = 0;
		int bef = -1;
		for(int i = 0;i < N;i++) {
			int a = scn.nextInt();
			if(bef >= a) {
				now++;
			}else {
				ans = Math.max(ans, now);
				now = 0;
			}
			bef = a;
		}
		ans = Math.max(ans, now);
		System.out.println(ans);
	}

}

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

int main() {
  string s;
  cin>>s;
  int alp[26];
  for(int i=0;i<26;i++) alp[i]=0;
  int n=s.size();
  for(int i=0;i<n;i++){
    int idx=s[i]-'a';
    //cout<<idx<<endl;
    alp[idx]++;
  }
  for(int i=0;i<26;i++){
    if(alp[i]>=2){
      cout<<"no"<<endl;
      return 0;
    }
  }
  cout<<"yes"<<endl;
}


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

using namespace std;
using ll = long long;


int main()
{
    string s; cin >> s;
    set<string> st;
    int n = s.size();
    
    for(int i = 0; i < n; i++) {
        for(int j = 1; j <= 5 && i + j <= n; j++) st.insert(s.substr(i, j));
    }
    int k; cin >> k;
    string ans;
    for(auto i : st) {
        k--;
        ans = i;
        if(!k)break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1664
# coding: utf-8
# Your code here!
D,N=map(int,input().split())

if(D==0):
    if(N!=100):
        
        print(N)
    else:
        print(101)

if(D==1):
    if(N!=100):
        
        print(100*N)
    else:
        print(10100)

if(D==2):
    if(N!=100):
        print(100*100*N)
    else:
        print(1010000)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
// atoi : atoi(変数名.c_str())
// find(): int i = 変数名.find(“文字列”) 何番目にあるかを得る
// cout << (条件 ? "Yes" : "No") << endl;
// 降順 sort(a.begin(),a.end(),greater<int>());
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  long x;
  cin >> x;
  long k = x / 11;
  k *= 2;
  long dx = x % 11;
  if(dx >= 6){
    k++;
    dx -= 6;
  }
  if(dx > 0) k++;
  cout << k << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# from itertools import combinations


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def main():
    N = int(input())
    A = list(map(int, input().split()))

    g = A[0]
    L = [g]
    for i in range(N - 1):
        g = gcd(g, A[i + 1])
        L.append(g)

    g = A[N - 1]
    R = [g]
    for i in range(N - 1):
        g = gcd(g, A[N - 2 - i])
        R.append(g)

    result = R[N - 2]
    for i in range(1, N - 1):
        result = max(result, gcd(L[i - 1], R[N - 2 - i]))
    result = max(result, L[N - 2])

    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14460
#include<iostream> 
using namespace std;int main(){int n;cin >> n;int a[n];int count = 0;for (int i = 0; i < n; i++) cin >> a[i];for (int i = 0; i < n; i++) {while (i + 1 < n && a[i] == a[i + 1]) i++; if (i + 1 < n && a[i] > a[i + 1]) while(i + 1 < n && a[i] >= a[i + 1]) i++;else if (i + 1 < n && a[i] < a[i +1]) while (i + 1 < n && a[i] <= a[i + 1]) i++;count++;}cout << count;}

Measured memory_bytes: 888
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;

int N, a[60];

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

  int min_k = 0, max_k = 0;
  for(int i=1;i<N;i++){
    if (a[i] < a[min_k]) {
      min_k = i;
    }
    if (a[i] > a[max_k]) {
      max_k = i;
    }
  }

  cout << (2 * N - 1) << endl;

  int add_k = abs(a[min_k]) < abs(a[max_k]) ? max_k : min_k;
  for(int i=0;i<N;i++) {
    cout << (add_k + 1) << " " << (i + 1) << endl;
  }
  if (a[add_k] >= 0) {
    for(int i=0;i+1<N;i++) {
      cout << (i + 1) << " " << (i + 2) << endl;
    }
  } else {
    for(int i=N-1;i-1>=0;i--) {
      cout << (i + 1) << " " << (i - 1 + 1) << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <iomanip>
#include <unordered_map>
#include <stack>
#include <cstring>

using namespace std;
typedef long long  ll;
const ll INF = 1000000007;
const ll mod = 998244353;

int main()
{
	ll N;
	cin >> N;
	vector<ll> a(N);
	for (ll i = 0; i < N; i++)
	{
		cin >> a[i];
	}
	ll zero = 0;
	for (ll i = 0; i < N; i++)
	{
		if (a[i] == 0) zero++;
	}
	ll prod = 1;
	if (zero > 0) {
		cout << 0 << endl;
		return 0;
	}
	else
	{
		for (ll i = 0; i < N; i++)
		{
			if (a[i] <= 1000000000000000000 / prod)
			{
				prod *= a[i];
			}
			else
			{
				cout << -1 << endl;
				return 0;
			}
		}
	}
	cout << prod << endl;
	return 0;
}

Measured memory_bytes: 3972
#include<stdio.h>

long ruijo(long a,int b){
	int i;
	long r=1;
	for(i=0;i<b;i++)r=r*a;
	return r;
}

int main(){
	long n,p,ans=1;scanf("%ld%ld",&n,&p);
	long i;
	if(n==1){
		printf("%ld\n",p);
		return 0;
	}
	if(n>=50){
		puts("1");
		return 0;
	}
	if(ruijo(2,n)>p){
		puts("1");
		return 0;
	}
	for(i=2;ruijo(i,n)<=p;i++){
		if(p%ruijo(i,n)==0){
			ans=i;
		//	p=p/(ruijo(i,n));
		}
	}
	printf("%ld\n",ans);
	return 0;
}


Measured memory_bytes: 128
def main(): 
  import numpy as np 
  h,w=map(int,input().split())
  grid=np.array([list(input()) for i in range(h)])
  grid=np.where(grid=='.',1,0)
    
  left=np.zeros((h,w),dtype=np.int64)
  right=np.zeros((h,w),dtype=np.int64)
  up=np.zeros((h,w),dtype=np.int64)
  down=np.zeros((h,w),dtype=np.int64)
  
  for i in range(w):
    left[:,i]=(left[:,i-1]+1)*grid[:,i]
    right[:,-i-1]=(right[:,-i]+1)*grid[:,-i-1]
  for i in range(h):
    up[i]=(up[i-1]+1)*grid[i]
    down[-i-1]=(down[-i]+1)*grid[-i-1]
  
  print(np.max(left+right+up+down)-3)
  
if __name__=='__main__':
  main()

Measured memory_bytes: 251044
using System;
namespace Program
{
	class test
    {
    	  static void Main()
        {
            int sum = 0;
            int count = 0;
            string A = Console.ReadLine();
            string B = Console.ReadLine();
            string C = Console.ReadLine();
            string D = Console.ReadLine();
            int AA = int.Parse(A);
            int BB = int.Parse(B);
            int CC = int.Parse(C);
            int DD = int.Parse(D);
            for(int i = 0;i<=AA;i++)
            {
                for (int j=0;j<=BB;j++)
                {
                    for (int k =0;k<=CC;k++)
                    {
                        sum = i * 500 + j * 100 + k * 50;
                        if (sum == DD) count++;
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)



// BFSによる(隣接リスト)塗りつぶし探索
#define MAX_E (100000)
#define MAX_V (100000)
int V, E; // V:頂点数、E:辺数
typedef pair<int, bool> P;
vector<P> G[MAX_V]; // 隣接リストでグラフを保持
int color[MAX_V];
bool seen[MAX_V];

void bfs(int v) {

	// キューを用意して、初期探索点をセット
	queue <int> que;
	color[v] = 0;
	seen[v] = true;
	que.push(v);

	while (!que.empty()) { // BFSループ
		// ★★　この中で迂闊に break しないこと

		// キューの先頭のセルを取得
		int from = que.front(); que.pop();

		// 取得したセルに対する処理

		// そのセルからつながるセルに処理を移行
		for (int i = 0; i < G[from].size(); i++) {
			int to = G[from][i].first;
			bool if_odd = G[from][i].second;

			if (!seen[to]) {
				color[to] = (color[from] + if_odd) % 2;
				seen[to] = true;
				que.push(to);
			}
		}
	}
}

int main() {

	cin >> V;

	for (int i = 0; i < V - 1; i++) {
		int u, v, w;
		cin >> u >> v >> w;
		G[u - 1].push_back(P(v - 1, bool(w % 2)));
		G[v - 1].push_back(P(u - 1, bool(w % 2))); // 無向グラフ
	}

	fill(color, color + V, -1);

	for (int i = 0; i < V; i++) {
		if (color[i] == -1) {
			bfs(i);
		}
	}

	for (int i = 0; i < V; i++) {
		cout << color[i] << endl;
	}

	return 0;

}



Measured memory_bytes: 6912
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i64,
    }
    let sq: i64 = (n as f64).sqrt() as i64;
    let mut answer: i64 = 0;
    for i in (1..sq + 1).rev() {
        if n % i == 0 {
            answer = i + (n / i) - 2;
            break;
        }
    }
    println!("{}", answer); 
}


Measured memory_bytes: 4352
#!/usr/bin/env python3
import sys


def solve(S: str):
    return "x" * len(S)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    print(solve(S))

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
while(1):
    a,op,b = (x for x in input().split())
    a = int(a)
    b = int(b)
    if(op=="?"):
        break
    elif(op=="+"):
        c = a+b
        print(c)
    elif(op=="-"):
        c = a-b
        print(c)
    elif(op=="*"):
        c = a*b
        print(c)
    elif(op=="/"):
        if(b!=0):
            c = int(a/b)
            print(c)


Measured memory_bytes: 5604
#include <stdio.h>

int max(int a,int b){return a>b?a:b;}

int n;
int value[100000][3];
int dp[100000][3]={};

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d %d %d",&value[i][0],&value[i][1],&value[i][2]);

    for(int i=0;i<3;i++) dp[0][i]=value[0][i];
    for(int i=1;i<n;i++)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+value[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+value[i][1];
        dp[i][2]=max(dp[i-1][1],dp[i-1][0])+value[i][2];
    }
    printf("%d\n",max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]));
}

Measured memory_bytes: 2560
Var n,l,min,sum,rem,i,srem:Longint;
Begin
    Readln(n,l); min:=10000000;
    For i:=1 to n do sum:=sum+(l+i-1);
    For i:=1 to n do begin
        rem:=sum-(l+i-1);
        If abs(rem-sum)<min then begin
            min:=abs(rem-sum);
            srem:=rem;
        End;
    End;
    Writeln(srem);
End.

Measured memory_bytes: 128
using System;

class main{
	static void Main(){
		int A = int.Parse(Console.ReadLine());
		int B = int.Parse(Console.ReadLine());
		int C = int.Parse(Console.ReadLine());
		int X = int.Parse(Console.ReadLine());
		int ans = 0;
		for(int i = 0; i <= A; i++){
			for(int j = 0; j <= B; j++){
				for(int k = 0; k <= C; k++){
					if(500 * i + 100 * j + 50 * k == X) ans++;
				}
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11092
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

const long long INF = 1e17+7;
const long long MOD = 1e9+7;
const double PI=acos(-1);

using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vector<pair<int,int>>pa(n);
	for(int i=0;i<n;i++){
		cin >> pa[i].second >> pa[i].first;
	}
	sort(pa.begin(),pa.end());
	int ans=pa[0].first + pa[0].second;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define MOD 1000000007
#define mp make_pair
#define ll long long
#define pb push_back
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug cout<<"Debugging.."<<endl
using namespace std;
int main()
{
	faster;

	ll int tc=1;
	while(tc--)
	{
		ll int n;
		cin>>n;
		 string s;
        while(n)
        {
            s+='a'+(n-1)%26;
            n=(n-1)/26;
        }
        reverse(s.begin(),s.end());
        cout<<s<<endl;

	}
}




Measured memory_bytes: 3632
n = int(input())
lis = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
    if lis[i + 1] < lis[i]:
        ans+=(lis[i]-lis[i+1])
        lis[i + 1] += (lis[i] - lis[i+1])
print(ans)

Measured memory_bytes: 32228
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    int n;
    cin >> n;
    float sum = 0;
    rep(i,n){
        float a;
        cin >> a;
        sum += 1/a;
    }
    float ans = 1/sum;
    printf("%.8lf",ans);
    //cout << ans << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define MOD 1000000007
void bulk(){}template<class H,class...T>void bulk(H&h,T&...t){cin>>h;bulk(t...);}
#define get(...) int __VA_ARGS__; bulk(__VA_ARGS__);

int digsum(int n){if(n<10)return n; return n%10+digsum(n/10);}

int main(){
	get(n);
	int ans=INF;
	vi p(n);
	rep(i,n)cin>>p[i];
	range(t,-100,101){
	    ans=min(ans,accumulate(all(p),0,[&](int a, int b){return a+(b-t)*(b-t);}));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool island[50][50];
int n,m;
int dx[9]={0,1,1,1,0,-1,-1,-1},dy[9]={-1,-1,0,1,1,1,0,-1};
void serch(int y,int x)
{
	island[y][x]=0;
	for(int i=0,ax,ay;i<9;i++)if((ay=dy[i]+y)<m&&(ax=dx[i]+x)<n&&ay>=0&&ax>=0&&island[ay][ax])serch(ay,ax);
}
int main() {
	while(cin>>n>>m,n,m){
		int ans=0;
		for(int i=0;i<m;i++)for(int j=0;j<n;j++)cin>>island[i][j];
		for(int i=0;i<m;i++){
			for(int j=0;j<n;j++){
				if(island[i][j]){
					ans++;
					serch(i,j);
				}
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1228
n = int(input())
f = []
for _ in range(10000):
    f.append(0)
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            id = x*x + y*y + z*z + x*y + y*z + z*x
            if id <= 10000:
                f[id-1] += 1
for i in range(n):
    print(f[i])


Measured memory_bytes: 9260
def main():
    n, m = map(int, input().split())
    ks = [list(map(int, input().split())) for _ in range(m)]
    p = list(map(int, input().split()))
    ans = 0
    

    for i in range(2**n):
        a = []
        flag = True
        for j in range(n):
            a .append(i>>j & 1)
        ok = 0
        for j in range(m):
            switch = 0
            for s in ks[j][1:]:
                switch += a[s - 1]
            if switch % 2 != p[j]:
                flag = False
        if flag:
            ans +=1
            
    print(ans)
                
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e9
typedef long long ll;
using namespace std;
//�I�[�o�[�t���[�ɋC���‚���您����������
//�m�F�Y���Ȃ您����������

int main() {
    int n, m, p; cin >> n >> m >> p;
    vector<bool> to(n);
    vector<int> right;
    vector<int> left;
    rep(i,m) {
        int d; cin >> d;
        to[d] = true;
    }

    for(int i = p+1; i < p+n; i++) {
        right.push_back(i%n);
    }

    left = right;
    reverse(ALL(left));

    right.insert(right.begin(),p);
    left.insert(left.begin(),p);

    vector<int> cntright;
    vector<int> cntleft;

    rep(i,n) {
        if(to[right[i]]) cntright.push_back(i);
    }
    rep(i,n) {
        if(to[left[i]]) cntleft.push_back(i);
    }

    int ans = min(cntright[m-1],cntleft[m-1]);

    rep(i,m-1) {
        ans = min(ans,min(cntright[i],cntleft[m-2-i])*2+max(cntright[i],cntleft[m-2-i]));
    }
    cout << ans*100 << endl;
    return 0;
}


Measured memory_bytes: 4180
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	p := construct(int64(nextInt()))

	pLen := len(p)
	fmt.Println(pLen * 2)
	for i := 0; i < pLen; i++ {
		fmt.Printf("%d ", i+1)
	}

	for _, v := range p {
		fmt.Printf("%d ", v)
	}

	fmt.Println()
}

func construct(N int64) []int {
	var n int
	var p []int
	for n = 40; n > 0; n-- {
		if N >= (int64(1)<<uint(n))-1 {
			break
		}
	}
	for i := 1; i <= n; i++ {
		p = append(p, i)
	}
	N -= (int64(1) << uint(n)) - 1

	for i := n - 1; i >= 0; i-- {
		if N < int64(1)<<uint(i) {
			continue
		}
		n++
		p = append(p[:i], append([]int{n}, p[i:]...)...)
		N -= int64(1) << uint(i)
	}

	return p
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	if x < y {
		return x
	}

	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}

	return y
}

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

// ---------- Util.


Measured memory_bytes: 768
#include <stdio.h>

int main(){

  int sum,n,i;
  while(1){
    scanf("%d",&sum);
    if(sum==0)break;
    for(i=0;i<9;i++){
      scanf("%d",&n);
      sum -= n;
    }
    printf("%d\n",sum);
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define ll long long int
#define lli long long int
#define fw(i, s, e) for (ll i = s; i < e; ++i)
#define fe(i, s, e) for (ll i = s; i <= e; ++i)
#define fb(i, e, s) for (ll i = e; i >= s; --i)
#define L(T)  \
    ll T;     \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
#define mem(a, i) memset(a, i, sizeof(a))
#define ld long double
#define endl "\n"
#define in(P) \
    ll P;     \
    cin >> P;
int main()
{
    FASTIO
    in(n);
    if (n % 1000 == 0)
    {
        cout << 0 << endl;
        return 0;
    }
    ll m = n % 1000;
    if (m < 0)
        m += 1000;
    cout << 1000 - m << endl;
    return 0;
}

Measured memory_bytes: 3648