akhauriyash/Code-Regression huggingface dataset:
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        hoge();
        //System.Console.ReadLine();
    }

    public static void hoge()
    {
        var vars = System.Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var n = vars[0];
        var k = vars[1];
        long[] machi = vars = System.Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        long[] kita = new long[n];
        long now = 0;
        for (long i = 1; i <= k; i++)
        {
            if (kita[now] > 0)
            {
                long loop = i - kita[now];
                var count = (k - i) % loop;
                count += 1;
                for (i = 0; i < count; i++)
                {
                    now = machi[now] - 1;
                }
                System.Console.WriteLine(now + 1);
                return;
            }
            kita[now] = i;
            now = machi[now] - 1;
        }
        System.Console.WriteLine(now + 1);
        return;

    }
}

Measured memory_bytes: 45336
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=3005;
int n,m,k,a[N][N],dp[N][N][4];
void chmax(int &a,int b){if(a<b)a=b;}
signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m>>k;
	for(int i=1;i<=k;i++)
	{
		int x,y,v;
		cin>>x>>y>>v;
		a[x][y]=v;
	}
	dp[1][1][1]=a[1][1];
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			for(int k=0;k<=3;k++)
			{
				chmax(dp[i+1][j][0],dp[i][j][k]);
				chmax(dp[i][j+1][k],dp[i][j][k]);
				chmax(dp[i+1][j][1],dp[i][j][k]+a[i+1][j]);
				if(k<3) chmax(dp[i][j+1][k+1],dp[i][j][k]+a[i][j+1]);
			}
		}
	}
	cout<<max(max(dp[n][m][0],dp[n][m][1]),max(dp[n][m][2],dp[n][m][3]))<<endl;
	return 0;
}

Measured memory_bytes: 355848
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>
#include<map>
 
 
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1e13
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
typedef long long int ll;
#define MOD 1000000007

int mp[91][91];
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ans = 0;
int m,n;

void dfs(int cnt,int x,int y){

    ans = max(ans,cnt);
    for(int i = 0;i < 4;i++){
        int nx = x + dx[i];
        int ny = y + dy[i];
        if(nx >= 0 && nx < n && ny >= 0 && ny < m && mp[nx][ny] == 1){

            mp[nx][ny] = 0;
            dfs(cnt+1,nx,ny);
            mp[nx][ny] = 1;
        }
    }
}


int main(){

    while(cin >> m >> n,m){

        REP(i,n){
            REP(j,m){
                cin >> mp[i][j];
            }
        }
        REP(i,n){
            REP(j,m){
                if(mp[i][j] == 1){
                    mp[i][j] = 0;
                    dfs(1,i,j);
                    mp[i][j] = 1;
                }
            }
        }
        cout << ans << endl;
        ans = 0;
    }




    return 0;
}




Measured memory_bytes: 3048
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,M=map(int,input().split())
    b=[0]*M
    for i in range(N):
        l=list(map(lambda x:int(x)-1,input().split()))
        for x in l[1:]:
            b[x]+=1
    ans=0
    for x in b:
        if x==N:
            ans+=1
    print(ans)

if __name__ == '__main__':
    main()


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

