akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef bitset<2005> bs;

bool f[2005][2005],e[2005][2005];
bs g[2005],h[2005];

char str[2005];

int main() {
  int n;
  scanf("%d",&n);
  for(int i=2;i<=n;i++) {
  	scanf("%s",str+1);
  	for(int j=1;j<i;j++)
  	  if (str[j]=='1') e[i][j]=1; else e[j][i]=1;
  }
  for(int i=1;i<=n;i++) {
  	f[i][i]=1;
  	h[i].flip(i);
  }
  for(int j=2;j<=n;j++) {
    for(int i=j;i<=n;i++) {
    	int l=i-j+1;
    	if (e[i][l]&&f[l][i-1]) g[i].flip(l);
    	if ((g[i]&h[l]).any()) {
    		f[i][l]=1;
    		h[l].flip(i);
		}
	}
	for(int i=1;i<=n-j+1;i++) {
		int r=i+j-1;
		if (e[i][r]&&f[r][i+1]) g[i].flip(r);
		if ((g[i]&h[r]).any()) {
			f[i][r]=1;
			h[r].flip(i);
		}
	}
  }
  int ans=0;
  for(int i=1;i<=n;i++) ans+=(f[i][1]&&f[i][n]);
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 9088
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

answer = []
for i in range(M):
    x, y, c = map(int, input().split())
    answer.append(a[x-1]+b[y-1]-c)

print(min(min(answer), min(a)+min(b)))

Measured memory_bytes: 18736
using System;
class ProgramA
    {
        static void Main(string[] args)
        {
            
            string input = Console.ReadLine();
            int n = int.Parse(input);
          
            if(n % 2 == 0)
                Console.WriteLine((n -2)/2);
            else
            {
                Console.WriteLine((n -1)/2);
            }
        }
    }

Measured memory_bytes: 13140
N, M = map(int, input().split())
rslt = [-1]*N
for m in range(M):
  s, c = map(int, input().split())
  if s == 1 and c == 0 and N>1:
    print(-1)
    exit()
  elif s > N:
    print(-1)
    exit()
  elif rslt[s-1] != -1 and rslt[s-1] != c:
    print(-1)
    exit()
  else:
    rslt[s-1] = c

if N>1 and rslt[0] == -1:
  rslt[0] = 1
rslt = ['0' if i == -1 else str(i) for i in rslt]
print(''.join(rslt))


Measured memory_bytes: 3064
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
print(N/3 * N/3 * N/3)

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

int main() {
    int n;
    long long g,a,b,sb=9999999999;
    cin >> n;
    for (int i=0;i<n;i++) {
        cin >> a >> b;
            if (sb > b) {
                sb = b;
                g = a+b;
            }
    }
    cout << g << endl;
    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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(a>b){a=b;return 1;}return 0;}

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

  int a, b;

  cin >> a >> b;
  int ans = a+b;
  ans = max(ans, a-b);
  ans = max(ans, a*b);

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main()
{
    LL n,k,ans=0;
    cin>>n>>k;
    if(k==0) cout<<n*n<<endl;
    else{
        for(LL b=k+1;b<=n;b++){
            ans+=(n/b)*(b-k);
            if(n%b>=k)
                ans+=n%b-k+1;
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 256
def examB():
    W, a, b =LI()
    ans = max(max(a,b)-(min(a,b)+W),0)
    print(ans)

import sys
import copy
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

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

using namespace std;
typedef long long ll;

int main() {
  ll n;
  cin >> n;
  vector<ll> primes = {2, 3, 5, 7, 11, 13};
  vector<int> factors;
  for (ll i = 17; i < 1000000; i += 2) {
    bool is_prime = true;
    for (int j = 0; primes[j] * primes[j] <= i; ++j) {
      if (i % primes[j] == 0) {
        is_prime = false;
        break;
      }
    }
    if (is_prime)
      primes.emplace_back(i);
  }
  for (int i = 0; i < primes.size(); ++i) {
    int cnt = 0;
    while (n % primes[i] == 0) {
      n /= primes[i];
      cnt++;
    }
    factors.emplace_back(cnt);
  }
  if (n != 1)
    factors.emplace_back(1);
  int ans = 0;
  for (int i : factors) {
    int t = 1;
    int rest = i;
    while (rest >= t) {
      rest -= t;
      ans++;
      t++;
    }
  }
  cout << ans;
}


Measured memory_bytes: 4332
import itertools

s = input()

a,b,c,d = int(s[0]),int(s[1]),int(s[2]),int(s[3])

comb = []

for i in itertools.product([1,0],repeat=3):
    comb.append(i)
    
for i in range(8):
    if comb[i][0] == 1:
        x = a+b
    
    if comb[i][0] == 0:
        x = a-b
    
    if comb[i][1] == 1:
        x += c
    
    if comb[i][1] == 0:
        x -= c
    
    if comb[i][2] == 1:
        x += d
    
    if comb[i][2] == 0:
        x -= d
    
    if x == 7:
        ans_comb = comb[i]
        break

if ans_comb[0] == 1:
    x_1 = '+'

if ans_comb[0] == 0:
    x_1 = '-'
    
if ans_comb[1] == 1:
    x_2 = '+'

if ans_comb[1] == 0:
    x_2 = '-'

if ans_comb[2] == 1:
    x_3 = '+'

if ans_comb[2] == 0:
    x_3 = '-'
    
print(str(a)+x_1+str(b)+x_2+str(c)+x_3+str(d)+'=7')
    

Measured memory_bytes: 3064
#include <bits/stdc++.h> 
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=2*1e5+2;
map<int,vector<int>> v;
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);

      int n,k;
      cin>>n>>k;
      int a[n+1];
      for(int i=1;i<=n;i++) cin>>a[i];
      a[0]=0;
      for(int i=1;i<=n;i++) a[i]+=a[i-1];
      v[0].pb(0);
      int ans=0;
      for(int i=1;i<=n;i++)
      {
        int s=a[i]-i;
        s%=k;
        // cout<<s<<" ";
        if(v[s].size()==0) {v[s%k].pb(i); continue;}
        // cout<<i<<" ";
        int r=i-k;
        int o=v[s].end()-upper_bound(all(v[s]),r);
        ans+=o;
        // cout<<i<<" "<<o<<" "<<s<<" "<<v[s].size()<<"\n";
        v[s%k].pb(i);
      }
      cout<<ans;
}
// I never lose. I either win or I learn

Measured memory_bytes: 23680
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define INF (int)1e9 + (int)1e8
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

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

void cpp(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

ll dp[101][100004];

int main(){
    cpp();
    ll n, k;
    cin>>n>>k;
    vector<ll> v(n);
    for(ll i=0; i<n; i++){
        cin>>v[i];
    }
    dp[0][0] = 1;
    for(ll i=1; i<=n; i++){
        for(ll j=0; j<=k; j++){
            if(j==0){
                dp[i][j] = dp[i-1][j];
                dp[i][j]%=mod;
                continue;
            }
            dp[i][j] = dp[i][j-1]+dp[i-1][j]-((j-1-v[i-1]>=0)?dp[i-1][j-1-v[i-1]]:0);
            dp[i][j]%=mod;
            dp[i][j]=(dp[i][j]+mod)%mod;
        }
    }
    cout<<dp[n][k]<<endl;
    return 0;
}






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

using namespace std;

#define forn(i, n) for (int i = 0; i < (int) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using ll = long long;
const int inf = 1e9+5; 

const double PI =  3.14159265;

int main(){
	IO;
	int n, k;
	cin>>n>>k;
	int h[n], dp[n+1];
	for(int i = 0; i<n ; i++)
		cin>>h[i];
	
	dp[0] = 0;
	for(int i = 1; i< n; i++){
		dp[i] = inf;
		for(int j = 1; j<=k; j++){
			if(i-j>=0) dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j])); 
		}
	}
	cout<<dp[n-1]<<'\n';
	return 0;
}


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

