akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

bool zero_exist(const vector<size_t> &A)
{
    for(size_t i = 0; i < A.size(); ++i)    
    {
        if(A[i] == 0)
        {
            return true;    
        }
    }

    return false;    
}

bool over_MM(const vector<size_t> &A, const size_t M)
{
    for(size_t i = 0; i < A.size(); ++i)    
    {
        if(A[i] > M*M)
        {
            return true;    
        }
    }

    return false;    
}

void set_TA(size_t A, vector<size_t> &TA, const size_t M)
{
    TA.resize(3);

    TA[2] = A / (M*M);
    TA[1] = (A % (M*M)) / M;
    TA[0] = A % M;
}

void prod_TA(vector<size_t> &TA, vector<size_t> &TB, vector<size_t> &output, const size_t M)
{
    output.clear();    
    output.resize(5);

    for(size_t i = 0; i < 5; ++i)
    {
        output[i] = 0;
    }

    for(size_t i = 0; i < TA.size(); ++i)
    {
        for(size_t j = 0; j < TB.size(); ++j)    
        {
            output[i+j] += TA[i] * TB[j];
        }
    }

    for(size_t i = 1; i < 5; ++i)
    {
        output[i] += output[i-1] / M;
    }

    for(size_t i = 0; i < 5; ++i)
    {
        output[i] %= M;
    }
}

int main()
{
    const size_t M = 1000000000;
    size_t N;    
    vector<size_t> A;
    cin >> N;
    A.resize(N, 0);
    for(size_t i = 0; i < N; ++i)
    {
        cin >> A[i];
    }

    // 0 チェック
    if(zero_exist(A))
    {
        cout << 0 << endl;    
        return 0;    
    }

    // M*M チェック    
    if(over_MM(A, M))
    {
        cout << -1 << endl;
        return 0;    
    }

    vector<size_t> prod(3, 0);    // prod[2]*M*M + prod[1]*M + prod[0]
    vector<size_t> TA;

    for(size_t i = 0; i < N; ++i)
    {
        set_TA(A[i], TA, M);

        if(i == 0)
        {
            prod = TA;    
        }
        else
        {
            vector<size_t> output;    
            prod_TA(TA, prod, output, M);

            if( (output[4] > 0) || (output[3] > 0) || (output[2] >= 2) )
            {   
                cout << -1 << endl;    
                return 0;
            }
            else if(output[2] == 1) 
            {
                if( (output[1] > 0) || (output[0] > 0) )
                {
                    cout << -1 << endl;    
                    return 0;
                }
            }

            prod[0] = output[0];
            prod[1] = output[1];
            prod[2] = output[2];
        }
    }
    cout << prod[2] * M * M + prod[1] * M + prod[0] << endl;

    return 0;    
}

Measured memory_bytes: 3988
#A
n = int(input())
h = list(map(int,input().split()))

cost = [0]*n
for i in range(n):
    if i == 0:
        continue
    if i == 1:
        cost[i] = abs(h[i]-h[i-1])
        continue
    cost[i] = min(cost[i-1]+abs(h[i]-h[i-1]),cost[i-2]+abs(h[i]-h[i-2]))
print(cost[n-1])

Measured memory_bytes: 13928
#include <stdio.h>

int main(){
    int n;
    int mgcSq[15][15];
    int x,y;
    
    while(scanf("%d",&n)!=EOF){
        x = y = n/2;
        y++;
        for (int i=0; i<n; i++){
            for (int j=0; j<n; j++){
                mgcSq[j][i]=0;
            }
        }
 
        for (int i=1; i<=n*n; i++){
            mgcSq[x][y]=i;
            x = (x+1)%n;
            y = (y+1)%n;
            if (mgcSq[x][y]){
                x = (x+n-1)%n;
                y = (y+1)%n;
            }
        }
        
        for (int i=0; i<n; i++){
            for (int j=0; j<n; j++){
                printf("%4d",mgcSq[j][i]);
            }
            printf("\n");
        }
    }
 
    return 0;
}

Measured memory_bytes: 1044
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
//#define int long long
using namespace std;
const int inf=0x3f3f3f3f;
const int N=2e4+300,M=2e6+10;
int n,m,s,t,h[N]; char g[N][N];
int head[N],nex[M],to[M],w[M],tot=1;
inline void ade(int a,int b,int c){to[++tot]=b; nex[tot]=head[a]; w[tot]=c; head[a]=tot;}
inline void add(int a,int b,int c){ade(a,b,c);	ade(b,a,0);}
inline int id(int x,int y){return (x-1)*m+y;}
inline int bfs(){
	queue<int> q; q.push(s); memset(h,0,sizeof h); h[s]=1;
	while(q.size()){
		int u=q.front();	q.pop();
		for(int i=head[u];i;i=nex[i]) if(w[i]&&!h[to[i]]) h[to[i]]=h[u]+1,q.push(to[i]);
	}
	return h[t];
}
int dfs(int x,int f){
	if(x==t)	return f;	int fl=0;
	for(int i=head[x];i&&f;i=nex[i]){
		if(w[i]&&h[to[i]]==h[x]+1){
			int mi=dfs(to[i],min(w[i],f));
			w[i]-=mi,w[i^1]+=mi,fl+=mi,f-=mi;
		}
	}
	if(!fl)	h[x]=-1;
	return fl;
}
inline int dinic(){
	int res=0;
	while(bfs())	res+=dfs(s,inf);
	return res;
}
signed main(){
	cin>>n>>m; t=2e4+275;
	for(int i=1;i<=n;i++)	scanf("%s",g[i]+1);
	for(int i=1;i<=n;i++)	for(int j=1;j<=m;j++){
		add(id(i,j),id(i,j)+n*m,1);
		if(g[i][j]=='S')	add(s,id(i,j)+n*m,inf);
		if(g[i][j]=='T')	add(id(i,j),t,inf);
		if(g[i][j]!='.'){
			add(id(i,j)+n*m,n*m*2+i,inf);
			add(n*m*2+i,id(i,j),inf);
			add(id(i,j)+n*m,n*m*2+n+j,inf);
			add(n*m*2+n+j,id(i,j),inf);
		}
	}
	int maxflow=dinic();
	if(maxflow>=0x3f3f3f3f)	return puts("-1"),0;
	cout<<maxflow<<endl;	
	return 0;
}