int main() {
  int X;
  int ans = 0;
  cin >> X;
  ans += (X / 500) * 1000;
  X = X % 500;
  ans += (X / 5) * 5;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
T = []
for i in range(ord("a"),ord("z")+1) :
    T.append(chr(i))

L = list(input())
counter = 0
flag = 0
for i in range(len(L)) :
    if i == 0 :
        if L[i] != "A" :
            ans = -1
            break
    elif i == 1 :
        if L[i] not in T :
            counter += 1
    elif 2 <= i <= len(L)-2 :
        if L[i] not in T and flag == 1 :
            counter += 1
        elif flag == 0 and L[i] == "C" :
            flag = 1
    else :
        if L[i] not in T :
            counter += 1
if counter > 0 or flag == 0 :
    print("WA")
else :
    print("AC")


Measured memory_bytes: 3064
#include<string>
#include<iostream>
#include<unordered_map>

using namespace std;

int main(void) {
  
  string s;
  cin >> s;
  
  unordered_map<char, char> map;
  map['A'] = 'T';
  map['T'] = 'A';
  map['C'] = 'G';
  map['G'] = 'C';
  
  for(int i = 0; i < s.size(); ++i) {
    s[i] = map[s[i]];
  }
  
  cout << s << endl;
  
  return 0;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define EPS 1e-9
using namespace std;

typedef complex<double> P;

P rot (P x, P p, double ang) {
    ang = ang / 180.0 * M_PI;
    double p1 = p.real() - x.real();
    double p2 = p.imag() - x.imag();
    return P( p1 * cos(ang) - p2 * sin(ang) + x.real()
              , p1 * sin(ang) + p2 * cos(ang) + x.imag() );
}

int main () {
    int n;
    while (cin >> n, n) {
        vector<P> v(n);
        for (auto &i : v) {
            double x, y;
            cin >> x >> y;
            i = P(x,y);
        }

        int res = 1;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i != j && abs(v[i] - v[j]) <= 2. + EPS) {
                    int count = 0;
                    P m = P(abs(v[i].real() + v[j].real()) / 2., abs(v[i].imag() + v[j].imag()) / 2.);
                    P p = m + (m - v[i]) / abs(m - v[i]) * sqrt(1. - pow(abs(m - v[i]), 2.));
                    p = rot(m, p, 90);
                    for (int k = 0; k < n; k++) {
                        if (abs(p - v[k]) <= 1. + EPS) count++;
                    }

                    res = max(res, count);
                }
            }
        }

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

Measured memory_bytes: 1268
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false ll_MAX ll_MIN insert erase clear pop push compare ll64_MAX ll64_MIN  reverse replace stringstream string::npos length substr front priority_queue

#ifndef ONLINE_JUDGE
#include "debug.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define debug(...) 42
#endif

#define endl '\n'
#define ll long long
#define rint register int
#define minpq priority_queue <int, vector<int>, greater<int> >
#define maxpq  priority_queue <int>

#define re register
#define pb(x) push_back(x);
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX

#define conutBits(n)	__builtin_popcount(n)
#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

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

	ll t, i, x, j, y, 	z, k, n;
	cin >> x >> y >> t;

	n = (x + y - 1) / y;
	z = n * t;

	ce(z);

}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n;
    cin >> n;
    vector<P> xl(n);
    rep(i,0,n-1){
        int x,l;
        cin >> x >> l;
        xl[i] = P(x+l,x-l);
    }

    sort(xl.begin(),xl.end());
    int arm = xl[0].first;
    int ans = 1;
    rep(i,1,n-1){
        if(xl[i].second >= arm){
            ++ans;
            arm = xl[i].first;
        }
    }

    // int arm = xl[0].first + xl[0].second;
    // int ans = 1;
    // rep(i,1,n-1){
    //     if(xl[i].first - xl[i].second >= arm){
    //         ++ans;
    //         arm = xl[i].first + xl[i].second;
    //     }
    // }
    // rep(i,0,n-1)cout << xl[i].first << " ";
    // cout << endl;

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n; cin >> n;
    vvi hpy(n, vi(3, 0));
    rep(i, n) rep(j, 3) cin >> hpy[i][j];
    vvi dp(n, vi(3, 0));

    for(ll i=0; i<n; i++){
        if(i == 0){
            rep(j, 3) dp[i][j] = hpy[i][j];
        }
        else{
            rep(j, 3){
                rep(k, 3){
                    if(j==k) continue;
                    chmax(dp[i][j], dp[i-1][k]+hpy[i][j]);
                }
            }
        }
    }

    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << endl;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 1000000000
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define zoom ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define precise cout.precision(8); cout << fixed;
#define seed srand(chrono::steady_clock::now().time_since_epoch().count());
using namespace std;

int main() {


    zoom;    
    ll N, K, S, i;
    cin >> N >> K >> S;
    if(S != MAX) {
        for(i = 0; i < K; i += 1)
            cout << S << " ";
        for(; i < N; i += 1)
            cout << S + 1 << " ";
    }
    else {
        for(i = 0; i < K; i += 1)
            cout << S << " ";
        for(; i < N; i += 1)
            cout << 3 << " ";
    }
    return 0;
}

Measured memory_bytes: 1280
class dice:
    def __init__(self,label):
        self.top, self.front, self.right, self.left, self.rear, self.bottom \
                = label
  
    def roll(self,op):
        if   op=='N': self.top, self.front, self.bottom, self.rear = \
                                self.front, self.bottom, self.rear , self.top
        elif op=='E': self.top, self.left , self.bottom, self.right = \
                                self.left , self.bottom, self.right, self.top
        elif op=='W': self.top, self.right, self.bottom, self.left = \
                                self.right, self.bottom, self.left , self.top
        elif op=='S': self.top, self.rear , self.bottom, self.front = \
                                self.rear , self.bottom, self.front, self.top
  
    def print_top(self): print(self.top)
    def print_right(self): print(self.right)
  
    def get_label(self):
        return [self.top, self.front, self.right, self.left, self.rear, self.bottom]
   
label = list(map(int,input().split()))
d = dice(label)
q = int(input())
for _ in range(q):
    top_front = [int(x) for x in input().split()]
    for op in 'EEENEEENEEESEEESEEENEEEN':
        if d.get_label()[:2] == top_front:
            d.print_right()
            break
        d.roll(op)


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

int main(){//main_program
  int a,b,min;
  string S,T;

  cin >> S >> T;
  
  a = S.size();
  b = T.size();
  min = b;
  //cout << (a-b) <<endl;
  
  for(int i = 0;i<(a-b);i++){
    int l = b;
    for(int k = 0;k<b;k++){
      if(S.at(i+k) == T.at(k)){
        l--;
      }
    }
    //cout << l <<endl;
    if(l<min){
      min = l;
    }
  }
  
  if(a == b){
    int l = b;
    for(int k = 0;k<b;k++){
      if(S.at(k) == T.at(k)){
        l--;
      }
    }
    //cout << l <<endl;
    if(l<min){
      min = l;
    }
  }
  
  cout << min <<endl;
  
}

