akhauriyash/Code-Regression huggingface dataset:
s = list(input())
answer=""
i =0
while i < len(s):
    if i+4<=len(s)-1 and s[i]=="d":
        if (s[i+1], s[i+2], s[i+3], s[i+4]) == ("r", "e", "a", "m"):
            if i+4 ==len(s)-1:
                answer="YES"
            i+=5
        else:
            answer="NO"
            break
    elif s[i]=="e":
        if i+5<=len(s)-1 and (s[i+1], s[i+2], s[i+3], s[i+4],s[i+5])==("r","a","s","e","r"):
            if i+5 ==len(s)-1:
                answer="YES"
            i+=6
        elif i+4<=len(s)-1 and (s[i+1], s[i+2], s[i+3], s[i+4])==("r","a","s","e"):
            if i+4 ==len(s)-1:
                answer="YES"
            i+=5
        elif i+1<=len(s)-1 and i>=5 and (s[i-5],s[i-4],s[i-3],s[i-2],s[i-1],s[i+1])==("d","r","e","a","m","r"):
            if i+1 ==len(s)-1:
                answer="YES"
            i+=2
        else:
            answer="NO"
            break
    else:
        answer="NO"
        break
print(answer)

Measured memory_bytes: 4212
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;

struct card{
    char suit;
    int num;
};

int BubbleSort(vector<card> &A){
    int N = A.size();
    int cnt = 0;
    for(int i = 0; i < N; ++i){
        for(int j = N - 1; j >= i + 1; --j){
            if(A[j].num < A[j - 1].num){
                card tmp = A[j];
                A[j] = A[j - 1];
                A[j - 1] = tmp;
                ++cnt;
            }
        }
    }
    return cnt;
}

int InsertionSort(vector<card> &A){
    int N = A.size();
    int cnt = 0;
    for(int i = 0; i < N; ++i){
        int minj = i;
        int flag = 0;
        for(int j = i; j < N; ++j){
            if(A[j].num < A[minj].num){
                minj = j;
                flag = 1;
            }
        }
        if(flag){
            card tmp = A[i];
            A[i] = A[minj];
            A[minj] = tmp;
            ++cnt;
        }
    }
    return cnt;
}

void read(vector<card> &A, int N){
    //char ch[3];
    for(int i = 0; i < N; ++i){
        cin >> A[i].suit >> A[i].num;
    }
}

void write(vector<card> A, int N){
    for(int i = 0; i < N; ++i){
        cout << A[i].suit << A[i].num;
        if(i != N - 1)
            cout << " ";
    }
    cout << endl;
}

int main(void){
    int N;
    cin >> N;
    vector<card> A1(N);
    read(A1, N);
    vector<card> A2 = A1;
    
    BubbleSort(A1);
    InsertionSort(A2);
    
    write(A1, N);
    cout << "Stable" << endl;
    write(A2, N);
    int flag = 1;
    for(int i = 0; i < N; ++i){
        if(A1[i].suit != A2[i].suit)
            flag = 0;
    }
    if(flag)
        cout << "Stable" << endl;
    else
        cout << "Not stable" << endl;
    return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
char s[105];
bool cal(int l,int r) {
    for(int i=l;i<=r;i++) {
        if(s[i]!=s[r+l-i]) return false;
    }
    return true;
}
int main() {
    //freopen("in.txt","r",stdin);
    scanf("%s",s+1);
    int n=strlen(s+1);
    bool f=true;
    if(!cal(1,n)) f=false;
    if(!cal(1,(n-1)/2)) f=false;
    if(!cal((n+3)/2,n)) f=false;
    printf("%s\n",f?"Yes":"No");
    return 0;
}

Measured memory_bytes: 256
n=int(input())
s=input()
dp=[(n+1)*[0]for _ in range(n+1)]
for i in range(1,n):
    for j in range(i+1,n+1):
        if s[i-1]==s[j-1]:
            dp[i][j]=dp[i-1][j-1]+1
        dp[i][j]=min(dp[i][j],i,j-i)
print(max(max(i)for i in dp))

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

int main(){
	int n;cin>>n;
  	map<string,int> mp;
  	for(int i=0;i<n;i++){
      string s;cin>>s;
      mp[s]++;
    }
  	cout<<"AC x "<<mp["AC"]<<endl;
  	cout<<"WA x "<<mp["WA"]<<endl;
  	cout<<"TLE x "<<mp["TLE"]<<endl;
  	cout<<"RE x "<<mp["RE"]<<endl;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int d[27];
int dp[27][50007];
int main() {
//    freopen("in3.txt", "r", stdin);
    int n, m;
    scanf("%d", &n);
    scanf("%d", &m);
    for(int i = 1; i <= m; i++) {
        scanf("%d", &d[i]);
    }
    sort(d+1, d+m+1);
    for(int i = 1; i <= n; i++) {
        dp[1][i] = i;
    }
    for(int i = 2; i <= m; i++) {
        int j;
        for(j = 1; j <= n; j++) {
            if(d[i] > j) {
                dp[i][j] = dp[i-1][j];
            } else if(d[i] == j) {
                dp[i][j] = 1;
            } else {
                dp[i][j] = min(1 + dp[i][j-d[i]], dp[i-1][j]);
            }
        }
    }
//    for(int i = 1; i <= m; i++) {
//        int j;
//        for(j = 1; j <= n; j++) {
//            printf("%d ", dp[i][j]);
//        }
//        printf("\n");
//    }



    printf("%d\n", dp[m][n]);
    return 0;
}



Measured memory_bytes: 7184
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    if (v.size() == 0) return os;
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    os << v[v.size() - 1];
    return os;
}

void solve() {
    int r, c, k;
    cin >> r >> c >> k;
    vector<vll> G(r, vll(c,0));
    REP(i,k) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        cin >> G[a][b];
    }
    vector<vector<vll>> dp(4, vector<vll>(r+1, vll(c+1, 0)));
    REP(i, r) {
        REP(j, c) {
            REP(k, 4) {
                /* dp[k][i][j+1] = max(dp[k][i][j+1], dp[k][i][j]); */
                /* dp[k][i+1][j] = max(dp[k][i+1][j], dp[k][i][j]); */
                /* dp[0][i+1][j+1] = max(dp[0][i+1][j+1], dp[k][i+1][j]); */
                
                dp[0][i+1][j+1] = max(dp[0][i+1][j+1], dp[k][i][j+1]);
                if (G[i][j] > 0) dp[1][i+1][j+1] = max(dp[1][i+1][j+1], dp[k][i][j+1]+G[i][j]);
                /* REP(k2, 4) { */
                /*     dp[k][i+1][j+1] = max(dp[k][i+1][j+1], dp[k2][i][j+1]); */
                /*     if (G[i][j] > 0 && k >= 1) dp[k][i+1][j+1] = max(dp[k][i+1][j+1], dp[k2][i][j+1]+G[i][j]); */
                /* } */
                dp[k][i+1][j+1] = max(dp[k][i+1][j+1], dp[k][i+1][j]);
                if (G[i][j] > 0 && k + 1 <= 3) dp[k+1][i+1][j+1] = max(dp[k+1][i+1][j+1], dp[k][i+1][j]+G[i][j]);
            }
        }
    }
    cout << max( dp[0][r][c], max(dp[1][r][c], max(dp[2][r][c], dp[3][r][c])) ) << endl;
}