Measured memory_bytes: 5464
#include<stdio.h>
int main(){
    int n,m=0,s=0;
    scanf("%d ",&n);
    int l[n];
    for(int i=0;i<n;i++)
        scanf("%d",&l[i]);

    for(int i=0;i<n;i++){
        if(l[i]>l[m]) m=i;
        s += l[i];
    }
    s-=l[m];

    if(l[m]<s){
        printf("Yes");
    }else{
        printf("No");
    }  

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
typedef pair<int,int> P;
#define INF 1e9
#define rep(i,N) for(int i=0;i<N;i++)

int main(){
    int t,num;
    while(cin>>t>>num){
        if(t == 0)break;
        int numd = 1 , tmp = num;
        bool isReject = false;
        string nums = to_string(num);
        while(tmp/=10){
            numd++;
        }
        //cout<<numd<<endl;
        int loop = pow(2,numd-1);
        int ans = 0,dist = 1e6;
        vector<int>ansm;
        rep(i,loop){
            int res = 0;
            int sum = 0;
            int b = 0;
            vector<int>m;
    		// for (int j=0; j<numd-1; j++) {
			// 	if ((1&i>>j) == 1) {
            //         if(j>0)b += j*2;
            //         else if(j==0)b += 1;
            //     }
			// }
            //cout<<"i:"<<i<<" b:"<<b<<endl;
            bool flag = true;
            for(int j = 0; j<numd; j++){
                sum *= 10;
                //cout<<numd-j<<endl;
                sum += (nums[j] - '0');
                if((1&i>>j) == 1){
                    //cout<<"sum:"<<sum<<endl;
                    res += sum;
                    m.push_back(sum);
                   // cout<<"sum:"<<sum<<" res:"<<res<<endl;
                    //cout<<"res:"<<res<<endl;
                    sum = 0;
                    flag = true;
                }else{
                    flag = false;
                }
            }
            if(!flag){
                res += sum;
               // cout<<"sum:"<<sum<<" res:"<<res<<endl;
                m.push_back(sum);
                //res += (nums[0] - '0');
            }

            //cout<<res<<endl;
            // if(t-res == 1){
            //     for(auto itr : ansm){
            //         cout<<itr<<" ";
            //     }
            //     cout<<res<<endl;
            // }
            if(res > t)continue;
            if(dist > (t-res)){
                dist = t-res;
                ansm = m;
                isReject = false;
            }else if(dist == (t-res)){
                isReject = true;
            }
//            dist = min(dist , t - res);
        }
        if(isReject){
            cout<<"rejected"<<endl;
        }else if(ansm.empty()){
            cout<<"error"<<endl;
        }else{
            ans = t - dist;
            cout<<ans;
            for(auto itr:ansm){
                cout<<" "<<itr;
            }
            cout<<endl;
        }
    }
}


Measured memory_bytes: 3400
#include "bits/stdc++.h"
using namespace std;
#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 ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll a,b,c=0,k=1,s=0,n,h,w,m,min=100000000000,ans=1,max=0;
    string s1,s2;
    cin >> h >> w;
    VS o(h+2);

    for(int i=0;i<h;i++){
        cin >> o[i];
        o[i] = '#' + o[i] + '#';
    }
    rep(i,w+2){
        cout << '#';
    }
    cout << endl;
    rep(i,h){
         cout << o[i] <<endl;;
    }
    rep(i,w+2){
        cout << '#';
    }
    return 0;
}

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

int main() {
  int x;
  cin >> x;
  int ans = 8;
  if ( x >= 600 ) { ans--; }
  if ( x >= 800 ) { ans--; }
  if ( x >= 1000 ) { ans--; }
  if ( x >= 1200 ) { ans--; }
  if ( x >= 1400 ) { ans--; }
  if ( x >= 1600 ) { ans--; }
  if ( x >= 1800 ) { ans--; }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000

int check(vector<vector<int>> &E,int start){
	map<int,int> mp;
	mp[start] = 0;
	vector<int> V(1,start);
	vector<int> new_V;
	
	while(true){
		for(int i=0;i<V.size();i++){
			int a = V[i];
			for(int j=0;j<E[a].size();j++){
				int to = E[a][j];
				if(mp.count(to)){
					if(abs(mp[to]-mp[a])!=1)return -1;
				}
				else{
					mp[to] = mp[a]+1;
					new_V.push_back(to);
				}
			}
		}
		if(mp.size()==E.size())break;
		swap(V,new_V);
		new_V.resize(0);
	}
	
	for(int i=0;i<E.size();i++){
		for(int j=0;j<E[i].size();j++){
			int from = i;
			int to = E[i][j];
			if(abs(mp[from]-mp[to])!=1)return -1;
		}
	}
	
	int maxi = 0;
	for(auto a:mp)maxi = max(maxi,a.second);
	return maxi+1;
	
}

int main(){
    
	int N;
	cin>>N;
	
	vector<vector<int>> E(N);
	
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			char c;
			cin>>c;
			if(c=='1'){
				E[i].push_back(j);
			}
		}
	}
	
	int maxi = -1;
	
	for(int i=0;i<N;i++){
		int ret = check(E,i);
		if(ret==-1)continue;
		maxi = max(maxi,ret);
	}
	
	cout<<maxi<<endl;
	
    
    
    return 0;
}



Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;