Measured memory_bytes: 3544
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void){
int s;scanf("%d",&s);
 
for(int i=1;;i++){
    if(s==4){printf("%d\n",i+3);return 0;}
    if(s==2){printf("%d\n",i+3);return 0;}
    if(s==1){printf("%d\n",i+3);return 0;}
    else if(s%2==0){s=s/2;}
    else{s=s+s+s+1;}
}
}

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

#define ll long long
#define N 22
#define mod 1000000007

ll dp[N][2097155];
int c[N][N], n;

ll solve(int i, ll s) {
	if (s == 0) {
		return 1;
	}

	if (i == n) {
		return 0;
	}

	if (dp[i][s] != -1) {
		return dp[i][s];
	}

	ll tmp = s;
	dp[i][s] = 0;

	for (int j = 0; j < n; j++) {
		int bit = tmp & 1;
		if (bit && c[i][j] == 1) {
			dp[i][s] = (dp[i][s] + solve(i + 1, (s ^  (1 << j)))) % mod;
		}
		tmp = tmp >> 1;
	}

	return dp[i][s];
}


int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;

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

	memset(dp, -1, sizeof dp);
	ll s = 0;
	for (int i = 0; i < n; i++) {
		s += 1 << i;
	}

	//cout << s;
	cout << solve(0, s);

}

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

