akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
using namespace std;
#define REP(i,n); for(int i = 0;i < (int)(n);i++)

int main() {
	int n;
	string tmp;
	vector<int> number;
	map<string, int> a;
	
	cin >> n;

	REP(i,n){
		cin >> tmp;
		auto it = a.find(tmp);
		if(it != a.end()){
			a[tmp] = 1 + a[tmp];
		}else{
			a[tmp] = 1;
		}
	}

	for(auto x: a){
		number.push_back(x.second);
	}

	sort(number.begin(), number.end(), greater<int>());

	for(auto x:a){
		if(number[0]==x.second){
			cout << x.first << endl;
		}
	}

	

	return(0);
}


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

int main() {
  int h, n;
  cin >> h >> n;
  int damage = 0;
  rep(i,n) {
    int a;
    cin >> a;
    damage += a;
  }
  if(h > damage) cout << "No" << endl;
  else cout << "Yes" << endl;
}

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

public class ABC
{
    //          long[] sp = Console.ReadLine().Split().Select(long .Parse).ToArray();
    //          int[] sp = Console.ReadLine().Split().Select(int.Parse).ToArray();
    //          int N =  int.Parse(Console.ReadLine());
    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int[] b = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] output = new int[N];
        output[0] = b[0];

        for (int i = 1; i < N-1; i++)
        {
            output[i] = Math.Min(b[i - 1], b[i]);

        }
        output[N - 1] = b.Last();
        Console.WriteLine(output.Sum());

    }

}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
	string st;
	cin>>st;
	int w;
	cin>>w;
	int t=0;
	while(t<st.size()){
		cout<<st[t];
		t+=w;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include<utility>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

typedef pair<ll, ll> P;

bool ps1(const P &element1, const P &element2)
{ //first昇順
	return element1.first < element2.first;
}
bool ps2(const P &element1, const P &element2)
{ //first降順
	return element1.first > element2.first;
}
bool ps3(const P &element1, const P &element2)
{ //second昇順
	return element1.second < element2.second;
}
bool ps4(const P &element1, const P &element2)
{ //second降順
	return element1.second > element2.second;
}
int GCD(int x, int y) {
	return x ? GCD(y % x, x) : y;
}

int main()
{
	int h,w;
	cin>>h>>w;
	int d;
	cin>>d;
	vector<vector<int>>grid(h,vector<int>(w));
	map<int,pair<int,int>>ans;
	map<int,int>len;

	rep(i,h)rep(j,w){
		int a;
		cin>>a;
		grid[i][j]=a;
		ans[a]=make_pair(i,j);
	}
	int q;
	cin>>q;
	rep(i,d){
		int tmp=i;
		len[tmp]=0;
		int length=0;
		while(tmp<=h*w){
			P prevl=ans[tmp];
			tmp+=d;
			P aftl=ans[tmp];
			length+=abs(prevl.F-aftl.F);
			length+=abs(prevl.S-aftl.S);
			len[tmp]=length;
			if(tmp+d>h*w){
				break;
			}
		}
	}
	rep(i,q){
		int l,r;
		cin>>l>>r;
		int length=0;
		length=len[r]-len[l];
		cout<<length<<endl;
	}


}

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

int main() {
  int N,M;
  cin >> N >> M;
  int sum=0;
  int m=0;
  int i;
  vector<int> vec(N);
  for (i=0; i<N; i++){
    cin >> vec.at(i);
    sum+=vec.at(i);
  }
  for (i=0; i<N; i++){
    if (sum%(4*M)!=0){
    if (vec.at(i)>(sum/(4*M))) m++;
    }
    else if(vec.at(i)>=(sum/(4*M))) m++;
  }
  if (m>=M) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){

	int N,A,x;
  
  	cin >> N >> A;
  
  	x = N % 500;
  
  	if(x <= A){
    	cout << "Yes" << endl;
    }else{
    	cout << "No" << endl;
    }


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define pi          3.14159265358979323

db pw[30];

void pre()
{
       pw[0]=1;
       pw[1]=2;
       for(ll i=2; i<30; i++) pw[i]=2*pw[i-1];
}

db fex(ll x)
{
       if(x==0) return 1.0;
       if(x==1) return 0.5;
       if(x&1)
       {
              db t = fex(x/2);
              return t*t*0.5;
       }
       else
       {
              db t = fex(x/2);
              return t*t;
       }
}



void solve()
{
       db n,k;
       pre();
       cin>>n>>k;
       fix(15);
       db ans=0;
       for(ll i=1; i<=min(n,k-1); i++)
       {
              db score = i;
              ll cnt=0;
              for(cnt=0; cnt<30; cnt++) if(score*pw[cnt]>=k) break;
              ans += (1.0 / n)*fex(cnt);
       }
       if(n>=k)
       {
              ans += (n-k+1)/n;
       }
       cout<<ans<<endl;
}

int main()
{
       speed_up;
       ll T=1;
       //cin>>T;
       while(T--) solve();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<string.h>
using namespace std;
int cmp(int a,int b)
{
    if(a%10==0)
        return 1;
    else if(b%10==0)
        return 0;
    else
    {
        return a%10>b%10;
    }
}
int main()
{
   int a[5],k,i;
   for(i=0;i<5;i++)
   {
       scanf("%d",&a[i]);

   }
   sort(a,a+5,cmp);
   int sum=0;
   for(i=0;i<4;i++)
   {
       if(a[i]%10==0)
        sum+=a[i];
       else
       {
           sum+=(a[i]/10+1)*10;
       }
   }
   sum+=a[4];
   printf("%d\n",sum);
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int n;
	while (cin >> n&&n != 0) {
		for (int i = 0; i < n; i++) {
			int e, f, g, a = 0, b = 0, c = 0;
			char l;
			cin >> e >> f >> g;
			if (e == 100 || f == 100 || g == 100)
				a++;
			if ((e + f) / 2 >= 90)
				a++;
			double d = (e + f + g) / 3;
			if (d >= 80)
				a++;
			if (d >= 70)
				b++;
			if (d >= 50 && (e >= 80 || f >= 80))
				b++;
			if (a != 0 )
				cout << 'A' << endl;
			else if (b != 0)
				cout << 'B' << endl;
			else
				cout << 'C' << endl;
		}
	}
}

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

using int64 = long long;
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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 T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

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

   string old = "*";

   set<string> S;
   rep (i, N) {
      string s;
      cin >> s;
      if (i == 0) {
         old = s;
         S.insert(s);
         continue;
      }
      if (S.find(s) != S.end()) {
         puts("No");
         return 0;
      }

      if (old.back() != s[0]) {
         puts("No");
         return 0;
      }

      S.insert(s);
      old = s;
   }

   puts("Yes");

   return 0;
}

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

#define int long long

using ll = long long;
//typedef long long ll;

#define INF (1LL << 31 - 1)
#define INFLL ((1LL << 62) - 1)
#define MOD int(1e9+7)
#define repi(i,j,n) for(int i = (j); i < (n); ++i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) for (int i = n; i >= 0; --i)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()

int vx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, vy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};

inline bool check(int ux, int uy, int x, int y) {
  return (0 <= x and x < ux and 0 <= y and y < uy);
}

inline void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int n, z, w, aa, dp[2001][2001][2];
vector<int> a;

int solve(int idx, int z, int w, int turn) {
  if (dp[idx][idx + 1][turn] != -1) return dp[idx][idx + 1][turn];

  int ret;

  if (idx == n) {
    return llabs(z - a[n - 1]);
  }

  if (turn == 0) {
    ret = 0;

    for (int i = idx; i < n; ++i) {
      ret = max(ret, solve(i + 1, a[i], w, abs(turn - 1)));
    }

    ret = max({ret, llabs(w - a[n - 1]), ((idx <= n - 2) ? llabs(a[n - 1] - a[n - 2]) : 0)});
  }
  else {
    ret = INFLL;

    for (int i = idx; i < n; ++i) {
      ret = min(ret, solve(i + 1, z, a[i], abs(turn - 1)));
    }

    ret = min({ret, llabs(z - a[n - 1]), ((idx <= n - 2) ? llabs(a[n - 1] - a[n - 2]) : INFLL)});
  }

  return dp[idx][idx + 1][turn] = ret;
}

signed main() {
  init();
  int z, w;
  cin >> n >> z >> w;
  a.resize(n);
  rep(i,n) {
    cin >> a[i];
  }

  memset(dp, -1, sizeof dp);

  cout << solve(0, z, w, 0) << endl;

  return 0;
}


Measured memory_bytes: 62976
import java.awt.Point;
import java.io.FileInputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Scanner;

import javax.naming.InitialContext;
 
public class Main {
     
	static int N;
	static int dp1[];
	static int dp2[];
	
	static void init()
	{
		dp1 = new int[1000001];
		dp1[0] = 0;
		dp1[1] = 1;
		for(int i = 2;i <= 1000000;i++)
		{
			dp1[i] = Integer.MAX_VALUE;
			for (int j = 1; j < 200; j++) {
				int d = j*(j+1)*(j+2)/6;
				if(i - d < 0)
				{
					break;
				}
				else if(i - d == 0)
				{
					dp1[i] = 1;
					break;
				}
				dp1[i] = Math.min(dp1[i], dp1[i-d]+1);
			}
		}
		
		dp2 = new int[1000001];
		dp2[0] = 0;
		dp2[1] = 1;
		for(int i = 2;i <= 1000000;i++)
		{
			dp2[i] = Integer.MAX_VALUE;
			for (int j = 1; j < 200; j++) {
				int d = j*(j+1)*(j+2)/6;
				if(d % 2 == 0) continue;
				if(i - d < 0)
				{
					break;
				}
				else if(i - d == 0)
				{
					dp2[i] = 1;
					break;
				}
				dp2[i] = Math.min(dp2[i], dp2[i-d]+1);
			}
		}
	}
	
    
    static void start()
    {
    	System.out.printf("%d %d\n", dp1[N], dp2[N]);
    }
     
    public static void main(String[] args)
    {
        Scanner sca = new Scanner(System.in);
        
        init();
        
        while(true)
        {
        	N = sca.nextInt();
        	
        	if(N == 0) break;
            
            start();
        }
        
    }
}

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

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    long long m,n;
    cin >> m >> n;
    cout << modpow(m, n, 1000000007) << endl;
}


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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 55, M = 3e3, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

