akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main(void) {
    
    int n;
    cin>>n;
    vll v(5,0);
    rep(i,n){
        string s;
        cin>>s;
        if(s[0]=='M')v[0]++;
        else if(s[0]=='A')v[1]++;
        else if(s[0]=='R')v[2]++;
        else if(s[0]=='C')v[3]++;
        else if(s[0]=='H')v[4]++;
    }
    ll ans=0;
    for(int i=0;i<5;i++){
        for(int j=i+1;j<5;j++){
            for(int k=j+1;k<5;k++){
                ans+=v[i]*v[j]*v[k];
            }
        }
    }
    fin(ans);
        
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mn=1e2+10;
int x[mn],y[mn],n,p,q;
bool vis[mn];
void dfs(int a){
    vis[a]=1;
    for(int i=0;i<n;i++){
        if(!vis[i]&&((x[i]==x[a]+p&&y[i]==y[a]+q)||(x[i]==x[a]-p&&y[i]==y[a]-q)))dfs(i);
    }
}
int ans=0x3f3f3f3f;
void tst(){
    memset(vis,0,sizeof(vis));
    int cnt=0;
    for(int i=0;i<n;i++)if(!vis[i])dfs(i),cnt++;
    ans=min(ans,cnt);
}
int main()
{
    int i,j;
    scanf("%d",&n);
    ans=n;
    for(i=0;i<n;i++)scanf("%d%d",x+i,y+i);
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            p=x[j]-x[i];
            q=y[j]-y[i];
            tst();
        }
    }
    printf("%d",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false); //cin.tie(NULL); cout.tie(NULL)
#define mp make_pair
#define pb push_back
#define fs first
#define sc second

using namespace std;
typedef long long ll;
typedef long double ld;

int n, k;
	
void solve(){
	cin >> n;
	k = n==3 || n==5 || n==7;
	cout << (k?"YES":"NO");
}	

int main(){ FIO;
	solve();
return 0;}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }

        int res = 0;
        for(int l=0; l<=n; l++) {
            for(int r=0; r<=n; r++) {
                if(l+r > k) break;
                if(l+r > n) break;
                int[] b = new int[l+r];
                System.arraycopy(a, 0, b, 0, l);
                System.arraycopy(a, n-r, b, l, r);
                Arrays.sort(b);
                for(int i=0; i<k-(l+r) && i<l+r; i++) {
                    if(b[i] < 0) b[i] = 0;
                }
                int ss = 0;
                for(int i=0; i<l+r; i++) {
                    ss+=b[i];
                }
                res = Math.max(res, ss);

            }
        }


        System.out.println(res);


    }

}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double db;
#define go(u) for(int i = head[u], v = e[i].to; i; i=e[i].lst, v=e[i].to)
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define pb push_back
#define re(x) memset(x, 0, sizeof x)
inline int gi() {
    int x = 0,f = 1;
    char ch = getchar();
    while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getchar();}
    while(isdigit(ch)) { x = (x << 3) + (x << 1) + ch - 48; ch = getchar();}
    return x * f;
}
template <typename T> inline bool Max(T &a, T b){return a < b ? a = b, 1 : 0;}
template <typename T> inline bool Min(T &a, T b){return a > b ? a = b, 1 : 0;}
const int N = 1e5 + 7;
int n, edc;
int head[N], f[N];
struct edge { int lst, to;}e[N << 1];
void Add(int a, int b) { e[++edc] = (edge) { head[a], b}, head[a] = edc;}
int val[N];
void dfs(int u) {
	go(u) {
		dfs(v);
	}
	int tp = 0;
	go(u) val[++tp] = f[v] + 1;
	sort(val + 1, val + 1 + tp);
	for(int i = 1; i <= tp; ++i) Max(f[u], val[i] + tp - i);
}
int main() {
#ifdef fwat
#endif
	n = gi();
	rep(i, 2, n) Add(gi(), i);
	dfs(1);
	printf("%d\n", f[1]);
	return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <set>
#include <vector>
#include <array>
using namespace std;

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

	vector<string> ans;
	for(int i = 0; i < n; i++) {
		string t;
		cin >> t;
		ans.push_back(t);
	}
	
	set<string> s;
	for(string x: ans) {
		s.insert(x);
	}
	cout << s.size() << endl;
}


Measured memory_bytes: 25028
# N T
# c1 t1
N, T = map(int, input().split())
c_min = 1001
for _ in range(N):
    c, t = map(int, input().split())
    if c < c_min and t <= T:
        c_min = c
if c_min == 1001:
    print('TLE')
else:
    print(c_min)