string lcs(string p,string q,int n,int m){
    
    int dp[n+1][m+1];
    memset(dp,0,sizeof(dp));
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            
            if(p[i-1]==q[j-1]){
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    
    string a="";
    
    int i=n,j=m;
    while(i>0&&j>0){
        if(p[i-1]==q[j-1]){
            a.push_back(p[i-1]);i--;j--;
        }
        else{
            if(dp[i-1][j]>dp[i][j-1]){
               i--;
            }
            else{
                j--;
            }
        }
    }

    reverse(a.begin(),a.end());
    return a;
}
 
int main() {
	    string p,q;
	    cin>>p>>q;
	    
	   
	    cout<<lcs(p,q,p.length(),q.length())<<endl;
	
	return 0;
}

Measured memory_bytes: 38804
console.log((S=>{
  let T = S.trim();
  do {
    S = T;
    T = S.replace(/(dream|dreamer|erase|eraser)$/,'');
  } while ( T.length < S.length );
  return T?'NO':'YES';
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 33024
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define F first
#define S secon
int main(){
  int n,k,p=1;
  cin>>n>>k;
  r(i,n){
    if(p<k)p*=2;
    else p+=k;
  }
  cout<<p<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
void q_sort(int x[], int start, int end)
{
	int i, k, pivot, temp;
	i = start;  
	k = end;    
	pivot = x[(i + k) / 2];
	while (1) {  
		while (x[i] < pivot)i++;
		while (pivot < x[k])k--;
		if (i >= k)break;
		temp = x[i];
		x[i] = x[k];
		x[k] = temp;//入れ替え
		i++;
		k--;
	}
	if (start < i - 1) q_sort(x, start, i - 1);
	if (k + 1 < end) q_sort(x, k + 1, end);
}
void quickSort(int numbers[], int array_size)
{
    q_sort(numbers, 0, array_size - 1);
}


#include <stdio.h>
#include <stdlib.h>
int main (void){
  int n,i,j,k,stack;
  int distance=1000000000;
  int h[100000];
  scanf("%d%d",&n,&k);
  for(i=0;i<n;i++){
    scanf("%d",&h[i]);
  }
  quickSort(h,n);
  for(i=0;i<=n-k;i++){
    stack=h[i+k-1]-h[i];
    distance=(distance>stack)?stack:distance;
  }
  printf("%d",distance);
  return 0;
}

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

int main()
{
  string S;
  cin >> S;
  rep(i, S.size()) cout << "x";
  cout << endl;
  return 0;
}


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

int main() {
	int n;
	int x;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		x = i;
		if (x % 3 == 0) {
			cout << " " << x;
		}
		else {
			while (1) {
				if (x % 10 == 3) {
					cout << " " << i;
					break;
				}
				else {
					x /= 10;
					if (!x) break;
				}
			}
		}
	}
	cout << endl;
	return 0;
}

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

#define pi 3.14159265

int main() {
	double x=0.0, y=0.0;
	int l,r, R=90;
	while(1) {
		scanf("%d,%d",&l,&r);
		if ( (l==0) && (r==0) ) break;
		x += cos(pi*R/180)*l;
		y += sin(pi*R/180)*l;
		R -= r;
	}
	printf("%d\n%d\n",(int)x ,(int)y);
	return 0;
}

Measured memory_bytes: 0
card_dk = int(input())
block = ['S','H','C','D']
no = [1,2,3,4,5,6,7,8,9,10,11,12,13]
card_st =[]
not_card =[]
for i in range(card_dk):    
    card = input().split()
    card[1] = int(card[1])
    card_st.append(card)


for ch_block in block:
    for ch_no in no:
        flag = 0
        for card in card_st:
            if card == [ch_block,ch_no]:
                flag = 1
        if flag == 0:
            card = [ch_block,ch_no]
            not_card.append(card)

for fud_card in not_card:
    print('{} {}'.format(fud_card[0],fud_card[1]))


Measured memory_bytes: 5596
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,h[101];
	scan(N);
	rep(i,N){
		scan(h[i]);
	}
	rep(ans,INF){
		int l=-1,r=-1;
		int flag=0;
		rep(i,N){
			if(h[i]>0&&flag==0){
				flag=1;
				l=i;
				if(i==N-1) r=i;
			}
			else if(h[i]==0&&flag==1){
				r=i-1;
				break;
			}
			else if(flag==1&&i==N-1){
				r=i;
				break;
			}
			else if(flag==0&&i==N-1){
				prin(ans);
				return 0;
			}
		}
		for(int j=l;j<=r;j++){
			h[j]--;
		}
	}
	return 0;
}


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

// const long long int MOD = 1000000007;
const int MOD = 1000000007;


int main() {
    long long int A,B,C,X,Y,p,q,r;
    cin >> A >> B >> C >> X >> Y;
    if (A+B > 2*C) {
        if (min(X,Y)==Y && A>2*C) {
            r = 2*X;
            p = 0;
            q = 0;
        }
        else if (min(X,Y)==Y && A<=2*C) {
            r = 2*Y;
            p = X-Y;
            q = 0;
        }
        else if (min(X,Y)==X && B>2*C) {
            r = 2*Y;
            p = 0;
            q = 0;
        }
        else if (min(X,Y)==X && B<=2*C) {
            r = 2*X;
            q = Y-X;
            p = 0;
        }
    }
    else {
        p=X;
        q=Y;
        r=0;
    }
    cout << A*p + B*q + C*r << endl;
}

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

int main(){
	string a, b;
	int x, i = 0;
	cin >> a >> b;
	while((x = a.find(b, i)) != -1){
		cout << x << '\n';
		i = x + 1;
	}
	return 0;
}

Measured memory_bytes: 3996
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;



int main(){
    int a, b;
    cin >> a >> b;
    if(b%a==0) out(a+b);
    else out(b-a);
}

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

int main() {
  int a, b;
  string op;
  
  cin >> a >> op >> b;
  
  if(op=="+"){
    a += b;
  }
  if(op=="-"){
    a -= b;
  }
  
  cout << a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define show(x) cout<<x<<'\n'
#define showh(x) cout<<x<<' '
#define go(i,a,n) for(ll i=a;i<n;i++)
#define gor(i,a,n) for(ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
bool prime[100001];
ll pre[2001][2001];
bool ispoweroftwo(ll x)
{
    return x && !(x & (x-1));
}
ll xorcal(ll n)
{
    if(n%4==0)
        return n;
    if(n%4==1)
        return 1;
    if(n%4==2)
        return n+1;
    if(n%4==3)
        return 0;
}
void sieve(ll n)
{
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(ll i=2;i*i<=n;i++)
    {
        if(prime[i]==true)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                prime[j]=false;
            }
        }
    }
}
bool isprime(ll n)
{
    if (n<=1) return false;
    if (n<=3) return true;

    if(n%2==0 or n%3==0) return false;

    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0 or n%(i+2)==0) return false;
    }
    return true;
}

ll modinverse(ll a,ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m; a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
       x += m0;

    return x;
}

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

ll power(ll A, ll B)
{
    if (A == 0)
        return 0;
    if (B == 0)
        return 1;

    ll y;
    if (B % 2 == 0) {
        y = power(A, B / 2);
        y = (y * y) % mod;
    }

    else {
        y = A % mod;
        y = (y * power(A, B - 1) % mod) % mod;
    }

    return (ll)((y + mod) % mod);
}
ll fib(ll n)
{
    if(n<=1)
    {
        return n;
    }
    return fib(n-1)+fib(n-2);
}
void ncr()
{
    pre[0][0]=1;
    go(i,1,2001)
    {
        pre[i][0] = 1;
        go(j,1,2001)
        {
            pre[i][j] = pre[i-1][j] + pre[i-1][j-1];
        }
    }
}
bool check(ll a[],ll n)
{
    ll b[n];
    go(i,0,n)
    {
        b[i]=a[i];
    }
    sort(b,b+n);
    ll ct=0;
    go(i,0,n)
    {
        if(a[i]!=b[i]) ct++;
    }
    if(ct==0 or ct==2) return true;
    return false;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    ll a[n];
    go(i,0,n)
    {
        cin>>a[i];
    }
    if(check(a,n))
    {
        show("YES");
    }
    else
    {
        show("NO");
    }
    return 0;
}


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