int main(){
    init();

    ll n, a, b;  cin >> n;

    a = b = 0;
    for(int i = 0;i < n;i++){
        ll x, y;    cin >> x >> y;
        ll gcd = __gcd(x, y);   x /= gcd, y /= gcd;
        ll l = 1, r = 1e18 / max(x, y);
        while(l <= r){
            ll mid = (l + r) >> 1;
            ll na = x * mid;
            ll nb = y * mid;
            if(na - a >= 0 && nb - b >= 0)
                r = mid - 1;
            else
                l = mid + 1;
        }

        a = x * l;
        b = y * l;
    }

    cout << a + b;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include<map>
typedef long long ll;
using namespace std;
void read(int &x){int f=1;x=0;char s=getchar();while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}x*=f;}
//void write(int x){if(x<0){putchar('-');x=-x;}if(x>9)write}
int GCD(int a,int b)
{    
	return b==0?a:GCD(b,a%b);
}
int main(){	
	int n,m;
	int a[100005];
	int b[100005];
	read(n);
	read(m);
	int h=0;
	int top=0;
	for(int i=0;i<n;i++){
		read(a[i]);
		b[top++]=abs(a[i]-m);
	}
	h=GCD(b[0],b[1]);
	for(int i=2;i<top;i++){
		h=GCD(b[i],h);
	}
	printf("%d\n",h);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define inf 0x3f3f3f3f 
int main(){
	ll  n , W; cin >> n >> W;
    ll w[101] , v[101] , dp[100001] = {0};
    for(int i = 0 ; i < n ; ++i)
        cin >> w[i] >> v[i];
    for(int i = 0 ; i < n ; ++i)
        for(int j = W ; j >= w[i] ; j--)
            dp[j] = max(dp[j] , dp[j - w[i]] + v[i]);

    cout<< dp[W] <<endl;
}

Measured memory_bytes: 4424
#include<cstdio>
    using namespace std;
    int n,m,x,y,tot,v[1500],c[1500][2];
    bool a[1500][1500],f[1500][1500];
    int read() {
    	int tmp=0, fh=1; char c=getchar();
    	while (c<'0'||c>'9') {if (c=='-') fh=-1; c=getchar();}
    	while (c>='0'&&c<='9') tmp=tmp*10+c-48, c=getchar();
    	return tmp*fh;
    }
    bool dfs(int x,int col) {
    	//printf("%d %d\n",x,col);
    	v[x]=col; c[tot][col-1]++;
    	for (int i=1;i<=n;i++) if (x!=i&&(!a[x][i])) {
    		if (!v[i]) {
    			if (!dfs(i,3-col)) return 0;
    		} else if (v[i]==v[x]) return 0;
    	}
    	return 1;
    }
    int main() {
    	n=read(); m=read();
    	for (int i=1;i<=m;i++) {
    		x=read(); y=read();
    		a[x][y]=a[y][x]=1;
    	}
    	for (int i=1;i<=n;i++) if (!v[i]) {
    		tot++;
    		if (!dfs(i,1)) {
    			printf("-1\n"); return 0;
    		}
    	}
    	f[0][0]=1;
    	for (int i=1;i<=tot;i++)
    	for (int j=n;j>=0;j--) if (f[i-1][j]) f[i][j+c[i][0]]=f[i][j+c[i][1]]=1;
    	for (int i=n/2;i>=0;i--) if (f[tot][i]) {
    		printf("%d\n",i*(i-1)/2+(n-i)*(n-i-1)/2);
    		return 0;
    	}
    }

Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#define LLMAX 9223372036854775807

using namespace std;
using ll = long long;

int main() {
	string argS;
	cin >> argS;

	int argA, argB, argC, argD;
	argA = argS.at(0) - '0';
	argB = argS.at(1) - '0';
	argC = argS.at(2) - '0';
	argD = argS.at(3) - '0';

	uint bitMax = 0b111;
	for (uint i = 0; i <= bitMax; ++i) {
		ll ret = argA;
		string op;
		op += ('0' + argA);
		if (i & (1 << 0)) {
			ret += argB;
			op += "+";
		}
		else {
			ret -= argB;
			op += "-";
		}
		op += ('0' + argB);

		if (i & (1 << 1)) {
			ret += argC;
			op += "+";
		}
		else {
			ret -= argC;
			op += "-";
		}
		op += ('0' + argC);

		if (i & (1 << 2)) {
			ret += argD;
			op += "+";
		}
		else {
			ret -= argD;
			op += "-";
		}
		op += ('0' + argD);

		op += "=";
		op += ('0' + ret);
		
		if (ret == 7) {
			cout << op << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define MOD 998244353
#define seg_size 524288
int main(){
	string s;
	cin >> s;
	int failed = 0;
	if (s[0] != 'A') {
		failed = 1;
	}
	int cnt = 0;
	for (int i = 2; i < s.length() - 1; ++i) {
		if (s[i] == 'C') {
			cnt++;
		}
	}
	if (cnt != 1) {
		failed = 1;
	}
	cnt = 0;
	for (int i = 0; i < s.length(); ++i) {
		if (s[i] >= 'A'&&s[i] <= 'Z')cnt++;
	}
	if (cnt != 2) {
		failed = 1;
	}
	if (failed == 0) {
		cout << "AC" << endl;
	}
	else cout << "WA" << endl;
	return 0;
}

Measured memory_bytes: 256
import math

def isPrime(num):
    if num < 2:
        return False
    elif num == 2:
        return True
    elif num % 2 == 0:
        return False

    for i in range(3, math.floor(math.sqrt(num))+1, 2):
        if num % i == 0:
            return False
    
    return True


def find_min_prime(num):
    if num == 2:
        return 2
    if num % 2 == 0:
        num +=1

    while True:
        if isPrime(num):
            break
        num += 2
        
    return num


X = int(input())
print(find_min_prime(X))

Measured memory_bytes: 3064
import java.io.InputStreamReader
import java.io.BufferedReader

//
fun _Do(){
    
    val scanEx = ScannerEx()
    
    //
    val ss = scanEx.strings()

    val s = ss[0]
    //
    for(c in s.indices)
        if(c%2==0)
            print(s[c])
}

//
fun main( argv : Array<String> ) {
    _Do()
}

//
class ScannerEx {
    fun nextString():String{
        if( idx == 0 || strings.size <= idx)
        {
            idx = 0
            strings = bufferedReader.readLine().split(' ')
        }
        var v = strings[idx]!!
        idx += 1
        return v
    }
    fun nextInt():Int{
        if( idx == 0 || strings.size <= idx )
        {
            idx = 0
            strings = bufferedReader.readLine().split(' ')
        }
        var v = strings[idx]!!.toInt()
        idx += 1
        return v
    }
    fun nextLong():Long{
        if( idx == 0 || strings.size <= idx)
        {
            idx = 0
            strings = bufferedReader.readLine().split(' ')
        }
        var v = strings[idx]!!.toLong()
        idx += 1
        return v
    }
    private var idx:Int = 0 //
    private var strings:List<String?> = emptyList()   //
    fun strings(): Array<String> {
        val strings = bufferedReader.readLine().split(' ')
        return Array(strings.size, { strings[it] })
    }
    fun ints(): Array<Int> {
        val strings = bufferedReader.readLine().split(' ')
        return Array(strings.size, { strings[it].toInt() })
    }
    fun longs(): Array<Long> {
        val strings = bufferedReader.readLine().split(' ')
        return Array(strings.size, { strings[it].toLong() })
    }
    private var bufferedReader = BufferedReader(InputStreamReader(System.`in`))
}

Measured memory_bytes: 44044
n,q = map(int,input().split())
S = input()
b = [0]*(n+1)
for i in range(n-1):
    if S[i] == 'A' and S[i+1] == 'C':
       b[i+1] += 1
from itertools import accumulate
b = list(accumulate(b))
#print(b)
for i in range(q):
    l,r = map(int,input().split())
    print(b[r-1]-b[l-1])

Measured memory_bytes: 8072
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;

int h, w, k; 

int check(vector<string> &da, int a, int b) {
    int ans = 0;
    rip(i,h,0) {
        rip(j,w,0) {
            if(((a >> i)&1)==0 && ((b >> j)&1) == 0) {
                if(da[i][j] == '#') ++ans;
            }
        }
    }
    return ans;
}

int main() {
    cin >> h >> w >> k;
    vector<string> da(h);
    rip(i,h,0) cin >> da[i];
    int ans = 0;
    rip(i, 1 << h, 0) {
        rip(j, 1 << w, 0) {
            if(check(da, i, j) == k) ++ans;
        }
    }
    cout << ans << endl;
}

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

int main() {
    string S,T;
    cin >> S >> T;
    int cnt = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] != T[i]) {
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3916
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  int n;
  cin>>n;
  vector<ll> a(n+2);
  REP(i,n) cin>>a[i+1];
  ll sum = 0;
  vector<ll> diff(n);
  REP(i,n+1) {
    sum += abs(a[i] - a[i+1]);
  }
  REP(i,n) {
    diff[i] = abs(a[i] - a[i+2]) - (abs(a[i] - a[i+1]) + abs(a[i+1] - a[i+2]));
  }
  REP(i,n) {
    cout << (sum + diff[i]) << endl;
  }
  return 0;
}


Measured memory_bytes: 2816
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
using namespace std;

double dist(vector<vector<int>> x,int y, int z ,int d){
  double dist = 0;
  for (int j=0; j<d; j++) dist += (double)(x[y][j]-x[z][j]) * (x[y][j]-x[z][j]);
  dist = sqrt(dist);
  return dist;
}

int main(){
  
  int n,d; cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  
  for (int i=0; i<n; i++) for (int j=0; j<d; j++) cin >> x[i][j];
  
  int ans=0;
  
  for (int y=0; y<n; y++){
    for (int z=y+1; z<n; z++){
      if (dist(x,y,z,d)==(int)dist(x,y,z,d)) ans++;
    }
  }
  
  cout << ans;
 
  return 0;
}



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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);
  // input variables
  

  int n, m, x;
  // input in all 
  cin >> n >> m >> x;
// vector integer 
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));
  for (int i = 0; i < n; ++i) {
    cin >> c[i];
    for (int j = 0; j < m; ++j) {
      // some more inputs 
      cin >> a[i][j];
    }
  }

  int64_t ans = 92233720368547758L;
  for (int i = 0; i < (1 << n); ++i) {
    vector<int64_t> sum(m, 0);
    int64_t sumc = 0;
    for (int j = 0; j < n; ++j) {
      if (i & (1 << j)) {
        for (int k = 0; k < m; ++k) sum[k] += a[j][k];
        sumc += c[j];
      }
    }
    bool ok = true;
    for (int j = 0; j < m; ++j) {
      if (sum[j] < x) ok = false;
    }
    if (ok) ans = min(ans, sumc);
  }
  // looping 
  if (ans == 92233720368547758L) {
    cout << -1 << '\n';
  } else {
    // output answer 
    cout << ans << '\n';
  }
  // return values

  return 0;
}

