akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))
'''
N = ii()
A = li()

ans = 0
for i in range(N):
    a = 0
    b = 0
    max_b = -float('inf')
    max_a = -float('inf')
    for j in range(i, N):
        if (j-i) % 2:
            b += A[j]
            if b > max_b:
                max_b = b
                max_a = a
        else:
            a += A[j]
    dp[max_a][]
    ans = max(ans, max_a)

print(ans)
'''

A, B =li()

if A == B == 1:
    print('Draw')
elif A == 1:
    print('Alice')
elif B == 1:
    print('Bob')
else:
    if A > B:
        print('Alice')
    elif B > A:
        print('Bob')
    else:
        print('Draw')

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int res = 0;
        for (int i = 111; i <= 999; i += 111) {
            if (i >= N) {
                res = i;
                break;
            }
        }
        System.out.println(res);
        sc.close();
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std; 
#define loop for(int i=0;i<n;i++)
#define pb push_back
#define int long long int
#define vi vector<int>
#define mod 1000000007
int32_t main()
{
	int n;
	int k;
	cin>>n>>k;
	int ar[n+1];
	memset(ar,0,sizeof(ar));
	while(k--)
	{
		int p;
		cin>>p;
		while(p--)
		{
			int a;
			cin>>a;
			ar[a]++;
			//cout<<"a"<<a<<"ar"<<ar[a]<<endl;
		}
}

int ans=0;
for(int i=1;i<=n;i++)
if(ar[i]==0)
ans++;
cout<<ans<<endl;
}



Measured memory_bytes: 3632
//                               //
    // author : samars_diary //
    // 17-09-2020 │ 07:54:55 //
//                               //

#include <iostream>
#include <cmath>

using namespace std;

void solve(){
    int a; cin>>a;
    cout<<1000*ceil(a/1000.0)-a;
}

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

    //#ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    //#endif

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

    return 0;
}

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

def main():
    N,K=map(int,input().split())
    H=list(map(int,input().split()))
    H.sort(reverse=True)
    print(sum(H[K:]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 81868
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;
 
int main() {
  string N;
  cin >> N;
  bool f = false;
  for (auto i = 0;i < 3; i++) {
    if (N[i] == '7') {
      f = true;
    }
  }
  if (f) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
 
  return 0;
}

Measured memory_bytes: 3620
if __name__ == "__main__":
    exp = input().split()

    operator = None
    stack = []
    for e in exp:
        if e == '+':
            r = int(stack.pop())
            l = int(stack.pop())
            stack.append(l+r)
        elif e == '-':
            r = int(stack.pop())
            l = int(stack.pop())
            stack.append(l-r)
        elif e == '*':
            r = int(stack.pop())
            l = int(stack.pop())
            stack.append(l*r)
        else:
            stack.append(int(e))
        # print('stack: {}'.format(stack))

    print(stack.pop())



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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define inf 1000000100

int main()
{
    string s;
    cin >> s;
    int a = inf, z = 0;
    for(int i = 0; s[i]; i++)
    {
        if(s[i] == 'A') a = min(a, i);
        if(s[i] == 'Z') z = max(z, i);
    }

    cout << z - a + 1<< endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int64_t K, A, B;
    cin >> K >> A >> B;
    if (B == 1 || (A + 1 >= B)) {
        cout << K + 1 << endl;
    } else {
        int64_t k = K - A + 1; // 最初に割るまでに必要な回数を引いた後の回数
        int64_t zoukabun = A + (k / 2 * (B - A));
        zoukabun += k % 2;
        cout << zoukabun << endl;
    }

    return 0;
}

Measured memory_bytes: 3572
/**
 *   author: sahushivam
 *   created: 26 January 2020 (Sunday)  17:30:24
**/
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1e18
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define int long long

void solve(){
	int h,n;
	cin>>h>>n;
	int ans=ceil((h*1.0)/n);	
	cout<<ans;
}

signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int t=1; while(t--) solve();
    return 0;
}

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

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, H: "List[int]"):

    for i in range(len(H)-1):
        if H[i] > H[i+1]:
            H[i] -= 1
        elif i > 0 and H[i-1] < H[i]:
            H[i] -= 1

    for i in range(len(H)-1):
        if H[i] > H[i+1]:
            print(NO)
            return


    print(YES)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    H = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, H)

if __name__ == '__main__':
    main()


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

int main(){
    int H, W;
    cin >> H >> W;
    vector<int> ok_gyou;
    vector<int> ok_retsu;
    vector<vector<char>> a(H, vector<char>(W));
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            char A;
            cin >> A;
            a.at(i).at(j) = A;
        }
    }
    for (int i = 0; i < H; i++){
        bool all_white = true;
        for (int j = 0; j < W; j++){
            if(a.at(i).at(j) == '#'){
                all_white = false;
                break;
            }
        }
        if(all_white == false){
            ok_gyou.push_back(i);
        }
    }
    for (int j = 0; j < W; j++){
        bool all_white = true;
        for (int i = 0; i < H; i++){
            if (a.at(i).at(j) == '#'){
                all_white = false;
                break;
            }
        }
        if (all_white == false){
            ok_retsu.push_back(j);
        }
    }
    for (int i: ok_gyou){
        for (int j : ok_retsu){
            cout << a.at(i).at(j);
        }
        cout <<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int N; cin>>N;
  int res=0;
  for(int i=0;i<N;i++){
    int a; cin>>a;
    while(a%2==0){
      a/=2;
      res++;
    }
  }
  cout<<res<<endl;
  return 0;
}


Measured memory_bytes: 256
L,R = map(int,input().split())
def judge_distance(i,j):
    if j-i >= 2019:
        return True