const int N = 100+(1<<21) , mod = 1e9 + 7;
int n , a[30][30] , mem[30][N];

int dp(int i , int msk){
	if(i == n && __builtin_popcount(msk) == n) return 1;
	int &ret = mem[i][msk];
	if( ret != -1 ) return ret;
	ret = 0;
	for(int j=0 ; j<n ; j++ )
		if(!(msk&(1<<j)) && a[i][j]) ret = (ret + dp(i+1 , msk|(1<<j)))%mod;
	return ret;
}

int main(){
	memset(mem , -1 , sizeof mem);
	scanf("%d" , &n);
	for(int i=0 ; i<n ; i++)
		for(int j=0 ; j<n ; j++)
			scanf("%d"  , &a[i][j]);
	printf("%d" , dp(0 , 0));

}


Measured memory_bytes: 246144
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  while(cin >> n >> k,n){
    vector<int> mp(n+1,false);
    for(int i=0;i<k;++i){
      int tmp;
      cin >> tmp;
      mp[tmp] = true;
    }
    vector<int> vec;
    vec.push_back(mp[1]);
    for(int i=2;i<n+1;++i){
      if(mp[i]&&mp[i-1]){
        vec.back()++;
        continue;
      }
      vec.push_back(mp[i]);
    }
    int ans = 0;
    if(!mp[0]||vec.size()<3){
      cout << *max_element(vec.begin(),vec.end()) << endl;
      continue;
    }
    for(int i=0;i<(int)vec.size()-2;++i){
      ans = max(ans,vec[i]+vec[i+2]+1);
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3588
# -*- coding:utf-8 -*-
import sys

def solve():
    N, K = list(map(int, sys.stdin.readline().split()))
    hs = list(map(int, sys.stdin.readline().split()))

    ans = 0
    for h in hs:
        if h >= K:
            ans += 1

    print(ans)

if __name__ == "__main__":
    solve()


Measured memory_bytes: 11904
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
--
local function find_min_true(n, f)
    -- Define f(-1) == false, f(n) == true
    -- Invariant: f(left) == false and f(right) == true
    local left = -1
    local right = n
    while right - left > 1 do
        local m = left + math.floor((right - left) / 2)
        if f(m) then
            right = m -- keep f(right) == true
        else
            left = m -- keep f(left) == false
        end
    end
    return right
end
---
local N, K = read.nn()
local A = read.N(N)
local F = read.N(N)
table.sort(A)
table.sort(F, function(x,y)return x>y end)
local upper_lim = A[N] * F[1]

local function possible(max_time)
    local kk = K
    for i=1, N do
        local time = A[i] * F[i]
        if time > max_time then
            local train_cost = math.ceil((A[i] * F[i] - max_time) / F[i])
            kk = kk - train_cost
            if kk < 0 then
                return false
            end
        end
    end
    return true
end
print(find_min_true(upper_lim, possible))


Measured memory_bytes: 9724
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  bool b=true;
  int count =0;
  if(s[0]!='A'){
    b=false;
  }
  else{
    if((s[1]>='a'&&s[1]<='z')&&(s[s.size()-1]>='a'&&s[s.size()-1]<='z')){
      for (int i=2;i<s.size()-1;i++){
        if(s[i]=='C'){
          count++;
        }
        else{
          if(s[i]<'a'&&s[i]>'z'){
            b=false;
            break;
          }
        }
      }
      if(count!=1){
        b=false;
      }
    }
    else{
      b=false;
    }
  }
  if(b){
    cout << "AC" << endl;
  }
  else {
    cout << "WA" << endl;
  }
}          

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    int n; cin >> n;
    int ans = 1;
    while(ans <= n){
        ans*=2;
    }
    if(ans > n) ans /=2;
    cout << ans  <<endl;
    return 0;
}

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

int main(){
	long long a,b,c;
	cin>>a>>b>>c;
	
	long long res=0;
	res=min(c,a+b)+b;
	if(c>min(c,a+b)) res++;
	
	
	cout<<res<<endl;

}


Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());

        var x = n%10;

        if(x == 2 || x == 4 || x == 5 || x == 7 || x == 9) {
            return "hon";
        }

        if (x == 0 || x == 1 || x == 6 || x == 8 ) {
            return "pon";
        }

        return "bon";
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


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

N = int(input())
S = input()

count_ABC = 0
for i in range(len(S)-2) : 
    if S[i] == "A" and S[i+1] == "B" and S[i+2] == "C" : 
        count_ABC += 1
        
print(count_ABC)

Measured memory_bytes: 2940
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long int;
using ULL = unsigned long long;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    vector<int> max_left(n + 1);
    vector<int> max_right(n + 1);
    max_left[0] = -1000000;
    rep(i, n) {
        max_left[i + 1] = max(a[i], max_left[i]);
    }
    max_right[n] = -1000000;
    rep(i, n) {
        max_right[i + 1] = max(a[n - 1 - i], max_right[i]);
    }
    rep(i, n) {
        cout << max(max_left[i], max_right[n - i - 1])<< endl;;
    }


}