Measured memory_bytes: 3684
#include <iostream>
#include <vector>
#include <functional>
#include <tuple>

#ifdef USE_PYTHON_LIKE_PRINT
#include "print.h"
#else
template<char SEP = ' ', char END = '\n'> inline void print(...){}
template<char SEP = ' ', char END = '\n'> inline void printe(...){}
template<char SEP = ' ', char END = '\n'> inline void printo(...){}
#define define_print(...)
#define define_print_with_names(...)
#define define_to_tuple(...)
#endif

using namespace std;

inline int pow2(int n){
	int x = 1;
	for(int i = 0; i < n; i ++){
		x *= 2;
	}
	return x;
}

inline int pow3(int n){
	int x = 1;
	for(int i = 0; i < n; i ++){
		x *= 3;
	}
	return x;
}

void combi(const int N, vector<int>& towns, const int K, const int l, const int n, function<void(void)> f){
	if(l == K){
		f();
	}else{
		for(int i = n; i <= N - K + l; i ++){
			towns[l] = i;
			combi(N, towns, K, l + 1, i + 1, f);
		}
	}
}

int main(void){
	int N;
	cin >> N;
	
	vector<tuple<int, int, int>> data;
	
	unsigned long min_value_0 = 0;
	for(int i = 0; i < N; i ++){
		int X, Y, P;
		cin >> X;
		cin >> Y;
		cin >> P;
		data.push_back(make_tuple(X, Y, P));
		min_value_0 += (unsigned long)min(abs(X), abs(Y)) * (unsigned long)P;
	}
	
	cout << min_value_0 << endl;
	
	const int B = pow2(N);
	
	vector<vector<int>> table_dists_h(B + 1);
	vector<vector<int>> table_dists_v(B + 1);
	
	for(int b = 0; b < B; b ++){
		auto& dists_h = table_dists_h[b];
		auto& dists_v = table_dists_v[b];
		
		dists_h.reserve(N);
		dists_h.reserve(N);
		for(int i = 0; i < N; i ++){
			const int X0 = get<0>(data[i]);
			const int Y0 = get<1>(data[i]);
			int x = b;
			int j = 0;
			int d_h = abs(X0);
			int d_v = abs(Y0);
			while(x > 0){
				if(x % 2 == 1){
					const int X1 = get<0>(data[j]);
					const int Y1 = get<1>(data[j]);
					d_h = min(d_h, abs(X1 - X0));
					d_v = min(d_v, abs(Y1 - Y0));
				}
				x /= 2;
				j += 1;
			}
			dists_h.push_back(d_h);
			dists_v.push_back(d_v);
		}
	}

	vector<unsigned long> table(N + 1, min_value_0);
	vector<int> stack(N, 0);
	int i = 0;
	int c = 0;
	int b0 = 0;
	int b1 = 0;
	int b = 1;
	while(true){
		if(i == N){
			unsigned long value = 0;
			const auto& t0 = table_dists_h[b0];
			const auto& t1 = table_dists_v[b1];
			for(int i = 0; i < N; i ++){
				const int P0 = get<2>(data[i]);
				value += (unsigned long)min(t0[i], t1[i]) * (unsigned long)P0;
			}
			if(table[c] > value){
				table[c] = value;
			}
			i --;
			b /= 2;
		}else{
			const auto s = stack[i];
			if(s == 3){
				if(i == 0){
					break;
				}else{
					stack[i] = 0;
					i --;
					b /= 2;
				}
			}else{
				if(s == 0){
					b0 += b;
					c += 1;
				}else if(s == 1){
					b0 -= b;
					b1 += b;
				}else{
					b1 -= b;
					c -= 1;
				}
				stack[i] = s + 1;
				i ++;
				b *= 2;
			}
		}
	}
	
	for(int K = 1; K <= N; K ++){
		cout << table[K] << endl;
	}
	
	return 0;
}



