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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        sc.close();
        for (int i = 0; i < k; i++) {
            if (i % 2 == 0) {
                if (a % 2 == 1) {
                    a = a--;
                }
                a = a / 2;
                b = a + b;
            } else {
                if (b % 2 == 1) {
                    b = b--;
                }
                b = b / 2;
                a = a + b;
            }
        }
        System.out.println(a + " " + b);
    }

}

Measured memory_bytes: 25300
#include <stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
 
int main(void)
{
    int i,j,n,k;
    scanf("%d%d",&n,&k);
    unsigned long h[n],temp,sum = 0;
    for(i = 0; i < n; i++)
    {
        scanf("%lu",&h[i]);
    }
    
    qsort(h,n,sizeof(unsigned long),compare_int);
    
    for(i = 0; i < n - k; i++)
    {
        sum += h[i];
    }
    printf("%lu",sum);
    return 0;
}

Measured memory_bytes: 3324
#include<stdio.h>

int main( )
{
    int n , sum= 0, mod , i , count , a ;
    scanf("%d" , &n);
    
    for( i = 1 ; i <= n ; i++)
    {
        if( i <= 9)
            sum++ ;
        else 
        {
            count = 0 ;
            a= i ;
            while( a != 0 )
            {
                mod = a%10 ;
                count++ ;
                a = a/10 ;
            }
            if( count%2 != 0)
                sum++ ;
        }
    }
    printf("%d\n" , sum);
    return 0;
}