Measured memory_bytes: 3968
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
ll a[100005];
int main(){
    ll K,N;
    cin>>N;
    for(ll i=0;i<N;i++){
        cin>>a[i];
    }
    sort(a,a+N);
    ll ans=0;
    ll sum[100005]={};
    ll clearMin=INF;
    sum[0]=a[0];
    for(ll i=1;i<N;i++){
        sum[i]=a[i]+sum[i-1];
    }
    for(ll i=N-2;i>=0;i--){
        if(a[i+1]>sum[i]*2){
            cout<<N-1-i<<endl;
            return 0;
        }
    }
    cout<<N<<endl;
    
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())
 
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;
 
 
 
int main(){
	int A,B,C;
	cin>>A>>B>>C;
	cout<<min(C,B/A)<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
A.insert(0,0)
B = [0] * (N + 1)

for i in range(1,N+1):
  B[A[i]] = i

B.remove(0)
B = map(str,B)

ans = ' '.join(B)
print(ans)

Measured memory_bytes: 17764
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

vector<ll> cnt(101010);
vector<ll> dp(101010);
vector<int> v[101010];
ll n, k;

 ll ans=1;

void dfs(int x,int p){
	ll cur=k-(p!=-1);
	for(auto to : v[x]){
		if(to==p)continue;
		ans*=--cur;
		ans%=mod;
		dfs(to,x);
	}
}

int main(){
	cin>>n>>k;
	rep(i,n-1){
		int x,y;
		cin>>x>>y;
		--x;--y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(0,-1);
	cout<<ans*k%mod<<endl;
	return 0;
}

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

int n, m;
vector<pair<int,int> > v;
set<int> S;
int ans;

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

    cin >> n >> m;

    for(int i=0; i<=n; i++) {
        S.insert(i);
    }

    for(int i=0; i<n; i++) {
        int a, b;
        cin >> a >> b;

        v.push_back({b, a});
    }

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

    for(int i = v.size()-1; i>=0; i--) {
        set<int>::iterator it = S.upper_bound(m - v[i].second);
        if(it != S.begin()) {
            ans += v[i].first;
            S.erase(--it);
        }
    }

    cout << ans;
}


Measured memory_bytes: 6140
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

using A = array<int, 1<<16>;
int main() {
    int n, c;
    while(cin >> n >> c, n){
        vector<int> a(n), b(c);
        for (int i = 0; i < n; ++i) {
            int val = 0;
            for (int j = 0; j < 16; ++j) {
                int x;
                cin >> x;
                val |= x << j;
            }
            a[i] = val;
        }
        for (int i = 0; i < c; ++i) {
            int val = 0;
            for (int j = 0; j < 16; ++j) {
                int x;
                cin >> x;
                val |= x << j;
            }
            b[i] = val;
        }
        vector<int> cnt(1 << 16);
        for (int k = 0; k < 1<<16; ++k) {
            for (int i = 0; i < 16; ++i) {
                if(k & (1 << i)) cnt[k] = cnt[k^(1 << i)]+1;
            }
        }
        vector<A> dp(n+1);
        dp[0][0] = 1;
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < 1 << 16; ++j) {
                if(!dp[i][j]) continue;
                int jj = j|a[i];
                for (int k = 0; k < c; ++k) {
                    chmax(dp[i+1][jj^(jj&b[k])], dp[i][j]+cnt[jj&b[k]]);
                }
            }
        }
        cout << *max_element(dp.back().begin(),dp.back().end())-1 << "\n";
    }

    return 0;
}