Measured memory_bytes: 9384
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define LL       long long
#define DS       pair<LL, LL>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

string s, ans;
deque<char> bck, fnt;

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    int q, f = 1;
    cin >> s >> q;
    while (q--) {
        int t, x; char c;
        scanf("%d", &t);
        if (t == 1) {
            f ^= 1;
        } else {
            scanf("%d %c", &x, &c);
            if (x == 1) {
                if (f) {
                    fnt.push_front(c);
                } else {
                    bck.push_back(c);
                }
            } else {
                if (f) {
                    bck.push_back(c);
                } else {
                    fnt.push_front(c);
                }
            }
        }
    }
    if (f) {
        ans = "";
        while (!fnt.empty()) {
            ans += fnt.front();
            fnt.pop_front();
        }
        for (auto i : s) {
            ans += i;
        }
        while (!bck.empty()) {
            ans += bck.front();
            bck.pop_front();
        }
    } else {
        ans = "";
        while (!bck.empty()) {
            ans += bck.back();
            bck.pop_back();
        }
        for (int i = s.size() - 1; i >= 0; i--) {
            ans += s[i];
        }
        while (!fnt.empty()) {
            ans += fnt.back();
            fnt.pop_back();
        }
    }
    cout << ans << '\n';
    return 0;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff;
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end