int q;
string X, Y;


int main(void) {
  int dp[1000][1000];
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> X >> Y;

    dp[0][0] = X[0] == Y[0];
    for (int j = 1; j < Y.size(); j++) dp[0][j] = dp[0][j-1] || X[0] == Y[j];
    for (int j = 1; j < X.size(); j++) dp[j][0] = dp[j-1][0] || X[j] == Y[0];

    for (int j = 1; j < X.size(); j++) {
      for (int k = 1; k < Y.size(); k++) {
        if (X[j] == Y[k]) {
          dp[j][k] = dp[j-1][k-1] + 1;
        } else {
          dp[j][k] = max(dp[j-1][k], dp[j][k-1]);
        }
      }
    }

    cout << dp[X.size()-1][Y.size()-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 7076
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
int main() {
  int k, a, b, check = 0;
  cin >> k;
  cin >> a >> b;
  for (int i = a; i<=b; i++) {
    if (i%k==0) check = 1;
  }
  if(check==0) printf("NG\n");
  else printf("OK\n");
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    int tmp;
    vector <int> p;
    cin >>n;
    FOR(i,0,n){
        cin >>tmp;
        p.push_back(tmp);
    }
    int sum =0;
    FOR(i,0,n-2){
        if(max(p[i],p[i+2])>p[i+1] &&p[i+1] >= min(p[i],p[i+2]))
            sum++;
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cassert>

using namespace std;

void failed() {
  cout << "NA" << endl;
}

int main() {
  
  int Q1, B, C1, C2, Q2;
  
  while(cin >> Q1 >> B >> C1 >> C2 >> Q2) {
    if(Q1 == 0) break;
    
    if(B/C1 == 0) {
      failed(); continue;
    }
    
    int AizuCh = min(B/C1, Q2);
    int NCh = 0;
    for(;;) {
      
      if(AizuCh <= 0) { failed(); break; }
      
      NCh = (B - AizuCh*C1)/C2;
      
      /*
      if(B - (NCh+1)*C2 - AizuCh*C1 >= 0) {
        NCh = (B - AizuCh*C1)/C2;
      }
      */
      if(AizuCh + NCh >= Q1) {
        cout << AizuCh << ' ' << NCh << endl; break;
      }
      /*
      else if(B - (NCh+1)*C2 - (AizuCh-1)*C1 >= 0) {
        NCh ++, AizuCh --;
      }
      */
      else AizuCh --;
    }
    
  }
  
  return 0;
}

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

int main() {
	int pasuta[3],juusu[2],pmin = 0,jmin = 0;
	for(int i = 0; i < 3; i++){
		cin >> pasuta[i];
	}
	pmin = pasuta[0];
	for(int i = 0; i < 2; i++){
		cin >> juusu[i];
	}
	jmin = juusu[0];
	for(int j = 0; j < 3; j++){
		if(pmin > pasuta[j]){
			pmin = pasuta[j];
		}
	}
	for(int j = 0; j < 2; j++){
		if(jmin > juusu[j]){
			jmin = juusu[j];
		}
	}
	cout << pmin + jmin - 50 <<endl;
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
using namespace std;


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


int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
    
  rep(i, n) cin >> a[i];

  sort(a.begin(), a.end());

  vector<int> cnt(n, INT_MAX);
  

  int itr = 0;
  int numnum = 0;
  bool end = false;


  for(int i = 0; i < n; ++i){
          
    numnum++;
    int num = a[i];
    cnt[itr] = 0;

    for(int j = i; ; ++j){
      if(j == n){
        i = j;
        end = true;
        break;
      }

      if(num != a[j]){
        i = j - 1;
        break;
      }

      cnt[itr]++;
    }

    if(end) {
      break;
    }
    itr++;
    
  }


  sort(cnt.begin(), cnt.end());
  int ans = 0;
  for(int i = 0; numnum > k; ++i){
    ans += cnt[i];
    numnum--;
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a[3][3];
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      cin>>a[i][j];
  int n;
  cin>>n;
  int b[n];
  for(int i=0;i<n;i++){
    cin>>b[i];
  	for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(b[i]==a[j][k])
          a[j][k]=0;
      }
    }
  }
  int check=0;
  for(int i=0;i<3;i++){
    if(a[0][i]==0&&a[1][i]==0&&a[2][i]==0)
      check=1;
    if(a[i][0]==0&&a[i][1]==0&&a[i][2]==0)
      check=1;
  }
  if(a[0][0]==0&&a[1][1]==0&&a[2][2]==0)
    check=1;
  if(a[0][2]==0&&a[1][1]==0&&a[2][0]==0)
    check=1;
  if(check==1)
    cout<<"Yes";
  else
    cout<<"No";
}

Measured memory_bytes: 256
n=int(input())
a=[0]+list(map(int,input().split()))+[0]

dis=0
d=[0]*n

for i in range(1,n+1):
    dis+=abs(a[i]-a[i-1])
    if a[i+1]<a[i] and a[i-1]<a[i]:
        d[i-1]=2*(a[i]-max(a[i-1],a[i+1]))
    if a[i+1]>a[i] and a[i-1]>a[i]:
        d[i-1]=2*(min(a[i-1],a[i+1])-a[i])
dis+=abs(a[n+1]-a[n])

for i in range(n):
    print(dis-d[i])

Measured memory_bytes: 14164
#include <iostream>

using namespace std;
int main(){
	int i,x;
	cin >> x;
	int y = x%100;
	int k = y/5;
	int l = 0;
	if(y%5!=0) l++;
	if(x - 100*(k + l)>=0){
		cout << 1 << endl;
	}else{
		cout << 0 << endl;
	}
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

const int MAXN = 100100;
ll sum[MAXN], sumPlus[MAXN];

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (int i = 0; i < N; i++)
		cin >> A[i];
	for (int i = 0; i < N; i++) {
		sum[i+1] = sum[i] + A[i];
	}
	for (int i = 0; i < N; i++) {
		sumPlus[i+1] = sumPlus[i] + (A[i] > 0 ? A[i] : 0);
	}
	ll ans = 0;
	for (int i = 0; i+K <= N; i++) {
		ans = max(ans, max(0ll, sum[i+K]-sum[i]) + sumPlus[i] + (sumPlus[N]-sumPlus[i+K]));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2304
H,W=map(int,input().split())
A=[]
a=[0 for i in range(W+2)]
A.append(a)
for i in range(H):
    s=input()
    s="0"+s+"0"
    S=list(s)
    A.append(S)
A.append(a)
#print(A)

for x in range(1,H+1):
    for y in range(1,W+1):
        cnt=0
        if A[x][y]==".":
            if A[x-1][y-1]=="#":
                cnt+=1
            if A[x-1][y]=="#":
                cnt+=1
            if A[x-1][y+1]=="#":
                cnt+=1
            if A[x][y-1]=="#":
                cnt+=1
            if A[x][y]=="#":
                cnt+=1
            if A[x][y+1]=="#":
                cnt+=1
            if A[x+1][y-1]=="#":
                cnt+=1
            if A[x+1][y]=="#":
                cnt+=1
            if A[x+1][y+1]=="#":
                cnt+=1
            A[x][y]=str(cnt)
i=0
j=0
ans=""
for i in range(1,H+1):
    for j in range(1,W+1):
        ans+=A[i][j]
    print(ans)
    ans=""

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define mx INT_MAX
#define mn INT_MIN
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define itr set<int> :: iterator
const int mod = 1e9+7;

int dp[1001][1001];

int main(){
    // ******* START HERE ******

    int n,m;
    cin>>n>>m;

    vector<string> grid;
    for(int i=0; i<n; i++){
      string str;
      cin>>str;
      grid.pb(str);
    }

    memset(dp, 0, sizeof(dp));
    
    dp[0][0] = 1;
     
    for(int i=0; i<n; i++){
      for(int j=0; j<m; j++){
        if(grid[i][j] == '#')
           continue;
        if(i>0)
          dp[i][j] += dp[i-1][j]%mod;
        if(j>0)
          dp[i][j] += dp[i][j-1]%mod;
      }
    }

    cout<<dp[n-1][m-1]%mod<<endl;

    // ***** END HERE ***** 
    return 0;
}

Measured memory_bytes: 8532
#include <stdio.h>
#include <stdlib.h>

#define MAX 2000001
#define VMAX 10000

int main(void)
{
	unsigned short *A, *B;
	
	int C[VMAX+1];
	int n, i, j;
	scanf("%d",&n);
	
	A = malloc(sizeof(short)*n+1);
	B = malloc(sizeof(short)*n+1);
	
	for(i=0;i<=VMAX;i++) C[i] = 0;
	
	for(i=0;i<n;i++) {
		scanf("%hu",&A[i+1]);
		C[A[i+1]]++;
	}
	
	for(i=1;i<=VMAX;i++) C[i] = C[i] + C[i-1];
	
	for(j=1;j<=n;j++) {
		B[C[A[j]]] = A[j];
		C[A[j]]--;
	}
	
	for(i=1;i<=n;i++) {
		if(i>1) printf(" ");
		printf("%d",B[i]);
	}
	printf("\n");
	
	return 0;
}



Measured memory_bytes: 9628
#include<iostream>
#include <cmath>
#include<algorithm>
using namespace std;
int main() {
	int n, d;
	cin >> n >> d;
	int x[10][20];
	for (int i=0; i < n; i++) {
		for (int j=0; j < d; j++) {
			cin >> x[i][j];
		}
	}
	int ans=0;
	int s1=0;
	float s=0;
	for (int i=0; i < n; i++) {
		for (int j=i+1; j < n; j++) {
			for (int k = 0; k < d; k++) {
				s1 += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
			}
			s = sqrt(abs(s1));
			s1 = (int)sqrt(abs(s1));
			//cout << s << s1 << endl;
			//cout << s1 << endl;
			if (s == s1) {
				++ans;
			}
			s = s1 = 0;
		}
	}
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
      Scanner sc =new Scanner(System.in);
    int ans=0;
    String str=sc.next();

    for(int i=0;i<str.length();i++){
     char a;
     a=str.charAt(i);
      switch (a){
        case '+':
          ans++;
          break;
        default:
          ans--;
          break;
      }
    }
    System.out.println(ans);

  }
}

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


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

  sort(a.begin(),a.end());
  int ans=0;
  for(int i=0;i<n;++i){
    if(i==n-1){
      ans+=(a[i]/2);
    }else{
      ans+=a[i];
    }
  }
  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>
#include <cstdint>
#include <cctype>
using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using Vii = vector<vector<int> >;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vs = vector<string>;
using Vb = vector<bool>;
using the = pair<int, int>;

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	transform(a.begin(), a.end(), a.begin(),::toupper);
	transform(b.begin(), b.end(), b.begin(), ::toupper);
	transform(c.begin(), c.end(), c.begin(), ::toupper);
	cout << a[0]<< b[0] << c[0] << endl;
}


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

using namespace std;
typedef long long ll;

int main()
{
	char s[100010];
	scanf("%s", s);
	int N = strlen(s);

	int all_g = 0;
	for (int i = 0; i < N; i++)
		all_g += s[i] == 'g' ? 0 : -1;

	printf("%d\n", all_g + N / 2);

	return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> height(N);

  int value1, value2;          //隣り合う二つのマスに対応する値を格納
  int num = 1;                         //左からnum+1番目を走査
  int max = 0;                         //移動回数の最大値

  cin >> value1;                   //最左のマスの値を格納
  height[0] = 0;                    //最左のマス開始時点で移動回数は0

  while(num < N){             //計算量O(N)
    cin >> value2;               //左からnum+1番目のマスに対応する値を取得
    if(value1 < value2)     //条件を満たさない
      height[num] = 0;        //基準は0
    else
      height[num] = height[num-1] + 1;             //移動回数を更新
    
    if(max < height[num])     //移動回数の最大値を更新
      max = height[num];

    //cout <<  max << endl;

    value1 = value2;
    num++;
  }

  cout << max << endl;
  return 0;

}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#define ll long long
#define INF 1000000007
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string o,e;
    cin >> o;
    cin >> e;
    for(int i=0;i<o.size()+e.size();i++){
        if(i%2==0){cout << o[i/2];}
        else cout << e[i/2];
    }
    cout << endl;

    return 0;
}

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

int main(){
  string S;
  bool bad=false;
  cin >> S;
  for(int i=0;i<3;i++){
    if(S[i]==S[i+1]){
      cout << "Bad" << endl;
      bad=true;
      break;
    }
  }
  
  if(!(bad)) cout << "Good" << endl;
  
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair< int, int >;
 
int main() {
    int n;
    scanf("%d", &n);
    map<ll, int> mp;
    rep(i, n) {
        ll t; cin >> t;
        mp[t]++;
    }
    ll ans=0;
    for (auto & t : mp) {
        if (t.second % 2) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6528
N = int(input())
tpr, xpr, ypr = 0, 0, 0
count = 0
for i in range(N):
    t, x, y = map(int, input().split())
    d = abs(x-xpr) + abs(y-ypr)
    n = ((t-tpr) - d) / 2
    if n >= 0 and n % 1 == 0:
        count += 1
    tpr, xpr, ypr = t, x, y
if count == N:
    print("Yes")
else:
    print("No") 

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

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

    for(int i = 0; i < N; i++){
        int val = array[i];
        int j = i - 1;
        while(j >= 0 && array[j] > val){
            array[j+1] = array[j];
            j--;
            array[j+1] = val;
        }
        for(int i = 0; i < N; i++){
            if(i != N-1)cout << array[i] << " ";
            else cout << array[i] << endl;
        }
    }

    return 0;
}

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

main(){
	while(true){
		
		// 銀行の数
		int n;
		cin >> n;
		if(n == 0){
			break;
		}
		
		// お金を預ける年数
		int y;
		cin >> y;
		
		double bestRate = 0.0;
		int bestBank = -1;
		for(int i=0; i<n; ++i){
			// 銀行番号, 年利率, 金利の種類(1単利 or 2複利)
			int b, r, t;
			cin >> b >> r >> t;
			
			double rate = 1;
			if(t == 1){// 単利
				for(int i=0; i<y; ++i){
					rate += r/100.0;
				}
			}else{// 複利
				for(int i=0; i<y; ++i){
					rate *= (1.0 + r/100.0);
				}
			}
			if(bestRate < rate){
				bestRate = rate;
				bestBank = b;
			}
		}
		
		cout << bestBank <<endl;
	}
}


Measured memory_bytes: 3056
#[allow(dead_code)]
fn main() {
    let buf = io::read_string();
    let mut sc = io::Scanner::new(&buf);
    let r: usize = sc.read();
    println!(
        "{}",
        if r < 1200 {
            "ABC"
        } else if r < 2800 {
            "ARC"
        } else {
            "AGC"
        }
    );
}
#[allow(dead_code)]
mod io {
    use std;
    use std::io::Read;
    use std::str::{FromStr, SplitWhitespace};
    pub struct Scanner<'a> {
        pub iter: SplitWhitespace<'a>,
    }
    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }
        pub fn read<T: FromStr>(&mut self) -> T {
            self.iter
                .next()
                .unwrap()
                .parse()
                .ok()
                .expect("parsing failed")
        }
        pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.read()).collect()
        }
    }
    pub fn read_string() -> String {
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }
}


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