int main() {
    char tmp;
    while (cin >> tmp) {
        cin.putback(tmp);
        solve();
    }
}



Measured memory_bytes: 425772
#include <stdio.h>
int main() {
	int n, d, x, a;
	long int ans = 0;
	scanf("%d%d%d", &n, &d, &x);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a);
		ans += (d - 1) / a + 1;
	}
	printf("%d\n", ans + x);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define st first
#define nd second

using ll = long long;
using namespace std;
using pii = pair<int,int>;
char s[150][150];
int dp[150][150];
const int INF = 1e9 + 7;
int main(){
	int h, w;
	scanf("%d %d",&h, &w);
	for(int i = 1;i <= h; i++){
		scanf("%s", s[i] + 1);
	}
	for(int i = 1; i <= h; i++) dp[i][0] = INF;
	for(int j = 1; j <= w; j++) dp[0][j] = INF;
	dp[0][1] = 0;
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			dp[i][j] = min(dp[i - 1][j] + (s[i-1][j] !='#' && s[i][j] == '#'), dp[i][j-1] + (s[i][j-1] != '#' && s[i][j] =='#'));
		}
		//("\n");
	}
	printf("%d",dp[h][w]);


}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll N, W, w[110], v[110], dp[103][100003], ans;
int main(void){
    // Your code here!
    cin >> N >> W;
    for (ll i = 0; i < N; i++) cin >> w[i] >> v[i];
    for (ll i = 0; i < N; i++)
    {
        for (ll j = 0; j <= W; j++)
        {
            dp[i + 1][j] = dp[i][j];
            if (j < w[i]) continue;
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
        }
    }
    for (ll i = 0; i <= W; i++) ans = max(ans, dp[N][i]);
    cout << ans << endl;
}


Measured memory_bytes: 79360
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <queue>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)

#define INF 1000000001
#define MOD 1000000007
#define INF64 1000000000000000001

#define F first
#define S second

#define Pii pair<SINT32,SINT32>
#define Pll pair<SINT64,SINT64>


using namespace std;

int main() {

	SINT64 N = 0;
	SINT64 ans = 0;
	cin >> N;

	vector<SINT64> DATA(N);

	cin >> ans;
	
	rep(i,1,N) {
		SINT64 buf;
		cin >> buf;

		ans = ans*(buf / __gcd(ans,buf));
	}

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

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());	//ソート後に使用

//	DATA.insert(DATA.begin() + X, 0);	//X番目の要素に0を挿入


//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));	//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();	//key以上を探す
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/
/* 文字列合成
	string N,M;
	cin >> N >> M;
	SINT64 ans = 0;
	ans = stoi(N+M);
*/

/*
//ワーシャルフロイド
vector<vector<SINT32>> dist(N,vector<SINT32>(N));
rep(i,0,N) {
	rep(j,0,N) {
		if (i != j) {
			dist[i][j] = INF;
		}
	}
}
rep(k,0,N) {
	rep(i,0,N) {
		rep(j,0,N) {
			dist[i][j] = MIN(dist[i][j], dist[i][k]+dist[k][j]);
		}
	}
}
*/