Measured memory_bytes: 18088
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSharp_AtCoder
{


    class Program
    {
        static long N;
        static long M;
        static long[] A;
        static Dictionary<long, long> dic_mod_cnt;
        

        static void Main(string[] args)
        {
            long[] input = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            N = input[0];
            M = input[1];

            A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            dic_mod_cnt = new Dictionary<long, long>();

            long sum = 0;
            dic_mod_cnt[0] = 1;
            for(int i = 0; i < N; i++)
            {
                sum += A[i];
                if (!dic_mod_cnt.ContainsKey(sum % M)) dic_mod_cnt[sum % M] = 1;
                else dic_mod_cnt[sum % M]++;
            }

            long ans = 0;
            foreach(var mod_cnt in dic_mod_cnt)
            {
                ans += mod_cnt.Value * (mod_cnt.Value - 1) / 2;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 22240
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int X = sc.nextInt();
    int sum = 0;
    int ans = 1;
    for(int i = 0; i < N;i++){
        sum += sc.nextInt();
        if(sum <= X) {
            ans++;
        } else {
            break;
        }
    }
    System.out.println(ans);
  }
}


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

typedef long long ll;
typedef pair<int, int> P;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n; cin>>n;
    vector<int> a(3*n);
    for(int i=0; i<3*n; i++) cin>>a[i];
    sort(a.begin(), a.end());
    ll ans=0;
    for(int i=3*n-2; i>=n; i-=2) ans+=a[i];
    cout << ans << endl;
}

Measured memory_bytes: 1408
n   = gets.to_i
ary = gets.split.map(&:to_i)

gcdL = ary[0]
gcdR = ary[-1]
aryGcdL = []
aryGcdR = []

for i in 0 .. n - 1
  gcdL = gcdL.gcd(ary[i])
  aryGcdL << gcdL
  gcdR = gcdR.gcd(ary[n - i - 1])
  aryGcdR << gcdR
end

aryGcdL.unshift(0).push(0)
aryGcdR.unshift(0).push(0).reverse!

tmp = []

for i in 0 .. n - 1
  tmp << aryGcdL[i].gcd(aryGcdR[i + 2])
end

#p aryGcdL, aryGcdR, tmp

puts tmp.max


Measured memory_bytes: 11544
import java.util.Scanner;

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

		while(true) {
			String a=sc.next();
			if(a.equals(".")) {
				System.exit(0);
			}
			int wa=sc.nextInt();
			int[] que=new int[100];
			int[] suuji=new int[4];
			int kosu=0;


			suuji[0]=wa/1000;
			suuji[1]=(wa%1000)/100;
			suuji[2]=(wa%100)/10;
			suuji[3]=wa%10;
			for(int i=0; i<a.length(); i++) {
				char k=a.charAt(a.length()-i-1);
				if(k=='[' || k==']') {
					//ignore
				}

				else if(k=='a') {
					que[kosu]=suuji[0];
					kosu++;
				}

				else if(k=='b') {
					que[kosu]=suuji[1];
					kosu++;
				}

				else if(k=='c') {
					que[kosu]=suuji[2];
					kosu++;
				}

				else if(k=='d') {
					que[kosu]=suuji[3];
					kosu++;
				}

				else {
					if(k=='+') {
						int p=que[kosu-1]|que[kosu-2];
						que[kosu-1]=0;
						que[kosu-2]=p;
						kosu--;

					}

					else if(k=='*') {
						int p=que[kosu-1]&que[kosu-2];
						que[kosu-1]=0;
						que[kosu-2]=p;
						kosu--;
					}

					else if(k=='^') {
						int p=que[kosu-1]^que[kosu-2];
						que[kosu-1]=0;
						que[kosu-2]=p;
						kosu--;
					}
				}
			}

			int ans=que[0];
			int ss=0;

			for(int l=0; l<=9999; l++) {
				suuji[0]=l/1000;
				suuji[1]=(l%1000)/100;
				suuji[2]=(l%100)/10;
				suuji[3]=l%10;
				kosu=0;
				for(int i=0; i<a.length(); i++) {
					char k=a.charAt(a.length()-i-1);
					if(k=='[' || k==']') {
						//ignore
					}

					else if(k=='a') {
						que[kosu]=suuji[0];
						kosu++;
					}

					else if(k=='b') {
						que[kosu]=suuji[1];
						kosu++;
					}

					else if(k=='c') {
						que[kosu]=suuji[2];
						kosu++;
					}

					else if(k=='d') {
						que[kosu]=suuji[3];
						kosu++;
					}

					else {
						if(k=='+') {
							int p=que[kosu-1]|que[kosu-2];
							que[kosu-1]=0;
							que[kosu-2]=p;
							kosu--;

						}

						else if(k=='*') {
							int p=que[kosu-1]&que[kosu-2];
							que[kosu-1]=0;
							que[kosu-2]=p;
							kosu--;
						}

						else if(k=='^') {
							int p=que[kosu-1]^que[kosu-2];
							que[kosu-1]=0;
							que[kosu-2]=p;
							kosu--;
						}
					}
				}
				if(ans==que[0]) {
					ss++;
				}
			}
			System.out.println(ans+" "+ss);
		}
	}
}


Measured memory_bytes: 31360
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let mut vs = scan!(i64;;);
    vs.sort();
    vs.dedup();
    println!("{}", vs.len());
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(src,dst)    for(int i=src; i<dst;  i++)
#define rep2(src,dst)   for(int j=src; j<dst;  j++)
#define INF 1000000000000 //1e+12
#define MOD 10000007 //1e9+7
#define PI  acos(-1)
#define ll long long
template<typename T> inline void ChMin(T* a, T* b) {if(*a>*b) *a=*b;}
template<typename T> inline void ChMax(T* a, T* b) {if(*a<*b) *a=*b;}
template<typename T> inline int  DivUp(T a, T b)   {return ((a+b-1)/b);}