Measured memory_bytes: 2940
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;



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

    vvi dp(n, vi(100));
    vi check(10);
    vi ggg(1000);
    rep(i, n) {
        if(i) dp[i] = dp[i-1];
        rep(j, 100) {
            if(dp[i][j]) {
                ggg[j + (s[i]-'0')*100]++;
            }
        }
        rep(j, 10) {
            if(check[j]) {
                dp[i][j + (s[i]-'0') * 10]++;
            }
        }

        check[s[i]-'0']++;

    }

    int ans = 0;
    rep(i, 1000) {
        if(ggg[i]) {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 13184
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#pragma GCC optimize(2)
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int a,b,c;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	in(a);in(b);in(c);
	a=(a-1)/b+1;
	printf("%d\n",a*c);
	return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <string>

int main(void) {
	int N;
	std::string S;
	std::cin >> N;
	std::cin >> S;
	char color = ' ';
	int slime_num = 0;
	for (int i = 0; i < N; i++) {
		if (color != S[i]) {
			color = S[i];
			slime_num++;
		}
	}
	std::cout << slime_num << std::endl;
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w,k;
    cin>>h>>w>>k;
    string s[10];
    for(int i=0;i<h;++i)cin>>s[i];
    int mx=(1<<h)-1;
    int mx2=(1<<w)-1;
    int ans=0;
    int a[10],b[10];
    for(int i=0;i<=mx;++i){
        int tmp=i;
        int cnt=0;
        memset(a,0,sizeof(a));
        while(tmp){
            a[cnt++]=tmp%2;
            tmp/=2;
        }
        for(int j=0;j<=mx2;++j){
            memset(b,0,sizeof(b));
            int tmp2=j;
            int cnt2=0;
            while(tmp2){
                b[cnt2++]=tmp2%2;
                tmp2/=2;
            }
            int num=0;
            for(int k=0;k<h;++k){
                if(a[k])continue;
                for(int l=0;l<w;++l){
                    if(b[l])continue;
                    if(s[k][l]=='#')num++;
                }
            }
            if(num==k)ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include<iostream>
using namespace std;
#define MAX 1100
int n,m;
char t[MAX][MAX];
int u[MAX];
void init(){
  for(int i=0;i<MAX;i++){
    for(int j=0;j<MAX;j++){
      t[i][j]='.';
    }
  }
  m=0;
}

int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    init();
    for(int i=0;i<n;i++){
      string str;cin>>str;
      int len=str.size();
      u[i]=len;
      m=max(m,len);
      for(int j=0;j<len;j++){
	if(j+1<len&&str[j]=='.'&&str[j+1]!='.')t[i][j]='+';
	else if(str[j]=='.')t[i][j]=' ';
	else t[i][j]=str[j];
      }
    }
    for(int j=0;j<m;j++){
      int last=-1;
      for(int i=0;i<n;i++){
	if(t[i][j]=='+'){
	  if(last!=-1)
	    for(int k=last+1;k<i;k++)t[k][j]='|';
	  last=i;
	}else if(t[i][j]!=' '){
	  last=-1;
	}
      }
    }

    for(int i=0;i<n;i++){
      for(int j=0;j<u[i];j++){
	cout<<t[i][j];
      }
      cout<<endl;
    }
  }
  return 0;
}

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

const int N = 300030;

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

  int h,w,m;
  cin >> h >> w >> m;

  vector<int> row(m), col(m);
  map<P, int> mp;
  for (int i = 0; i < m; i++) {
    cin >> row[i] >> col[i];
    mp[{row[i], col[i]}] = 1;
  }


  vector<int> row_cnt(N), col_cnt(N);

  int row_max = 0, col_max = 0;
  int row_v = 0, col_v = 0;
  for(int i = 0; i < m; i++) {
    row_cnt[row[i]]++;
    col_cnt[col[i]]++;
    if(row_cnt[row[i]] > row_max) {
      row_max = row_cnt[row[i]];
      row_v = row[i];
    }
    if(col_cnt[col[i]] > col_max) {
      col_max = col_cnt[col[i]];
      col_v = col[i];
    }
  }

  int ans = 0;
  // row_v固定
  for (int i = 0; i < N; i++) {
    int tmp = row_max + col_cnt[i];
    if(mp[{row_v, i}]) tmp--;
    ans = max(ans, tmp);
  }
  // col_v固定
  for (int i = 0; i < N; i++) {
    int tmp = col_max + row_cnt[i];
    if(mp[{i, col_v}]) tmp--;
    ans = max(ans, tmp);
  }

  cout << ans << '\n';




}



Measured memory_bytes: 64164
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
char memarr[96000000];
template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
  static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
  (*arr)=(T*)(*mem);
  (*mem)=((*arr)+x);
}
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = my_getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline int rd_int(void){
  int x;
  rd(x);
  return x;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    my_putchar_unlocked(c[i]);
  }
}
int N;
int T;
int F;
char *S;
char C;
int main(){
  int Lj4PdHRW;
  wmem = memarr;
  int r = 0;
  walloc1d(&S,1000000);
  S = S + 400000;
  N = rd(S);
  int KL2GvlyY = rd_int();
  for(Lj4PdHRW=(0);Lj4PdHRW<(KL2GvlyY);Lj4PdHRW++){
    rd(T);
    if(T == 1){
      r ^= 1;
    }
    else{
      rd(F);F += (-1);
      rd(C);
      if(F==r){
        S = S - 1;
        S[0] = C;
      }
      else{
        S[N] = C;
      }
      N++;
    }
  }
  if(r){
    reverse(S, S+N);
  }
  S[N] = '\0';
  wt_L(S);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200303-1 [beta]

// --- original code ---
// int N, T, F;
// char *S, C;
// {
//   int r = 0;
// 
//   walloc1d(&S,1d6);
//   S = S + 4d5;
// 
//   rd(S@N);
//   REP(rd_int()){
//     rd(T);
//     if(T == 1){
//       r ^= 1;
//     } else {
//       rd(F--, C);
//       if(F==r){
//         S = S - 1;
//         S[0] = C;
//       } else {
//         S[N] = C;
//       }
//       N++;
//     }
//   }
//   if(r) reverse(S, S+N);
//   S[N] = '\0';
//   wt(S);
// }


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

int main(){
ll n;
ll k;
cin>>n>>k;
string s;
cin>>s;
s[k-1]=s[k-1]+' ';
cout<<s<<endl;
}










Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int H[251];
	int h,i;

	scanf("%d", &h);
	for (i = 1; i < h+1; i++) {
		scanf("%d", &H[i]);
	}
	for (i = 1; i < h+1; i++) {
		printf("node %d: key = %d, ",i,H[i]);
		if(i/2>0)printf("parent key = %d, ", H[i/2]);
		if (2 * i <= h)printf("left key = %d, ", H[2 * i]);

		if (2 * i + 1 <= h)printf("right key = %d, ", H[2 * i + 1]);
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  int N, M; std::cin >> N >> M;

  std::vector< std::pair<int,int> > L(M);
  for(int i=0; i<M; i++) std::cin >> L[i].first >> L[i].second;

  std::unordered_map<int, std::vector< std::pair<int,int> >> K;
  for(int i=0; i<M; i++) K[L[i].first].push_back( { i, L[i].second} );

  std::vector< std::string > ans(M);
  for(auto&& v : K ) {
    auto list = v.second;
    std::sort(list.begin(), list.end(), [] (std::pair<int,int> &l, std::pair<int,int> &r) { return l.second < r.second; });
    int i=1;
    for(auto&& l : list) {
      char buf[100];
      sprintf(buf, "%06d%06d", v.first, i);
      ans[l.first] = buf;
      i++;
    }
  }

  for(auto&& A : ans) std::cout << A << std::endl;

  return 0;
}

Measured memory_bytes: 16548
/*
If all letters in S are the same, print 1.
If |S| <= 3, burte force. 
Otherwise, count the number of strings T such that
--- |T| = |S|
--- sum(S) = sum(T) mod 3
--- There is at least one pair of adjacent same letters in T
*/
#include <bits/stdc++.h>

using namespace std;

const int MOD = 998244353;
const int MAXN = 200005;

string s;

int f[MAXN][3][3][2];

int n;

set<string> myset;
set<char> char_set;

void dfs(string x)
{
	for (int i = 0; i + 1 < n; i++)
	{
		if (x[i] != x[i + 1])
		{
			string y = x;
			for (char c = 'a'; c <= 'c'; c++)
				if (x[i] != c && x[i + 1] != c)
					y[i] = y[i + 1] = c;
			if (!myset.count(y))
			{
				myset.insert(y);
				dfs(y);
			}
		}
	}
}

void brute()
{
	myset.insert(s);
	dfs(s);
	cout << myset.size() << endl;
	exit(0);
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> s, n = s.size();
	if (n <= 3)
		brute();
	else
	{
		f[0][0][0][0] = 1;
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < 3; j++)
			{
				for (int k = 0; k < 3; k++)
				{
					for (int l = 0; l < 2; l++)
					{
						if (!f[i][j][k][l])
							continue;
						int cur = f[i][j][k][l];	
						for (int w = 0; w < 3; w++)
							(f[i + 1][w][(k + w) % 3][((i > 0 && (w == j)) ? 1 : 0) | l] += cur) %= MOD;
					}
				}
			}
		}
		int x = 0;
		for (auto c : s)
			(x += c - 'a') %= 3, char_set.insert(c);
		if (char_set.size() == 1)
		{
			cout << 1 << endl;
			exit(0);	
		}
		int res = 0;
		for (int j = 0; j < 3; j++)
			(res += f[n][j][x][1]) %= MOD;
		bool ch = 1;
		for (int i = 0; i + 1 < n; i++)
			ch &= (s[i] != s[i + 1]);
		if (ch)
			(res += 1) %= MOD;
		cout << res << endl;
	}
	return 0;	
}