ll dp[20010]={};

int main(){
    int n; scanf("%d",&n);
    vector<int> w(n),s(n),v(n),ord(n);
    rep(i,0,n)scanf("%d%d%d",&w[i],&s[i],&v[i]);
    iota(ALL(ord),0);
    sort(ALL(ord),[&](int i,int j){return s[i]+w[i]<s[j]+w[j];});
    for(int i:ord)rrep(j,s[i],-1){
        chmax(dp[j+w[i]],dp[j]+v[i]);
    }
    ll ans=0;
    rep(i,0,20010)chmax(ans,dp[i]);
    printf("%lld\n",ans);
    return 0;
}

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

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

// Mod int library

ll minv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) { ll t = a/b; swap(a -= t*b, b); swap(u -= t*v, v); }
  return (u%m+m)%m;
}
struct mint {
    ll x;
    mint():x(0){}
    mint(ll x):x((x%mod+mod)%mod){}
    mint& fix() { x = (x%mod+mod)%mod; return *this;}
    mint operator-() const { return mint(0) - *this;}
    mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
    mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
    mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
    mint& operator/=(const mint& a){ (x*=minv(a.x, mod))%=mod; return *this; }
    mint operator+(const mint& a)const{ return mint(*this) += a;}
    mint operator-(const mint& a)const{ return mint(*this) -= a;}
    mint operator*(const mint& a)const{ return mint(*this) *= a;}
    mint operator/(const mint& a)const{ return mint(*this) /= a;}
    bool operator<(const mint& a)const{ return x < a.x;}
    bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}