/* SET コンテナ
	set<SINT32> DATA;
	for (SINT32 i = 0; i < N; i++) {
		SINT32 buf;
		cin >> buf;
		DATA.insert(buf);
	}

	//全表示
    set<string>::iterator it; //  イテレータを用意
    for(it = DATA.begin(); it != DATA.end(); it++) {
        cout << *it << endl;
    }

	//N番目を一部表示
	set<string>::iterator it; //  イテレータを用意
	it = DATA.begin();
	rep (i,0,N) {
		it++;
	}
	cout << *it << endl;
*/

/* map
	map<string,SINT32> mp;
	SINT32 N = 0;
	SINT32 mx = 0;

	cin >> N;
	for (SINT32 i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++) {
		mx=max(mx,it->second);
	}
*/

/*
	//順列全表示
	//sortしてからでないと全列挙にならない
	sort(DATA.begin(),DATA.end());
	do {
		cout << buf << endl;
		rep(i,0,R) {
			cout << DATA[i] << " ";
		}
		cout << endl;

    } while (next_permutation(DATA.begin(),DATA.end()));
*/

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
ll kaijo[100010];
void init() {
	kaijo[0] = 1;
	for (ll i = 1;i <= 100010;i++)kaijo[i] = (kaijo[i - 1] * i) % N;
}

ll inv(ll x) {
	ll res = 1;
	ll k = N - 2;
	ll y = x;
	while (k) {
		if (k & 1)res = (res*y) % N;
		y = (y%N*y%N) % N;
		k /= 2;
	}
	return res;
}

ll Comb(ll n, ll k) {
	if (n < 0 || k < 0 || (n - k) < 0)return 0;
	ll b = kaijo[n];
	ll c = kaijo[n - k];
	ll d = kaijo[k];
	ll cd = (c*d) % N;
	return ((b%N)*(inv(cd)) % N) % N;
}