int main(){
    int x, n; cin >> x >> n;
    int dif=102, ans=0;
    vector<bool> flg(102);
    rep(0,n){
        int d;
        cin >> d;
        flg[d] = 1;
    }
    rep(0,102){
        if(flg[i] || dif <= abs(i-x)) continue;
        dif = abs(i-x);
        ans = i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<stdio.h>
 
int main(void)
{
int n, k, x;
int a, b;
int i, min, sum;
 
scanf("%d %d", &n, &k);
 
for(i = 1; i <= n; i++){
scanf("%d", &x);
a = x * 2;
b = (k - x) * 2;
if(a < b){
min = a;
}else{
min = b;
}
sum += min;
}
 
printf("%d", sum);
return 0;
}

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

int main() {
  string S,ans;
  cin >> S;
  ans = "Sunny";
  if(S == "Sunny"){
    ans = "Cloudy";
  }else if(S == "Cloudy"){
    ans = "Rainy";
  }
  cout << ans << endl;
}


Measured memory_bytes: 3532
a,b,c=map(int, input().split())

if a > b:
    t = a
    a = b
    b = t

if b > c:
    t = c
    c = b
    b = t

if a > b:
    t = a
    a = b
    b = t

print(f'{a} {b} {c}')



Measured memory_bytes: 5608
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<tuple>
#include<utility>
#define rep(i,n) for(ll i=0; i<n; i++)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int n;  cin >> n;
  vll a(n);
  int ans = 0;
  bool flag = true;
  rep(i,n){
    cin >> a[i];
    if(a[i] % 2 == 1){
      flag = false;
    }
  }
  while(flag){
    rep(i,n){
      if(a[i] % 2 == 1){
        flag = false;
        break;
      }
      a[i] /= 2;
    }
    if(flag){
      ans++;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
ans=1
l=[0]*(n+1)
r=[0]*(n+1)
for i in range(n):
    l[i]=gcd(l[i-1],a[i])
for i in reversed(range(n)):
    r[i]=gcd(r[i+1],a[i])
for i in range(n):
    if gcd(l[i-1],r[i+1])>ans:
        ans=gcd(l[i-1],r[i+1])
print(ans)


Measured memory_bytes: 16144
// ARC100A.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 2e5 + 200;

int n, ai[MAX_N];
long long suf[MAX_N];

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &ai[i]), ai[i] -= i;
    sort(ai + 1, ai + 1 + n);
    for (int i = n; i >= 1; i--)
        suf[i] = suf[i + 1] + ai[i];
    long long ans = 1e18, acc = 0;
    for (int i = 1; i <= n; i++)
    {
        int b = ai[i];
        acc += ai[i];
        ans = min(ans, 1LL * b * i - acc + suf[i + 1] - 1LL * (n - i) * b);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main(){
	int N,C=0;
	cin >> N;
	int R[N];
	for(int i=0;i<N;i++)cin >> R[i];
	for(int j=0;j<N;j++){
		if(R[R[j]-1]-1==j){
			C++;
		}
	}
	C/=2;
	cout << C << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cmath>
#include <stdio.h>
using namespace std;
 
int main(){
    int n;
    double x[100] = {}, y[100] = {};
    double q;

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

    double tmp=0;
    for(int i=0;i<n;i++){
        tmp += abs(x[i]-y[i]);
    }
    cout << tmp << endl;

    tmp = 0;
    q = 2;
    for(int i=0;i<n;i++){
        tmp += pow((x[i] -y[i]),q);
    }
    // cout << pow(tmp, 1.0/q) << endl;
    printf("%.8lf\n", pow(tmp, 1/q));

    tmp = 0;
    q = 3;
    for(int i=0;i<n;i++){
        tmp += pow(abs(x[i] -y[i]),q);
    }
    // cout << pow(tmp, 1/q) << endl;
    printf("%.8lf\n", pow(tmp, 1/q));

    tmp = 0;
    for(int i=0;i<n;i++){
        tmp = max(abs(x[i]-y[i]), tmp);
    }
    cout << tmp << endl;
}


Measured memory_bytes: 3476
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
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;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int w,a,b;
    cin >> w >> a >> b;
    if (a > b) swap(a,b);

    cout << max(0, (b - (a+w))) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int house[4][3][10],b,f,r,v,n,i,j,k;
	for(i=0;i<4;i++)
	{
		for(j=0;j<3;j++)
		{
			for(k=0;k<10;k++)
			{
				house[i][j][k] = 0;
			}
		}
	}
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d %d",&b,&f,&r,&v);
		house[b-1][f-1][r-1]+=v;
	}
	for(i=0;i<4;i++)
	{
		for(j=0;j<3;j++)
		{
			for(k=0;k<10;k++)
			{
				printf(" %d",house[i][j][k]);
			}
		printf("\n");
		}
		if(i<3)
		{
			printf("####################\n");
		}
	}
		
	return 0;
}

Measured memory_bytes: 612
/******* VIVEK PAl *******/
/*************************/
#include <bits/stdc++.h>
#define prime 1000000007
#define mod 998244353
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long int ll;
/****** END OF HEADER ******/
/***************************/
int maxN=2e+3 + 8;
void solve()
{
    int x; cin>>x;
    int a=x/500;
    int b=x%500;
    b=5*(b/5);
    a=a*1000+b;
    printf("%d\n", a);
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int T=1, t; 
  //cin>>T;
  t = T;
  while(T--)
  {
      //printf("Case #%d: ", t-T);
      solve();
  }
}

Measured memory_bytes: 256