Measured memory_bytes: 14612
#include<iostream>
using namespace std;
string s[3];
main()
{
	while(cin>>s[0],s[0]!="0")
	{
		cin>>s[1]>>s[2];
		char ans='-';
		for(int i=0;i<3;i++)
		{
			if(s[i][0]=='+')continue;
			if(s[i][0]==s[i][1]&&s[i][0]==s[i][2])
			{
				ans=s[i][0];break;
			}
		}
		for(int i=0;i<3;i++)
		{
			if(s[0][i]=='+')continue;
			if(s[0][i]==s[1][i]&&s[0][i]==s[2][i])
			{
				ans=s[0][i];break;
			}
		}
		if(s[0][0]!='+'&&s[0][0]==s[1][1]&&s[0][0]==s[2][2])ans=s[0][0];
		if(s[0][2]!='+'&&s[0][2]==s[1][1]&&s[1][1]==s[2][0])ans=s[1][1];
		if(ans=='-')cout<<"NA"<<endl;
		else cout<<ans<<endl;
	}
}



Measured memory_bytes: 3140
package main;

import (
	"fmt"
	"strconv"
)

func main() {
	var S string
	fmt.Scan(&S)
	sm := 0
	N := uint(len(S))
	for i := uint(0); i < 1 << N; i++ {
		l := ""
		for j := uint(0); 1 << j <= i; j ++ {

			if ((1 << j) & i) > 0 {
				l += S[j:j + 1]
			} else {
				a, _ := strconv.Atoi(l)
				sm += a
				l = ""
			}
		}
		a, _ := strconv.Atoi(l)
		sm += a
	}
	fmt.Println(sm)
}