class Program
{
    const int MOD = 1000000007;
    const int INF = 1 << 30;

    static void Main(string[] args)
    {
        Solve();
    }



    static void Solve()
    {
        Scan sc = new Scan();
        write wr = new write();

        string S=sc.str;
        long N=sc.longarr[0];
        int i = 0;
        while (i+1<=S.Length&&S[i] == '1')
        {
            i++;
        }

        if (N < i+1)
        {
            wr.wri(1);
        }
        else wr.wri(S[i]);
    }
}
    




class Scan
{
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
    public char[] chararr => str.ToArray();


}



class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


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

int main(){
    string s;
    cin >> s;
    int rainy = 0;
    int ans =0;
    for(auto&c: s){
        if(c=='R'){
            rainy++;
        }else{
            rainy=0;
        }
        ans = max(ans, rainy);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define NAME "Knapsack1"
#define ll long long
const int maxw = 1e5+1;
int n,m;
int w;
int v;
ll  dp[maxw];
int main(){
    //ifstream cin(NAME".inp");
    //ofstream cout(NAME".out");
    ios::sync_with_stdio(0);cin.tie(0);
    cin>>n>>m;
    for(int i = 1;i<=n;i++){
        cin>>w>>v;
        for(int j=m;j>=w;j--)
            if (dp[j] < dp[j-w] + v) dp[j] = dp[j-w] + v;
    }
    cout<<dp[m];
}



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

public class Main {
  private static boolean debug = false;
  private static boolean elapsed = false;

  private static PrintWriter _err = new PrintWriter(System.err);

  private int N;
  private int L;
  private String[] S;

  private void solve(Scanner sc, PrintWriter out) {
    N = sc.nextInt();
    L = sc.nextInt();
    sc.nextLine();
    S = new String[N];
    for (int i = 0; i < N; ++i) {
      S[i] = sc.nextLine();
    }

    Arrays.sort(S);

    for (String s : S) {
      out.print(s);
    }
    out.println();
  }
  private long C(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    for (long i = r; i > 1; --i) {
      res /= i;
    }
    return res;
  }
  private long P(long n, long r) {
    long res = 1;
    for (long i = n; i > n - r; --i) {
      res *= i;
    }
    return res;
  }
  private long ceil2pow(long n) {
    if (n == 0) {
      return 1;
    }
    n--;
    n |= (n >>> 1);
    n |= (n >>> 2);
    n |= (n >>> 4);
    n |= (n >>> 8);
    n |= (n >>> 16);
    n++;
    return n;
  }
  /*
   * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
   * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
   */
  public static void main(String[] args) {
    long S = System.currentTimeMillis();

    Scanner sc = new Scanner(System.in);
    PrintWriter out = new PrintWriter(System.out);
    new Main().solve(sc, out);
    out.flush();

    long G = System.currentTimeMillis();
    if (elapsed) {
      _err.println((G - S) + "ms");
    }
    _err.flush();
  }
}

Measured memory_bytes: 10452
package main
import (
        "fmt"
        "sort"
)

func main() {
        var n, k, ans int
        ans = 1<<30
        fmt.Scan(&n)
        fmt.Scan(&k)
        d := make([]int, n)
        for i:=0; i < n; i++ {
                fmt.Scan(&d[i])
                //fmt.Printf("%d %d\n", i, d[i])
        }
        sort.Ints(d)
        for i:=0; i+k-1 < n; i++ {
                var w = d[i+k-1] - d[i]
                if  ans > w {
                        ans = w
                }
                //fmt.Printf("%d\n", w)
        }
        fmt.Printf("%d\n",ans)
}


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

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

  vector<int> X(N), Y(N);
  rep(i, N) cin >> X[i] >> Y[i];

  int cnt = 0;
  rep(i,N){
    double dst = sqrt(pow(X[i], 2.0) + pow(Y[i], 2.0));
    if(dst<=D)
      cnt++;
  }

  cout << cnt << endl;

  return 0;
}


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

int main ()
{
    int cnt = 0;
    string w, t;
    cin >> w;
    while(cin >> t && t != "END_OF_TEXT")
    {
        
        for (int i = 0;i < t.size();i++)
        {
            bool find = true;
            for (int j = 0, temp = i;j < w.size() && temp < t.size();j++)
            {
                if (t.size() == w.size())
                {
                    if (65 <= t[temp] && t[temp] < 91) t[temp] += 32;
                    if (t[temp] != w[j])
                    {
                        find = false;
                        break;
                    }
                    else
                    {
                        if(j == w.size()-1) cnt++;
                        else temp++;
                    }
                }
                else find = false;
            }
            if (!find) break;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    string s; cin>>s;
    int n=s.length();
    bool ok=true;
    if(s[0]!='A') ok=false;
    int cnt=0;
    for(int i=2; i<n-1; ++i){
        if(s[i]=='C') cnt++;
    }
    if(cnt!=1) ok=false;
    cnt=0;
    rep(i,n){
        if(isupper(s[i])) cnt++;
    }
    if(cnt!=2) ok=false;
    cout<<(ok?"AC":"WA")<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <queue>

using namespace std;
#define ll long long
#define pb push_back
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)


int cnt, h, w, xy[2000][2000]={-1};
int L[2000][2000] = {0}, R[2000][2000] = {0}, B[2000][2000] = {0}, U[2000][2000] = {0};
int dx[2] = {1, -1}, dy[2] = {1, -1};
pair<int,int> p;
char c[2000][2000];
queue<pair<int,int> > q;
 
void count_point(){
  // 上方向についてみていく
  rep(i, h){
    rep(j, w){
      if(c[i][j]=='.'){
        if(i == 0) {
          U[i][j] = 1;
        }
        else {
          U[i][j] =  U[i-1][j] + 1;
        } 
      } else {
        U[i][j] = 0;
      }
    }
  }

  // 左方向についてみていく
  rep(i, h){
    rep(j, w){
      if(c[i][j]=='.'){
        if(j == 0) {
          L[i][j] = 1;
        }
        else {
          L[i][j] =  L[i][j-1] + 1;
        } 
      } else {
        L[i][j] = 0;
      }
    }
  }

  for(int i = h-1; i >= 0; i--){
    for(int j = w-1; j >= 0; j--){
      if(c[i][j]=='.'){
        if(i == h-1) {
          R[i][j] = 1;
        }
        else {
          R[i][j] =  R[i+1][j] + 1;
        } 
      } else {
        R[i][j] = 0;
      }
    }
  }
  for(int i = h-1; i >= 0; i--){
    for(int j = w-1; j >= 0; j--){
      if(c[i][j]=='.'){
        if(j == w-1) {
          B[i][j] = 1;
        }
        else {
          B[i][j] =  B[i][j+1] + 1;
        } 
      } else {
        B[i][j] = 0;
      }
    }
  }
}


int32_t main()
{
	cin>>h>>w;
	for(int i =0; i<h; i++)
		for(int j =0; j<w; j++)
			cin>>c[i][j];

  count_point();
  
	for(int i =0; i<h; i++){
    for(int j =0; j<w; j++){
      if(c[i][j]=='.'){
        cnt = max(cnt, R[i][j] + U[i][j] +B[i][j] + L[i][j] - 3);
      }
    }
  }
			
	cout << cnt << endl;
	return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M);
  vector<int> b(M);
  vector<int> Ans(N);
  
  for(int i = 0;i < M;i++){
    cin >> a.at(i) >>b.at(i);
  }
  for(int j =0;j < N;j++){
    for(int i =0;i < M;i++){
      if(a.at(i)==j+1 ||b.at(i)==j+1){
        Ans.at(j) +=1;
      }
    }
  }
  for(int i =0;i < N;i++){
    cout << Ans.at(i) << endl;
  }
}

Measured memory_bytes: 256
h = gets.chomp.to_i

tmpSum = 1
sum_i = 1
sum = 3
if h == 1 then
  puts 1
elsif h <= 3 then
  puts 3
else
  tmpSum *= 2
  sum_i += tmpSum
  while sum_i<h do
    tmpSum *= 2
    sum_i += tmpSum
    sum += tmpSum
  end
  puts(sum)
end

Measured memory_bytes: 1788
#include <stdio.h>

int a,d,i,j, el;
char b[100000000],e[100000000],c[100000000];

int main(){
	while(1){
		scanf("%d",&a);
		if(a==0){
			return 0;
		}
		for(i=0;i<a;i++){
			scanf(" %c %c",&b[i],&e[i]);
		}
		scanf("%d",&d);
		for(i=0;i<d;i++){
			scanf(" %c",&c[i]);
			for(j=0;j<a;j++){
				if(c[i]==b[j]){
					c[i]=e[j];
					break;
				}
			}
		}
		for(i=0;i<d;i++){
			printf("%c",c[i]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 4672
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h, w;
  cin >> h >> w;
  vector<string> v(h);
  
  for(int j = 0; j < w + 2; j++)
    cout << '#';
  cout << endl;
  
  for(int i = 0; i < h; i++) {
    cout << '#';
    cin >> v.at(i);
    cout << v.at(i);
    cout << '#' << endl;
  }
  
  for(int j = 0; j < w + 2; j++)
    cout << '#';
  cout << endl;
}

Measured memory_bytes: 256
/**
 *      purpose : ABC 120 B
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

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

  int a, b, k; cin >> a >> b >> k;
  // int cnt = 0;
  vector<int> v;

  for (int i = 1; i < 1000; ++i){
    if (a % i == 0 && b % i == 0){
      v.push_back(i);
    }
  }

  int SIZE = v.size();

  print(v[SIZE - k]);

  return 0;
}

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

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

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << (x-a)%b << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

using namespace std;

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

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))

ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

const ll mod = 1e9 + 7;
const ll IMF = 1LL<< 29;
const double PI = 3.14159265358979323846;


int main(){
        ll N;
        cin >> N;
        vector<ll> t(N), x(N), y(N);
        for(ll i = 0; i < N; i++){
                cin >> t[i] >> x[i] >> y[i];
        }

        int time = 0;
        int xxx = 0;
        int yyy = 0;

        for(int i = 0; i < N; i++){
                if(t[i] - time >= (abs(x[i] - xxx) + abs(y[i] - yyy)) && (t[i] - time) % 2 == (abs(x[i] - xxx) + abs(y[i] - yyy)) % 2){
                        time = t[i];
                        xxx = x[i];
                        yyy = y[i];
                        continue;
                }
                cout << "No" << endl;
                return 0;
        }
        
        cout << "Yes" << endl;
        return 0;
}



Measured memory_bytes: 2560
f[168],d[]={23,24,25,12,36,11,13,35,37,22,26,48,0},i,x,s,m=23,c=100;main(y){for(;s?++f[y*12+x+d[--s]]:~scanf("%d,%d,%d",&x,&y,&s)?s=s*4+1:++m<142?m%12<10?i=fmax(i,f[m]),f[m]?c--:1:1:!printf("%d\n%d\n",c,i););}

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

using namespace std;

#define PI 3.14159265358979323846
#define INF 1e+9
#define DIV_NUM (1000000007)



int main() {

	string S, T;
	cin >> S >> T;
	int A, B;
	cin >> A >> B;
	string U;
	cin >> U;
	if (U == S) A--;
	if (U == T) B--;


	long long int N = 10000000000;
	long long ans = 0;
	for (long long i = 0; i < N; i++) {
		ans += 1;
	}

	ans *= 0;

	A = A - ans;

	cout << A << " " << B << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, N) for(int i = 0; i< N; i++)

int main() {
    int X, N; cin >> X >> N;
    int p[100]; rep(i, N) cin >> p[i];

    //pにXが含まれない時はXを出力
    int res = true;
    rep(i, N) {
        if(p[i] == X) res = false;
    }
    if(res) cout << X << endl;
    else {
        //X +-iで見ていく
        rep(i, 100) {
            int plus = X+1+i;
            int minus = X-1-i;
            bool canPlus = true;
            bool canMinus = true;

            rep(j, N) {
                if(minus == p[j]) {
                    canMinus = false;
                } else if(plus == p[j]) {
                    canPlus = false;
                }
            }

            if(canMinus) {
                cout << minus << endl;
                break;
            } else if(canPlus) {
                cout << plus << endl;
                break;
            }
        }
    }

}


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

int main(){
  string s,p;
  int flag = 0;
  getline(cin,s);
  getline(cin,p);

  string s2 = s+s;
  
  for(int i=0; i<(int)s2.length(); i++){
    for(int j=0; j<(int)p.length(); j++){
      //cout << "Try :" << s2[i+j] << " " << p[j]<<endl;
      if(s2[i+j]!=p[j]){
	break;
      }else if((int)p.length() == j+1){
	flag = 1;
      }
    }
    if(flag) break;
  }
  
  if(flag) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 3192
fn solve() {
    let n = read();
    let mut a: Vec<usize> = vec![];
    for _ in 0..n + 1 {
        a.push(read());
    }
    let mut b: Vec<usize> = vec![];
    for _ in 0..n {
        b.push(read());
    }
    let mut res0 = 0;
    let mut rem = 0;
    for i in 0..n {
        res0 += min(b[i] + rem, a[i]);
        if b[i] + rem > a[i] {
            rem = b[i] - (a[i].saturating_sub(rem));
        } else {
            rem = 0;
        }
    }
    res0 += min(a[n], rem);
    let mut res1 = 0;
    let mut rem = 0;
    for i in (1..n + 1).rev() {
        res1 += min(b[i - 1] + rem, a[i]);
        if b[i - 1] + rem > a[i] {
            rem = b[i - 1] - (a[i].saturating_sub(rem));
        } else {
            rem = 0;
        }
    }
    res1 += min(a[0], rem);
    println!("{}", max(res0, res1));
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 2728
n = input()
R = []
for i in range(0, n):
   R.append(int(raw_input()))

maxv = R[1] - R[0]
minv = R[0]

for v in range(1, n):
   if minv > R[v]:
      minv = R[v]
   elif maxv < R[v] - minv:
      maxv = R[v] - minv
print maxv   

Measured memory_bytes: 18796
#include <bits/stdc++.h>
using namespace std;
const int maxN = 2e5 + 5555;

int mxTree[4 * maxN];
int n;
int a[maxN];
vector<int> g[maxN];

void upd(int id, int l, int r, int idx, int val) {
    if(r < idx || l > idx)
        return;

    if(l == idx && r == idx) {
        mxTree[id] = val;
        return;
    }

    int mid = (l + r) / 2;

    upd(id * 2, l, mid, idx, val);
    upd(id * 2 + 1, mid + 1, r, idx, val);

    mxTree[id] = max(mxTree[id * 2], mxTree[id * 2 + 1]);
}

int getMx(int id, int l, int r, int L, int R) {
    if(L <= l && r <= R)
        return mxTree[id];

    if(r < L || l > R)
        return 0;

    int mid = (l + r) / 2;
    return max(getMx(id * 2, l, mid, L, R), getMx(id * 2 + 1, mid + 1, r, L, R));
}

void upd(int idx, int val) {
    upd(1, 0, n + 1, idx, val);
}

int getMx(int l, int r) {
    return getMx(1, 0, n + 1, l, r);
}

int ans[maxN], f[maxN];
map<int, int> mp;

void dfs(int u, int par = 0) {
    int old = getMx(a[u], a[u]);

    f[u] = getMx(0, a[u] - 1) + 1;

    ans[u] = max(f[u], ans[par]);

    bool undo = false;
    int fau = getMx(a[u], a[u]);

    if(f[u] > fau) {
        upd(a[u], f[u]);
        undo = true;
    }

    for(auto v : g[u]) {
        if(v != par) {
            dfs(v, u);
        }
    }

    if(undo)
        upd(a[u], old);
}

vector<int> path;

int lis() {
    vector<int> dp((int)path.size(), 0);

    int ans = 0;

    for(int i = 0; i < (int)path.size(); i++) {
        dp[i] = 1;
        for(int j = 0; j < i; j++) {
            if(path[j] < path[i])
                dp[i] = max(dp[i], dp[j] + 1);
        }

        ans = max(ans, dp[i]);
    }

    return ans;
}

void brute(int u, int par) {
    cerr << "a[" << u << "] = " << ' ' << a[u] << '\n';
    cerr << "ans[" << u << "] = " << ans[u] << '\n';
    path.push_back(a[u]);

    assert(lis() == ans[u]);

    for(auto v : g[u]) {
        if(v != par) {
            //cerr << u << ' ' << v << '\n';
            brute(v, u);
        }
    }

    path.pop_back();
}

void genTree() {
    freopen("in.txt", "w", stdout);

    int N = 60;
    cout << N << '\n';

    for(int i = 1; i <= N; i++) {
        int ai = rand() % N + 1;
        cout << ai << ' ';
    }

    cout << '\n';

    for(int i = 1; i < N;  i++) {
        int anc = rand() % i + 1;
        cout << anc << ' ' << i + 1 << '\n';
    }

    //exit(0);
}

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

//    srand(time(NULL));
//    genTree();

//    freopen("in.txt", "r", stdin);

    cin >> n;

    vector<int> vv;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        vv.push_back(a[i]);
    }

    sort(vv.begin(), vv.end());
    vv.resize(unique(vv.begin(), vv.end()) - vv.begin());

    for(int i = 0; i < (int)vv.size(); i++)
        mp[vv[i]] = i + 1;

    for(int i = 1; i <= n; i++) {
        a[i] = mp[a[i]];
        //cerr << a[i] << ' ';
    }
    //cerr << '\n';

    for(int i = 0; i < n - 1; i++) {
        int u, v;   cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    dfs(1);
//
//    brute(1, 0);

    for(int i = 1; i <= n; i++)
        cout << ans[i] << '\n';

    return 0;
}


Measured memory_bytes: 38400
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

#define ROOP(i,n) for(i=0;i<n;i++)

//prototype declaration
int getint();
long long getllint();
double getdint();
char getch();
void setstring(char *s);
void showint(int i);
void showllint(long long i);
void showdouble(double i);
void showchar(char c);
void showstring(char *s);

int myPower(int a, int n) { // aのn乗の計算
	int x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int min(int a, int b) {
	return a < b ? a : b;
}

int main(void) {
	int n, i, j;
	n = getint();
	char w[n+1][20];
	ROOP(i, n) {
		scanf("%s", w[i]);
	}
	ROOP(i, n) {
		for (j = i + 1; j < n; j++) {
			if (strcmp(w[i], w[j]) == 0) {
				showstring("No");
				return 0;
			}
		}
	}
	ROOP(i, n - 1) {
		if (w[i][strlen(w[i]) - 1] != w[i+1][0]) {
			showstring("No");
			return 0;
		}
	}
	showstring("Yes");
	return 0;
}

int getint() {
	int i;
	scanf("%d", &i);
	return i;
}

long long getllint() {
	long long i;
	scanf("%lld", &i);
	return i;
}

double getdint() {
	double i;
	scanf("%lf", &i);
	return i;
}

char getch() {
	char c;
	scanf("%c", &c);
	return c;
}

void setstring(char *s) {
	scanf("%s", s);
}

void showint(int i) {
	printf("%d\n", i);
}

void showllint(long long i) {
	printf("%lld\n", i);
}

void showdouble(double i) {
	printf("%lf\n", i);
}

void showchar(char c) {
	printf("%c\n", c);
}

void showstring(char *s) {
	printf("%s\n", s);
}


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;


int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  vector<int> w(n);
  for(int i = 0; i < n; i++){
    cin >> w.at(i);
  }
  int tmp1, tmp2;
  int res = 99999999;
  for(int i = 0; i < n; i++){
    tmp1 = 0;
    tmp2 = 0;
    for(int j = 0; j < n; j++){
      if(j < i){
        tmp1 += w.at(j);
      }else{
        tmp2 += w.at(j);
      }
    }

    res = min(res, abs(tmp1 - tmp2));
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
			int n = Integer.parseInt( kb.readLine() );
			String[] nums = kb.readLine().split( " " );
			int len = nums.length;
			int[] A = new int[ len ];
			int i, len2 = len-1;

			StringBuilder output = new StringBuilder( 100+1 );									
			for( i=0; i<len; i++ ) {
				A[i] = Integer.parseInt( nums[i] );
				output.append( A[i]+" "  );
			}
			output.deleteCharAt( output.lastIndexOf( " " ) );
			System.out.println( output  );
			output.setLength( 0 );

			int key;
			int j, k;
 			for( i=1; i<len; i++ ) {
				key = A[i];
				j = i - 1;
				while( 0 <= j && key < A[j] ) {
					A[ j+1 ] = A[j];
					j--;
				}
				A[ j+1 ] = key;
				for( k=0; k<len; k++ ) {
					output.append( A[k]+" "  );
				}
				output.deleteCharAt( output.lastIndexOf( " " ) );
				System.out.println( output  );
				output.setLength( 0 );
			}
			
 			kb.close();
		} catch( IOException e ) {
			System.err.println( e );
		}
	}
}

Measured memory_bytes: 24184
#include <iostream>
#include <vector>

#define rep(i,n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i,N) cin >> A[i];

  vector<int> ans(N,0);
  rep(i,N){
    ans[A[i]-1] += i+1;
  }
  rep(i,N){
    cout << ans[i] << " ";
  }
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std; 
#define int long long
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<n;++i)
#define ld long double
int32_t main() 
{ 
	int n; cin>>n;
	ld mul=1,comp=1e18,x;
	bool ans=0;
	int a[n];
	f(i,0,n) {cin>>a[i]; if(a[i]==0) ans=1;}
	if(ans){
		cout<<"0\n";
		return 0;
	}
	f(i,0,n){
		x=a[i];
		mul*=x;
		if(mul>comp){
			cout<<"-1\n";
			return 0;
		}
	}
	int lp=mul;
	cout<<lp<<"\n";
	return 0; 
} 




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

int main(void){
  int x,y; cin >> x >> y;

  for(int a = 0;a<=x;a++){
    int b = x-a;
    if(y == 2*a+4*b){
      cout << "Yes" << endl;
      return 0;
    }
  }

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


Measured memory_bytes: 3628
N, K = map(int, input().split())
a = list(map(int, input().split()))

a_cnt = {}
for i in a:
    if i in a_cnt:
        a_cnt[i] += 1
    else:
        a_cnt[i] = 1
from  operator import itemgetter

a_cnt = sorted(a_cnt.items(), key=itemgetter(1))

from collections import deque
cnt_list = deque([])
for i, j in a_cnt:
    cnt_list.append(j)

ans = 0
while len(cnt_list) > K:
    ans += cnt_list[0]
    cnt_list.popleft()
print(ans)

Measured memory_bytes: 39760
#include <bits/stdc++.h>
using namespace std;
//*******************
// Mahmoud Magdy    *
//*******************
#define ll long long
#define endl "\n"

void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m ;
    cin>>m;
    return m ;
}
int main()
{
int a=D(),b=D(),c=D(),d=D();
if(c>b)
{
    cout<<0<<endl;
    return 0;
}
if (a>d){
  cout<<0<<endl;
    return 0;
}
int mx=max(a,c);
int mn=min(b,d);
cout<<mn-mx<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int ans = 0;
  int end = 0;
  for(int i=1; i<=N; i++){
    ans += i;
    if(ans >= N){
      end = i;
      break;
    }
  }
  int no = ans - N;
  
  for(int i=1; i<=end; i++){
    if(i == no){
      continue;
    }
    cout << i << endl;
  }
}

Measured memory_bytes: 256
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let mut a: Vec<i64> = (0..n).map(|_| read()).collect();

    a.sort();
    let max_i: i64 = a.pop().unwrap();
    let mut close = std::i64::MAX;
    let mut ans = a[0];

    for &a_i in a.iter() {
        if close > (a_i * 2 - max_i).abs() {
            close = (a_i * 2 - max_i).abs();
            ans = a_i;
        }
    }

    println!("{} {}", max_i, ans);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>

int main(void) {
	char nyuuryoku[128];
	if (scanf("%127s", nyuuryoku) != 1) return 1;
	if (strcmp(nyuuryoku, "ani") == 0) puts("square1001");
	else if (strcmp(nyuuryoku, "otouto") == 0) puts("e869120");
	else puts("YOU ARE AN IDIOT!!!!!");
	return 0;
}



Measured memory_bytes: 2140
import java.util.Scanner;

public class Main {
	
	public static void  main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		int tmp;
		int count = 0;
		for (int i=0; i<N; i++) {
			A[i] = sc.nextInt();
		}
		for (int i=0; i<N; i++){
			for (int j=N-1; j>0; j--){
				if(A[j] < A[j-1]) {
					tmp = A[j];
					A[j] = A[j-1];
					A[j-1] = tmp;
					count++;
				}
			}
		}
		
		for (int i=0; i<N-1; i++) {
			System.out.print(A[i] + " ");
		}
		System.out.println(A[N-1]);
		System.out.println(count);
	}
}



Measured memory_bytes: 26452
f=lambda:map(int,input().split())
R,C,K=f()
g=[[0]*(C+1) for _ in range(R+1)]
for _ in range(K):
  r,c,v=f()
  g[r][c]=v
dp=[[[0]*(C+2) for _ in range(R+2)] for _ in range(4)]
for i in range(1,R+1):
  for j in range(1,C+1):
    for k in range(3,-1,-1):
      if k: dp[k][i][j]=max(dp[k][i][j],dp[k-1][i][j]+g[i][j])
      dp[0][i+1][j]=max(dp[0][i+1][j],dp[k][i][j])
      dp[k][i][j+1]=max(dp[k][i][j+1],dp[k][i][j])
print(max(dp[i][R][C] for i in range(4)))

Measured memory_bytes: 429120
def d_simple_knapsack(N, W, Baggage):
    from collections import defaultdict
    # dp[w]:ナップサックに重さがwになるように荷物を入れたときの価値の最大値
    dp = defaultdict(int)
    dp[0] = 0  # 重さ0で達成できる価値は0とする
    for w, v in Baggage:
        # dpの各要素(現時点におけるナップサック内の荷物の重さ)に対して、
        # 注目した荷物を入れても重さがWを超えなければ、
        # ナップサックに荷物を入れて価値の最大値を更新する
        tmp = defaultdict(int)  # 価値の最大値を更新できた荷物の重さの情報
        for kw, kv in dp.items():
            if kw + w <= W:
                if kw + w in dp:
                    tmp[kw + w] = max(dp[kw + w], kv + v)
                else:
                    tmp[kw + w] = kv + v
        for key, value in tmp.items():
            dp[key] = value
    ans = max(dp.values())
    return ans

N, W = [int(i) for i in input().split()]
Baggage = [[int(i) for i in input().split()] for j in range(N)]
print(d_simple_knapsack(N, W, Baggage))

Measured memory_bytes: 3996
//template code, C343, 2019
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public void printAdjMatrix() {
		int[][] adjMatrix = new int[totalVertex][totalVertex];
		int i = 0;
		for (LinkedList<Integer> vertex : adjList ) {
			if (!vertex.isEmpty()) {
				for (int edge : vertex) {
					adjMatrix[i][edge] = 1;
				}
			}
			i++;
		}
		for (i = 0; i < totalVertex; i++) {
			for (int j = 0; j < totalVertex; j++) {
				System.out.print("" + adjMatrix[i][j]);
				if (j != totalVertex - 1) System.out.print(" ");
			}
			System.out.println();
		}
		
	}
}

//change class name GraphRepresentation to Main() for submission to AIZU
public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.printAdjMatrix();
	}
}


Measured memory_bytes: 35504
program resistors_in_parallel
  implicit none
  integer :: n
  real(8) :: a(100) = 0.d0
  character(64) :: s
  read(*,*) n
  read(*,*) a(1:n)
  write(s,'(f32.16)') 1.d0/sum(1.d0/a(1:n))
  write(*,'(a)') trim(adjustl(s))
end program resistors_in_parallel

Measured memory_bytes: 256
def check(x):
    str_x = str(x)
    if min(str_x.count("3"),str_x.count("5"),str_x.count("7")) > 0:
        return True
    else:
        return False

def solve(x):
    if x > N:
        return 0
    if check(x):
        ans = 1
    else :
        ans = 0
    ans += solve(10*x + 3)
    ans += solve(10*x + 5)
    ans += solve(10*x + 7)
    return ans
N = int(input())
print(solve(0))



Measured memory_bytes: 3060
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n;
    cin>>n;
    cout<<(180*n-360);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 15460
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<ll>;
using VV = vector<VI>;
using VS = vector<string>;

// tourist set
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << '\n'; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
// tourist set end

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<'\n'
#define p2(s, t) cout << (s) << " " << (t) << '\n'
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << '\n'
#define p_yes() p("YES")
#define p_no() p("NO")
#define SZ(x) ((int)(x).size())
#define SORT(A) sort(ALL(A))
#define RSORT(A) sort(ALL(A), greater<ll>())

void no(){p_no(); exit(0);}
void yes(){p_yes(); exit(0);}

const ll mod = 1e9 + 7;
const ll inf = 1e18;
const double PI = acos(-1);

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

    // input
    ll N; 
    cin >> N;

    VI A(N);
    rep(i, N){
        cin >> A.at(i);
    }

    ll sum = 0;
    for(ll a : A){
      sum += a;
    }

    ll ans = sum-N;
    p(ans);
    
    return 0;
}

Measured memory_bytes: 256
import Data.List
main = do
  n <- getLine
  xs <- map read . words <$> getLine
  putStrLn . show $ solve xs
 
solve :: [Int] -> Int
solve xs =  snd $ foldr calc (0,0) $ sort xs

calc x (i,r)
 | i `mod` 2 == 0 = (i+1, r+x)
 | otherwise      = (i+1, r-x)

Measured memory_bytes: 1020
#include <cstdio>
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(void){
    string input;
    
    while(getline(cin, input), !cin.eof()){
        int a, b;
        char op;
        
        sscanf(input.c_str(), "%d %c %d\n", &a, &op, &b);
        
        int result;
        switch(op){
            case '+':
                result = a + b;
                break;
                
            case '-':
                result = a - b;
                break;
                
            case '*':
                result = a * b;
                break;
                
            case '/':
                result = a / b;
                break;
                
            case '?':
            default:
                goto end;
        }
        
        printf("%d\n", result);
    }
    
end:
    return(0);
}



Measured memory_bytes: 3292
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (ll i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    int N;
    cin >> N;
    vector<int> D(N);
    rep(i, N){
        int d1, d2;
        cin >> d1 >> d2;
        if(d1==d2) D[i]++;
    }
    rep(i, N-2){
        if(D[i]+D[i+1]+D[i+2]==3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3600