int main(void){
    init();
    ll n,k;
    cin>>n>>k;
    vector<ll>a(n);
    for(ll i=0;i<n;i++)cin>>a[i];
    sort(a.begin(),a.end());
    ll ans = 0;
    for(int i = 0;i<n;i++){
        ll tmp = Comb(i,k-1)*a[i];
        tmp = tmp%N;
        ll tmp1 = Comb(n-i-1,k-1)*a[i];
        tmp1 =tmp1%N;
        tmp1 =-tmp1;
        //cout<<tmp<<" "<<tmp1<<endl;
        tmp1 = (N+tmp1)%N;
        ll tmp2 =(tmp+tmp1)%N;
        ans = (ans+tmp2)%N;
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
const int INF=(int)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;

#define pb push_back

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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


signed main() {
    string s;cin >>s;
    cout <<(s=="ABC"?"ARC":"ABC")<<endl;
}

















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

struct node {
	int first, second, c;
};
bool operator<(node a, node b) {
	return a.second > b.second;
}
vector<P>E[100];
int d[100][11];

int main() {
	int c, n, m, s, g;
	while (scanf("%d%d%d%d%d", &c, &n, &m, &s, &g), c) {
		s--; g--;
		rep(i, 100)E[i].clear();
		memset(d, 0x3f, sizeof(d));
		rep(i, m) {
			int a, b, f; scanf("%d%d%d", &a, &b, &f);
			a--; b--;
			E[a].push_back(P(b, f)); E[b].push_back(P(a, f));
		}
		priority_queue<node>que;
		que.push({ s,0,c });
		d[s][0] = 0;
		while (!que.empty()) {
			node p = que.top(); que.pop();
			for (P i : E[p.first]) {
				if (p.c&& d[i.first][p.c - 1] > p.second + i.second / 2) {
					d[i.first][p.c - 1] = p.second + i.second / 2;
					que.push({ i.first, d[i.first][p.c - 1],p.c - 1 });
				}
				if (d[i.first][p.c] > p.second + i.second) {
					d[i.first][p.c] = p.second + i.second;
					que.push({ i.first, d[i.first][p.c],p.c });
				}
			}
		}
		int Min = INT_MAX;
		rep(i, c + 1)Min = min(Min, d[g][i]);
		printf("%d\n", Min);
	}
}

Measured memory_bytes: 3184
//#include <algorithm>
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <map>



typedef unsigned long long ULONG;
typedef long long LONG;
using namespace std;

#define PI 3.1415926535897932384626433
//#define _DBG_



map< ULONG, ULONG> P0;
map< ULONG, ULONG> P1;

int main(void) {
	vector<ULONG> x(5);
	for (int i = 0; i < 5; i++) {
		cin >> x[i];
		if (x[i] == 0) {
			cout << i+1 << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 3596
def bfs(s)
    q = []
    q << [s,0]
    used = {}
    until q.empty?
        v, vd = q.shift
        D[v] = vd
        used[v] = true
        G[v].each do |u, ud|
            if !used[u]
                q << [u, vd + ud]
            end
        end
    end
end
n = gets.to_i
G = {}
D = Array.new(n + 1)
E = (n - 1).times.map do |i|
    gets.split.map(&:to_i)
end
(1 .. n).each do |v|
    G[v] = []
end
E.each do |u,v,d|
    G[u] << [v,d]
    G[v] << [u,d]
end

q, k = gets.split.map(&:to_i)
bfs(k)

q.times do
    a,b = gets.split.map(&:to_i)
    puts D[a] + D[b]
end



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

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) 
    while (s[i] == s[i + 1]) s.erase(s.begin());  // BBBBBBみたいなのをBに変換する
  cout << s.size() - 1 << endl;
}


Measured memory_bytes: 512
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n, k = map(int, input().split())
  n += 1
  cnt = 0
  for ik in range(k, n+1):
    cnt += ik * (n - ik) + 1
    cnt %= (10**9 + 7)
  print(cnt)

if __name__=='__main__':
  main()


Measured memory_bytes: 9108
N,M=map(int,input().split())
X=list(map(int,input().split()))
X.sort(reverse=True)
Y=[]
for i in range(M-1):
  Y.append(X[i]-X[i+1])
Y.sort()
if M-N<=0:
  print(0)
else:
  print(sum(Y[:M-N]))
  

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

int main() {
  int N;
  std::cin >> N;
  std::vector<int> d(N);
  for (int i = 0; i < N; ++i) std::cin >> d[i];
  std::sort(d.begin(), d.end());
  std::cout << d[N / 2] - d[N / 2 - 1] << std::endl;
}

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

bool solve() {
  int H, W; cin >> H >> W;
  int g1 = H & W & 1;
  int g2 = H % 2 * W / 2 + W % 2 * H / 2;
  vector<int> cnt(26);
  for (int i = 0; i < H*W; i++) {
    char c; cin >> c;
    ++cnt[c-'a'] &= 3;
  }
  int c1 = 0, c2 = 0;
  for (int i = 0; i < 26; i++) {
    c2 += cnt[i] & 2;
    c1 += cnt[i] & 1;
  }
  if (c1 > g1 || c2 / 2 > g2) return false;
  return true;
  
}

int main() {
  if (solve()) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

class A {
    static void Main(string[] args) {
        var st = Console.ReadLine().Split().ToArray();
        string S = st[0];
        string T = st[1];

        var x = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int A = x[0];
        int B = x[1];

        string U = Console.ReadLine();

        if (U == S) {
            A -= 1;
        } else {
            B -= 1;
        }

        Console.WriteLine(A + " " + B);

    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<bool>    vecbool;
typedef vector<int>     vecint;
typedef vector<ll>      vecll;
typedef vector<string>  vecstr;
typedef vector<vecint>  vec2int;
typedef vector<vecbool> vec2bool;
int dx[4] {-1,+1, 0, 0};
int dy[4] { 0, 0,-1,+1};
int main()
{
  string s, t; cin >> s >> t;
  int n = s.size();
  int m = t.size();
  // length
  vec2int  dp(n + 1,vector<int>(m + 1,0));
  
  REP(i,n){
    REP(j,m){
      if(s[i] == t[j]){
        dp[i + 1][j + 1] = dp[i][j] + 1;
      }else{
        dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
      }
    }
  }
  string ans = "";
  int i = n;
  int j = m;
  while(i > 0 && j > 0){
    if(dp[i][j]== dp[i - 1][j]){
      --i;
    }else if(dp[i][j] == dp[i][j - 1]){
      --j;
    }else{
      ans = s[i - 1] + ans;
      --i; --j;
    }
  }
  cout << ans << endl;
}

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

int main() {
  int N; cin >> N;
  int f[N+1]; for (int i = 1; i <= N; i++) f[i] = 0;
  for (int i = 1; i <= N; i++)
    for (int j = i; j <= N; j += i)
      f[j]++;
  long sum = 0;
  for (int k = 1; k <= N; k++) {
    sum += (long)k * f[k];
  }
  cout << sum << endl;
}

Measured memory_bytes: 42688
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <string.h> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;



int main(){
    //std::ifstream in("resource/input.txt");
    //std::cin.rdbuf(in.rdbuf());
	string s;
	cin >> s;
	s = s + s;
	string p;
	cin >> p;

	string res;
	if(s.find(p) !=std::string::npos)
	{
		res = "Yes";
	}
	else
	{
		res = "No";
	}

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




Measured memory_bytes: 3184
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    ll n,t;
    cin >> n >> t;
    vector<ll> time(n);
    rep(i,n) cin >> time[i];
    ll ans = t;
    rep(i,n-1) {
        if(time[i]+t <= time[i+1]) ans += t;
        else ans += time[i+1]-time[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main() {
	int N, TM;
	long long ans = 0;
	scanf("%d%d", &N, &TM);
	long long *T = (long long *)malloc(sizeof(long long)*N);
	for (int i = 0; i < N; i++)
	{
		scanf("%lld", &T[i]);
	}

	for (int i = 1; i < N; i++)
	{
		if (T[i]-T[i-1]<TM)
		{
			ans += T[i] - T[i - 1];
		}else
		{
			ans += TM;
		}
	}
	ans += TM;
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	char b;
	cin >> b;
    char res;
    if (b == 'A') {
        res = 'T';
    } else if (b == 'T') {
        res = 'A';
    } else if (b == 'C') {
        res = 'G';
    } else if (b == 'G') {
        res = 'C';
    }
	cout << res << endl;
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int n;
int c[100],v[100], mi[100];
int ans;
int main() {
    cin >> n;
    for (int i=0;i<n;i++) {
        cin >> v[i];
    }
    for (int i=0;i<n;i++) {
        cin >> c[i];
        mi[i] = v[i] - c[i];
        if (mi[i]>0) {
            ans += mi[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a, b = 1;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a;
        if (a == b) b++;
    }
    if (b == 1) cout << -1;
    else cout << n - b + 1;
}


Measured memory_bytes: 3624
#include <iostream> 
#include <cstdio>

using namespace std;

#define For(i , a , b) for (int i = a , _b = b ; i <= _b ; ++i)
#define Ford(i , a  ,b) for (int i = a , _b = b : i >= _b ; --i)
#define Rep(i , n) for (int i = 0 , _n = n ; i < _n ; ++i)
#define sz(A) ((int)A.size())
#define LL(x) (x << 1)
#define RR(x) ((x << 1) | 1)

typedef pair<int , int> pt;

const int maxn = 200000 + 123;
string s,t;
int n, m;
void ReadData() {
	cin >> s >> t;
	n = sz(s);
	m = sz(t);
	s = ' ' + s;
	t = ' ' + t;
}	

int f(int x) {
	x %= 3;
	if (x < 0) x += 3;
	return x;
}

int sums[maxn], sumt[maxn];
void Process() {
	For(i,1,n) sums[i] = sums[i - 1] + (s[i] == 'B' ? -1 : 1);
	For(i,1,m) sumt[i] = sumt[i - 1] + (t[i] == 'B' ? -1 : 1);
	int q; cin >> q;
	while (q--) {
		int x,y,u,v; cin >> x >> y >> u >> v;
		if (f(sums[y] - sums[x - 1]) == f(sumt[v] - sumt[u - 1])) {
			puts("YES");
		} else puts("NO");
	}
}	

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	//freopen("input.inp", "r" , stdin);
	ReadData();
	Process();

	return 0;

}			

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

int main() {
    string s;
    cin >> s;
    if (s == "SUN" )
        cout << 7;
    if (s == "MON" )
        cout << 6;
    if (s == "TUE" )
        cout << 5;
    if (s == "WED" )
        cout << 4;
    if (s == "THU" )
        cout << 3;
    if (s == "FRI" )
        cout << 2;
    if (s == "SAT" )
        cout << 1;

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n);
    rep(i,n) {
        cin >> a[i];
    }
    rep(i,n) {
        cin >> b[i];
    }
    rep(i,n) {
        cin >> c[i];
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll ans = 0;
    vector<int> x,y;
    rep(i,n) {
        int point = lower_bound(a.begin(),a.end(),b[i]) - a.begin();
        x.push_back(point);
    }
    rep(i,n) {
        int point = upper_bound(c.begin(),c.end(),b[i]) - c.begin();
        point = n - point;
        y.push_back(point);
    }
    rep(i,n) {
        ans += (ll)x[i] * y[i];
    }
    cout << ans << "\n";
    return 0;
}


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

using namespace std;

int main()
{
string a,b;
cin>>a>>b;
int j;
if(a.size()==b.size()){
for(int i=0,j=0;i<a.size(),j<b.size();i++,j++)
{
    cout<<a[i]<<b[j];
}}
else if(a.size()>b.size())
{
  for(int i=0,j=0;i<a.size(),j<b.size();i++,j++)
{
    cout<<a[i]<<b[j];
}
  for(int i=b.size();i<a.size();i++)
{
    cout<<a[i];
}
}
else{
    for(int i=0,j=0;i<a.size(),j<b.size();i++,j++)
{
    cout<<a[i]<<b[j];
}

}
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll a[110000];
main(){
  ll n,k,x,ans=0;
  cin>>n>>k>>x;
  //rep(i,0,n)cin>>a[i];
  if(n+k+x>=22)cout<<"bust";
  else cout<<"win";

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
int main()
{
    int a, b, c;
    int rec, loz;
 
    rec = loz = 0;
    while (scanf("%d,%d,%d", &a, &b, &c) == 3) {
        if (a*a + b*b == c*c) rec++;
        else {
            if (a == b && a + b > c && b + c > a && c + a > b) loz++;
        }
    }
    printf("%d\n%d\n", rec, loz);
    return 0;
}


Measured memory_bytes: 2036
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = 2000000000;
// const ll MOD = 1000000007;

const int MAX_N = 100000;

unordered_set<int> prime;
bool is_prime[MAX_N + 1];

// prime table
void eratosthenes(int n) {
  for (int i = 0; i <= n; i++) {
    is_prime[i] = true;
  }
  is_prime[0] = false, is_prime[1] = false;

  for (int i = 2; i <= n; i++) {
    if (!is_prime[i]) {
      continue;
    }
    prime.insert(i);
    for (int j = 2 * i; j <= n; j += i) {
      is_prime[j] = false;
    }
  }
}

int Q;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  eratosthenes(MAX_N);
  vector<int> c_sum(MAX_N + 1, 0);
  for (int i = 1; i <= MAX_N; i++) {
    if (prime.find(i) == prime.end() ||
        prime.find((i + 1) / 2) == prime.end()) {
      c_sum[i] = c_sum[i - 1];
    } else {
      c_sum[i] = c_sum[i - 1] + 1;
    }
  }

  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int l, r;
    cin >> l >> r;
    cout << c_sum[r] - c_sum[l - 1] << endl;
  }
  return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	long long int res;
	scanf("%lld",&res);
	int h,m,s;
	s = res%60;
	m = res/60%60;
	h = res/60/60;
	printf("%d:%d:%d\n",h,m,s);
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main(void){
  int64_t X;
  cin >> X;
  int64_t A, B;
  cin >> A >> B;
  for(int64_t i = -1001; i < 1001; i++){
    for(int64_t j = -1001; j < 1001; j++){
      A = i * i * i * i * i;
      B = j * j * j * j * j;
      if(A - B == X){
        cout << i << " " << j;
        break;
      }
    }
     if(A - B == X){
        break;
      }
  }
}

Measured memory_bytes: 3636
N = int(input())
S = input()

K = []
for i in range(1,N):
    X = list(set(S[:i]))
    Y = list(set(S[i:]))
    cnt = 0
    for i in range(len(X)):
        if X[i] in Y:
            cnt += 1

    K.append(cnt)

print(max(K))

Measured memory_bytes: 3316
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] tmp = br.readLine().split(" ");
		long[] input = new long[n];
		for (int i = 0; i < n; i++) {
			input[i] = Long.parseLong(tmp[i]);
		}
		long max = input[0];
		long min = input[0];
		long sum = 0;
		for(long x : input){
			max = Math.max(max, x);
			min = Math.min(min, x);
			sum += x;
		}
		System.out.printf("%d %d %d%n", min, max, sum);
	}

}

Measured memory_bytes: 25592
n = int(input())
num_list = [ int(v) for v in input().split() ]

multi_list = [[num_list[0]]]

for i in range(1,n):
    if num_list[i] == multi_list[-1][-1]:
        multi_list[-1].append(num_list[i])
    else:
        multi_list.append([num_list[i]])
    
print(sum(map(lambda x: len(x)//2 ,multi_list)))

Measured memory_bytes: 38384
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = a * b;
        if (c % 2 == 0) System.out.println("Even");
        else System.out.println("Odd");
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=1<<31-1=2147483647
constexpr ll INF = (ll)1e18;//1<<63-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define PI (acos(-1))
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/


void warshall_floyd(vector<vector<ll>> &d) {
	ll node_size=d.size();
	for (int k=0; k<node_size; k++) {
		for (int i=0; i<node_size; i++) {
			for (int j=0; j<node_size; j++){
				if(d[i][k] != INF && d[k][j] != INF){
					d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}
	}
}


signed main() {
	ll H,W;
	cin>>H>>W;

	//node_size:ノードの数、0〜(node_size-1)がノード番号として定義される
	ll node_size=10;

	vector<vector<ll>> d(node_size, vector<ll>(node_size, 0));
	for(ll i=0; i<node_size; i++) {
		for(ll j=0; j<node_size; j++) {
			if(i==j) d[i][j] = 0;
			else d[i][j] = INF;
		}
	}

	rep(i,10){
		rep(j,10){
			ll cost;
			cin>>cost;
			if(i==j)continue;
			d[i][j] = cost;
		}
	}	

	warshall_floyd(d);

	ll ans=0;
	rep(i,H){
		rep(j,W){
			ll t;
			cin>>t;
			if(t==1 || t==-1)continue;
			ans+=d[t][1];
		}
	}
	p(ans);
	return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main()
{
    int a;
    string s;

    cin >> a;
    cin >> s;

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

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

int main() {
  int N;
  cin >> N;
  int a = N % 10;
  if (a == 3) {
    cout << "bon" << endl;
  }
  else if (a ==0 || a == 1 || a == 6 || a == 8) {
    cout << "pon" << endl;
  }
  else {
    cout << "hon" << endl;
  }
}

Measured memory_bytes: 3636
using Yorukatsu022.Questions;
using Yorukatsu022.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu022.Questions
{
    /// <summary>
    /// ABC045 B
    /// </summary>
    public class QuestionC : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var s = new[] { inputStream.ReadLine(), inputStream.ReadLine(), inputStream.ReadLine() };
            var index = new[] { 0, 0, 0 };

            var player = 0;   // Aさんは0,以下1,2

            while (index[player] != s[player].Length)
            {
                player = s[player][index[player]++] - 'a';
            }

            yield return (char)(player + 'A');
            yield break;
        }
    }
}


namespace Yorukatsu022
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu022.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu022.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; cin >> N; 
	int ans = N;
	int now = 1;  
	for(int i = 0; i < N; i++){
		int a; cin >> a; 
		if(a == now){
			ans --; now ++; 
		}
	}
	if(ans == N) cout << -1 << endl; 
	else cout << ans << endl; 
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

inline int read()
{
	int data = 0, w = 1;
	char ch = getchar();
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') w = -1, ch = getchar();
	while (ch >= '0' && ch <= '9') data = data * 10 + (ch ^ 48), ch = getchar();
	return data * w;
}

const int N(100010);
int a[N], cnt[2], n;

void trans()
{
	for (int i = 1; i <= n; i++) if (a[i] & 1) --a[i]; int g = a[1];
	for (int i = 2; i <= n; i++) g = std::__gcd(g, a[i]);
	for (int i = 1; i <= n; i++) a[i] /= g;
}

int check()
{
	cnt[0] = cnt[1] = 0;
	for (int i = 1; i <= n; i++) ++cnt[a[i] & 1];
	if (cnt[0] & 1) return 1; else if (cnt[1] > 1) return 0;
	else
	{
		for (int i = 1; i <= n; i++) if (a[i] == 1) return cnt[0] & 1;
		return trans(), check() ^ 1;
	}
}

int main()
{
	n = read();
	for (int i = 1; i <= n; i++) a[i] = read();
	puts(check() ? "First" : "Second");
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <vector>
#include <string>

typedef long long ll;

void print(){ std::cout << std::endl; }
template<typename H> void print(H&& head){ std::cout << head << std::endl; }
template<typename H, typename... T> void print(H&& head, T&&... tail){
  std::cout << head << " ", print(std::forward<T>(tail)...);
}

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

  bool judge = M >= N;
  if (judge) print("unsafe");
  else print("safe");

  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
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; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    string s; cin >> s;
    int Ocnt = 0, Icnt = 0;
    rep(i, s.size())
    {
        if (s[i] == '0')
        {
            Ocnt++;
        }
        if (s[i] == '1')
        {
            Icnt++;
        }
    }
    if (Ocnt <= Icnt) cout << Ocnt * 2 << endl;
    else cout << Icnt * 2 << endl;
}

Measured memory_bytes: 512
<?php
$k = trim(fgets(STDIN));
$s = str_split(trim(fgets(STDIN)));
if (count($s) <= $k) {
    echo trim(implode($s));
} else {
    $arr = [];
    $arr = array_slice($s, 0, $k);
    array_push($arr, "...");
    echo trim(implode($arr));
}

Measured memory_bytes: 16120
#include<cmath>
#include<cstdio>

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

using namespace std;

const double EPS=1e-8;

struct point3{
	double x,y,z;
	point3():x(0),y(0),z(0){}
	point3(double x,double y,double z):x(x),y(y),z(z){}
	point3 operator-(const point3 &a)const{ return point3(x-a.x,y-a.y,z-a.z); }
};

double dot(const point3 &a,const point3 &b){ return a.x*b.x+a.y*b.y+a.z*b.z; }

point3 cross(const point3 &a,const point3 &b){ return point3(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x); }

double abs(const point3 &a){ return sqrt(a.x*a.x+a.y*a.y+a.z*a.z); }

double abs2(const point3 &a){ return a.x*a.x+a.y*a.y+a.z*a.z; }

struct segment3{
	point3 a,b;
	segment3(){}
	segment3(const point3 &a,const point3 &b):a(a),b(b){}
};

struct sphere{
	point3 c;
	double r;
	sphere():c(point3(0,0,0)),r(0){}
	sphere(const point3 &c,double r):c(c),r(r){}
};

double dist(const segment3 &S,const point3 &p){
	if(dot(S.b-S.a,p-S.a)<=0) return abs(p-S.a);
	if(dot(S.a-S.b,p-S.b)<=0) return abs(p-S.b);
	return abs(cross(S.b-S.a,p-S.a))/abs(S.a-S.b);
}

bool intersect(const sphere &C,const segment3 &S){
	return dist(S,C.c)<C.r+EPS;
}

bool cover(const sphere &S,const point3 &p){
	return abs(S.c-p)<S.r+EPS;
}

bool cover(const sphere &C,const segment3 &S){
	return cover(C,S.a) && cover(C,S.b);
}

int main(){
	for(int n,m,k;scanf("%d%d%d",&n,&m,&k),n;){
		sphere S[2000];
		rep(i,n) scanf("%lf%lf%lf%lf",&S[i].c.x,&S[i].c.y,&S[i].c.z,&S[i].r);
		point3 p[15];
		double bright[15];
		rep(i,m) scanf("%lf%lf%lf%lf",&p[i].x,&p[i].y,&p[i].z,bright+i);
		point3 tar; scanf("%lf%lf%lf",&tar.x,&tar.y,&tar.z);

		int mask[2000]={}; // mask[i] := ( 風船 i が遮断している光源の集合 )
		rep(j,m){
			segment3 T(p[j],tar);
			rep(i,n) if(!cover(S[i],T) && intersect(S[i],T)) mask[i]|=1<<j;
		}

		double power[15];
		rep(i,m) power[i]=bright[i]/abs2(p[i]-tar);

		double ans=0;
		rep(S,1<<m){
			double pwr=0;
			rep(i,m) if(S>>i&1) pwr+=power[i];
			if(pwr<ans) continue;

			int cnt=0;
			rep(i,n) if(mask[i]&S) cnt++;
			if(cnt<=k) ans=pwr;
		}
		printf("%.9f\n",ans);
	}

	return 0;
}

Measured memory_bytes: 1164
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{ 
    static void Main(string[]args)
    {
        Magatro m = new Magatro();
        m.Scan();
        m.Solve();
    }
}

public class Scanner
{
    private StreamReader Sr;
    private string[] S;
    private int Index;

    private const char Separator=' ';

    public Scanner()
    {
        Index = 0;
        S = new string[0];
        Sr = new StreamReader(Console.OpenStandardInput());
    }

    private string[] Line()
    {
        return Sr.ReadLine().Split(Separator);
    }

    public string Next()
    {
        string result;
        if (Index >= S.Length)
        {
            S = Line();
            Index = 0;
        }
        result = S[Index];
        Index++;
        return result;
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public string[] StringArray(int index = 0)
    {
        Next();
        Index = S.Length;
        return S.Skip(index).ToArray();
    }
    public int[] IntArray(int index = 0)
    {
        return StringArray(index).Select(int.Parse).ToArray();
    }
    public long[]LongArray(int index = 0)
    {
        return StringArray(index).Select(long.Parse).ToArray();
    }

    public bool ScanToEnd(ref string s)
    {
        if (Sr.EndOfStream)
        {
            return false;
        }
        else
        {
            s = Sr.ReadLine();
            return true;
        }
    }
}

public class Magatro
{
    private long N, M;

    private Scanner Sc = new Scanner();
    public void Scan()
    {
        N = Sc.NextInt();
        M = Sc.NextInt();
    }

    public void Solve()
    {
        bool[] bo = new bool[N];
        int[] cnt = (new int[N]).Select(i => 1).ToArray();

        bo[0] = true;
        for (int i = 0; i < M; i++)
        {
            int x = Sc.NextInt() - 1;
            int y = Sc.NextInt() - 1;
            if (bo[x])
            {
                if (cnt[x] > 1)
                {
                    bo[y] = true;
                }
                else
                {
                    bo[x] = false;
                    bo[y] = true;
                }
            }
            cnt[x]--;
            cnt[y]++;
        }
        Console.WriteLine(bo.Count(b => b==true));

    }
}





Measured memory_bytes: 8888
n = gets.to_i
a = gets.split.map(&:to_i)
a.sort!
l = Hash.new(0)

a.each do |b|
    l[b] += 1
end

sum = 0

l.values.each do |i|
    if i >= 2
        sum += i - 1
    end
end
if sum == 1
    sum += 1
end
if sum % 2 != 0
    sum += 1
end
puts n - sum


Measured memory_bytes: 15352
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,k;
vector<int> v[20];

int pin[10][7]={
  {1,1,1,0,1,1,1},
  {0,0,1,0,0,1,0},
  {1,0,1,1,1,0,1},
  {1,0,1,1,0,1,1},
  {0,1,1,1,0,1,0},
  {1,1,0,1,0,1,1},
  {1,1,0,1,1,1,1},
  {1,0,1,0,0,1,0},
  {1,1,1,1,1,1,1},
  {1,1,1,1,0,1,1},
};

int pic[10]={6,2,5,5,4,5,6,3,7,6};

int he(int x,int p){
  int ans=pic[x];
  for(int i=0;i<v[p].size();i++){
    ans-=pin[x][v[p][i]];
  }
  return ans;
}

signed main(){
  cin>>n>>k;
  for(int i=0;i<k;i++){
    int p,q;
    cin>>p>>q;
    v[p].push_back(q);
  }
  int time[50]={};
  for(int i=0;i<=23;i++){
    for(int j=0;j<=59;j++){
      for(int k=0;k<=59;k++){
	int cnt=0;
	cnt+=he(i/10,8);
	cnt+=he(i%10,9);
	cnt+=he(j/10,10);
	cnt+=he(j%10,11);
	cnt+=he(k/10,12);
	cnt+=he(k%10,13);
	time[cnt]++;
      }
    }
  }
  int ans=0;
  for(int i=0;i<10000;i++){
    int f=0;
    if(i%400==0)f=1;
    if(i%100&&i%4==0)f=1;
    for(int j=1;j<=12;j++){
      for(int k=1;k<=31;k++){
	if(j==4||j==6||j==9||j==11)
	  if(k==31)break;
	if(j==2){
	  if(!f&&k==29)break;
	  if(k==30)break;
	}
	int cnt=0;
	int ti=i,tj=j,tk=k;
	for(int x=0;x<4;x++){
	  if(x<2){
	    cnt+=he(tj%10,5-x);
	    cnt+=he(tk%10,7-x);
	  }
	  cnt+=he(ti%10,3-x);
	  ti/=10,tj/=10,tk/=10;
	}
	int tmp=n-cnt;
	if(0<=tmp&&tmp<50){
	  ans+=time[tmp];
	}
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}



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

int	main() {
	int N;
	cin >>N;
	vector<long> a(N);
	long Total=0;
	for (int i=0; i<N; i++) {
		cin >>a.at(i);
		Total +=a.at(i);
	}
	long P1=a.at(0);
	long D=abs(Total-P1-P1);
	for (int i=1; i<N-1; i++) {
		P1 +=a.at(i);
		D=min(D, abs(Total-P1-P1));
	}
	cout <<D <<endl;
	return 0;
};


Measured memory_bytes: 1792