def search_2019(i,j):
    res = False
    for p in range(j-i+1):
        if i+p % 2019 == 0:
            res = True
            exit()

if judge_distance(L,R) or search_2019(L,R):
    print(0)
else:
    mincount = float("inf")
    for i in range(L,R):
        for j in range(L+1,R+1):
            if i*j%2019 <= mincount:
                mincount = (i*j)%2019

    print(mincount)

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
using namespace std;
typedef long long int ll;
int main(){
  ll N;
  cin>>N;
  int len=0;
  ll sum=0;
  for(int i=1; i<=17; i++){
    sum+=pow(26,i);
    if(sum>=N){
      len=i;
      break;
    }
  }
  N-=(len>1)?(sum-pow(26,len)):0;
  // cout<<len<<endl;
  // cout<<N<<endl;
  for(int i=1; i<=len; i++){
    int rest=len-i;
    if(rest==0){
      cout<<char('a'+N-1);
      continue;
    }
    ll to_come=pow(26,rest);
    for(int i=1; i<=26; i++){
      if(i*to_come>=N){
        cout<<char('a'+i-1);
        N-=(i-1)*to_come;
        break;
      }
    }
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 3500
#include <bits/stdc++.h>
/**  I'm Klaus, NicKlaus :v **/
using namespace std;
#define ms(a,v) memset(a,v,sizeof a)
#define ll long long
#define LOG2(X) ((unsigned) (8*sizeof(int) - __builtin_clz((X)) - 1))
ll gcd(ll x, ll y){return (y ? gcd(y, x%y) : x); }
ll lcm(ll x, ll y){return x*(y/gcd(x,y));}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	#ifdef LOCAL_JUDGE
		//freopen("in_out/in.txt", "rt", stdin);
		//freopen("int_out/out.txt", "wt", stdout);
	#endif
	int n, k, q;
	cin>>n>>k>>q;
	vector<int> frq(n,0);
	for(int i=0; i<q; i++){
		int x; cin>>x;
		frq[x-1]++;
	}
	int ans = 0;
	for(int i=0; i<n; i++){
		if(k-(q - frq[i]) > 0){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 1152
N, W = map(int, input().split())
wv = [[int(i) for i in input().split()] for _ in range(N)]
dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(N):
	for j in range(W + 1):
		if j >= wv[i][0]:
			dp[i + 1][j] = max(dp[i][j], dp[i][j - wv[i][0]] + wv[i][1])
		else:
			dp[i + 1][j] = dp[i][j]
			
print(dp[-1][-1])

Measured memory_bytes: 120172
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int N;
    cin >> N;
    if (N / 100 == 7 || (N / 10) % 10 == 7 || N % 10 == 7)
    {
        cout << "Yes" << endl;
        return 0;
    }

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


Measured memory_bytes: 3632
n,m=map(int,input().split())

pre=-1

li=[-1]

for i in range(m):
  a=int(input())
  if pre+1==a:
    print(0)
    exit()
  pre=a
  li.append(a)

li.append(n+1)

result=[]
for i in range(1,len(li)):
  sum1=1
  sum2=1
  sum3=1
  if 3>li[i]-li[i-1]:
    continue
  for j in range(3,li[i]-li[i-1]):
    sum3=sum1+sum2
    sum1=sum2
    sum2=sum3
  result.append(sum3)

result_=1
for i in result:
  result_*=i
#print(result)  
print(result_%1000000007)

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

int main(){
    long N, M, ans = 0; cin >> N >> M;
    multimap<long,long> shop;

    long A, B;
    while(cin >> A >> B){
        shop.emplace(A,B);
    }

    for( auto itr = shop.begin(); itr != shop.end(); itr++ ){
        if( M >= (*itr).second ){
            M -= (*itr).second;
            ans += ((*itr).second)*((*itr).first);
        } else {
            ans += M*((*itr).first);
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;

const int MAXN = 400100;
vector<PII> graph[MAXN];

void add_edge(int v, int u, int c) {
  graph[v].push_back(PII(u,c));
  graph[u].push_back(PII(v,c));
}


int main() {
  int N;
  cin >> N;
  for(int i=0; i<N; i++) {
    LL p;
    cin >> p;
    add_edge(i, i+N, p);
  }

  for(int i=0; i<N-1; i++) {
    int v,u,c;
    cin >> v >> u >> c;
    v--;u--;
    add_edge(v, u, c);
  }

  priority_queue<pair<LL,PII> , vector<pair<LL,PII> >, greater<pair<LL,PII> > > pq;
  vector<int> used(2*N, 0), dist(2*N, 0);
  int cnt = 1;
  LL ans = 0;
  for(int i=0; i<N; i++) {
    pq.push(make_pair(0, PII(i+N, -1)));
  }
  while(!pq.empty()) {
    auto cur = pq.top(); pq.pop();
    LL v = cur.second.first;
    if(used[v]) {
      LL u = cur.second.second;
      if(used[v] > used[u])
	ans += dist[v] + cur.first;
      continue;
    }
    used[v] = cnt;
    cnt++;
    dist[v] = cur.first;
    for(auto uc: graph[v]) {
      LL u = uc.first;
      LL c = uc.second;
      pq.push(make_pair(dist[v] + c, PII(u, v)));
    }
    
  }
  cout << ans << endl;
  
  return 0;
}


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

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

int main(){
  int N,T,A;
  cin >> N >> T >> A;
  vector<int> H(N);
  for(int i = 0;i<N;i++){
    cin >> H[i];
  }

  int d = 0;
  vector<pair<double,int>> p(N);//各地点の平均気温とAの差と、地点番号のペア配列
  rep(i,N){
    p[i].first = abs(A-(T-H[i]*0.006));
    p[i].second = i+1;
  }
  sort(p.begin(),p.end());

  cout << p[0].second << endl;
  
 }

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

int main(){
	int k,x;
	cin>>k>>x;
	cout<<x-k+1;
	for(int i=x-k+1+1;i<x+k;i++){
		cout<<" "<<i;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n;
	int i,j,t=0,h=0,d;
	char ct[100],ch[100];
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
	{
		scanf("%s %s",ct,ch);
		
		j=0;
		while(ct[j]!='\0' || ch[j]!='\0')
		{
			if(ct[j]<ch[j])
			{
				h++;
				break;
			}
			else if(ct[j]>ch[j])
			{
				t++;
				break;
			}
			j++;
		}
	}
	d=n-h-t;
	
	printf("%d %d\n",d+t*3,d+h*3);
	
	return 0;
}


Measured memory_bytes: 2064
#include <stdio.h>
#include <algorithm>

#define LIM_S 200002
#define LIM_N 100001

char str[LIM_S];

int A, B;

void receive_input() {
	fgets(str, sizeof(str), stdin);
	sscanf(str, "%d %d", &A, &B);

	// for (size_t i = 0; i < N; i++) {
	// 	scanf("%d", &H[i]);
	// }
}

void initialize() {
}

int solve() {
	if (A == B) {
		return A * 2;
	}

	return (A > B) ? (A * 2 - 1) : (B * 2 - 1);
}

int main(void) {
	receive_input();
	initialize();

	printf("%d\n", solve());

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
 
//int dxy[5] = {0, 1, 0, -1, 0};
// assign
 
signed main()
{
    string a, b;
    cin >> a >> b;

    int ans = 0;

    string odd, even;

    rep(i, a.size()) {
        if (i % 2) {
            odd.pb(a[i]);
        } else {
            even.pb(a[i]);
        }
    }

    int pt = 0;
    rep(i, b.size()) {
        if (b[i] == odd[pt]) {
            pt++;
        }
        if (pt == odd.size()) {
            break;
        }
    }
    if (pt == odd.size()) {
        cout << "Yes" << endl;
        return 0;
    }

    pt = 0;
    rep(i, b.size()) {
        if (b[i] == even[pt]) {
            pt++;
        }
        if (pt == even.size()) {
            break;
        }
    }
    if (pt == even.size()) {
        cout << "Yes" << endl;
        return 0;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3192
n = int(input())
ans = 2
for i in range(2,int((n-1) ** 0.5) + 2):
    if (n-1) % i == 0:
        #print(i)
        ans += 1
        if i ** 2 < n-1:
            ans += 1
        else:
            if i ** 2 > n-1:
                ans -= 1
            break
#print(ans)

for i in range(2,int(n ** 0.5) + 2):
    if n % i == 0:
        nt = n
        while (nt % i == 0):
            nt = nt // i
        if nt % i == 1:
            ans += 1
        if i ** 2 < n:
            nt = n
            it = n - i
            while (nt % it == 0):
                nt = nt // it
            if nt % i == 1:
                ans += 1
                
if n == 2:
    ans = 1
print(ans)      



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define   ipr         	pair<int, int>
#define   pb            push_back
#define   ff            first
#define   ss            second
#define   fr(i, j, k)   for (int i = j; i < k; i++)
#define   rf(i, j, k)   for (int i = j; i >= k;i--)
#define   int           long long
#define   ll 			unsigned long long
#define   ld            long double
#define   all(x)        x.begin(), x.end()
#define   rall(x)       x.rbegin(),x.rend()
#define   mp            make_pair
#define   inf           INT_MAX
#define   read_file();	freopen("input.txt", "r", stdin);	freopen("output.txt", "w", stdout);
#define   IOS           std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const int Maxn  =  10000;
const ld  pi   =  acos(-1);
const int mod =  1000000007;
 
 
template<class T> ostream& operator <<(ostream &out,vector<T> &A){for(auto x:A) out<<x;return out;}
template<class T> ostream& operator <<(ostream &out,set<T> &A){for(auto x:A) out<<x<<" ";return out;}
template <class T1,class T2>T1 powr(T1 a,T2 b){T1 res = 1;fr(i,1,b+1)res = res*a;return res;}
int roundUp(int numToRound, int multiple)
{
 if(multiple == 0)
 {
  return numToRound;
 }

 int roundDown = ( (int) (numToRound) / multiple) * multiple;
 int roundUp = roundDown + multiple; 
 int roundCalc = roundUp;
 return (roundCalc);
}
 


 
int32_t main(){IOS
int n;
cin>>n;
vector<int>k(n);
fr(i,0,n)cin>>k[i];
int max=INT_MAX;
fr(i,0,100){
   int sum=0;
   fr(j,0,n){
      sum=sum+(k[j]-i)*(k[j]-i);
   }
   if(sum<max)max=sum;

}

cout<<max;
}




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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define per(i, n) for(int i = (n)-1; i >= 0; --i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}

using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

constexpr char sp = ' ';
constexpr char cmm = ',';
constexpr int MOD = 1e9+7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}

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; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s<<'[';for(size_t i=0;i<v.size();++i){s << v[i];if(i < v.size()-1) s << ", ";}s<<']';return s;
}

vector<ll> num(65, 0);
int main(){

    ll n;
    scanf("%lld", &n);

    rep(i, n){
        ll a;
        scanf("%lld", &a);
        for(int d = 0; a > 0; a >>= 1, ++d){
            num[d] += a&1;
        }
    }

    ll ans = 0;
    rep(i, 61){
        (ans += num[i]*(n-num[i])%MOD*powmod(2, i)%MOD) %= MOD;
    }
    ppp(ans);



    return 0;
}


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

using namespace std;

int n;
string m;
set<string> s;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    while (n--)
    {
        cin >> m;
        s.insert(m);
    }
    cout << s.size();
    return 0;
}

Measured memory_bytes: 19080
#include <bits/stdc++.h>
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
	int N,K,ans=0;
	std::cin >> N >> K;
	std::vector<int> v;
	for ( int i = 0 ; i < N ; i++ ) {
		int x;
		std::cin >> x;
		v.push_back(x);
	}
	sort(v.begin(),v.end(),std::greater<int>());
	for ( int i = 0 ; i < K ; i++ ) {
		ans += v[i];
	}
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 256
// Author - Saikat_7
    #include <bits/stdc++.h> 
    using namespace std;
    #define fl(i,a,b) for(int i=a;i<b;i++)
    #define trav(i,cont) for(const auto& i:cont)
    #define cs(x) cout<<x<<" "
    #define cn(x) cout<<x<<" "<<endl
    #define ll long long int
    #define endl '\n'
    #define pb push_back
    #define ff first
    #define ss second
    #define mod 1000000007 //998244353 
    #define inf 1e17
    const int mx = 2999; // 2* (10 to power 5);
    double dp[3000][3000];
    double coins(double arr[],int n, int h)
    {	if(dp[n][h]==-1)
    	{
    	if(h==0|| n==0)
    		dp[n][h]= 1;
    	else if(h<n)
    		dp[n][h]=arr[n-1]*coins(arr,n-1,h-1) + (1-arr[n-1])*coins(arr,n-1,h);
    	else if(h==n)
    		dp[n][h]=arr[n-1]*coins(arr,n-1,h-1);
    	else
    		dp[n][h]=0;
    		return dp[n][h];
    	}
    	else
    		return dp[n][h];
     
    }
    int main()
    {
        ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
        int tc=1;
        // cin>>tc;
        while(tc-- > 0)
        {
       		int n;
       		cin>>n;
       		double arr[n];
       		int h=(n/2)+1;
       		for(int i=0;i<=n;i++)
       		{
       			for (int j=0;j<=h;j++)
       				dp[i][j]=-1;
       		}
       		for(int i=0;i<n;i++)
       		{
       			cin>>arr[i];
       		}     
       		double ans=coins(arr,n,(n/2)+1);
       		cout<<fixed<<setprecision(10)<<ans;
        }
        return 0;
    }

Measured memory_bytes: 69888
N = int(input())
rates = [int(i) for i in input().split()]

def get_cols(rates):
    col_flags = [False for _ in range(8)]
    wild_colors = 0
    for rate in rates:
        if rate >= 3200:
            wild_colors += 1
        else:
            col_flags[rate // 400] = True

    decided_cols = col_flags.count(True)
    max_cols = decided_cols + wild_colors
    
    if decided_cols > 0:
        min_cols = decided_cols
    else:
        min_cols = 1
    return (min_cols, max_cols)

print("{} {}".format(*get_cols(rates)))


Measured memory_bytes: 3060
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)

    val s = sc.next()

    val ans = if (s == "ABC") "ARC" else "ABC"

    println(ans)

  }

  def debug(args: Any*): Unit = {
    Console.err.println(args.mkString(" "))
  }

  def printExecTime(process: => Unit): Unit = {
    val start = System.currentTimeMillis
    process
    debug("処理時間： " + (System.currentTimeMillis - start) + " ミリ秒")
  }

}


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

int main() {
 int N;
 cin >> N;
 vector<ll> a(N);
 for(int i = 0;i<N;i++){
   cin >> a[i];
 }
  vector<ll> s(N+1);//x
  s[0]= 0;
  for(int i = 0;i<N;i++){
    s[i+1] = s[i] +a[i];
  }
  
  ll sum = 0;
  for(int i = 0;i<N;i++){
    sum += a[i];
  }
  
  vector<ll> D(N+1);//y
  for(int i = 0;i<N+1;i++){
    D[i] = sum-s[i];
  }
    ll ans = 10000000000000000;
  for(int i = 1;i<N;i++){
    ans = min(ans,abs(s[i]-D[i]));
  }
  
  if(a.size() >= 3){
  cout << ans << endl;
  }
  
  else if(a.size() == 2){
    cout << abs(a[0]-a[1]) << endl;
  }
  
}

Measured memory_bytes: 4992
fn read() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let (n, k) = {
        let v: Vec<usize> = read()
            .split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect();
        (v[0], v[1])
    };
    read();

    let ans = (n + ((k - 1) - (n - 1) % (k - 1)) % (k - 1) - 1) / (k - 1);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int MOD=1e9+7,MAX=1e6;
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
typedef struct{int SPF[1000001];int Primes[1000001];int count[1000001];int sz;}Template;
struct T{int fact[1000001],inv[1000001];};
Template P;struct T MODINV;
static inline int MPow(int a,int b){return b?1l*MPow(1l*a*a%MOD,b>>1)*(b&1?a:1)%MOD:1;}
static inline void ready(void)
{
  *P.SPF=1,*P.Primes=2,*P.count=0,P.sz=1;
  rep(i,MAX/2)P.SPF[2*(i+1)]=2,P.SPF[2*(i+1)-1]=2*(i+1)-1;
  rep(i,MAX/2-1)
  {
    int x=2*(i+1)+1;if(P.SPF[x]==x)P.Primes[P.sz++]=x;
    rep(j,P.sz)
    {
      if(P.Primes[j]<=P.SPF[x]&&x*P.Primes[j]<=MAX)P.SPF[x*P.Primes[j]]=P.Primes[j];
      else break;
    }
  }
  rep(i,P.sz/2)P.count[P.Primes[2*i]]=P.count[P.Primes[2*i+1]]=0;
}
static inline void init(void)
{
  MODINV.fact[0]=1;rep(i,MAX)MODINV.fact[i+1]=1l*MODINV.fact[i]*(i+1)%MOD;
  MODINV.inv[MAX]=MPow(MODINV.fact[MAX],MOD-2);
  rep(i,MAX)MODINV.inv[MAX-1-i]=1l*MODINV.inv[MAX-i]*(MAX-i)%MOD;
}
void start(int *p,int N) {
	for (int i = 2; i < N; i++) {
		if (p[i]) continue;
		for (int j = i; j < N; j += i)
			p[j] = i;
	}
}
int main(void)
{
  int N=IN(),A=0,flag=1,invsum=0,k=0,lcm=1,x=0,temp[10000],box[168]={};ready();init();
  int b[MAX];start(b,MAX);
  rep(i,N)
  {
    A=IN();invsum=(invsum+1l*MODINV.fact[A-1]*MODINV.inv[A]%MOD)%MOD;
    rep(j,168){x=0;while(A%P.Primes[j]==0){A/=P.Primes[j];if(box[j]<++x)box[j]=x;}}
    if(A!=1){rep(j,k){if(temp[j]==A)flag=0;}if(flag)temp[k++]=A;}flag=1;
  }
  rep(i,168){rep(j,box[i]){lcm=1l*lcm*P.Primes[i]%MOD;}}
  x=-1;rep(i,k){if(x!=temp[i]){lcm=1l*lcm*temp[i]%MOD;x=temp[i];}}
  x=1l*lcm*invsum%MOD;return printf("%d\n",x),0;
}

Measured memory_bytes: 21440
#include <bits/stdc++.h>
#define rep(i , x , y) for(register int i = (x) , _## i = ((y) + 1) ; i < _## i ; i ++)
#define Rep(i , x , y) for(register int i = (x) , _## i = ((y) - 1) ; i > _## i ; i --)
using namespace std ;
#define int long long
using ll = long long ;
using pii = pair < int , int > ;
const static int _ = 1 << 20 ;
char fin[_] , * p1 = fin , * p2 = fin ;
inline char gc() { return (p1 == p2) && (p2 = (p1 = fin) + fread(fin , 1 , _ , stdin) , p1 == p2) ? EOF : * p1 ++ ; }
inline int read() {
	bool sign = 1 ; char c = 0 ; while(c < 48) ((c = gc()) == 45) && (sign = 0) ;
	int x = (c & 15) ; while((c = gc()) > 47) x = (x << 1) + (x << 3) + (c & 15) ;
	return sign ? x : -x ;
}
template < class T > void print(T x , char c = '\n') {
	(x == 0) && (putchar(48)) , (x < 0) && (putchar(45) , x = -x) ;
	static char _st[100] ; int _stp = 0 ;
	while(x) _st[++ _stp] = x % 10 ^ 48 , x /= 10 ;
	while(_stp) putchar(_st[_stp --]) ; putchar(c) ;
}
template < class T > void cmax(T & x , T y) { (x < y) && (x = y) ; }
template < class T > void cmin(T & x , T y) { (x > y) && (x = y) ; }
int n ;
const int N = 1e5 + 10 ;
vector < int > G[N] ;
int a , b ;
int fa[N] , d[N] , mx[N] ;
void dfs(int u) {
	for(int v : G[u]) {
		if(v == fa[u]) continue ;
		fa[v] = u ;
		d[v] = d[u] + 1 ;
		dfs(v) ;
	}
}
void dfs2(int u) {
	mx[u] = d[u] ;
	for(int v : G[u]) {
		if(v == fa[u]) continue ;
		dfs2(v) ;
		if(mx[v] > mx[u]) mx[u] = mx[v] ;
	}
}
signed main() {
#ifdef _WIN64
	freopen("testdata.in" , "r" , stdin) ;
#endif
	n = read() ; a = read() ; b = read() ;
	rep(i , 1 , n - 1) {
		int a = read() , b = read() ;
		G[a].push_back(b) ;
		G[b].push_back(a) ;
	}
	dfs(b) ; dfs2(b) ;
	int dep = d[a] >> 1 ;
	while(dep --) a = fa[a] ;
	print(mx[a] - 1) ;
	return 0 ;
}


Measured memory_bytes: 13056
def main():
    x,y=map(int, input().split()) 

    all_crane = x * 2
    all_turtle = x * 4

    if y >= all_crane and y <= all_turtle and y % 2 == 0:
        print("Yes")
    else:
        print('No')

if __name__ == "__main__":
    main()

Measured memory_bytes: 9168
def check(i,j):
    c=0
    dx=[-1,0 , 1,-1,1,-1,0,1]
    dy=[-1,-1,-1, 0,0, 1,1,1]
    for k in range(8):
        y=i+dy[k]
        x=j+dx[k]
        if x>=0 and x<w and y>=0 and y<h:
            if S[y][x]=="#":
                c+=1
    return c

h,w=map(int,input().split())
S=[input() for i in range(h)] 
for i in range(h):
    s=""
    for j in range(w):
        if S[i][j]=="#":
            s+="#"
        else:
            count=check(i,j)
            s+=str(count)
    print(s)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main() {
  int n; cin >>n;
  int m = -1;
  for(int i = 0; i <= n; ++i){
    if(i*(i+1)/2==n){
      m=i;
      break;
    }
  }
  if(m==-1){
    cout << "No" << endl;
    return 0;
  }
  vector<vector<int> > a(m+1, vector<int> (m));
  int num =1;
  for(int i = 0; i < m+1; ++i){
    for(int j = i; j < m; ++j){
      a[i][j]=a[j+1][i]=num;
      ++num;
    }
  }
  cout << "Yes" << endl;
  cout << m+1 << endl;
  for(int i = 0; i < m+1; ++i){
    cout << m << " ";
    for(int j = 0; j < m-1; ++j){
      cout << a[i][j] << " ";
    }
    cout << a[i][m-1] << endl;
  }
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N;
string X;
vector<pair<string, ll>> inpt;
ll i, j;
int main(){
    cin >> N;
    fornum(i,0,N){
        string s;
        ll t;
        cin >> s >> t;
        inpt.push_back({s, t});
    }
    cin >> X;

    ll ans = 0;
    for (i = N - 1; i >= 0;--i){
        if(inpt[i].first==X){
            break;
        }
        ans += inpt[i].second;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans = 0;
int main() {
	string S;
	vl A[10];
	cin >> n;
	cin >> S;
	rep(i, n) {
		A[S[i] - '0'].push_back(i);
	}
	rep(i, 10) {
		rep(j, 10) {
			rep(k, 10) {
				if (A[i].size() * A[j].size() * A[k].size() != 0) {
					x = A[i][0];
					y = A[j].back();
					if (lower_bound(all(A[k]), y) - lower_bound(all(A[k]), x+1) > 0) {
						ans++;
					}
				}
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 768
N=int(input())-1
B = [int(i) for i in input().split( )]
C = [0]* (N+1)
A = [0]* (N+1)
A[N] = B[N-1]
for i in range(N):
    C[i+1]=B[i]
C[0]=C[1]
for i in range(N):
    A[i] = min(C[i],C[i+1])
print(sum(A))

Measured memory_bytes: 3064
list=[]
for a in range(1,10):
 list.append(a)
 for b in range(a-(a>0),a+(a<9)+1):
  list.append(a*10+b) 
  for c in range(b-(b>0),b+(b<9)+1):
   list.append(a*100+b*10+c)
   for d in range(c-(c>0),c+(c<9)+1):
    list.append(a*1000+b*100+c*10+d)
    for e in range(d-(d>0),d+(d<9)+1):
     list.append(a*10000+b*1000+c*100+d*10+e)
     for f in range(e-(e>0),e+(e<9)+1):
      list.append(a*100000+b*10000+c*1000+d*100+e*10+f)
      for g in range(f-(f>0),f+(f<9)+1):
       list.append(a*1000000+b*100000+c*10000+d*1000+e*100+f*10+g)
       for h in range(g-(g>0),g+(g<9)+1):
        list.append(a*10000000+b*1000000+c*100000+d*10000+e*1000+f*100+g*10+h)
        for i in range(h-(h>0),h+(h<9)+1):
         list.append(a*100000000+b*10000000+c*1000000+d*100000+e*10000+f*1000+g*100+h*10+i)
         for j in range(i-(i>0),i+(i<9)+1):
          list.append(a*1000000000+b*100000000+c*10000000+d*1000000+e*100000+f*10000+g*1000+h*100+i*10+j)

list.sort()
x=int(input())
print(list[x-1])

Measured memory_bytes: 12368
#include<bits/stdc++.h>
#define ll unsigned long long int
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,i,j,k,sum=0;
    cin>>n;
    for(i=1;i<=n;i++){
    	for(j=1;j<=n;j++){
    		for(k=1;k<=n;k++){
    			ll a =__gcd(i,__gcd(j,k));
    			sum+=a;
			}
		}
	}
	cout<<sum;
}


Measured memory_bytes: 3656
const main = stdin => {
  const input = stdin.trim().split('\n')

  const [A, B, C] = input[0].split(' ').map(x => parseInt(x))
  console.log(Math.max(C - (A - B), 0));
}

// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 30408
k, n = map(int, input().split())
A = list(map(int, input().split()))
Adist = []
for i in range(len(A)):
  if i == 0:
    Adist.append(k - (A[i-1] - A[i]))
  else:
    Adist.append(A[i] - A[i-1])
print(k - max(Adist))

Measured memory_bytes: 26420
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

    typedef long long ll;
    #define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
    #define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

    ll pow(ll a, ll n) { //compute a^n with o(logn)
        ll res = 1;
        while (n > 0) {
            if (n & 1) res = res * a;
            a = a * a;
            n >>= 1;
        }
        return res;
    }

    ll pow(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
        ll res = 1;
        while (n > 0) {
            if (n & 1) res = res * a % mod;
            a = a * a % mod;
            n >>= 1;
        }
        return res;
    }

    int main(){
        ll n;
        cin >> n;
        ll a[n+1];
        rep1(i,n) cin >> a[i];
        sort(a+1,a+n+1);
        ll sum = 0;
        rep1(i,n-1){
            sum += a[n - (ll)floor(i/2.0)];
        }
        cout << sum << endl;
        return 0;
    }

Measured memory_bytes: 4816
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <list>
#include <cmath>
#include <iomanip>

class dice{
public:
    int num[7] = {0,0,0,0,0,0,0};

    void n(){
        int temp = num[1];
        num[1] = num[2];
        num[2] = num[6];
        num[6] = num[5];
        num[5] = temp;
    }

    void s(){
        int temp = num[1];
        num[1] = num[5];
        num[5] = num[6];
        num[6] = num[2];
        num[2] = temp;
    }

    void w(){
        int temp = num[4];
        num[4] = num[1];
        num[1] = num[3];
        num[3] = num[6];
        num[6] = temp;
    }

    void e(){
        int temp = num[4];
        num[4] = num[6];
        num[6] = num[3];
        num[3] = num[1];
        num[1] = temp;
    }

    int top(){
        return num[1];
    }
};

int main()
{
    dice d;

    for(int i = 1; i < 7; i++){
        std::cin >> d.num[i];
    }

    std::string str;
    std::cin >> str;
    for(int i = 0; i < str.length(); i++){
        if(str[i] == 'S'){
            d.s();
        }else if(str[i] == 'N'){
            d.n();
        }else if(str[i] == 'E'){
            d.e();
        }else{
            d.w();
        }
    }

    std::cout << d.top() << std::endl;

    return 0;
}


Measured memory_bytes: 3160
#include <iostream>
#include <queue>
#include <utility>

using namespace std;

int H,W;
char m[50][50];
int c[50][50];
queue<pair<int,int> > q;
int dif[5] = {0,-1,0,1,0};

int main(){
  int count = 0;
  cin >> H >> W;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> m[i][j];
      c[i][j] = -1;
      if(m[i][j] == '.') count++;
    }
  }
  c[0][0] = 1;
  q.push(make_pair(0,0));
  while(!q.empty()){
    int x = q.front().first;
    int y = q.front().second;
    q.pop();
    for(int i=0;i<4;i++){
      if(x+dif[i] < 0 || y+dif[i+1] < 0) continue;
      if(x+dif[i] >= H || y+dif[i+1] >= W) continue;
      int X = x+dif[i];
      int Y = y+dif[i+1];
      if(m[X][Y] == '#' || c[X][Y] != -1) continue;
      c[X][Y] = c[x][y] + 1;
      q.push(make_pair(X,Y));
    }
  }
  if(c[H-1][W-1] == -1){
    cout << -1 << endl;
    return 0;
  }
  cout << count - c[H-1][W-1] << endl;
  return 0;
}


Measured memory_bytes: 256
using System;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            Console.ReadLine();
            var numsS = Array.ConvertAll(Console.ReadLine().TrimEnd().Split(), int.Parse);
            Console.ReadLine();
            var numsT = Array.ConvertAll(Console.ReadLine().TrimEnd().Split(), int.Parse);
            int ans = 0;

            for (int i = 0; i < numsT.Length; i++)
            {
                for (int j = 0; j < numsS.Length; j++)
                {
                    if (numsT[i] == numsS[j])
                    {
                        ans++;
                        break;
                    }
                }
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 20084
#

import itertools
from collections import Counter
from collections import defaultdict
import bisect

def main():
    A, B = map(int, input().split())
    if A >= 13:
        print(B)
    else:
        if 6 <= A <= 12:
            print(B // 2)
        else:
            print(0)

if __name__ == '__main__':
    main()


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

public class Main {

  private static void solve() {
    int n = nextInt();
    long[] a = new long[n];

    for (int i = 0; i < n; i++) {
      a[i] = nextInt();
    }

    long[] sum = new long[n];

    sum[0] = a[0];
    for (int i = 1; i < n; i++) {
      sum[i] = sum[i - 1] + a[i];
    }

    long[][] dp = new long[n][n];

    for (int i = 0; i < n; i++) {
      dp[i][i] = a[i];
    }


    for (int len = 2; len <= n; len++) {
      for (int l = 0; l < n; l++) {
        int r = l + len - 1;
        if (r >= n) break;

        dp[l][r] = Math.max(a[l] + (sum[r] - sum[l] - dp[l + 1][r]),
                            a[r] + (sum[r - 1] - (l == 0 ? 0 : sum[l - 1]) - dp[l][r - 1]));
      }
    }

    out.println(2 * dp[0][n - 1] - sum[n - 1]);
  }

  private static void run() {
    br = new BufferedReader(new InputStreamReader(System.in));
    out = new PrintWriter(System.out);

    solve();

    out.close();
  }

  private static StringTokenizer st;
  private static BufferedReader br;
  private static PrintWriter out;

  private static String next() {
    while (st == null || !st.hasMoreElements()) {
      String s;
      try {
        s = br.readLine();
      } catch (IOException e) {
        return null;
      }
      st = new StringTokenizer(s);
    }
    return st.nextToken();
  }

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

  private static long nextLong() {
    return Long.parseLong(next());
  }

  public static void main(String[] args) {
    run();
  }
}

Measured memory_bytes: 129876
void main(){
	
	auto N = readLine!long()[0];
	
	long[string] dict;
	
	foreach( i ; 0..N ){
		dict[ readln().chomp() ] = 1;
	}
	
	writeln(dict.length);
	
	
}


import std.stdio, std.string, std.conv;
import std.math, std.algorithm, std.array;
import std.regex;


T[] readLine( T = size_t )( string sp = " " ){
	T[] ol;
	foreach( string elm ; readln().chomp().split(sp) ){
		ol ~= elm.to!T();
	}
	return ol;
}

Measured memory_bytes: 24004
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;

string str[3];
string o="";
int main() {
	for (int i = 0; i < 3; i++) {
		cin >> str[i];
		o += str[i][i];
	}
	cout << o << endl;
	return 0;
}

Measured memory_bytes: 256
// Vicfred
// https://atcoder.jp/contests/abc162/tasks/abc162_a
// implementation
import std.stdio;

void main() {
    string n = readln;

    foreach(ch; n) {
        if(ch == '7') {
            "Yes".writeln;
            return;
        }
    }
    "No".writeln;
}



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

#define lli long long int
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define INF 1000000007
#define endl "\n"

lli nn,a,dp[100005];
vector<lli> v;

lli dfs(int n){
	if(dp[n]!=-1){
		return dp[n];
	}
	if(n==nn-2){
		return dp[n]=abs(v[n]-v[n+1]) + dfs(n+1);
	}
	if(n==nn-1){
		return 0;
	}
	return dp[n] = min(abs(v[n]-v[n+1]) + dfs(n+1), abs(v[n]-v[n+2]) + dfs(n+2));
}

int main(){
	memset(dp,-1,sizeof(dp));
	cin>>nn;
	for (int i = 0; i < nn; i++)
	{
		cin>>a;
		v.pb(a);
	}
	cout<<dfs(0);
	//system("pause");
}

Measured memory_bytes: 4212
def Trained():
    button = []
    N = int(input())
    for _ in range(N):
        button.append(int(input()) - 1)
    adr = 0
    for i in range(N):
        adr = button[adr]
        if adr == 1:
            print(i + 1)
            return()
    print(-1)
    return()
Trained()


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

int main(){
  int n;
  cin >> n;
  if(n%1000!=0)cout << 1000-n%1000 << endl;
  else cout << "0" << endl;
}

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

const int N=200005;
const int mod=1000000007;
typedef long long ll;

int n,a,b,c,d;
char s[N];
bool fa,fb;

int main()
{
    scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
    scanf("%s",s+1);
    for(int i=a;i<c;i++)
    {
        if(s[i]=='#' && s[i+1]=='#')
        {
            fa=true;
            break;
        }
    }
    if(fa) printf("No\n");
    else
    {
        for(int i=b;i<d;i++)
        {
            if(s[i]=='#' && s[i+1]=='#')
            {
                fb=true;
                break;
            }
        }
        if(fb)  printf("No\n");
        else
        {
            if(c<d) printf("Yes\n");
            else
            {
                bool flag=false;
                for(int i=b;i<=d;i++)
                {
                    if(s[i-1]=='.' && s[i+1]=='.' && s[i]=='.' && i+1<=n && i-1>0)
                    {
                        flag=true;
                        break;
                    }
                }
                if(flag) printf("Yes\n");
                else printf("No\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 384
N, x = map(int, raw_input().split())
a = map(int, raw_input().split())

a = sorted(a)
c = 0
for _a in a:
	x -= _a
	if x >= 0:
		c += 1
	else:
		break
		
if x > 0:
	c -= 1
print c


Measured memory_bytes: 2568
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    int H,W;
    string S;
    cin >> H >> W;
    for(int i = 1;i <= H;i++){
        for(int j = 0;j < W;j++){
            cin >> S;
            if(S == "snuke"){
                printf("%c%d\n",'A'+j,i);
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
using namespace std; 
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(x % y, y);
}
int main() {
	int N, X, x[100000] = {},ans=-1;
	cin >> N >> X;
	for (int i = 0; i < N; i++)
	{
		cin >> x[i];
		if (ans==-1)
		{
			ans = abs(X-x[i]);
		}
		ans = gcd(ans, abs(X - x[i]));
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    double a,b,x;
    cin >> a >> b >> x;
    double ans;
    double V=a*a*b;
    if(x>V/2)
        ans=atan((b-x/a/a)/(a/2))*180.0/M_PI;
    else 
        ans=atan(b/(2*x/a/b))*180.0/M_PI;
        
    printf("%.7f\n",ans);
        return 0;
}

Measured memory_bytes: 4084
#include<bits/stdc++.h>
#define L long long
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define pii pair<pi,int>
#define aa first
#define bb second
#define xx aa.aa
#define yy aa.bb
#define zz bb
#define mp make_pair
#define mpp(a,b,c) mp(mp(a,b),c)
using namespace std;
int n,s[2010],l[2010],r[2010],p=1e9;
char a[2010],b[2010];
pi x[2010];
inline int calc(int i,int l,int r)
{
//	cout<<l<<" "<<r<<"\n";
	l=min(l,i);
	r=max(r,i);
	return 2*(r-l)-abs(i);
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k,w,u,o;
	scanf("%s%s",&a,&b);
	n=strlen(a);
	for(i=0;i<n;i++)
	  s[i]=(i?s[i-1]:0)+b[i]-'0';
	if(!s[n-1])
	  {
	   for(i=0;i<n;i++)
	     if(a[i]=='1')
	       break;
	   if(i<n)
	     printf("-1\n");
	   else
	     printf("0\n");
	   return 0;
	  }
	for(i=0;i<n;i++)
	  {
	   k=min(i,n-i)+n;
	   for(j=0;j<n;j++)
	     if(a[j]!=b[(i+j)%n])
	       k++;
	   p=min(p,k);
	  }
	for(i=0;i<n;i++)
	  {
	   for(j=0;b[(i+j)%n]=='0';j++);
	   r[i]=j;
	   for(j=0;b[(i+j+n)%n]=='0';j--);
	   l[i]=j;
	   //cout<<l[i]<<" "<<r[i]<<"!!!\n";
	  }
	for(i=-(n-1);i<n;i++)
	  {
	   k=0;
	   w=0;
	   for(j=0;j<n;j++)
	     if(a[j]!=b[(i+j+n)%n])
	       {
	        k++;
	        if(i>l[j] && i<r[j])
	          x[++w]=mp(l[j],r[j]);
		   }
	   sort(x+1,x+w+1);
	   o=1e9;
	   u=0;
	   x[w+1].aa=0;
	   for(j=0;j<=w;j++)
	     {
		  if(j)
		    u=max(u,x[j].bb);
		  o=min(o,calc(i,x[j+1].aa,u));
		 }
	   p=min(p,k+o);
	   //cout<<i<<" "<<k<<" "<<o<<"-----------\n";
	  }
	printf("%d\n",p);
	return 0;
}


Measured memory_bytes: 256