mint mod_pow(mint a, long long x) {
  mint res = 1;
  while(x > 0) {
    if (x & 1) res *= a;
    a *= a; x >>= 1;
  }
  return res;
}

int MAXN = 200005;
vector<mint> fact(MAXN+1);

void init() {
  fact[0] = 1;
  for(int i=1; i<=MAXN; i++) fact[i] = fact[i-1]*i;
}

// nCr
mint comb(int n, int r) {
  if (n < r || n < 0 || r < 0) return 0;
  return fact[n]/(fact[r]*fact[n-r]);
}

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

  int n, m, k; cin >> n >> m >> k;
  init();
  mint base = comb(n*m-2, k-2);

  mint ans1 = 0;
  for(int i=1; i<=m-1; i++) {
    ans1 += (mint)i*(mint)(m-i);
  }
  ans1 *= (n*n);

  mint ans2 = 0;
  for(int i=1; i<=n-1; i++) {
    ans2 += (mint)i*(mint)(n-i);
  }
  ans2 *= (m*m);

  cout << (ans1+ans2)*base << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct M {
    unsigned int m, a, b;
    bool in;
};

bool operator<( M const& lhs, M const& rhs )
{
    return lhs.a < rhs.a;
}

int main()
{
    int n;
    while( cin >> n ) {
        if ( n == 0 )
            break;

        vector<M> ds;
        for( int iii=0; iii<n; ++iii ) {
            unsigned int m, a, b;
            cin >> m >> a >> b;
            
            M data = { m, a, b };
            ds.push_back( data );
        }

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

        unsigned long long int cur = 0;
        unsigned int t = 0;
        for( size_t i=0; i<ds.size(); ++i ) {
            t = ds[i].a;
            cur += ds[i].m;
            ds[i].in = true;
            for( size_t j=0; j<ds.size(); ++j ) {
                if ( ds[j].in && ds[j].b <= t ) {
                    cur -= ds[j].m;
                    ds[j].in = false;
                }
            }

            if ( cur > 150 ) {
                cout << "NG" << endl;
                goto fin;
            }
        }
        cout << "OK" << endl;
    fin:
        ;
    }
}