Measured memory_bytes: 2136
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
    int A,B;
    cin >> A >> B;
    if (A >= 13) {
        cout << B << endl;
    } else if (6 <= A && A <= 12) {
        cout << B/2 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main() {
	int N, K;
	cin >> N >> K;

	if(K>(N-2)*(N-1)/2) {
		cout << -1 << endl;
		return 0;
	}

	int add = (N-2)*(N-1)/2 - K; //うにの針先どうしを繋ぐ数
	int M = N-1 + add; // 全体のグラフ数
	cout << M << endl;
	// うにを出力
	rep(i, N-1) {
		cout << 1 << ' ' << i+2 << endl;
	}

	for(int i=1; i<N; i++) {
		for(int j=i+1; j<N; j++) {
			if(add==0) return 0;
			cout << i+1 << ' ' << j+1 << endl;
			add--;
		}
	}

	return 0;
}

Measured memory_bytes: 256
def main():
    s=input()
    n=len(s)
    if s[n-1]=="1" or s[0]=="0":
        print(-1)
        return 0
    for i in range(n//2):
        if s[i]!=s[n-i-2]:
            print(-1)
            return 0
    t=[]
    now=1
    for i in range(n//2-1):
        t.append([now,i+2])
        if s[i]=="1":
            now=i+2
    t2=[[i+n//2,j+n//2] for i,j in t]
    if s[n//2-1]=="1":
        t.append([now,now+n//2])
    else:
        for i in range(len(t2)):
            if t2[i][0]==now+n//2:
                t2[i][0]=now
            if t2[i][1]==now+n//2:
                t2[i][1]=now
        t.append([now,now+n//2])
    if n%2==1:
        t.append([now,n])
    t+=t2
    for i,j in t:
        print(i,j)
main()

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

int main(int argc, char const *argv[])
{
	long long s;
	cin>>s;
	long long x[3],y[3];
	x[0]=0LL;
	y[0]=0LL;
	x[1]=1000000000LL;
	y[1]=1LL;
	y[2]=(s+x[1]-1)/x[1];
	x[2]=x[1]*y[2]-s;
	cout<<x[0]<<" "<<y[0]<<" "<<x[1]<<" "<<y[1]<<" "<<x[2]<<" "<<y[2]<<endl; 
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second

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

main(){
  int w,h;
  while(cin>>w>>h,w|h){
    string in[h];
    rep(i,h)cin>>in[i];

    rep(i,h){
      rep(j,w){
	if(in[i][j]!='.')continue;

	bool cont=true;
	rep(k,4){
	  int ni=i+dx[k],nj=j+dy[k];
	  if(ni<0 || h<=ni || nj<0 || w<=nj)continue;
	  if(in[ni][nj]=='W' || in[ni][nj]=='B'){
	    cont=false;
	    switch(in[ni][nj]){
	    case 'W':
	      in[i][j]='w';
	      break;
	    case 'B':
	      in[i][j]='b';
	      break;
	    }
	    break;
	  }
	}
	if(cont)continue;
	
	cont=true;
	queue<PI> Q;
	Q.push(mp(i,j));

	while(!Q.empty()){
	  int cx=Q.front().F,cy=Q.front().S;
	  Q.pop();

	  rep(k,4){
	    int nx=cx+dx[k],ny=cy+dy[k];
	    if(nx<0 || ny<0 || h<=nx || w<=ny)continue;
	    if(in[nx][ny]=='w' || in[nx][ny]=='b')continue;
	    if(in[nx][ny]=='W' || in[nx][ny]=='B'){
	      if(in[nx][ny]=='W' && in[i][j]=='w')continue;
	      if(in[nx][ny]=='B' && in[i][j]=='b')continue;
	      cont=false;
	      break;
	    }
	    switch(in[i][j]){
	    case 'w':
	      in[nx][ny]='w';
	      break;
	    case 'b':
	      in[nx][ny]='b';
	      break;
	    }
	    Q.push(mp(nx,ny));
	  }
	  if(!cont)break;
	}

	if(cont)continue;

	queue<PI> nq;
	nq.push(mp(i,j));
	in[i][j]='X';
	
	while(!nq.empty()){
	  int cx=nq.front().F,cy=nq.front().S;
	  nq.pop();

	  rep(k,4){
	    int nx=cx+dx[k],ny=cy+dy[k];
	    if(nx<0 || ny<0 || h<=nx || w<=ny)continue;
	    if(in[nx][ny]=='X' || in[nx][ny]=='W' || in[nx][ny]=='B')continue;
	    in[nx][ny]='X';
	    nq.push(mp(nx,ny));
	  }
	}
      }
    }
    int bl=0,wl=0;
    rep(i,h)rep(j,w){
      //if(!j)cout<<in[i]<<endl;
      switch(in[i][j]){
      case 'w':++wl;break;
      case 'b':++bl;break;
      }
    }

    cout<<bl<<" "<<wl<<endl;
  }
}

Measured memory_bytes: 0
#include <stdio.h>

typedef struct _tree_t {
	int id;
	struct _tree_t *p, *l, *r;
} tree_t;

tree_t* tree_insert(tree_t* root, int id){
	tree_t *y = NULL;
	tree_t *x = root;
	tree_t *z = (tree_t*)malloc(sizeof(tree_t));
	z->id = id;
	z->l = z->r = z->p = NULL;

	while(x != NULL) {
	    y = x;
	    if(z->id < x->id) {
	        x = x->l;
	    } else { 
	        x = x->r;
	    }
	}
	z->p = y;
	if(y == NULL) {
    	root = z;
	} else if(z->id < y->id) {
	    y->l = z;
	} else { 
	    y->r = z;
	}
	
	return root;
}

void print_preorder(tree_t *tree) {
    printf(" %d", tree->id);
    if(tree->l != NULL) print_preorder(tree->l);
    if(tree->r != NULL) print_preorder(tree->r);
}

void print_inorder(tree_t *tree) {
    if(tree->r == NULL && tree->l == NULL) {
        printf(" %d", tree->id);
    } else if(tree->r == NULL) {
        print_inorder(tree->l);
        printf(" %d", tree->id);
    } else if(tree->l == NULL) {
        printf(" %d", tree->id);
        print_inorder(tree->r);
    } else {
        print_inorder(tree->l);
        printf(" %d", tree->id);
        print_inorder(tree->r);
    }
}

int main(void) {
	int i, n, id;
	char buff[100];
	tree_t *root = NULL;
	scanf("%d\n", &n);
	for(i=0;i<n;i++) {
		scanf("%s %d\n", buff, &id);
		if(buff[0] == 'i') {
			root = tree_insert(root, id);
		} else if(buff[0] == 'p') {
			print_inorder(root);
			printf("\n");
			print_preorder(root);
			printf("\n");
		}
	}
	
	return 0;
}



Measured memory_bytes: 25152
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] x = new int[n];
        for (int i = 0 ; i < n ; i++) {
            x[i] = sc.nextInt();
        }
        int sum = 0;
        for (int i = 0 ; i < n ; i++) {
            sum += 2 * Math.min(x[i], k - x[i]);
        }
        System.out.println(sum);
    }

}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n, m, a, b;
	cin >> n >> m >> a >> b;
	vector<vector<char>> ans(n, vector<char>(m, '.'));
	bool flag = false;
	if (n >= 3 && m >= 3 && n % 2 == 1 && m % 2 == 1 && a % 2 != m / 2 % 2) {
		for (int i = 0; i < n - 3; i += 2) {
			if (b > 0) {
				ans[i][m - 1] = '^'; ans[i + 1][m - 1] = 'v'; b--;
			}
		}
		for (int j = 0; j < m - 3; j += 2) {
			if (a > 0) {
				ans[n - 1][j] = '<'; ans[n - 1][j + 1] = '>'; a--;
			}
		}
		if (a > 0) {
			ans[n - 3][m - 2] = '<'; ans[n - 3][m - 1] = '>'; a--;
		}
		if (a > 0) {
			ans[n - 1][m - 3] = '<'; ans[n - 1][m - 2] = '>'; a--;
		}
		if (b > 0) {
			ans[n - 2][m - 1] = '^'; ans[n - 1][m - 1] = 'v'; b--;
		}
		if (b > 0) {
			ans[n - 3][m - 3] = '^'; ans[n - 2][m - 3] = 'v'; b--;
		}
		flag = true;
	}
	else {
		if (m % 2 != 0) {
			for (int i = 0; i < n - 1; i += 2) {
				if (b > 0) {
					ans[i][m - 1] = '^'; ans[i + 1][m - 1] = 'v'; b--;
				}
			}
		}
		if (n % 2 != 0) {
			for (int j = 0; j < m - 1; j += 2) {
				if (a > 0) {
					ans[n - 1][j] = '<'; ans[n - 1][j + 1] = '>'; a--;
				}
			}
		}
	}
	for (int i = 0; i < n - 1; i += 2) {
		for (int j = 0; j < m - 1; j += 2) {
			if (flag && i == n - 3 && j == m - 3) continue;
			if (a > 0) {
				ans[i][j] = '<'; ans[i][j + 1] = '>'; a--;
				if (a > 0) {
					ans[i + 1][j] = '<'; ans[i + 1][j + 1] = '>'; a--;
				}
			}
			else if (b > 0) {
				ans[i][j] = '^'; ans[i + 1][j] = 'v'; b--;
				if (b > 0) {
					ans[i][j + 1] = '^'; ans[i + 1][j + 1] = 'v'; b--;
				}
			}
		}
	}
	if (a > 0 || b > 0) cout << "NO\n";
	else {
		cout << "YES\n";
		rep(i, n) {
			rep(j, m) cout << ans[i][j];
			cout << '\n';
		}
	}
}

Measured memory_bytes: 4236
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <inttypes.h>

int main(void){
	int a,b,sum;

	scanf("%d %d",&a,&b);
	sum=a+b;
	if(a%3==0){
		printf("Possible");
		return 0;
	}
	if(b%3==0){
		printf("Possible");
		return 0;
	}
	if(sum%3==0){
		printf("Possible");
		return 0;
	}
	printf("Impossible");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100009;
ll cost[N],h[N];

int main(){

    ll n,i,a,b;
    scanf("%lld",&n);
    for(int i=1; i<=n; i++){
        scanf("%lld",&h[i]);
    }

    cost[n-1]=fabs(h[n-1]-h[n]);
    for(i=n-2; i>=1; i--){
        a=fabs(h[i]-h[i+1])+cost[i+1];
        b=fabs(h[i]-h[i+2])+cost[i+2];
        cost[i]=min(a,b);
    }
    printf("%lld\n",cost[1]);
}

Measured memory_bytes: 5300
#include <iostream>

#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int N;cin >> N;
	vector<string> S (N+1);
	for(int i=0;i<N;i++){
		cin>>S[i];
		sort(S[i].begin(),S[i].end());
	}
	long long ans=0;
	
	S[N]=("zzzzzzzzzzz");
	sort(S.begin(),S.end());
	
	long long count=0;
	for(int i=0;i<N;i++){
		//cout<<S[i]<<endl;
		if(S[i]==S[i+1]){
			count++;
		}else{
			ans+=count*(count+1)/2;
			count=0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8960
/*** 𝕒𝕜𝕤𝕙𝕒𝕪𝕜𝕦𝕞𝕒𝕣𝟡𝟡 ***/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=2e5+1;
 
typedef int ll;
typedef long double ld;

void test_case()
{
    ll n,k,i,j;
    cin>>n>>k;
    bool a[n+1]={0};
    f(i,0,k)
    {
        ll d;
        cin>>d;
        f(j,0,d)
        {
            ll x;
            cin>>x;
            a[x]=1;
        }
    }
    ll ans=0;
    f(i,1,n+1)
    {
        if(!a[i])
            ans++;
    }
    cout<<ans<<'\n';
   
}

int32_t main()
{
    IOS();
   
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b) //最大公約数
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

ll lcm(ll a, ll b) //最小公倍数
{
	return a * b / gcd(a, b);
}

ll box(double a) //doubleの切り捨て
{
	ll b = a;
	return b;
}

ll fff(double a) //doubleの四捨五入
{
	ll b = a + 0.5;
	return b;
}

ll sum(ll n) { //整数sまでの合計
	if (n == 0) {
		return 0;
	}

	int s = sum(n - 1);
	return s + n;
}

bool prime(ll num)//素数判定、primeならtrue,違うならfalse
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}

// ===============================================================

int main() {
	ll k, a, b; cin >> k >> a >> b;
	bool hantei = false;
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			hantei = true;
		}
	}
	if (hantei) cout << "OK" << endl;
	else cout << "NG" << endl;
}

Measured memory_bytes: 3656
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

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

ll a[100010];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    //cout << fixed << setprecision(15);

    int N, x;
    cin >> N >> x;
    for (int i = 0; i < N; ++i)
        cin >> a[i];

    ll ans = 0;
    for (int i = 1; i < N; ++i)
    {
        if (a[i] + a[i - 1] > x)
        {
            if (a[i] + a[i - 1] - x <= a[i])
            {
                ans += a[i] + a[i - 1] - x;
                a[i] = x - a[i - 1];
            }
            else
            {
                ans += a[i];

                a[i] = 0;
                ans += a[i - 1] - x;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
template<class T>
inline bool chmax(T &a, T b) {if(a < b) {a = b;return true;}return false;}
template<class T>
inline bool chmin(T &a, T b) {if(a > b) {a = b;return true;}return false;}
const ll INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

ll n;
int k;

int main(){
    cin >> n >> k;
    cout << floor((log(n)/log(k)))+1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""
int main(void)
{
    int N,M, X, Y;cin>>N>>M>>X>>Y;
    vector<int> x(N);
    vector<int> y(M);
    for(int i=0;i<N;i++) cin>>x[i];
    for(int i=0;i<M;i++) cin>>y[i];


    for(int z=X+1; z<=Y;z++){
      bool flag1=true; bool flag2=true;
      for(int i=0;i<N;i++){
        if(x[i]>=z) flag1=false;
      }

      for(int i=0;i<M;i++){
        if(y[i]<z) flag2=false;
      }

      if(flag1 && flag2){
        cout<<"No War"<<endl;
        return 0;
      }

    }

    cout<<"War"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    int n;
    cin>>n;
    vector<int> vec(n);
    vector<int> v(n);
    vector<int> c(n);
    rep(i,n)cin>>v[i];
    rep(i,n)cin>>c[i];
    rep(i,n){
        vec[i]=v[i]-c[i];
    }
    int ans=0;
    rep(i,n){
        if(vec[i]>0){
            ans+=vec[i];
        }
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import * as fs from 'fs';

const input = fs.readFileSync('/dev/stdin', 'utf8');
const [strA, strB] = input.split(' ');
const [strB1, strB2] = strB.split('.');

const a = BigInt(strA);
const b1 = BigInt(strB1);
const b2 = BigInt(strB2);

const result = a * b1 + (a * b2 / 100n);

console.log(result.toString())




Measured memory_bytes: 29608
#include <iostream>
#include <tuple>
#include <vector>
using namespace std;

const int mod = 1000000007;

int N;
vector<int> G[100009];

pair<int, int> dfs(int u, int p) {
    long long black = 1, white = 1;
    for(int v : G[u]) {
        if(v != p) {
            int b, w;
            tie(b, w) = dfs(v, u);
            black *= w;
            black %= mod;
            white *= w + b;
            white %= mod;
        }
    }
    return make_pair(black, white);
}

int main() {
    cin >> N;
    for(int i = 0; i < N - 1; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    int b, w;
    tie(b, w) = dfs(0, -1);

    cout << (b + w) % mod << endl;

    return 0;
}

Measured memory_bytes: 12672
#include<stdio.h>
int main(void)
{
 int a,b,c,e;
 scanf("%d %d %d",&a,&b,&c);
 
 if(a>b){
  e=a;
  a=b;
  b=e;
 }
 if(b>c){
  e=b;
  b=c;
  c=e;
 }
 if(a>b){
  e=a;
  a=b;
  b=e;
 }
 printf("%d %d %d\n",a,b,c);
 return 0;
}

Measured memory_bytes: 596
<?php
fscanf(STDIN,"%d",$N);
$arr_v=explode(' ',trim(fgets(STDIN)));
$arr_c=explode(' ',trim(fgets(STDIN)));

$sum=0;
$atai_arr=array();
for($i=0;$i<$N;$i++){
	$atai[$i]=$arr_v[$i]-$arr_c[$i];
	if($atai[$i]>0){
		$sum += $atai[$i];
	}
}
echo $sum;

?>

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.size()-1;i++)
    	if(s[i]=='A' && s[i+1]=='C'){cout<<"Yes";exit(0);}
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int N=310;
using namespace std;
inline int read(){
	int f=1,x=0;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return f*x;
}
int a[N][N],n,m,ans;
int c[N],d[N];
int main(){
	n=read();m=read();
	for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)a[i][j]=read();
	ans=n;
	for(int i=1;i<=m;i++){
		memset(c,0,sizeof(c));
		for(int j=1;j<=n;j++)for(int k=1;k<=m;k++)if(!d[a[j][k]]){
			c[a[j][k]]++;break;
		}
		int k=1;
		for(int j=1;j<=m;j++)if(c[j]>c[k])k=j;
		d[k]=1;ans=min(ans,c[k]);
	}
	printf("%d\n",ans);
}

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

using namespace std;
const int mod = 1e9 + 7;

int main() {
	long long N;
	cin >> N;
	long long ans = 1;

	for (int i = 1; i <= N; i++) {
		ans = ans * i % mod;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string b;
  cin >> b;

  if (b == "A"){
    cout << "T" << endl;
  }else if (b == "T"){
    cout << "A" << endl;
  }else if (b == "C"){
    cout << "G" << endl;
  }else {
    cout << "C" << endl;
  }
}

Measured memory_bytes: 256
n,s = map(int,input().split())
a = list(map(int,input().split()))
if n == 1:
    if a[0] == s:
        print(1)
        quit()
    else:
        print(0)
        quit()

mod = 998244353
dp = [[0]*(s+1) for _ in range(n+1)]
dp[0][0] = 1
for i in range(n):
    dp[i+1][0] = 2*dp[i][0]%mod
    for j in range(s+1):
        dp[i+1][j] = dp[i][j]*2%mod
    if a[i] <= s:
        for j in range(a[i],s+1):
            dp[i+1][j] += dp[i][j-a[i]]
            dp[i+1][j] %= mod
print(dp[-1][-1]%mod)

Measured memory_bytes: 139160
/*
    author: Salam_35
    Created at :

*/

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

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF	1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() int testsalam;cin >> testsalam;while(testsalam--)
#define Mod 100000007
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;
#define endl '\n'
//void inversemod(ll n, ll mod, ll invmod[],ll MOD){for(int i=2; i<=n; ++i) invmod[i]=MOD-MOD/i*invmod[MOD%i]%MOD;}
//void bigmod( ll a, ll b ,ll mod){ll r = 1;a = a%mod;while(b){if( b%2 ) r = (r*a)%mod;b = b/2;a = (a*a)%mod; }return (ll)r;}
string inttostr(ll n){std::stringstream ss;ss << n;string out=ss.str();return out;}
ll stringtoint(string s){istringstream iss (s);ll n;iss >> n;return n;}
typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;

int main()
{
    int k;
    string s;
    cin >> k >> s;
    int n=s.size();
    if(n<=k)cout<<s<<endl;
    else {
    	string ss=s.substr(0,k);
    	ss+="...";
    	cout<<ss<<endl;
    }
}


Measured memory_bytes: 3632
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import collections
import math
import numpy as np

#### START
n = int(input())
li = list(map(int,input().split()))
s_li = sorted(li)
left_num = s_li[n//2-1]
right_num = s_li[n//2]
for i in li:
    if i>left_num:
        print(left_num)
    else:
        print(right_num)
        

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

int main() {
  int n;
  cin >> n;
  int p[n + 1];
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    p[i]--;
  }
  p[n] = n;

  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (p[i] == i) {
      swap(p[i], p[i + 1]);
      cnt++;
    }
  }

  cout << cnt << endl;
  return 0;
}


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

using std::cin;
using std::cout;
using std::cerr;

using std::abs;
using std::min;
using std::max;
using std::swap;

using std::map;
using std::pair;
using std::set;
using std::string;
using std::vector;

using std::sort;
using std::reverse;

using ll = long long;

#define forn(i, n) for (ll i = 0; i < (ll) n; ++i)
#define sz(a) static_cast<int>(a.size())
#define endl '\n'

struct __init {
    __init() {
        cin.tie(nullptr);
        std::iostream::sync_with_stdio(false);
        cout << std::fixed << std::setprecision(10);
        cerr << std::fixed << std::setprecision(5);
        std::mt19937 rand(300);
    }

    ~__init() {
        #ifdef SEREZHKA
            cerr << "Time elapsed: " << static_cast<double>(clock()) / CLOCKS_PER_SEC << endl;
        #endif
    }
} init;

const ll inf = (ll) 1e9 + 7ll;
const int maxn = (int) 1e6 + 17;

int n;
int a[maxn];

bool read() {
    if (!(cin >> n))
        return false;

    forn (i, n)
        cin >> a[i];

    return true;
}

void solve() {
    ll L = 2, R = 2;

    for (int i = n - 1; i >= 0; --i) {
        ll l = 0, r = inf * inf;

        for (; l < r; ) {
            auto m = (l + r) / 2;

            if ((m / a[i]) * a[i] < L)
                l = m + 1;
            else
                r = m;
        }

        L = l;
        l = 0, r = inf * inf;

        for (; l < r; ) {
            auto m = (l + r + 1) / 2;

            if ((m / a[i]) * a[i] > R)
                r = m - 1;
            else
                l = m;
        }

        R = r;

        if (L > R) {
            cout << -1 << endl;
            return ;
        }
    }

    cout << L << ' ' << R << endl;
}

int main() {
#if SEREZHKA
    freopen("file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}


Measured memory_bytes: 640
import Data.Set (fromList)

main :: IO ()
main = do
    l1 <- getLine
    l2 <- getLine
    let n = read l1
    let as = (map read . words) l2 :: [Int]
    putStrLn $ solve n as

solve :: Int -> [Int] -> String
solve n as = show . countRemain $ (dup, uniq)
    where
        uniq = length $ fromList as
        dup = n - uniq

countRemain :: (Int, Int) -> Int
countRemain (dup, uniq)
    | dup `mod` 2 == 0  = uniq
    | otherwise         = uniq - 1


Measured memory_bytes: 31100
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
    int n, cnta=0,cntw=0,cntt=0,cntr=0;
    cin>>n;
    while(n--)
    {
      string s;
      cin>>s;
      
      
      
          if(s=="AC")
          cnta++;
          else if(s=="WA")
          cntw++;
          else if(s=="TLE")
          cntt++;
          else if(s=="RE")
          cntr++;
      
     
    }
    cout<<"AC x "<<cnta<<endl;
      cout<<"WA x "<<cntw<<endl;
      cout<<"TLE x "<<cntt<<endl;
      cout<<"RE x "<<cntr<<endl;

    return 0;
}

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

int n, m, q;
int a[50], b[50], c[50], d[50];
int v[10];
int ans=0;

void dfs(int prev, int dig){
  if(dig == n){
    int res = 0;
    for(int i=0; i<q; i++){
      if(v[b[i]]-v[a[i]]==c[i]) res += d[i];
    }
    ans = max(res, ans);
    return;
  }
  for(int j=prev; j<=m; j++){
    v[dig] = j;
    dfs(j, dig+1);
  }
}
 
int main(){
  cin >> n >> m >> q;
  for(int i=0; i<q; i++){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--; b[i]--;
  }
  dfs(1,0);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3640
var N = 0
var A = 0

fun main(args: Array<String>) {
    readLine()?.split(" ")?.map {
        it.toInt()
    }?.let {
        N = it[0]
        A = it[1]
    }


    val x = IntArray(N + 1)
    readLine()?.split(" ")?.map {
        it.toInt()
    }?.forEachIndexed { i, n ->
        x[i + 1] = n
    }

    val dp = Array(N + 1) {
        Array(N + 1) {
            LongArray(N * A + 1)
        }
    }
    for (i in 0..N) {
        dp[i][0][0] = 1
    }

    for (i in 1..N) {
        for (j in 1..i) {
            for (k in 1..(N * A)) {
                dp[i][j][k] = if (k < x[i]) {
                    dp[i - 1][j][k]
                } else {
                    dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]
                }
            }
        }
    }

    var ans = 0L
    for (j in 1..N) {
        ans += dp[N][j][j * A]
    }

    println(ans)
}



Measured memory_bytes: 111540
#include<bits/stdc++.h>
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

double dp[1 << 15][15];
int r[10];
int main() {
	string s;
	while (getline(cin, s)) {
		stringstream buf(s);
		double w; buf >> w;
		int p = 0; while (buf >> r[p++]); p--;
		fill(dp[0], dp[1 << 15], INF);
		rep(i, p)dp[1 << i][r[i]] = r[i] * 2;
		rep(i, 1 << p) {
			rep(k, 11) {
				rep(j, p) {
					if (i >> j & 1)continue;
					double d = sqrt((k + r[j])*(k + r[j]) - (k - r[j])*(k - r[j])) - k + r[j];
					dp[i | 1 << j][r[j]] = min(dp[i | 1 << j][r[j]], dp[i][k] + d);
				}
			}
		}
		rep(i, 11) {
			if (dp[(1 << p) - 1][i] <= w) {
				puts("OK"); goto g;
			}
		}
		puts("NA");
	g:;
	}
}

Measured memory_bytes: 7084
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int P[] = new int[N];
            for (int i = 0; i < N; i++) {
                P[i] = in.nextInt() - 1;
            }

            int SUM[] = new int[N];

            int A[] = new int[N];
            int B[] = new int[N];

            int MIDDLE = 1000000000;

            int Q[] = new int[N];

            for (int i = 0; i < N; i++) {
                Q[P[i]] = i;
            }

            A[0] = 1;
            B[0] = MIDDLE;

            SUM[Q[0]] = A[0] + B[0];

            for (int i = Q[0] - 1; i >= 0; i--) SUM[i] = SUM[i + 1] - 1;
            for (int i = Q[0] + 1; i < N; i++) SUM[i] = SUM[i - 1] + 1;

            for (int i = 1; i < N; i++) {
                if (SUM[Q[i]] < SUM[Q[i - 1]]) {
                    A[i] = A[i - 1] + 1;
                    B[i] = SUM[Q[i]] - A[i];
                } else {
                    B[i] = B[i - 1] - 1;
                    A[i] = SUM[Q[i]] - B[i];
                }
            }

            for (int i = 0; i < N; i++) {
                out.print(A[i] + " ");
            }
            out.println();
            for (int i = 0; i < N; i++) {
                out.print(B[i] + " ");
            }
            out.println();
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


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

int main(){
    int H,N; //HP
    cin >> H >> N;

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

    for(i=0;i<N;i++){
        H -= A[i];
    }

    if(H <= 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    char c;
    bool hasYellow = false;
    for (int i = 0; i < n; i++) {
        cin >> c;
        if (c == 'Y') hasYellow = true;
    }
    cout << (hasYellow ? "Four" : "Three");
    return 0;
}

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

ostream& operator<<(ostream& os, const vector<pair<ll, int>>& vp) {
    for (auto& p : vp) {
        os << p.first << " -> " << p.second << "\n";
    }
    return os;
}

void solve() {
    ll a, b;
    cin >> a >> b;
    ll gcd = __gcd(a, b);
    map<ll, int> mp;

    for (ll i = 1; i * i <= gcd; ++i) {
        if (gcd% i == 0) {
            mp[i]++;
            if (gcd / i != i) {
                mp[gcd / i]++;
            }
        }
    }

    vector<pair<ll, int>> vp;
    for (auto& p : mp) {
        vp.push_back(p);
    }

    //cout << "CKS " << vp << endl;
    set<ll> st;

    for (int i = 0; i < (int)vp.size(); ++i) {
        bool ok = true; ll x = vp[i].first;
        for (int j = 0; j < i; ++j) {
            ll y = vp[j].first;
            if (__gcd(x, y) != 1) {
                ok = false;
                break;
            }
        }
        if (ok)
            st.insert(vp[i].first);
    }
    cout << st.size() << "\n";
}

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

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


Measured memory_bytes: 4040
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll ans = max(a * c, a * d);
	ans = max(ans,b*c);
	ans = max(ans,b*d);
	cout << ans <<endl;
	return 0;
} 
	


Measured memory_bytes: 3604
#include<iostream>
#include <numeric>
using namespace std;
int a, b, c;

int main() {
    cin >> a >> b >> c;
    if(a==b && b==c) cout << 1 << endl;
    else if(a!=b&&b!=c&&a!=c) cout << 3 << endl;
    else cout << 2 << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque


S = deque(list(input()))
Q = int(input())
queries = []
for _ in range(Q):
    query = input().split()
    if len(query) == 3:
        queries.append([int(x) for x in query[:2]] + [query[2]])
    else:
        if len(queries[-1]) == 1:
            queries.pop()
        else:
            queries.append([int(x) for x in query])
p = True
count = 0
for query in queries:
    if len(query) == 3:
        if p:
            if query[1] == 1:
                S.appendleft(query[2])
            else:
                S.append(query[2])
        else:
            if query[1] == 1:
                S.append(query[2])
            else:
                S.appendleft(query[2])
    else:
        p = not p
        count += 1

if count % 2:
    S.reverse()
print(''.join(S))

Measured memory_bytes: 119272
#include <stdio.h>
#include <stdint.h>

int A[100000];
int B[100000];
int N;

int main(){
  scanf("%d", &N);
  for(int i = 0; i < N; i++){
    scanf(" %d %d", &A[i], &B[i]);
  }
  int64_t count = 0;
  for(int i = N - 1; i >= 0; i--) {
    int64_t rem = (A[i] + count) % B[i];
    if(rem) count += B[i] - rem;
  }
  printf("%lld\n", count);
  return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;

int main() {
    vector<vector<int>> vec(3,vector<int>(3));
    for(int i = 0;i < 3;i++) {
        for(int j = 0;j < 3;j++) {
            cin >> vec.at(i).at(j);
        }
    }
    int N;
    cin >> N;
    vector<int> cnt(N);
    for(int i = 0;i < N;i++) {
        cin >> cnt.at(i);
    }
    vector<vector<bool>> ret(3,vector<bool>(3));
    for(int i = 0;i < N;i++) {
        for(int j = 0;j < 3;j++) {
            for(int k = 0;k < 3;k++) {
                if(vec.at(j).at(k) == cnt.at(i)) {
                    ret.at(j).at(k) = true;
                }
            }
        }
    }
    bool ret2 = false;
    for(int i = 0;i < 3;i++) {
        bool ret3 = true;
        for(int j = 0;j < 3;j++) {
            if(ret.at(i).at(j) == false) {
                ret3 = false;
            }
        }
        if(ret3 == true) {
            ret2 = true;
        }
    }
    for(int i = 0;i < 3;i++) {
        bool ret3 = true;
        for(int j = 0;j < 3;j++) {
            if(ret.at(j).at(i) == false) {
                ret3 = false;
            }
        }
        if(ret3 == true) {
            ret2 = true;
        }
    }
    if(ret.at(0).at(0) == true && ret.at(1).at(1) == true && ret.at(2).at(2) == true) {
        ret2 = true;
    }
    if(ret.at(0).at(2) == true && ret.at(1).at(1) == true && ret.at(2).at(0) == true) {
        ret2 = true;
    }
    if(ret2 == true) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	//定義関数から参照できる変数定義はこの辺
	//static Var_form Var_name

	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	long wk_cost = 0;
    	long wk_time = 0;
    	long min_cost = Long.MAX_VALUE;
    	String ans="TLE";
    	//Integer.MAX_VALUE;
		long N = sc.nextLong();
		long T = sc.nextLong();
		for(int i=1;i<=N;i++){
			wk_cost=sc.nextLong();
			wk_time=sc.nextLong();
			if (wk_time<=T) {
				min_cost=Math.min(min_cost,wk_cost);
			}
		}
		if (min_cost==Long.MAX_VALUE){
			System.out.println(ans);		
		}
		else{
			System.out.println(min_cost);

		}  
    }
    //関数定義
	//public static int funk(long X,long A) {
    //    return ;    
    //}
}	

Measured memory_bytes: 27324
#include<iostream>
#include<vector>
#include<algorithm>
#include <string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>

#define ok printf("ok\n");
#define MAX 1000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define pb push_back

using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

int main()
{
	int n,a,b,c,d,num,dig,sum,ans = 0;
	string s,t;
	vi v,w;
	cin >> n >> a >> b;
	rep(i,n)
	{
		num = i+1;
		sum = 0;
		while(num)
		{
			dig = num % 10;
			sum = sum + dig;
			num = num / 10;
		}
		//cout << sum << endl;
		if(sum >= a && sum <= b)
		{
			ans += (i+1);
			//ok
		}


	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>

using namespace std;

typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<vector<int>> VVI;
typedef map<int, int> M;
typedef pair<int, int> P;
typedef stack<int> S;
typedef queue<int> Q;

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

    LL n, k;
    cin >> n >> k;
    VL a,b;
    if (!(k % 2))
    {
        for (int i = 1; i <= n; ++i)
        {
            if (i % k == 0) a.push_back(i);
            if (i % k == k/2) b.push_back(i);
        }
        cout << (LL)(pow((LL)a.size(), 3) + pow((LL)b.size(), 3)) << endl;
    }
    else
    {
        for (int i = 1; i <= n; ++i)
        {
            if (i % k == 0) a.push_back(i);
        }
        cout << (LL)(pow((LL)a.size(), 3)) << endl;
    }

    return 0;
}

Measured memory_bytes: 2420
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = Array(N) {
        readLine()!!.toInt()
    }
    val AC = A.copyOf().sortedDescending()

    val result = IntArray(N)
    for (i in A.indices) {
        if (A[i] == AC.first()) {
            result[i] = AC[1]
        } else {
            result[i] = AC[0]
        }
    }
    result.joinToString("\n").let(::println)
}



Measured memory_bytes: 62272
a=Array.new(21,1)
(2..20).each{|i| a[i]=a[i-1]*i}

b=Array.new(26,0)
s=gets.chomp
s.bytes{|p| b[p-97]+=1}

c=s.length&1==0
p b.inject(a[s.length/2]){|pi,p|
  if p&1==1
    break 0 if c
    c=true
  end
  pi/a[p/2]
}

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

using namespace std;

int S(int N) {
  int s = 0;
  while (N) {
    s += N % 10;
    N /= 10;
  }
  return s;
}

int main() {
  int N;
  cin >> N;
  if (N % S(N) == 0) {
    cout << "Yes";
  } else {
    cout << "No";
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>

#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(void){
  int N;
  int sum = 0;
  cin >> N;
  int _N = N;

  while(N){
    int dig = N%10;
    sum = sum + dig;
    N = N/10;
  }


  if(_N%sum == 0){
  cout << "Yes" << endl;
  }else{
  cout << "No" << endl;   
  }
}

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

int64_t gcd(int64_t a, int64_t b){
  if(a == 0 || b == 0) return max(a,b);
  if(a == 1 || b == 1) return 1;

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

int main(){
  int N;
  vector<int64_t> A(100010);

  cin >> N;
  for(int i=1; i<=N; i++) cin >> A[i];

  // L[i]:A[1]~A[i]のgcd, R[i]:A[i]~A[N]のgcd
  vector<int64_t> L(100010,0), R(100010, 0);
  L[1] = A[1]; R[N] = A[N];

  for(int i=1; i<=N; i++){
    L[i+1] = gcd(L[i], A[i+1]);
    R[N-i] = gcd(R[N-i+1], A[N-i]);
  }

  int64_t ans = 0;
  for(int i=0; i<=N; i++){
    ans = max(ans, gcd(L[i-1], R[i+1]));
  }

  cout << ans << endl;
}

Measured memory_bytes: 2560
#include<stdio.h>

int main(){
     
     int i,j;
     
     for(i = 1; i < 10 ;i++){

          for(j = 1 ; j < 10 ; j++){
              
              printf("%dx%d=%d\n",i,j,i*j);
          
          }
     }
    
    return 0;
}

Measured memory_bytes: 524
let () =
  let n = read_int () in
  let arr = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d in
  let ans = Array.fold_left
      (fun (x, i) a -> if a = x then (x+1, i) else (x, i+1)) (1,0) arr in
  print_int (if (snd ans) = Array.length arr then -1 else snd ans)

Measured memory_bytes: 6144
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);


int main() {
	int n, k;
	while (cin >> n >> k&&n&&k) {
		int cards[100001] = { 0 };
		int a;
		for (int i = 0; i < k; i++) {
			cin >> a;
			cards[a] = 1;
		}

		bool f = cards[0];
		cards[0] = 0;
		for (int i = 1; i <= n; ++i) {
			cards[i] += cards[i - 1];
		}

		int ans = 0;
		int l = 0;
		for (int r = 1; r <= n; ++r) {
			while (cards[r] - cards[l] + f < r - l) l++;
			if (ans < r - l)ans = r - l;
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 3368
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s, t;
	cin >> s >> t;
	int ans = 2147483647;
	for (int i = 0; i + t.size() <= s.size(); i++){
		int c = 0;
		for (int j = 0; j < t.size(); j++){
			if (s[i + j] != t[j]) c++;
		}
		ans = min(ans, c);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 3688
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		long Q = long.Parse(str[1]);
		long[]A = new long[N];
		long[]B = new long[N];
		string[] str2 = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			A[i] = long.Parse(str2[i]);
		}
		long sum = 0;
		for(var i=N-1;i>=0;i--){
			sum += A[i];
			B[i] = sum;
		}
		long sum2 = 0;
		long sum3 = 0;
		long[]C = new long[N];
		for(var i=0;i<N;i++){
			if(i%2==1){
				sum2 += A[i];
				C[i] = sum2;
			} else {
				sum3 += A[i];
				C[i] = sum3;
			}
		}
		for(var i=0;i<Q;i++){
			int Q1 = int.Parse(Console.ReadLine());
			int min = 0;
			int max = N-1;
			while(min<max){
				int na = (min+max)/2;
				int na2 = N-1-(N-na)/2;
				if(A[na2] - Q1 < Q1 - A[na]){
					min = na+1;
				} else {
					max = na;
				}
			}
			int m3 = N-(N-min+1)/2;
			long a = B[m3];
			int m4 = m3 - (N-min+1)/2 - 1;
			if(m4>=0){
				a += C[m4];
			}
			Console.WriteLine(a);
		}
	}
}

Measured memory_bytes: 31828
N=int(input())
for n in range(1,3501):
    for w in range(1,3501):
        if n*(4*w-N)-N*w==0:
            continue
        if N*n*w % (n*(4*w-N)-N*w) ==0:
            h= (N*n*w) // (n*(4*w-N)-N*w)
            if h>=1:
                print(h,n,w)
                exit()

Measured memory_bytes: 41708