Measured memory_bytes: 640
N = int(input())
H = list(map(int, input().split(' ')))
res = 'Yes'
for i in range(N - 1, 0, -1):
  if H[i] + 1 == H[i - 1]:
    H[i - 1] -= 1
  elif H[i] < H[i - 1]:
    res = 'No' 
print(res)

Measured memory_bytes: 14396
from collections import Counter

G=[[] for _ in range(4)]

for i in range(3):
  a,b=map(int,input().split())
  G[a-1].append(b-1)
  G[b-1].append(a-1)
  
deg = [len(G[i]) for i in range(4)]

c = Counter(deg)

cnt=0
for k in c.keys():
  if k%2: cnt += c[k]
    
if cnt in (0,2):
  print('YES')
else:
  print('NO')

Measured memory_bytes: 9456
#K = int(input())
#AB = list(map(int, input().split()))
#s = input().split()

S = input()
T = input()

sl = len(S)
tl = len(T)

if (len(S) + 1 == len(T) and S == T[0:sl]):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 61584
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair < int, int >;

int main() {
	ios_base::sync_with_stdio (false);
	cin.tie (0); cout.tie (0);
	int n; string s;
	cin >> n >> s;
	assert (n == (int) s.length());
	for (char & c : s) {
		if (c == 'R') c = '0';
		else if (c == 'G') c = '1';
		else if (c == 'B') c = '2';
	}
	//cerr << s << endl;
	vector < vector < int > > count (n + 1, vector < int > (3));
	for (int i = 0; i < n; i++) {
		count[i + 1] = count[i];
		count[i + 1][s[i] - '0']++;
	}
	
	vector < int > cnt (3);
	ll sum = 0;
	for (int i = n - 1; i >= 0; i--) {
		int sj = s[i] - '0';
		for (int si = 0; si < 3; si++) {
			for (int sk = 0; sk < 3; sk++) {
				if (si != sj && sj != sk && sk != si) {
					sum += (ll) count[i][si] * cnt[sk];
				}
			}
		}
		int left = i - 1, right = i + 1;
		while (left >= 0 && right < n) {
			if (s[i] != s[left] && s[left] != s[right] && s[right] != s[i]) {
				sum--;
				
			}
			left--, right++;
		}
		cnt[s[i] - '0']++;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3844
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
    int n, x, t;
    int count = 0;
    cin >> n >> x >> t;
    
    while(1){
        
        if(n > 0){
        n = n - x;
        count++;
        }

        else break;
    }

    cout << count * t << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll dp[110][100007];
int main(){
  ll n, W;
  cin >> n >> W;
  vi w(n+1,0);
  vi v(n+1,0);
  rep(i,n){
    cin >> w[i+1] >> v[i+1];
  }
  rep(i, W + 1){
    dp[0][i] = 0;
  }
  for (ll i = 1; i <= n;i++){
    dp[i][0] = 0;
    for (ll j = 1; j <= W;j++){
      if(j<w[i]){
        dp[i][j] = dp[i - 1][j];
      }
      else{
        dp[i][j] = max(dp[i - 1][j - w[i]] + v[i], dp[i-1][j]);
      }
    }
  }
  print(dp[n][W]);
}

Measured memory_bytes: 80128
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    string s; cin >> s;
    if (n % 2 == 1) cout << "No\n";
    else {
        bool is_c = true;
        REP(i, n / 2) {
            if (s[i] != s[n / 2 + i]) is_c = false;
        }
        if (is_c) cout << "Yes\n";
        else cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O2")
#endif
#include <iostream>
#include <vector>
#include<algorithm>
using namespace std;

int main(){
    int a; cin >> a;
    string s; cin >> s;

    if(a>=3200)
    {
        cout << s;
    }
    else
    {
        cout << "red";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
#define maxv 100001
#define che 1LL<<32
int main()
{
    ll n;
    cin>>n;
    ll a[n];
    ll i;
    ll sum=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    ll m;
    cin>>m;
    for(i=0;i<m;i++)
    {
        ll sum1=sum;
        ll x,y;
        cin>>x>>y;
        sum1=sum1-a[x-1]+y;
        cout<<sum1<<endl;
    }
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

typedef vector<ll> Edges;
typedef vector<Edges> Graph;

const ll V_MAX = 1010101;
vector<ll> ts(V_MAX, -1);
int topologicalSort(Graph &G){
	ll V = G.size();
	vector<ll> indeg(V, 0);
	queue<ll> qu;

	REP(i, V){
		REP(j, G[i].size()){
			indeg[G[i][j]]++;
		}
	}
	REP(i, V){
		if(!indeg[i]) qu.push(i);
	}

	ll depth = 0;
	while(!qu.empty()){
		ll s = qu.size();
		REP(i, s){
			ll now = qu.front();qu.pop();
			ts[now] = depth;
			REP(j, G[now].size()){
				ll next = G[now][j];
				indeg[next]--;
				if(!indeg[next]) qu.push(next);
			}
		}
		depth++;
	}

	REP(i, V){
		if(ts[i] == -1) return -1;
	}
	return depth;
}

struct battle{
	ll x, y;
	bool operator<(const battle &right)const{
		return (x != right.x ? x < right.x : y < right.y);
	}
};

vector<battle> id2b(1010101);
map<battle, ll> b2id;
ll V;

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

    ll N;
    cin >> N;

    ll V = N * N;

    Graph G(V);

    REP(i, N){
    	vector<ll> tmp(N-1);
    	REP(j, N-1) cin >> tmp[j], tmp[j]--;
    	REP(j, N-2){
    		ll x1, y1, x2, y2;
    		x1 = i;
    		y1 = tmp[j];
    		x2 = i;
    		y2 = tmp[j+1];
    		if(x1>y1) swap(x1, y1);
    		if(x2>y2) swap(x2, y2);
    		G[N*x1+y1].push_back(N*x2+y2);
    	}
    }

    int res = topologicalSort(G);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 74880
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define vP vectorProduct

double vectorProduct(double ax,double ay,double bx,double by){return ax*by-ay*bx;}

int main(){
  int f = 0;
  double x1,y1,x2,y2,x3,y3,xp,yp;

  while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp) != EOF){
    f = 0;
    if(vP(x2-x1, y2-y1, xp-x1, yp-y1) > 0 &&
       vP(x3-x2, y3-y2, xp-x2, yp-y2) > 0 &&
       vP(x1-x3, y1-y3, xp-x3, yp-y3) > 0)
      f = 1;
      if(vP(x2-x1, y2-y1, xp-x1, yp-y1) < 0 &&
         vP(x3-x2, y3-y2, xp-x2, yp-y2) < 0 &&
         vP(x1-x3, y1-y3, xp-x3, yp-y3) < 0)
      f = 1;

    if(f) printf("YES\n");
    else printf("NO\n");
  }

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1e18
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ii>
ll modexp(ll a,ll b,ll m){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a) % m;  a = (a * a) % m;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 1e5 + 7;
ll i,n,a,b,c;
vi adj[N];
ll col[N];
void dfs(ll v,ll par,ll s)
{
    col[v] = s % 2;
    for(auto it: adj[v]) if(it.f != par)
        dfs(it.f, v, s + it.se);
}
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n;
    rep(i,1,n){
        cin>>a>>b>>c;
        adj[a].pb({b, c}); adj[b].pb({a, c});
    }
    dfs(1,-1,0);
    rep(i,1,n + 1) cout<<col[i]<<endl;
    return 0;
}

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

public class Main {
    public static String S;
    public static int ans(int start,long left){
        if(S.charAt(start)-'0'!=1){
            return S.charAt(start)-'0';
        }
        if (left == 0) {
            return S.charAt(start) - '0';
        }
        return ans(start+1,left-1);
    }
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        S = br.readLine();
        long K = Long.parseLong(br.readLine());
        System.out.println(ans(0,K-1));
    }
}


Measured memory_bytes: 21076
s=int(input())
n=s
p=10**9+7
fac=[0]*(n+1)
inv=[0]*(n+1)
finv=[0]*(n+1)

fac[0]=fac[1]=1
inv[1]=1
finv[0]=finv[1]=1
for i in range(2,n+1):
  fac[i]=fac[i-1]*i%p
  inv[i]=(-(p//i)*inv[p%i])%p
  finv[i]=finv[i-1]*inv[i]%p

#nCr
def comb(n,r,p):
  return fac[n]*finv[n-r]*finv[r]%p


ans=0
k=1
while s-3*k>=0:
  ans+=comb(s-2*k-1,k-1,p)
  k=k+1
print(ans%p)

  

Measured memory_bytes: 65068
while 1:
    n, m = map(int, input().split())
    if n == 0:
        break

    veg = list(map(int, input().split()))
    veg.sort(reverse=True)

    cnt = 0
    ans = 0
    while veg != []:
        cnt += 1
        tmp = veg.pop(0)
        if cnt % m == 0:
            pass
        else:
            ans += tmp

    print(ans)



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

#define MAX 1000

int cnt[MAX][MAX], N, D;
int s2[MAX + 1][MAX + 1], s3[MAX + 1][MAX + 1];

int sum2( int x1, int y1, int x2, int y2 )
{
	if( x1 > x2 || y1 > y2 ) {
		return 0;
	}
	x1++;
	y1++;
	x2++;
	y2++;
	return s2[x2][y2] - s2[x2][y1 - 1] - s2[x1 - 1][y2] + s2[x1 - 1][y1 - 1];
}
int sum3( int x1, int y1, int x2, int y2 )
{
	if( x1 > x2 || y1 > y2 ) {
		return 0;
	}
	x1++;
	y1++;
	x2++;
	y2++;
	return s3[x2][y2] - s3[x2][y1 - 1] - s3[x1 - 1][y2] + s3[x1 - 1][y1 - 1];
}
bool check2( int x, int y, int b )
{
	int d1 = sum2( max( 0, x + b + 1 - D ), max( 0, y + b + 1 - D ), x - 1, y - 1 );
	int d2 = sum2( x + b + 1, y + b + 1, D - 1, D - 1 );
	int d3 = sum2( max( 0, x + b + 1 - D ), y + b + 1, x - 1, D - 1 );
	int d4 = sum2( x + b + 1, max( 0, y + b + 1 - D ), D - 1, y - 1 );
	return d1 == 0 && d2 == 0 && d3 == 0 && d4 == 0;
}
bool check3( int x, int y, int b )
{
	int d1 = sum3( x + b + 1, 0, D - 1, D - 1 );
	int d2 = sum3( 0, y + b + 1, D - 1, D - 1 );
	int d3 = sum3( max( 0, x + b + 1 - D ), 0, x - 1, D - 1 );
	int d4 = sum3( 0, max( 0, y + b + 1 - D ), D - 1, y - 1 );
	return d1 == 0 && d2 == 0 && d3 == 0 && d4 == 0;
}

int main() {
	cin >> N >> D;
	for(int i = 0; i < N ; i++ ) {
		int x, y;
		cin >> x >> y;
		cnt[x % D][y % D]++;
	}
	int a = 0;
	for( int i = 0 ; i < D ; i++ ) {
		for( int j = 0 ; j < D ; j++ ) {
			if( cnt[i][j] ) {
				int t = ceil( sqrt( cnt[i][j] ) );
				a = max( t - 1, a );
		    }
		}
	}
	for(int i = 0 ; i < D ; i++ ) {
		for(int j = 0 ; j < D ; j++ ) {
			if( a * a < cnt[i][j] && cnt[i][j] <= a * (a + 1) ) {
				s2[i + 1][j + 1]++;
			}
			else if( cnt[i][j] > a * (a + 1) ) {
				s3[i + 1][j + 1]++;
			}
		}
	}
	for( int i = 1; i <= D; i++ ) {
		for( int j = 1; j <= D; j++ ) {
			s2[i][j] = s2[i][j] + s2[i - 1][j] + s2[i][j - 1] - s2[i - 1][j - 1];
			s3[i][j] = s3[i][j] + s3[i - 1][j] + s3[i][j - 1] - s3[i - 1][j - 1];
		}
	}
	int b;
	for( b = 0; b < D; b++ ) {
		if( check2( 0, 0, b ) && check3( 0, 0, b ) ) {
			break;
		}
	}
	for(int i = 0; i < D; i++ ) {
		for(int j = 0; j < D; j++ ) {
			if( i == 0 && j == 0 ) {
				continue;
			}
			while( b ) {
				if( check2( i, j, b - 1 ) && check3( i, j, b - 1 ) ) {
					b--;
				}
				else {
					break;
				}
			}
		}
	}

    cout << a * D + b << endl;

	return 0;
}


Measured memory_bytes: 12032
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{


    class Program
    {
        static int s = 0;

        static void Partition(int[] data_ary)
        {
            int length = data_ary.Length;

            int i = -1;
            int j = 0;
            int base_val = data_ary[length - 1];

            for(j = 0; j < length; j++)
            {
                if(data_ary[j] <= base_val)
                {
                    int tmp = data_ary[i + 1];
                    data_ary[i + 1] = data_ary[j];
                    data_ary[j] = tmp;
                    i++;
                }
            }
            s = i;
        }

        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] data_ary = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            Partition(data_ary);

            for(int i = 0; i < data_ary.Length; i++)
            {
                if(i == s)
                {
                    Console.Write($" [{data_ary[i]}]");
                }
                else if(i == 0)
                {
                    Console.Write($"{data_ary[i]}");
                }
                else
                {
                    Console.Write($" {data_ary[i]}");
                }
                
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 29716
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		int[] c = new int[30];
		for(int i = 0; i < s.length(); i++) {
			c[s.charAt(i) - 'a']++;
		}
		for(int i = 0; i < 30; i++) {
			if(c[i] % 2 == 1) {
				System.out.println("No");
				sc.close();
				return;
			}
		}
		System.out.println("Yes");
		sc.close();
	}

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

Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define watch(x) cout<<(#x)<<" is "<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
using graph=vector<vector<int>>;
using wgraph=vector<vector<pll>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ex[8]={1,1,0,-1,-1,-1,0,1};
const int ey[8]={0,1,1,1,0,-1,-1,-1};
const ld E=1e-10;

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    if(ret>=p)ret%=p;
    b=b>>1;
  }
  return ret;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  int i;
  ll ret=1;
  for(i=0;i<n;i++){
    ret=ret*(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll binom(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modRev(fact))%p;
}

void pushHeap(vector<ll>& h,int n){
  int i=h.size();
  h.push_back(n);
  while(i!=0 && h[(i-1)/2]<h[i]){
    swap(h[i],h[(i-1)/2]);
    i=(i-1)/2;
  }
  h[i]=n;
}

ll popHeap(vector<ll>& h){
  int n=h.size()-1;
  if(n==-1)return 0;
  ll i,ret=h[0];
  swap(h[0],h[n]);
  h.pop_back();
  for(i=0;i<n;){
    int j=2*i+1;
    if(j>=n)break;
    if(j!=n-1 && h[j]<h[j+1])j++;
    if(h[i]<h[j]){
      swap(h[i],h[j]);
    }
    i=j;
  }
  return ret;
}

int bis(vector<int> v,int key){
  int left=-1,right=v.size();
  while(abs1(right-left)>1){
    int mid=left+(right-left)/2;
    if(v[mid]<=key)left=mid;
    else right=mid;
  }
  return left;
}

int main(){
  int i,j,k,cnt=0;
  string s,t;
  cin>>s>>t;
  cout<<t+s<<endl;
}


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

int main (void) {
    int n, ju;
    int score1=0, score2=0;
    char str1[101], str2[101];

    scanf ("%d", &n);

    for (int i=0; i<n; i++) {
        scanf ("%s %s", str1, str2);
        ju = strcmp (str1, str2);
        if (ju>0) score1+=3;
        else if (ju<0) score2+=3;
        else if (ju==0) {
            score1++;
            score2++;
        }
    }

    printf ("%d %d\n", score1, score2);

    return 0;
}


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

using namespace std;
typedef long long ll;
const int N = 1e6+50;
const int oo = 1e9;
int q[5];
void dfs(int idx,int s,bool t,vector<int> v){
	if(idx!=0){
		v.push_back(t);
	}
	if(idx == 3){
		if(s==7){
			for(int i=0;i<v.size();i++){
				cout << q[i];
				if(v[i]){
					cout << '+';
				}else{
					cout << '-';
				}
			}
			cout << q[3] << "=7" << endl;
			exit(0);
		}else{
			return;
		}
	}
	dfs(idx+1,s+q[idx+1],1,v);
	dfs(idx+1,s-q[idx+1],0,v);
}
vector<int> m;
int main(){
	string s;
	cin>>s;
	for(int i=0;i<4;i++){
		q[i] = s[i]-'0';
	}
	dfs(0,q[0],0,m);
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<map>
#include<math.h>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
const int maxn=2e5+7;
typedef long long ll;

ll dp[100];

int main (){
   int  n,x;
   cin>>n>>x;
   printf ("%d\n",n*n-x);


}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[][] ab = new int[n][2];
		for(int i = 0; i < n; i++){
			String str = sc.next();
			String str2[] = str.split(",");
			for(int j = 0; j < 2; j++){
				ab[i][j] = Integer.parseInt(str2[j])-1;
			}
		}
		int[] data = new int[w];
		for(int i = 0; i < w; i++){
			data[i] = i+1;
		}
		for(int i = 0; i < n; i++){
			int work = data[ab[i][0]];
			data[ab[i][0]] = data[ab[i][1]];
			data[ab[i][1]] = work;
		}
		for(int dd : data){
			System.out.println(dd);
		}
	}
}



Measured memory_bytes: 26224
#include<stdio.h>
int main(void)
{
	int s[100]={0};
	int i;
	
	for(i=0; i<3; i++)
	{
		scanf("%d",&s[i]);
	}
	
	s[3] = s[0];
	s[0] = s[2];
	s[2] = s[1];
	s[1] = s[3];
	
		for(i=0; i<3; i++)
	{
		printf("%d ",s[i]);
	}
	

	return 0;
}

Measured memory_bytes: 1724
#include<iostream>
#include<algorithm>
#include<vector>
#include <numeric>
using namespace std;
int main(int argc, char const *argv[]) {
    int N,X,tmp;
    long long ans=0;
    std::cin >> N>>X;
    int i=1;
    if(X==0){
        std::cout << 0 << '\n';
        return 0;
    }
    while(1){
        std::cin >> tmp;
        ans+=tmp;
        if(ans>X){
            std::cout << i << '\n';
            return 0;
        }
        i++;
        if(i==N+1)break;
    }
    std::cout << i << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll ans[1111][1111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll h,w,a,b;cin>>h>>w>>a>>b;
  if(h/2<b||w/2<a){
    cout<<-1<<endl;
    return 0;
  }
  for(int j=0;j<b;j++){
    for(int i=0;i<a;i++)
      ans[j][i]=1;
  }
  for(int j=b;j<h;j++){
    for(int i=a;i<w;i++){
      ans[j][i]=1;
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++)
      cout<<ans[i][j];
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 9856
using System;

public class Test
{
	public static void Main()
	{
		// your code goes here
		string[] line = Console.ReadLine().Split(' ');
		var n = int.Parse(line[0]); var k = int.Parse(line[1]);
		//余りがあるか？
		if(0<n%k)
		{
			Console.WriteLine(1);
		}//余りがない
		else Console.WriteLine(0);
	}
}

Measured memory_bytes: 13140
#include <stdio.h>
int main(){
  
  int player[51] = {0};
  int n,p,pool=0,i;
  for(;;){
  scanf("%d %d",&n,&p);

  if(n==0&&p==0){
    break;
  }
  pool=p;
  i=0; 
  for(;;){
    for(i=0;i<=n-1;i++){
      if(pool==0){
	pool=player[i];
	player[i]=0;
	continue;
      }
      if(pool==1&&player[i]==p-1){
	break;
      }

      if (pool!=0){
	pool=pool-1;
	player[i]+=1;
      }
    }
    if(pool==1&&player[i]==p-1){
      break;
    }
    i++;
  }
  printf("%d\n",i);
  pool=0;
  player[i]=0;
  }
  return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <queue>
#include <map>
using namespace std;

int N;
int main() {
	while (cin >> N) {
		long long sum = 0;
		for (int i = 0; i < N; ++i) {
			int a;
			cin >> a;
			sum += a;
		}
		if (sum % 2 == 0) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void)
{
  char S[3];
  int i;
  int o_cnt;
  
  scanf("%s",S);
  
 	for (i=0;i<3;i++)
    {if (S[i] == 'o')
      o_cnt++;
    } 
		
     if (o_cnt == 1)
        printf("800");
      else if (o_cnt == 2)
        printf("900");
      else if (o_cnt == 3)
        printf("1000");
  	else
      printf("700");
      return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int A, B, K; cin >> A >> B >> K;
  for (int i=A; i<=B; i++) if ( i-A<K || B-i<K ) cout << i << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
using namespace std;
const int nx=2e5+5;
const int inf=1e18+7;
const int mod=1e9+7;
vector<int>adj[nx];


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



Measured memory_bytes: 4992
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

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

typedef array<int,2> P;

int main(){
   ios::sync_with_stdio(false);
   cin.tie(nullptr);
   int n; cin>>n;
   vector<int> v(n),w(n);
   rep(i,0,n)cin>>v[i]>>w[i];
   vector<P> zen[1<<10];
   rep(i,0,1<<10){
      if(i>n)break;
      int x=i; vector<P> a;
      while(x){
         a.push_back({v[x-1],w[x-1]});
         x>>=1;
      }
      int p=a.size();
      rep(mask,0,1<<p){
         P add={};
         rep(i,0,p)if(mask>>i&1){
            add[0]+=a[i][1]; add[1]-=a[i][0];
         }
         zen[i].push_back(add);
      }
      sort(ALL(zen[i]));
      rep(j,0,zen[i].size()-1)chmin(zen[i][j+1][1],zen[i][j][1]);
   }
   int q; cin>>q;
   rep(_,0,q){
      int x,y; cin>>x>>y;
      vector<P> a;
      while(x>=(1<<10)){
         a.push_back({v[x-1],w[x-1]});
         x>>=1;
      }
      int m=a.size();
      vector<P> kou;
      rep(mask,0,1<<m){
         P add={};
         rep(i,0,m)if(mask>>i&1){
            add[0]+=a[i][1]; add[1]+=a[i][0];
         }
         kou.push_back(add);
      }
      int res=0;
      for(auto [w,v]:kou){
         auto it=lower_bound(ALL(zen[x]),P{y-w+1,-inf});
         if(it==zen[x].begin())continue;
         it--; chmax(res,v-(*it)[1]);
      }
      cout<<res<<endl;
   }
   return 0;
}

Measured memory_bytes: 10960
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
char str[1000000];
typedef pair<char,char>P;
int main(){
  int n,k;
  P sezi[100];
  while(1){
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n;i++){   
      cin>>sezi[i].first>>sezi[i].second;
    }  
    cin>>k;
    for(int i=0;i<k;i++){
      cin>>str[i];
    }
    int flg = 0;
    for(int i=0;i<k;i++){
      for(int j=0;n>j;j++){
	if(str[i]==sezi[j].first){
	  printf("%c",sezi[j].second);
	  flg++;
	  break;
	}
      }
      if(flg==0){
	cout<<str[i];
      }
      flg=0;
    }
    cout<<endl;
  } 
  return 0;
}

Measured memory_bytes: 1252