akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Abhilash Mandaliya
 */
public class Main {
    public static void main (String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader( inputStream );
        PrintWriter out = new PrintWriter( outputStream );
        TaskA solver = new TaskA();
        solver.solve( 1, in, out );
        out.close();
    }

    static class TaskA {
        public void solve (int testNumber, InputReader in, PrintWriter out) {
            out.println( "ABC" + in.nextInt() );
        }

    }

    static class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar;
        private int snumChars;

        public InputReader (InputStream st) {
            this.stream = st;
        }

        public int read () {
            if ( snumChars == - 1 )
                throw new InputMismatchException();
            if ( curChar >= snumChars ) {
                curChar = 0;
                try {
                    snumChars = stream.read( buf );
                } catch ( IOException e ) {
                    throw new InputMismatchException();
                }
                if ( snumChars <= 0 )
                    return - 1;
            }
            return buf[curChar++];
        }

        public int nextInt () {
            int c = read();
            while ( isSpaceChar( c ) ) {
                c = read();
            }
            int sgn = 1;
            if ( c == '-' ) {
                sgn = - 1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while ( ! isSpaceChar( c ) );
            return res * sgn;
        }

        public boolean isSpaceChar (int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == - 1;
        }

    }
}



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

using namespace std;

#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz(x) ((int)(x).size())

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

const int N = 1e5 + 5;