Measured memory_bytes: 1216
from sys import stdin

n, x, y = [int(x) for x in stdin.readline().rstrip().split()]
dic = { x: 0 for x in range(1, n)}

for i in range(1, n):
    for j in range(i + 1, n + 1):
        if i >= y or j <= x:
            dis = j - i
        elif i <= x and j >= y:
            dis = j - y + x - i + 1
        elif i >= x and j <= y:
            dis = min(j - i, i + y - x + 1 - j)
        elif i >= x:
            dis = j - y + min(y - i, i - x + 1)
        else:
            dis = x - i + min(j - x, y + 1 - j)
        dic[dis] = dic[dis] + 1

for x in range(1, n):
    print(dic[x])


Measured memory_bytes: 3572
#include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for (int i=0;i<n;i++)

int main() {
  int s[5][5];
  rep(i,3) rep(j,3) cin>>s[i][j];
  bool k[3][3];
  rep(i,3) rep(j,3) k[i][j]=false;
  int n;
  cin>>n;
  rep(p,n) {
    int t;
    cin>>t;
    rep(i,3) rep(j,3) {
      if (s[i][j]==t) {
        k[i][j]=true;
      }
    }
  }
  bool ans=false;
  rep(i,3) {
    if (k[i][0]&&k[i][1]&&k[i][2]) {
      ans=true;
    }
  }
  rep(j,3) {
    if (k[0][j]&&k[1][j]&&k[2][j]) {
      ans=true;
    }
  }
  if (k[0][0]&&k[1][1]&&k[2][2]) {
    ans=true;
  }
  if (k[0][2]&&k[1][1]&&k[2][0]) {
    ans=true;
  }
  cout<< (ans ? "Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 256
ans = ['delicious', 'safe', 'dangerous']

def judge(x, a, b):
	if a >= b:
		return 0
	if x + a >= b:
		return 1
	return 2

inpt = map(int, raw_input().split())
x = inpt[0]
a = inpt[1]
b = inpt[2]

print ans[judge(x, a, b)]


Measured memory_bytes: 2568
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())
d = factorization(n)
ans = 0


for i, j in d:
    for k in range(1, 100000):
        if i == 1:
            break
        if j >= k:
            ans += 1
            j -= k
        else:
            break

print(ans)

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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int N; cin >> N;
    int x, ans;
    for (int i = 9; i >= 1; i--) {
        x = i * 111;
        if (N <= x) ans = x;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    #define int ll
    #define M 1000000007
    #define hell 998244353
    #define inf 1e18
    #define pb push_back
    #define pi 3.1415926536
    #define mp make_pair
    #define ub upper_bound
    #define lb lower_bound
    #define all(a) a.begin(),a.end()
    #define ll long long
    #define vec vector <int>
    #define pii pair<int,int>
    #define endl "\n"
    #define gcd __gcd
    using namespace std;
    int power(int x, unsigned int y, unsigned int m) 
    { 
        if (y == 0) 
            return 1; 
        int p = power(x, y/2, m) % m; 
        p = (p * p) % m; 
  
        return (y%2 == 0)? p : (x * p) % m; 
    } 
    int modInverse(int a, int m) 
    {   
        return power(a, m-2, m);
    }
    int nCrModPFermat(int n, int r, int p) 
    { 
           if (r==0) 
              return 1; 
  
        int fac[n+1]; 
        fac[0] = 1; 
        for (int i=1 ; i<=n; i++) 
            fac[i] = fac[i-1]*i%p; 
  
        return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
    } 
    signed main()
    {
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
        ll t=1;
        // cin >> t;
        /*SAARE INPUTS LENA*/
        /*VARIABLES KI RANGE DEKHLENA*/
        /*EXPONENT RANGE OF OUTPUT KA DHYAN RAKHNA*/
        while(t-->0)
        {
            ll n=0;
            cin>>n;
            ll ans;
            ll x=10,y=9,m=M;
            // cout<<power(x,n,m)<<endl<<power(9,n,M)<<endl<<power(8,n,M)<<endl;
            ans=power(x,n,m)-2*power(9,n,M)+power(8,n,M);
            // ans=0;
            if(ans<0)
                ans=(M+ans)%M;
            if(ans<0)
                ans=(M+ans)%M;
            if(ans<0)
                ans=(M+ans)%M;
            cout<<ans;

        }
        return 0;
    }

Measured memory_bytes: 3648
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    usize n;
    std::cin >> n;
    vec<i64> a(n), b(n);
    for (usize i=0; i<n; i++) {
        i64 x, y;
        std::cin >> x >> y;

        i64 r = x % y;
        a.at(i) = r ? y - r : 0;
        b.at(i) = y;
    }

    for (usize i=n-2; i!=-1; i--) {
        if (a.at(i) < a.at(i+1)) {
            a.at(i) += (a.at(i+1) - a.at(i) + b.at(i) - 1) / b.at(i) * b.at(i);
        }
    }
    std::cout << a.front() << '\n';
}


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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            string n = Console.ReadLine();
            int N = int.Parse(n);

            var dict = new Dictionary<string, int>();
            var list = new List<string>();

            for (int i = 0; i < N; i++)
            {
                string S = Console.ReadLine();
                if (dict.ContainsKey(S) == false)
                {
                    dict.Add(S, i);
                    //dict.Sort();
                }
                //if(list.BinarySearch(S) < 0)
                //{
                //    list.Add(S);
                //    list.Sort();
                //}
            }

            Console.WriteLine(dict.Count);

        }
    }
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