using namespace std;
typedef long long ll;

int n;
int a[22][22];
int md = 1e9+7;
int dp[22][1<<22];
void addMd(int &x, int y)
{
    x += y;
    if (x >= md)
        x -= md;
}
int f(int cur, int msk)
{
    if (cur == n) return 1;
    int &ret = dp[cur][msk];
    if (~ret) return ret;
    ret = 0;
    for (int i = 0; i < n; ++i)
        if (!((1<<i) & msk) && a[cur][i])
        {
            addMd(ret, f(cur+1, msk | (1<<i)));
        }
    return ret;
}
int main()
{
    memset(dp, -1, sizeof dp);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        for (int j =0 ; j < n ; ++j)
            scanf("%d", &a[i][j]);
    printf("%d\n", f(0, 0));

    return 0;
}


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

if N > K:
    ans = 0
    while K > 0:
        ans = A[ans] -1
        K -= 1
    print(ans+1)
else:
    count = 0
    a = 0
    # visited = [0]
    is_visited = [0 for _ in range(N)]
    is_visited[0] = 1
    while True:
        a = A[a]-1
        count += 1
        if is_visited[a] > 0:
            before_roop = is_visited[a]-1
            cycle = count - before_roop
            break
        is_visited[a] = count+1
        # if a in visited:
        #     break
        # visited.append(a)
    # before_roop = visited.index(a)
    # cycle = len(visited) - before_roop
    mod = (K - before_roop)%cycle
    # print(visited[before_roop + mod] +1)
    print(is_visited.index(is_visited[a] +mod) +1)