string s[111];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; ++i) cin >> s[i];
	for(int i = 0; i < m + 2; ++i) cout << "#";
	cout << endl;
	for(int i = 0; i < n; ++i) {
		cout << '#';
		for(int j = 0; j < m; ++j) cout << s[i][j];
		cout << "#\n";
	}
	for(int i = 0; i < m + 2; ++i) cout << "#";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	char s[10001];
	int i,w;
	scanf("%s",s);
	scanf("%d",&w);
	i=0;
	while(1)
	{
		if(i%w==0)
			printf("%c",s[i]);
		i++;
		if(s[i]=='\0')
			break;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<tuple>

using namespace std;

typedef long long ll;
typedef tuple<int, int, bool> T3;//値、何番目、表裏

int N;
int A[50], B[50];

const int INF = 100000000;

int dp[1 << 18][50 + 5];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++)cin >> A[i];
	for (int i = 0; i < N; i++)cin >> B[i];

	for (int i = 0; i < (1 << N); i++)for (int j = 0; j <= 50; j++)dp[i][j] = INF;

	dp[0][0] = 0;
	for (int bit = 0; bit < (1 << N); bit++) {
		int nowpos = 0;
		for (int i = 0; i < N; i++)
			if ((bit >> i) & 1)nowpos++;
		for (int i = 0; i <= 50; i++) {
			if (dp[bit][i] == INF)continue;
			int cost = 0;
			for (int j = 0; j < N; j++) {
				if ((bit >> j) & 1)continue;
				int target = (j - nowpos + 100) % 2 == 0 ? A[j] : B[j];
				if (target >= i) {
					dp[bit | (1 << j)][target] = min(dp[bit | (1 << j)][target], dp[bit][i] + cost);
				}
				cost++;
			}
		}
	}
	int ans = INF;
	for (int i = 0; i <= 50; i++) {
		ans = min(ans, dp[(1 << N) - 1][i]);
	}
	if (ans == INF)cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 56576
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(int i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

ll dp[3001][3001];
bool visited[3001][3001] = {false};
vector<int> a;

ll dfs(int cur, int l, int r){
  if(visited[l][r]) return dp[l][r]; 
  if(l>r) return 0;
  int isfirst;
  if(cur%2==0) isfirst = 1;
  else isfirst = -1;
  ll ret1 = dfs(cur+1, l+1, r) + isfirst*a[l];
  ll ret2 = dfs(cur+1, l, r-1) + isfirst*a[r];
  ll ret = max(isfirst*ret1,isfirst*ret2);
  ret *= isfirst;
  visited[l][r] = true;
  return dp[l][r] = ret;
}

int main(void){
  int N;cin >> N;
  a.resize(N);
  REP(i,N) cin >> a[i];
  cout << dfs(0,0,N-1) << endl;
  return 0;
}


Measured memory_bytes: 78592
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max()/4 ;
const ll linf = numeric_limits<ll>::max()/4 ;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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

int kai(string s){
    rep(i,0,sz(s)){
        if(s[i] != s[sz(s)-i-1])ret 0;
    }
    ret 1;
}
int main(){
	
    string s;
    cin >> s;
    int cnt = 0;
    string t = s;
    rep(i,0,sz(t)){
        if(t[i] == 'x'){
            t.erase(i,1);
            //cnt++;
            i--;
        }
    }
   // P(t);

    if(kai(t) == 1){
        //P(cnt);
        int l = 0,r = sz(s)-1;

        while(l < r){
            if(s[l] != s[r]){
                if(s[l] == 'x'){
                    cnt++;
                    l++;
                }else if(s[r] == 'x'){
                    cnt++;
                    r--;
                }
            }else{
                l++;
                r--;
            }
        }
        P(cnt);
    }else P(-1);
    
	return  0;
}

Measured memory_bytes: 512
import collections as c
N = int(input())
L = c.Counter(list(map(int, input().split())))

key = list(L.keys())
val = list(L.values())

cnt = 0

for i in range(len(key)):
	if key[i] <= val[i]:
		cnt += val[i] - key[i]
	else:
		cnt += val[i]

print(cnt)

Measured memory_bytes: 18672
h,w,k=map(int,input().split())
b=[list("#"*(w+2))]+[list("#"+input()+"#")for _ in range(h)]+[list("#"*(w+2))]
for i in range(h+2):
  for j in range(w+2):
    if b[i][j]=="S":
      Q=[(i,j)]
      ans=0--min(i-1,h-i,j-1,w-j)//k
co=0
dx=[1,0,-1,0]
dy=[0,1,0,-1]
while Q and co!=k+1:
  co+=1
  P=[]
  for i,j in Q:
    ans=min(ans,0--min(i-1,h-i,j-1,w-j)//k)
    for x,y in zip(dx,dy):
      if b[i+x][j+y]==".":
        b[i+x][j+y]=0
        P.append((i+x,j+y))
        if i+x in [1,h] or j+y in [1,w]:print(1);exit()
  Q=P
print(ans+1)

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

int p[10001];
int main(void){
    int m, n_min, n_max;
    while(cin >> m >> n_min >> n_max && m) {
        rep(i, m) cin >> p[i];
        sort(p, p+m, greater<int>());
        int gap = 0;
        int ans = 0;
        for(int i=n_min; i<=n_max; ++i) {
            if(p[i-1]-p[i] >= gap) {
                gap = p[i-1]-p[i];
                ans = i;
            }
        }
        cout << ans << endl;
    }
}

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

int main() {
    int n;
    cin>>n;
    
    int a[n];
    double c=1;
    double d=0;
    
    for(int i=0;i<n;i++){
        cin>>a[i];
        c*=a[i];
    }
    for(int i=0; i<n; i++){
        d+=c/a[i];
    }
    cout<<c/d<<endl;
    return 0;
    
}


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

// 小数点以下桁数
// fixed << setprecision(i)

int gcd(int a,int b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//   for(auto x : v) cout << x << " "; cout << "\n";    // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }

int main()
{
  int64_t x, y;
  int n, d, count = 0;

  cin >> n >> d;
  for (int i = 0; i < n; i++)
  {
    cin >> x >> y;
    if (sqrt(pow(x, 2) + pow(y, 2)) <= d)
      count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3656
#include <stdio.h>
#include <math.h>
int main (void){
        int A,B;
        scanf("%d",&A);
        scanf("%d",&B);
        if (B!=100) {
                  printf("%d",B);
        }else{
          printf("101");
        }
        if (A==1) {
          printf("00");
        }else if (A==2) {
          printf("0000");
        }
        printf("\n");
        return 0;
}


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


int N, K, a[100000];

int main(){
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    long long plus_sum = 0;
    for(int i = 0; i < N; i++){
        if(a[i] > 0){
            plus_sum += a[i];
        }
    }

    long long black_diff = 0;
    for(int i = 0; i < K; i++){
        if(a[i] < 0){
            black_diff += a[i];
        }
    }
    long long ans = -10000000000000000;
    for(int i = 0; i + K <= N; i++){
        long long tmp = plus_sum + black_diff;
        ans = max(ans, tmp);
        if(i+K != N){
            if(a[i+K] < 0){
                black_diff += a[i+K];
            }
            if(a[i] < 0){
                black_diff -= a[i];
            }
        }
    }
    long long white_diff = 0;
    for(int i = 0; i < K; i++){
        if(a[i] > 0){
            white_diff -= a[i];
        }
    }
    for(int i = 0; i + K <= N; i++){
        long long tmp = plus_sum + white_diff;
        ans = max(ans, tmp);
        if(i + K != N){
            if(a[i+K] > 0){
                white_diff -= a[i+K];
            }
            if(a[i] > 0){
                white_diff += a[i];
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
N = int(input())
H = list(map(int, input().split()))

last = 0
tmp = 0
ans = 0
for x in H:
    if x > last:
        ans = max(ans, tmp)
        tmp = 0
    else:
        tmp += 1
    last = x

ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 15020
#include<stdio.h>
int main(void)
{
  for(;;){
    int houkosu={0};
    int comkosu={0};
    int hou[21][21]={{0},{0}};
    int zahyo[21][21]={{0},{0}};
    int mypox={10};
    int mypoy={10};
    int x={0},y={0};
    int i={0},j={0};
    char dire={0};
    int dis={0};
    int hantei={0};
    char dir[31]={0};
    int di[31]={0};
     
    scanf("%d",&houkosu);
    if(houkosu==0)
      break;
       
    for(i=0;i<houkosu;i++){
      scanf("%d %d",&x,&y);
      hou[x][y]=1;
    }
 
    scanf("%d",&comkosu);
     
    hou[10][10]=0;
    for(i=0;i<2*comkosu;i++){
      scanf("%c",&dire);
      dir[i/2]=dire;
      scanf("%d",&dis);
      di[(i-1)/2]=dis;
    }
     
    for(i=0;i<comkosu;i++){
 
      if(dir[i]=='N'){
        for(j=mypoy+1;j<=mypoy+di[i];j++){
          if(hou[mypox][j]==1)
            hou[mypox][j]=0;
        }
        mypoy+=di[i];
      }else if(dir[i]=='S'){
        for(j=mypoy-1;j>=mypoy-di[i];j--){
          if(hou[mypox][j]==1)
            hou[mypox][j]=0;
        }
        mypoy-=di[i];
      }else if(dir[i]=='E'){
        for(j=mypox+1;j<=mypox+di[i];j++){
          if(hou[j][mypoy]==1)
            hou[j][mypoy]=0;
        }
        mypox+=di[i];
      }else{
        for(j=mypox-1;j>=mypox-di[i];j--){
          if(hou[j][mypoy]==1)
            hou[j][mypoy]=0;
        }
        mypox-=di[i];
      }
    }
     
    for(i=0;i<21;i++){
      for(j=0;j<21;j++){
        if(hou[i][j]!=0)
          hantei=1;
      }
    }
     
    if(hantei==0)
      puts("Yes");
    else
      puts("No");
     
  }
  return 0;
}

Measured memory_bytes: 1012
import sys

input = sys.stdin.readline

n = int(input())
in_list = []
for _ in range(n):
    a, b = map(int, input().split())
    in_list.append([b, a])
in_list.sort()
t, flag = 0, 0
for b, a in in_list:
    t += a
    if t > b:
        flag = 1
        break
if flag == 0:
    print('Yes')
else:
    print('No')


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.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 int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    string s,t;
    cin >> s >> t;
    vector<vector<int>> v(26);
    for (int i = 0; i < s.size(); ++i) {
        v[s[i] - 'a'].push_back(i);
    }

    ll res = 0;
    int now = -1;
    for (int i = 0; i < t.size(); ++i) {
        int c = t[i] - 'a';
        if (v[c].empty()) {
            cout << -1 << endl;
            return 0;
        }

        auto itr = upper_bound(all(v[c]), now);
        if (itr == v[c].end()) {
            res += (ll)s.size() - now + v[c][0];
            now = v[c][0];
        } else {
            res += *itr - now;
            now = *itr;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 4232
#include <bits/stdc++.h> 
using namespace std;
const int N = 10000 + 5;
int v[N];

int main()
{
	for(int i = 1; i <= 100; i++){
		for(int j = 1; j <= 100; j++){
			for(int k = 1; k <= 100; k++){
				int z = i*i+j*j+k*k+i*j+i*k+j*k;
				if(z <= 10000)
					v[z]++;
			}
		}
	}
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
		cout << v[i] << endl; 
	return 0;
}

Measured memory_bytes: 3624
mt = int(input())
mt_list = list(map(int, input().split()))

j = 0
count = 0

for i in range(mt):

    visible_flg = True

    j = i

    while j > 0:
        if mt_list[i] < mt_list[j-1]:
            visible_flg = False
            break
        j -= 1
    
    if visible_flg:
        count += 1

print(count)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define double long double
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;

int cnt[N];

signed main(){
    IOS;
    int n;
    cin >> n;
    int s = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        s += a;
        cnt[a]++;
    }
    int q;
    cin >> q;
    while (q--) {
        int b, c;
        cin >> b >> c;
        s -= cnt[b] * b;
        s += cnt[b] * c;
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 4420
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	int n, k;
	scanf("%d", &n);
	scanf("%d", &k);
	n = n % 500;

	if(n<=k)printf("Yes\n");
	else printf("No\n");


	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;


template<typename T>
bool is_prime(T n)
{
	if (n == 2)
	{
		return true;
	}
	else if ((n == 1) || (n % 2 == 0))
	{
		return false;
	}

	T p = (T)sqrt(n);
	for (T i = 3; i <= p; i += 2)
	{
		if (n % i == 0)
		{
			return false;
		}
	}

	return true;
}

template<typename T>
vector<T> prime_factor(T n)
{
	vector<T> pf;

	T m = n;
	for (T i = 2; m > 1;)
	{
		if (m % i == 0)
		{
			m /= i;
			pf.push_back(i);
		}
		else
		{
			if (is_prime(m))
			{
				pf.push_back(m);
				return pf;
			}
			else
			{
				i++;
			}
		}
	}
	return pf;
}

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

	cout << n << ": ";

	vector<ullong> pf = prime_factor(n);
	for (ullong i = 0; i < pf.size(); i++)
	{
		cout << pf.at(i) << (i == pf.size() - 1 ? "" : " ");
	}

	cout << endl;
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    for(int i = sqrt(n);i>=1;i--) {
        if(n%i == 0) {
            cout<<(n/i)+i-2<<endl;
            break;
        }
    }
}


Measured memory_bytes: 3652
-- 入力を受け取り、 Int にする
getInt = do
  x <- getLine
  let intValue = read x :: Int
  return intValue

main = do
  inNum <- getInt
  let hours = inNum `div` 3600 :: Int
  let minutes = (inNum `mod` 3600) `div` 60
  let seconds = (inNum `mod` 60)
  putStrLn ((show hours) ++ [':'] ++ (show minutes) ++ [':'] ++ (show seconds))


Measured memory_bytes: 3632
/*
 * Improve XOR funcition using != notation.
 * Ref: http://stackoverflow.com/questions/1596668/logical-xor-operator-in-c
 */
#include <cstdio>
#include <iostream>

using namespace std;

int main(){
    //freopen("a4.in", "r", stdin);
    string s;
    cin >> s;
    bool nflag = false;
    bool eflag = false;
    bool wflag = false;
    bool sflag = false;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'N') {
            nflag = true;
        } else if (s[i] == 'E') {
            eflag = true;
        } else if (s[i] == 'W') {
            wflag = true;
        } else if (s[i] == 'S') {
            sflag = true;
        }
    }

    bool ns_impossible = nflag != sflag;
    bool ew_impossible = eflag != wflag;

    if (ns_impossible || ew_impossible) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	string s,t;
	cin>>s>>t;
	rep(i,t.size()){
		cout<<s[i]<<t[i];
	}
	if(s.size()-t.size()==1){
		cout<<s.back();
	}
	cout<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
    int n, s[1000];
    while(1){
        cin >> n;
        if(n == 0)break;

        for(int i = 0; i < n; i++){
            cin >> s[i];
        }
        int sum = 0;
        for(int i = 0; i < n; i++){
            sum += s[i];
        }
        double a = 0.0;
        double m = 1.0 * sum / n;
        for(int i = 0; i < n; i++){
            a += (m - s[i]) * (m - s[i]);
        }

        printf("%lf\n", sqrt(a/n));
    }
    return 0;
}


Measured memory_bytes: 3212
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int n,W;
int w[105];
int v[105];
int dp[105][10005];

int main()
{
	memset(dp,-1,sizeof(dp));
	scanf("%d%d",&n,&W);
	for(int i=0;i<n;i++)
		scanf("%d%d",&v[i],&w[i]);
	dp[n][W]=0;
	for(int i=n-1;i>=0;i--)
		for(int j=W;j>=0;j--)
		{
			dp[i][j]=max(dp[i][j],dp[i+1][j]);
			if(dp[i+1][j]!=-1&&j-w[i]>=0)dp[i][j-w[i]]=max(dp[i][j-w[i]],dp[i+1][j]+v[i]);
		}
	int ans=0;
	for(int i=0;i<=W;i++)
		ans=max(ans,dp[0][i]);
	printf("%d\n",ans);
}

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


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

    int a, b;
    cin >> a >> b;

    if (a%2==1 && b%2==1){
        cout << "Odd" << "\n";
    }else{
        cout << "Even" << "\n";
    }


    return 0;
}

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

char board[55][55];

string s;
int match[10010];

int cy = -1, cx = -1, dir = 0;
int gy = -1, gx = -1;
const int dy[4] = { -1, 0, 1, 0};
const int dx[4] = {0, 1, 0, -1};

const int limit = 10000010;

int cnt = 0;
int ans = 0;
bool term = false;

void move(int i) {
	ans++;
	if (cnt > limit) term = true;

	if (s[i] == '^') {
		const int ny = cy + dy[dir];
		const int nx = cx + dx[dir];

		if (board[ny][nx] != '#') {
			cy = ny;
			cx = nx;
		}
	}

	if (s[i] == 'v') {
		const int ny = cy + dy[dir ^ 2];
		const int nx = cx + dx[dir ^ 2];

		if (board[ny][nx] != '#') {
			cy = ny;
			cx = nx;
		}
	}

	if (s[i] == '>') {
		dir = (dir + 1) % 4;
	}

	if (s[i] == '<') {
		dir = (dir + 3) % 4;
	}

	//cerr << cy << " " << cx << endl;
}

bool condition(char c, bool flag) {
	if (cnt > limit) return false;
	const int ny = cy + dy[dir];
	const int nx = cx + dx[dir];

	bool cond;
	if (c == 'T') cond = true;
	if (c == 'N') cond = (dir == 0);
	if (c == 'E') cond = (dir == 1);
	if (c == 'S') cond = (dir == 2);
	if (c == 'W') cond = (dir == 3);
	if (c == 'C') cond = (board[ny][nx] == '#');

	if (cond)
		return flag;
	else
		return flag ^ true;
}

void program(int f, int t) {
	cnt++;
	if(cnt > limit) term = true;
	if (gy == cy and gx == cx) term = true;
	if (f >= t) return;
	if (term) return;

	if (s[f] == '[') {
		int nf = f + 1;
		bool flag = true;
		char c = s[nf++];

		if (c == '~') {
			flag = false;
			c = s[nf++];
		}

		const int nt = match[f];


		if (term == false and condition(c, flag)) {
			program(nf, nt);
		}

		program(nt + 1, t);
	} else if (s[f] == '{') {
		int nf = f + 1;

		bool flag = true;
		char c = s[nf++];

		if (c == '~') {
			flag = false;
			c = s[nf++];
		}

		const int nt = match[f];

		while (term == false and condition(c, flag)) {
			program(nf, nt);
		}

		program(nt + 1, t);
	} else {
		int nf = f + 1, nt = t;
		move(f);
		program(nf, nt);
	}
}

int main(void) {
	int h, w;
	cin >> h >> w;

	rep(i, h)rep(j, w) cin >> board[i][j];

	rep(i, h)rep(j, w) {
		if (board[i][j] == 's') {
			cy = i, cx = j, dir = 0;
		}
		if (board[i][j] == 'g') {
			gy = i, gx = j;
		}
	}


	cin >> s;
	const int n = s.size();

	stack<int> stk;
	rep(i, n) {
		if (s[i] == '[' or s[i] == '{') {
			stk.push(i);
		}

		if (s[i] == ']' or s[i] == '}') {
			int cur = stk.top();
			stk.pop();
			match[i] = cur, match[cur] = i;
		}
	}

	program(0, n);

	if(cy == gy and cx == gx)
		cout << ans << endl;
	else
		cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
int k,s,ans,x,y;
int main()
{
	cin>>k>>s;
	for(x=0;x<=k;x++)
	{
		for(y=0;y<=k;y++)
		{
			if(s-x-y<=k&&s-x-y>=0) ans++;//非负整数且小于k 
		}
	}
	cout<<ans<<endl; 
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
//#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
                        
using namespace std;
                        
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
                        
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}

#define int long long
#define ghost signed
#define left left228
#define right right228
#define prev prev228
#define list list228
#define complex complex228
#define count count228
#define sin sin228

const int N = 200 * 1000 + 228;

int n;
int t[N];

void inc(int i) {
	for (; i < n; i |= (i + 1)) ++t[i];
}

int getr(int r) {
	int res = 0;
	for (; r >= 0; r = (r & (r + 1)) - 1) res += t[r];
	return res;
}

int get(int l, int r) {
	return getr(r) - getr(l - 1);
}

int cnt[26], p[N];
bool used[N];
deque<int> poses[26];

ghost main() {
    ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	n = (int)s.size();
	for (char c : s) cnt[c - 'a'] ^= 1;
	int kek = 0;
	int symb = -1;
	for (int i = 0; i < 26; ++i) {
		kek += cnt[i];
		if (cnt[i]) {
			symb = i;
		}
	}
	if (kek > 1) {
		cout << -1 << '\n';
		return 0;
	}
	for (int i = 0; i < n; ++i) poses[s[i] - 'a'].push_back(i);
	int res = 0;
	if (kek == 1) {
		int Middle = poses[symb][(int)poses[symb].size() / 2];
		p[n / 2] = Middle;
		string t = "";
		for (int i = 0; i < n; ++i) {
			if (i != Middle) t.push_back(s[i]);
		}
		s = t;
		used[Middle] = 1;
	}
	int ptr = 0;
	for (int i = 0; i < (int)s.size(); ++i) {	
		int c = s[i] - 'a';
		if (poses[c].empty()) continue;
		if (poses[c].size() == 1) continue;
		int l = poses[c].front();
		int r = poses[c].back();
		poses[c].pop_front();
		poses[c].pop_back();
		p[ptr] = l;
		p[n - ptr -1] = r;
		++ptr;
	}
	for (int i = 0; i < n; ++i) {
		res += get(p[i], n - 1);
		inc(p[i]);
	}
	cout << res << '\n';
	return 0;
} // kek ;
// Ого! Кажетсья это $#@!







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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

constexpr int MOD = 1000000007;

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

    int h, n;
    cin >> h >> n;

    rep(i, 0, n) {
        int a;
        cin >> a;
        h -= a;
        if (h <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char S[ 200100 ];
char T[ 200100 ];


bool Chk( char A, char B )
{
int i;
char C;

	i = 0;
	while( ( C = S[ i ] ) != '\0' )
	{
		if( C == A && T[ i ] != B ) return false;
		if( C != A && T[ i ] == B ) return false;

		i++;
	}

	return true;
}

int Pos( char X )
{
int i;
char C;

	i = 0;
	while( ( C = S[ i ] ) != '\0' )
	{
		if( C == X ) return i;

		i++;
	}

	return - 1;
}

int main()
{
int i;
char C;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> S;
	cin >> T;

	for( C = 'a'; C <= 'z'; C++ )
	{
		i = Pos( C );
		if( i < 0 ) continue;

		if( ! Chk( S[ i ], T[ i ] ) )
		{
			cout << "No" << endl;

			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}






Measured memory_bytes: 640
#include<iostream>

struct Point
{
	double x;

	double y;
};

double Abs(double x)
{
	return x>=0 ? x : -x; 
}

double Square(const Point& P, const Point& Q, const Point& R)
{
	Point A = {Q.x-P.x, Q.y-P.y};

	Point B = {R.x-P.x, R.y-P.y};

	return Abs(A.x*B.y-A.y*B.x); 
}

bool JudgeS(const Point& P, const Point& Q, const Point R, const Point O)//P,Q,R,Sが四角形になる准に
{
	return (Square(P, Q, R) > Square(O, P, Q) + Square(Q, R, O));
}

int main()
{
	Point A, B, C, D;

	char c;

	while(std::cin >> A.x >> c >> A.y >> c >> B.x >> c >> B.y >> c 
			>> C.x >> c >> C.y >> c >> D.x >> c >> D.y)
	{
		if(JudgeS(A,B,C,D) || JudgeS(B,C,D,A) || JudgeS(C,D,A,B) || JudgeS(D,A,B,C))
		{
			std::cout << "NO\n";
		}
		else
		{
			std::cout << "YES\n";
		}
	}
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    cin >> N;
    vector<ll> H(N);
    rep(i, N) cin >> H[i];
    ll maxi = 0;
    ll ans = 0;
    iter(i, H) {
        if(i >= maxi) {
            maxi = i;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3540
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  a,b:Integer;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Read(a);
    Readln(b);

    if a=1 then
      a:=14;
    if b=1 then
      b:=14;

    if a>b then
      Writeln('Alice')
    else if a=b then
      Writeln('Draw')
    else
      Writeln('Bob');
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 128
import java.util.*;
public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int i = 1000;
    while (N > 0) {
    	N -= i;
    }
    System.out.println(Math.abs(N));
  }
}

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

using namespace std;

#define int long long
int const maxn = 2e5 + 5;
int a[maxn];
int inf = 1e18 + 1;

int cnt(int x, int n) {
    int sum = 0, mid = x;
    for (int i = 1; i <= n; ++i) {
        if (a[i] == 0) {
            if (mid >= 0) sum += (n - i);
        }
        else {
            if (a[i] > 0) {
                int L = i, R = n + 1;
                while (R - L > 1) {
                    int M = (R + L) / 2;
                    if (a[M] * a[i] <= mid) L = M;
                    else R = M;
                }
                //cout << i << ' ' << L << endl;
                sum += (L - i);
            }
            else {
                int L = i, R = n + 1;
                while (R - L > 1) {
                    int M = (R + L) / 2;
                    if (a[M] * a[i] <= mid) R = M;
                    else L = M;
                }
                sum += (n + 1 - R);
            }
        }
        //cout << i << ' ' << cnt << endl;
    }
    return sum;
}

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    sort(a + 1, a + n + 1);
    int lef = -inf, righ = inf;
    //cout << cnt(0, n) << endl;
    //return 0;
    while (righ - lef > 1) {
        int mid = (righ + lef) / 2;
        if (cnt(mid, n) < k) lef = mid;
        else righ = mid;
    }
    cout << righ << endl;
    return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <vector>
    
int main(){
    u_int a;    // width
    u_int b;    // height
    while(std::cin >> a >> b){
        if(a == 0 && b == 0){
            break;
        }
           
        // initialization
        std::vector<std::vector<u_int>> path(a+1, std::vector<u_int>(b+1, 1));
           
        // construction
        u_int n;
        std::cin >> n;
        for(u_int i = 0; i < n; ++i){
            u_int x, y;
            std::cin >> x >> y;
            path[x][y] = 0;
        }
           
        // out path
        for(u_int i = 0; i < a+1; ++i) path[i][0] = 0;
        for(u_int i = 0; i < b+1; ++i) path[0][i] = 0;
           
        // calc the number of path
        for(u_int x = 1; x <= a; ++x){
            for(u_int y = 1; y <= b; ++y){
                if(path[x][y] != 0 && !(x == 1 && y == 1)){
                    path[x][y] = path[x-1][y] + path[x][y-1];
                }
            }
        }
           
        std::cout << path[a][b] << std::endl;
            
    }
    return 0;
}


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

int main(){
  int N, d;
  cin >> N;
  vector<int> num(110);
  rep(i, N) {
    cin >> d;
    num[d]++;
  }
  
  int ans = 0; 
  rep(i, 100){
    if(num[i+1]) ans++; 
  }
  
  cout << ans << endl;

}


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


using namespace std;


int main(){
    vector<int> lowv;
    vector<int> midv;
    vector<int> highv;
    int N,A,B;
    cin >> N >> A >> B;
    for(int i=0;i<N;i++){
        int ipt;
        cin >> ipt;
        if(ipt<=A){
            lowv.push_back(ipt);
        }else if(ipt <= B){
            midv.push_back(ipt);
        }else highv.push_back(ipt);
    }

    int cnt=0;

    while(lowv.size()>0&&midv.size()>0&&highv.size()>0){
        lowv.pop_back();midv.pop_back();highv.pop_back();
        cnt++;
    }
    cout << cnt << endl;




    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int a,b;
    cin >> a >> b;
    cout<<(a-1)*(b-1)<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

struct MaxThree {
  priority_queue<int> que;

  void add(int x){
    que.push(x);
  }

  ll get(){
    int a = 0, b = 0, c = 0;
    if(!que.empty()){
      a = que.top(); que.pop();
    }
    if(!que.empty()){
      b = que.top(); que.pop();
    }
    if(!que.empty()){
      c = que.top(); que.pop();
    }
    ll ret = (ll)a + (ll)b + (ll)c;
    que.push(a);
    que.push(b);
    que.push(c);
    return ret;
  }
};


int R, C, K;
int field[3005][3005];

ll dp[3005][3005];


int main(){
  cin >> R >> C >> K;
  rep(i,K){
    int r, c, v;
    cin >> r >> c >> v;
    r--;
    c--;
    field[r][c] = v;
  }

  {
    MaxThree maxthree;
    for(int j=C-1; j>=0; j--){
      maxthree.add(field[R-1][j]);
      dp[R-1][j] = maxthree.get();
    }
  }
  
  for(int i=R-2; i>=0; i--){
    vector<vector<ll>> dp2(4, vector<ll>(C+10, -1));

    dp2[0][C-1] = dp[i+1][C-1];
    dp2[1][C-1] = field[i][C-1] + dp[i+1][C-1];
    for(int j=C-2; j>=0; j--){
      dp2[0][j] = dp[i+1][j];
      dp2[1][j] = field[i][j] + dp[i+1][j];

      rep(jj,4){
        if(dp2[jj][j+1]>=0) dp2[jj][j] = max(dp2[jj][j], dp2[jj][j+1]);
      }
      REP(jj,1,4){
        if(dp2[jj-1][j+1]>=0) dp2[jj][j] = max(dp2[jj][j], field[i][j] + dp2[jj-1][j+1]);
      }
    }
    
    rep(j,C){
      rep(jj,4){
        dp[i][j] = max(dp[i][j], dp2[jj][j]);
      }
    }
  }

  cout << dp[0][0] << endl;

  
  return 0;
}


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

int main() {
  string n;
  cin >> n;
  for (int i=0; i<n.length(); i++) {
    if (n[i] == '9') {
      n[i] = '1';
        } else {
      n[i]='9';
    }
  }
  cout <<n<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
using namespace std;
int a[505][505];
int ap[505],p[505],del[505];
int n,m,i,j,ans;
bool check(int val)
{
    for(i=1;i<=m;i++)
        ap[i]=del[i]=0;
    for(i=1;i<=n;i++)
    {
        p[i]=1;
        ap[a[i][1]]++;
    }
    bool ok=1;
    while(ok)
    {
        ok=0;
        for(i=1;i<=m;i++)
            if(ap[i]>val)
              del[i]=1,ap[i]=0,ok=1;
        for(i=1;i<=n;i++)
            if(del[a[i][p[i]]])
        {
            while(p[i]<=m&&del[a[i][p[i]]])
                p[i]++;
            ap[a[i][p[i]]]++;
        }
    }
    return (p[1]<=m);
}
int main()
{
    //freopen("data.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin>>n>>m;
    for(i=1;i<=n;i++)
        for(j=1;j<=m;j++)
           cin>>a[i][j];
    ans=511;
    for(int p=8;p>=0;p--)
        if(check(ans-(1<<p)))
           ans-=(1<<p);
    cout<<ans;
    return 0;
}


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

using namespace std;
int main(){
    int a[26];
    memset(a,0,sizeof(a));
    string s;
    cin>>s;
    for(int i=0;i<4;i++){
        a[s[i]-'A']++;
    }
    int num=0;
    for(int i=0;i<26;i++){
       // cout<<i<<' '<<a[i]<<endl;
        if(a[i]==2){
            num++;
        }
    }
    if(num==2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
int main(){
 string A,B,C; cin >> A >> B >> C;
  if( A.back() == B.front() && B.back() == C.front()){ cout << "YES" << endl;}
  else{ cout << "NO" << endl;}
  
  return 0;
}

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

int n;
long long int a[1001];

int main(){
  while(cin>>n&&n){

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

    long long int ans = 1000001;

    for(int i = 0; i < n-1; ++i){
      for(int j = i + 1; j < n; ++j){
        if(ans > abs(a[j]-a[i])){
          ans = abs(a[j]-a[i]);
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3068
local n, m = io.read("*n", "*n")
local parent = {}
for i = 1, n do
  parent[i] = i
end

local function uf_findroot(idx)
  local idx_update = idx
  while parent[idx] ~= idx do
    idx = parent[idx]
  end
  while parent[idx_update] ~= idx do
    parent[idx_update], idx_update = idx, parent[idx_update]
  end
  return idx
end

for i = 1, m do
  local a, b = io.read("*n", "*n")
  local ra, rb = uf_findroot(a), uf_findroot(b)
  parent[rb], parent[b] = ra, ra
end
local map = {}
for i = 1, n do
  local r = uf_findroot(i)
  if not map[r] then map[r] = 1
  else map[r] = map[r] + 1
  end
end
local max = 0
for _k, v in pairs(map) do
  max = max < v and v or max
end
print(max)

Measured memory_bytes: 12472
/*
....................../´¯/)
....................,/¯../
.................../..../
............./´¯/'...'/´¯¯`·¸
........../'/.../..../......./¨¯\
........('(...´...´.... ¯~/'...')
.........\.................'...../
..........''...\.......... _.·´
............\..............(
..............\.............\...
*/


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define ye cout<<"YES";
#define no cout<<"NO";
#define ln cout<<"\n";
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define pi 3.14159265358979323846
// cout<<"Case #"<<ts<<": “;
//priority_queue < pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;


using namespace std;

ll mod(ll x, ll m) {
	return (x % m + m) % m;
}

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

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

	ll t = 1, r, n, a, d, c, b, x, y, sum, cnt, i, j, k, m, l, q, maxx, minn, temp, ans, flag, g, ts;
	ll mod = 1000000007;
	char ch, chh;
	double dans;
	string str, ttr;

	//cin >> t;


	for (ts = 1; ts <= t; ts++)
	{
		flag = 0; sum = 0; cnt = 0; ans = 0; k = 0; maxx = 0; minn = 0; a = 0; b = 0; temp = 0;

		cin >> n;
		ll arr[n]; for (i = 0; i < n; i++) {cin >> arr[i];}

		for (i = 0; i < n; i++)
		{
			maxx = max(maxx, arr[i]);

			if (arr[i] < maxx)
				ans += (maxx - arr[i]);
		}

		cout << ans;




		ln
	}
	return 0;
}


Measured memory_bytes: 5220
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
using namespace std;
#define int long long
#define inf   1000000009
#define minf -1000000009

signed main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size() - 1; i++) {
		if (s[i] == 'A'&&s[i + 1] == 'C') {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
}

Measured memory_bytes: 256
n=int(input())
L=list(input())
w=0
r=0
for i in range(n):
    if L[i]=="W":
        w+=1
    else:
        r+=1
s2=w
s1=r
s3=0
for i in range(r):
    if L[i]=="W":
        s3+=1
print(min(s1,s2,s3))

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

int mod3(int N, int M) {

}

int main(){
  int N, K;
  char S[10];
  cin >> N;
  cin >> S;
  cin >> K;
  char a;
  a = S[K-1];
  int i;
  for(i = 0;S[i];i++){
  	if(S[i] != a)
  		S[i] = '*';
  }
  for(i = 0;S[i];i++){
  	cout << S[i];
  }
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		int highest = 0;
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			int h = sc.nextInt();
			if (h >= highest) cnt++;
			highest = Math.max(highest, h);
		}
		
		System.out.println(cnt);
		
		sc.close();
	}
	
}




Measured memory_bytes: 26992
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll x,a,b;cin>>x>>a>>b;
    if(abs(x-a)<abs(x-b)){
        cout<<"A"<<endl;
    }else{
        cout<<"B"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 1000000000000000005
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	printf("%d\n",min(a,b)+min(c,d));
}


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

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    map<vector<int>, int> mp;
    for(int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        vector<int> cnt(26, 0);
        for(char c : s) {
            cnt[c - 'a']++;
        }
        mp[cnt] += 1;
    }
    long long ans = 0;
    for(auto & x : mp) {
        ans += 1ll * x.second * (x.second - 1) / 2;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 19072