signed main(){
    int N, L[10];
    cin >> N;
    REP(i, N) cin >> L[i];
    sort(L, L + N);
    int sum = 0;
    REP(i, N - 1) sum += L[i];
    if(sum > L[N - 1]) PRINT("Yes");
    else PRINT("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool chmax(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF 1000000007 //4000000000000000037
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  int N;
  cin>>N;

  rep(i,100000){
    if(i*i>N) {
      cout<< (i-1)*(i-1)<<"\n";
      return;
    }
  }
}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll, ll> P;

mat G(2e+5, vec(0));
vec kind(2e+5, -1), num(2,0), ans(2e+5, INF);
void dfs(int v, int k){
    kind[v] = k;
    ++num[k];
    k = 1 - k;
    for(int to : G[v]){
        if(kind[to] == -1){
            dfs(to, k);
        }
    }
}

int main() {
    cin>>N;
    rep(i,N - 1){
        cin>>A>>B;
        --A;
        --B;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    dfs(0, 0);
    if(num[0] >= N / 3 + 1 && num[1] >= N / 3 + 1){
        int a = 1, b = 2, c = 3;
        rep(i,N){
            if(kind[i] == 0){
                ans[i] = a;
                a += 3;
            }else if(kind[i] == 1){
                ans[i] = b;
                b += 3;
            }
        }
        rep(i,N){
            if(ans[i] > N){
                ans[i] = c;
                c += 3;
            }
        }
    }else{
        int few = (num[0] <= N / 3 ? 0 : 1), c = 3;
        rep(i,N){
            if(kind[i] == few){
                ans[i] = c;
                c += 3;
            }
        }
        rep(i,N){
            if(c > N) break;
            if(ans[i] > N){
                ans[i] = c;
                c += 3;
            }
        }
        int k = 1;
        rep(i,N){
            if(ans[i] > N){
                ans[i] = k;
                k += (k%3 == 1 ? 1 : 2);
            }
        }
    }
    rep(i,N){
        cout<<ans[i];
        i == N - 1 ? cout<<endl : cout<<' ';
    }
}

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

int main(){
    int n;
    cin >> n;
    if(n<105)cout << 0 << endl;
    else if(n<135) cout << 1 << endl;
    else if(n<165) cout << 2 << endl;
    else if(n<189) cout << 3 << endl;
    else if(n<195) cout << 4 << endl;
    else cout << 5 << endl;
    return 0;
}

Measured memory_bytes: 256
# ARC073D - Simple Knapsack (ABC060D)
from itertools import accumulate


def main():
    N, W, *A = map(int, open(0).read().split())
    V, x = [[] for _ in range(4)], A[0]  # x: w1 (W1 ≤ wi ≤ w1 + 3)
    for i in range(0, 2 * N, 2):
        w, v = A[i : i + 2]
        V[w - x] += [v]
    for i in range(4):
        V[i] = tuple(accumulate([0] + sorted(V[i], reverse=1)))
    L = [len(v) for v in V]
    ans = 0
    for i in range(L[0]):
        for j in range(L[1]):
            for k in range(L[2]):
                for l in range(L[3]):
                    w = i * x + j * (x + 1) + k * (x + 2) + l * (x + 3)
                    if w > W:
                        break
                    v = V[0][i] + V[1][j] + V[2][k] + V[3][l]
                    ans = max(ans, v)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
a=[]
w=""
while(w!="0 0"):
    w=input()
    a.append(w)
a.pop()
for st in a:
    s=st.split()
    n=int(s[0])
    x=int(s[1])
    count=0
    for a in range(1,x//3+1):
        for b in range(a+1,(x-a)//2+1):
            if (x-a-b)<=n and b<(x-a-b):
                count+=1
    print("{0}".format(count))

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

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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1e9+7;

int main() {
	int n,m;
	cin >> n >> m;
	int x[m];
	int dif[m-1];
	for (int i = 0;i < m;i++) {
		cin >> x[i];
	}
	sort(x,x+m);
	for (int i = 0;i < m - 1;i++) {
		dif[i] = x[i+1] - x[i];
	}
	sort(dif,dif+m-1);
	ll ans = 0;
	for (int i = 0;i < m-n;i++) {
		ans += dif[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024