Measured memory_bytes: 99548
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int n;
vi v;
double dp[22][222222];

ld solve(int i, int t)
{
	if (i == n) return 0;
	if (dp[i][t] >= 0) return dp[i][t];
	ld tmp = (abs(t - v[i]) / (ld)v[i]);
	ld res = INF;
	for (int j = 1;; j++)
	{
		ld nx = t*j;
		if (nx > v.back()*2) break;
		chmin(res, max(solve(i + 1, nx), tmp));
	}
	return dp[i][t] = res;
}

int main()
{
	MS(dp, -1);
	cin >> n;
	v.resize(n);
	REP(i, n) cin >> v[i];
	ld ans = INF;
	FOR(i, 1, v.back()+1)
	{
		chmin(ans, solve(0, i));
	}
	cout << D10 << ans << endl;
	return 0;
}

Measured memory_bytes: 41440
// AOJ1160
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ipair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}
int w,h;
vector<vector<int>> ma(60,vector<int>(60));
int ans;
void dfs(int y,int x){
    if(y<0||h<=y||x<0||w<=x) return;
    if(ma[y][x]==0) return;
    ma[y][x]=0; //陸を海にしちゃう
    for(int i=-1;i<=1;i++){
        for(int j=-1;j<=1;j++){
            dfs(y+i,x+j);
        }
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    while(cin>>w>>h){
        ans=0;
        if(w==0 && h==0) break;
        rep(y,h){
            rep(x,w){
                cin>>ma[y][x];
            }
        }
        rep(y,h){
            rep(x,w){
                if(ma[y][x]==0) continue;
                dfs(y,x);
                ans++;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
// #ifndef ONLINE_JUDGE
// #include "debug.cpp"
// #endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  int n; cin >> n;
  string s; cin >> s;

  if(n%2==1){
    cout << "No\n";
    return 0;
  }

  string left = "";
  string right = "";

  for(int i=0;i<n/2;i++) left+=s[i];
  for(int i=n/2;i<n;i++) right+=s[i];

  // print(left,right);

  if(left==right) cout << "Yes\n";
  else cout << "No\n";


  

  return 0;
}

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

class two_numbers {
public:
	int x;
	int y;

	int orderingnum(int n);
};

int two_numbers::orderingnum(int n) {
	switch (n) {
	case 1:
		if ( x > y)
			return x;
		else
			return y;
	case 2:
		if ( x > y)
			return y;
		else
			return x;
	default:
		return -1;
	}
}

int main() {

	int i=0,k;
	class two_numbers nm[3001];

	cin >> nm[i].x >> nm[i].y;
	while (!(nm[i].x==0 && nm[i].y==0)) {
		i++;
		cin >> nm[i].x >> nm[i].y;
	}
	k=i;
	while ( i > 0 ) {
		cout << nm[k-i].orderingnum(2) << " " << nm[k-i].orderingnum(1) << endl;
		i--;
	}

	return 0;
}



Measured memory_bytes: 3040
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)
 
int n,m,ans;
int main(){
    scanf("%d%d",&n,&m);
    printf("%d",m+100*max(0,10-n));
}

Measured memory_bytes: 128
N=int(input())
list=[]
for i in range(N):
  A=int(input())
  list.append(A)
l=sorted(list,reverse=True)
A_1=l[0]
A_2=l[1]
for j in range(N):
  if list[j]!=A_1:
    print(A_1)
  else:
    print(A_2)

Measured memory_bytes: 14112
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define ll long long
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)

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

  vector<int> x(n);

  r(i,n){
    cin>>x.at(i);
  }

  int mini=1<<30,sum;

  for(int i=0;i<n-k+1;i++){
    sum=0;
    sum+=min(abs(x.at(i)),abs(x.at(i+k-1)));
    sum+=abs(x.at(i)-x.at(i+k-1));
    mini=min(sum,mini);
  }

  cout<<mini<<endl;


  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
using namespace std;

int main(int argc, char const *argv[])
{
    int r, c;
    cin >> r >> c;
    int a[r + 1][c + 1];
    int num;
    for(int i = 0; i < r; i ++){
        for(int j = 0; j < c; j ++){
            cin >> num;
            a[i][j] = num;
        }
    }
    for(int i = 0; i < r; i ++){
        num = 0;
        for(int j = 0; j < c; j ++)
            num += a[i][j];
        a[i][c] = num;
    }
    for(int j = 0; j < c + 1; j ++){
        num = 0;
        for(int i = 0; i < r; i ++)
            num += a[i][j];
        a[r][j] = num;
    }
    for(int i = 0; i < r + 1; i ++){
        for(int j = 0; j < c + 1; j ++){
            cout << a[i][j];
            if (j < c) cout << " ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3152
#include <iostream>
//#include <numeric>
//#include <vector>
//#include<math.h>
//#include <algorithm>
//#include <functional>
//#include <numeric>
//#include<cmath>
//#include <stdio.h> 
//#include <cstdint>
//#include <string>
//#include <cstdlib>
//#define pi 3.14159265359
using namespace std;

int main() {

	int a;
	cin >> a;

	cout << a * a;


	return 0;

}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int len,n,i,j,x,a,b,c,kr[10001],max,cnt=1,p,su;
	scanf("%d",&n);
	scanf("%d %d",&a,&b);
	scanf("%d",&c);
	for(i=0;i<n;i++){
		scanf("%d",&kr[i]);
	}
	sort(kr,kr+n,greater<int>());
	max=c/a;
	p=c;
	for(i=0;i<n;i++){
		p+=kr[i];
		x=p/(a+b*(i+1));
		if(max<x){
			max=x;
		}
	}
	printf("%d\n",max);

	return 0;
}

Measured memory_bytes: 1048
# coding: utf-8
# Your code here!

S = input()
if S == "MON":
	print(6)
elif S == "TUE":
	print(5)
elif S == "WED":
	print(4)
elif S == "THU":
	print(3)
elif S == "FRI":
	print(2)
elif S == "SAT":
	print(1)
else:
	print(7)

Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main (int argc, const char * argv[])
{
    int x,y,r,W,H;
    
    cin >> W >> H >> x >> y >> r ;
    
    //水平
    if (((x-r)>=0 and (x+r)<=W) and ((y-r)>=0 and (y+r)<=H)){
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }
      return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define ll long long
#define MAX 100000

using namespace std;

vector<vector<int> > g(MAX);
vector<bool> vis(MAX);
vector<int> dp(MAX);

int dfs(int u)
{
    vis[u] = true;
    dp[u] = 0;

    for(int i=0; i<g[u].size(); i++){
        int v = g[u][i];
        if(vis[v] == true){
            dp[u] = max(dp[u],dp[v]+1);
        }

        else{
            dp[u] = max(dp[u],dfs(v)+1);
        }
    }

    return dp[u];
}

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

    for(int i=0; i<n; i++){
        if(vis[i] == false){
            dfs(i);
        }
    }

    int res = dp[0];
    for(int i=1; i<n; i++){
        res = max(res,dp[i]);
    }

    cout << res;

    return 0;
}


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


int main() {
  int n, r;
  cin >> n >> r;
  if(n < 10) {
    cout << r + (10 - n) * 100 << endl;
  } else {
    cout << r << endl;
  }
  return 0;
}

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

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

    ll res = 0;
    for (int i = 0; i < n; ++i) {
        if (b[i] > a[i]) {
            int t = b[i] - a[i];
            res += a[i] + min(a[i + 1], t);
            a[i + 1] -= min(a[i + 1], t);
        } else {
            res += b[i];
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll n,m;
  cin >>n>>m;
  ll ans=1;
  for(ll i=0;i<m;i++) ans*=2;
  ll k=1900*m+100*(n-m);
  cout<<k*ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <climits>
#include <cstdio>
#include <cstring>
using namespace std;
#define INF INT_MAX
typedef unsigned int uint;
int in() {
    int x = 0, c;
    for (; (uint)((c = getchar()) - '0') >= 10; ) { if (c == '-') return -in(); if (!~c) throw ~0; }
    do { x = (x << 3) + (x << 1) + (c - '0'); } while ((uint)((c = getchar()) - '0') < 10);
    return x;
}
 
vector< vector<int> > one , two;
 
void put(vector<int> &s,int x,int v){
    x += s.size()/2-1;
    while(x){
        s[x] = min(v,s[x]);
        x /= 2;
    }
}
int get(vector<int> &s,int l,int r,int k,int a,int b){
    //cout << a << " " << b << " " << s.size() << " " << endl;
    if(l==a && r==b) return s[k];
    if(b < l || r < a) return INF;
    return min(get(s,l,min((a+b)/2,r),k*2,a,(a+b)/2),get(s,max((a+b+1)/2,l),r,k*2+1,(a+b+1)/2,b));
}
 
int gen(int n){
    int ans = 1;
    while(ans < n) ans *= 2;
    return ans;
}
 
int main(){
    int H,W,Q;
    while(H = in() , W = in() , Q = in() , H){
        one.resize(H+1);
        two.resize(W+1);
        int hH = gen(H) , wW = gen(W);
        for(int i = 1 ; i <= H ; i++){
            one[i].resize(2*wW+1);
            fill(one[i].begin(),one[i].end(),INF);
        }
        for(int i = 1 ; i <= W ; i++){
            two[i].resize(2*hH+1);
            fill(two[i].begin(),two[i].end(),INF);
        }
        for(int i = 1 ; i <= H ; i++)
            for(int j = 1 ; j <= W ; j++){
                int a; a = in();
                put(one[i],j,a);
                put(two[j],i,a);
            }
        for(int i = 0 ; i < Q ; i++){
            int y1 = in() , x1 = in() , y2 = in() , x2 = in();
            x1++,y1++,x2++,y2++;
            if(x2-x1 >= y2-y1){
                int ans = INT_MAX;
                for(int j = y1 ; j <= y2 ; ++j) ans = min( ans , get(one[j],x1,x2,1,1,wW) );
                printf("%d\n",ans);
            }else{
                int ans = INT_MAX;
                for(int j = x1 ; j <= x2 ; ++j) ans = min( ans , get(two[j],y1,y2,1,1,hH) );
                printf("%d\n",ans);
            }
        }
         
    }
}

Measured memory_bytes: 63940
import Control.Monad

main = do
    getLine -- dummy
    
    nsStr <- getLine
    let ns = (map read (words nsStr)) :: [Int]
    let n = if (length ns) == 2
        then gcd (ns!!0) (ns!!1)
        else gcd (gcd (ns!!0) (ns!!1)) (ns!!2)
    
    let sr = floor (sqrt (fromIntegral n)) :: Int
    
    let factor1 = filter (\i -> (mod n i) == 0) [1..sr]
    let factor2 = reverse (map (\i -> div n i) factor1)
    let factor2b = if (head factor2) == sr then drop 1 factor2 else factor2
    forM_ factor1 (\i -> do putStrLn (show i))
    forM_ factor2b (\i -> do putStrLn (show i))



Measured memory_bytes: 3776
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
using namespace std;
int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {

  int n; cin >> n;
  vector<int> d(n);
  inputV(d, n);
  sort(d.begin(), d.end());
  int cnt = 1;
  for(int i=1; i<n; i++){
    if( d[i-1] < d[i] ) cnt++;
  }
  cout << cnt << endl;

  return 0;
}




//


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeSearch(Node u, int k){
  if(u == NIL || u->key == k) return u;
  else if(u->key > k) return treeSearch(u->left, k);
  else if(u->key < k) return treeSearch(u->right, k);
}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;

}

void inorder(Node u){
  if(u->left != NIL) inorder(u->left);
  printf(" %d", u->key);
  if(u->right != NIL) inorder(u->right);
}
void preorder(Node u){
  printf(" %d", u->key);
  if(u->left != NIL) preorder(u->left);
  if(u->right != NIL) preorder(u->right);
}
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

Measured memory_bytes: 19364
#include <bits/stdc++.h>
#define mod 1000000007
#define MOD 998244353
#define pb push_back
#define fi first
#define se second
#define vii vector<pair<int,int> >
#define vi vector<ll>
#define ll long long
#define rep(i,a,b) for(i=a;i<=b;i++)
#define inf 100000000000000000
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
using namespace std;
 
int main()
{
    IOS;
    int n,a,b;
    cin>>n>>a>>b;
    ll p[n];
    for(int i=0;i<n;i++)
    {
        cin>>p[i];
    }
    sort(p,p+n);
    int l1=upper_bound(p,p+n,a)-p;
    int l2=(upper_bound(p,p+n,b)-p)-l1;
    int l3=n-l1-l2;
    cout<<min(l1,min(l2,l3));
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
2 1 1
2
0 1 4 1
3 0 3 3

output:
1.00000000 1.00000000 3.00000000 1.00000000
3.00000000 1.00000000 3.00000000 1.00000000
"""

import sys
import math


class Segment(object):
    __slots__ = ('source', 'target')

    def __init__(self, source, target):
        self.source = complex(source)
        self.target = complex(target)


class Circle(object):
    __slots__ = ('centre', 'radius')

    def __init__(self, centre, radius):
        self.centre = complex(centre)
        self.radius = float(radius)


def dot(a, b):
    return a.real * b.real + a.imag * b.imag


def project(s, p):
    base_vector = s.target - s.source
    prj_ratio = dot(p - s.source, base_vector) / pow(abs(base_vector), 2)
    return s.source + base_vector * prj_ratio


def get_cross_point(c, l):
    prj_vector = project(l, c.centre)
    line_unit_vector = (l.target - l.source) / (abs(l.target - l.source))
    base = math.sqrt(pow(c.radius, 2) - pow(abs(prj_vector - c.centre), 2))
    p1, p2 = prj_vector + line_unit_vector * base, prj_vector - line_unit_vector * base

    if p1.real < p2.real:
        ans = (p1, p2)
    elif p1.real == p2.real:
        if p1.imag < p2.imag:
            ans = (p1, p2)
        else:
            ans = (p2, p1)
    else:
        ans = (p2, p1)
    return ans


def solve(_lines):
    for line in _lines:
        line_axis = tuple(map(int, line))
        p0, p1 = (x + y * 1j for x, y in zip(line_axis[::2], line_axis[1::2]))
        l = Segment(p0, p1)
        cp1, cp2 = get_cross_point(circle, l)
        print('{0:.8f} {1:.8f} {2:.8f} {3:.8f}'.format(cp1.real, cp1.imag, cp2.real, cp2.imag))

    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()

    cx, cy, r = map(int, _input[0].split())
    q_num = int(_input[1])
    lines = map(lambda x: x.split(), _input[2:])

    circle = Circle(cx + cy * 1j, r)
    solve(lines)

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

using namespace std;

bool calc(const std::vector<int>& as, const std::vector<int>& bs) {
  int64_t minus = 0;
  int64_t plus = 0;
  for (int i = 0; i < as.size(); i++) {
    int64_t const d = (int64_t)bs[i] - (int64_t)as[i];
    if (d >= 0) {
      plus += d / 2;
    } else {
      minus -= d;
    }
  }
  return minus <= plus;
}

int main() {
  int n;
  std::cin >> n;
  std::vector<int> as(n);
  std::vector<int> bs(n);
  for (auto& a : as) {
    std::cin >> a;
  }
  for (auto& b : bs) {
    std::cin >> b;
  }
  std::cout << (calc(as, bs) ? "Yes" : "No") << std::endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
long long x, y, a, b, c;
long long p[100010], q[100010], r[100010], z, ans;
priority_queue<pair<long long, int> > que;
int main() {
	cin >> x >> y >> a >> b >> c;
	for (long long i = 1; i <= a; i++) cin >> p[i], que.push(make_pair(p[i], 1));
	for (long long i = 1; i <= b; i++) cin >> q[i], que.push(make_pair(q[i], 2));
	for (long long i = 1; i <= c; i++) cin >> r[i], que.push(make_pair(r[i], 3));
	while (!que.empty()) {
		if (x + y <= z) break;
		int f = que.top().first;
		int s = que.top().second;
		que.pop();
		if (s == 1 && x > 0) {
			ans += f;
			x--;
		} else if (s == 2 && y > 0) {
			ans += f;
			y--;
		} else if (s == 3) {
			ans += f;
			z++;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 12652
var Main = (input) => {
        input = input.replace("\n","")
       if([ "2", "4", "5", "7", "9" ].includes(input[input.length-1])) console.log("hon");
  else if([ "0", "1", "6", "8"      ].includes(input[input.length-1])) console.log("pon");
  else if([ "3"                     ].includes(input[input.length-1])) console.log("bon");
 
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29472
N = int(input())
ans = 0
for i in range(1, N+1):
    ans += i * (N-i+1)
for _ in range(N-1):
    u, v = map(int, input().split())
    if u > v:
        u, v = v, u
    ans -= u * (N-v+1)
print(ans)

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yesorno(a) printf(a ? "yes\n" : "no\n")
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define YESorNO(a) printf(a ? "YES\n" : "NO\n") 
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  int n;
  cin >> n;
  vector<string> s(n);
  rep(i,n) {
    cin >> s[i];
  }
  for(char i = 'a'; i <= 'z'; i++){
    int cnt = inf;
    rep(j,n){
      int tmp = 0;
      rep(k,s[j].size()) {
        if(s[j][k] == i) tmp++;
      }
      cnt = min(cnt, tmp);
    }
    rep(j,cnt) cout << i;
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int main(){
  long ii,jj,kk;
  vector<int> a;
  int n;

  cin >> n;

  a.resize(n);
  for(ii=1;ii<=n;ii++){
    a[ii-1] = ii;
  }

  do{
    for(ii=0;ii<n;ii++){
      cout << a[ii];
      if(ii != n-1){
        cout << " ";
      }
      else{
        cout << endl;
      }
    }    
  }while(next_permutation(a.begin(),a.end()));
  
  return 0;
}



Measured memory_bytes: 3100