akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define endl '\n'
#define x first
#define y second
#define ii pair<int, int>
#define mp make_pair
#define pb push_back
#define vii vector<ii>
#define vi vector<int>
#define vvi vector<vi>
#define INF int(1e9)
#define TAM int(2e5)
#define LL long long int 

using namespace std;

int n;
string str;

map<pair<char, char>, vector<ii> > mapa;

LL solve(vi R, vi G, vi B){
    LL ans = 0;

    for(int i : R){
        //cout << i << endl;

        for(int j : G){
            if(j<i)
                continue;

            int init = lower_bound(B.begin(), B.end(), j+1)-B.begin();
            int k = lower_bound(B.begin(), B.end(), j+(j-i))-B.begin();

            //cout << init << " " << k << endl;
            if(init==B.size())
                continue;
            
            if(k==B.size())
                k = B.size()-1;
            //cout << i << " " << j << " "<< B[init] << " " << B[k] << endl;
            if(B[k]-j==j-i)
                ans+=(k-init)+(B.size()-k-1);
            else ans+=B.size()-init;
        }
    }

    return ans;
}
int main () {
    ios_base::sync_with_stdio(false);

    vector<int> R, G, B;

    cin >> n >> str;

    for(int i=0; i<n; i++){
        if(str[i]=='R') R.pb(i);
        else if(str[i]=='G') G.pb(i);
        else B.pb(i);
    }

    
    LL ans = 0;

    ans+=solve(R, G, B);
    ans+=solve(R, B, G);
    ans+=solve(G, R, B);
    ans+=solve(G, B, R);
    ans+=solve(B, R, G);
    ans+=solve(B, G, R);


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

Measured memory_bytes: 3656
def _rot13(c):
    if 'A' <= c and c <= 'Z':
        # 13 文字分ずらす
        return chr((ord(c) - ord('A') + 1) % 26 + ord('A'))

    if 'a' <= c and c <= 'z':
        # 13 文字分ずらす
        return chr((ord(c) - ord('a') + 1) % 26 + ord('a'))

    # その他の文字は対象外
    return c


def rot13(s):
    # ジェネレータ内包表記で文字列に ROT13 を適用する
    g = (_rot13(c) for c in s)
    # 文字列に直す
    return ''.join(g)


a = input()
print(rot13(a))


Measured memory_bytes: 3060
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	char a[100001];
	cin>>a;
	printf("%c%d%c\n",a[0],strlen(a)-2,a[strlen(a)-1]);
	return 0;
}

Measured memory_bytes: 256
import numpy as np

n, m  = map(int, input().split())
nums  = list(map(int, input().split()))
length = len(nums)

arr = np.array([list(map(int, input().split())) for i in range(m)])
mask = arr.T[1].argsort()[::-1]
arr = arr[mask]

cnt = 0
for b, c in arr:
    nums.extend([int(c)]*b)
    cnt += b
    if cnt > length:
        break

nums = list(nums)
nums.sort(reverse=True)

print(sum(nums[:length]))

Measured memory_bytes: 41856
n,k = map(int,input().split())

if n % k == 0:
    print(0)
elif n < k:
    if n <= abs(n-k):
        print(n)
    else:
        print(abs(n-k))
else:
    n = n % k
    if n <= abs(n-k):
        print(n)
    else:
        print(abs(n-k))

Measured memory_bytes: 3064
class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        # 根への距離を管理
        self.weight = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 併合
    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            # 木の高さが同じだった場合の処理
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]
    
n,m = map(int,input().split())
lrd = [[int(i) for i in input().split()] for j in range(m)]

ki = WeightedUnionFind(n)

for i in range(m):
    if ki.same(lrd[i][0],lrd[i][1]):
        if ki.diff(lrd[i][0],lrd[i][1]) != lrd[i][2]:
            print('No')
            exit()
    else:
        ki.union(lrd[i][0],lrd[i][1],lrd[i][2])
    
print('Yes')

Measured memory_bytes: 121048
N, M = map(int, input().split())
a = []
for i in range(M):
    a.append(int(input()))

for n, i in enumerate(a):
    if n > 0:
        if (a[n] - a[n-1]) == 1:
            print(0)
            exit()

dp = [-1] * (N+2)

dp[N] = 1
dp[N+1] = 0
for i in range(M):
    dp[a[i]] = 0

for i in range(N)[::-1]:
    if dp[i] == 0:
        continue
    dp[i] = dp[i+1] + dp[i+2]


print(dp[0]%1000000007)

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


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


if __name__ == "__main__":
    main()

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

int n,a[100000],cnt;
int main(){

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

    cout<<cnt/2<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
        #include <bitset>
        #include <cassert>
        #include <chrono>
        #include <cmath>
        #include <complex>
        #include <cstdio>
        #include <cstdlib>
        #include <cstring>
        #include <ctime>
        #include <deque>
        #include <functional>
        #include <iomanip>
        #include <iostream>
        #include <iterator>
        #include <limits>
        #include <climits>
        #include <list>
        #include <map>
        #include <numeric>
        #include <queue>
        #include <random>
        #include <ratio>
        #include <set>
        #include <sstream>
        #include <stack>
        #include <string>
        #include <unordered_map>
        #include <unordered_set>
        #include <utility>
        #include <vector>
        using namespace std;
         
        typedef long long ll;
        typedef long double LD;
        #define int ll
        #define double LD
        #define pb push_back
        #define mp make_pair
        #define REP(i,n) for (int i = 0; i < n; i++)
        #define loop(i,n) for (int i = 0; i < n; i++)
        #define FOR(i,a,b) for (int i = a; i < b; i++)
        #define REPD(i,n) for (int i = n-1; i >= 0; i--)
        #define FORD(i,a,b) for (int i = a; i >= b; i--)
        #define remax(a,b) a = max(a,b)
        #define remin(a,b) a = min(a,b)
        #define mem(a, b) memset(a, b, sizeof a)
        #define append push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define print(x) cout << (x) << endl
        #define PRECISION(x) cout << fixed << setprecision(x)
        #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
        #define Test(){int t;cin >> t;for(int i=1;i<=t;i++){cout << "Case #" << i << ": ";solve();}}
        #define test(){int t; cin>>t; for(int i=1;i<=t;i++){solve();}}
        #define vi vector<int>
        #define vii vector<pair<int,int> > 
        #define vci vector<pair<char,int> >
        #define vic vector<pair<int,char> > 
        #define N 200005
        #define pb push_back
        const double PI=acos(-1);
        const int MOD = 1000000007;
        const int FMOD = 998244353;
		
		int dx[]={-1,0,0,1};
		int dy[]={0,1,-1,0};
		
		map<int,vector<int> > v1,v2;
		void solve()
		{
			int h,w,m;
	cin >> h >> w >> m;
	loop(i,m){
		int x,y;
		cin >> x >> y;
		v1[x].pb(y);
		v2[y].pb(x);
	}
	set<pair<int,int>,greater<pair<int,int> > >st;
	for(auto i : v1){
		st.insert({i.S.size(),i.F});
	}
	int ans = 0;
	for(auto x : v2){
		int cur = 0;
		for(auto j : x.S){
			int si=x.S.size();
			cur = max(cur,si+(int)v1[j].size()-1);
			st.erase({v1[j].size(),j});
		}
		if(st.empty() == 0){
		   int val = (int)x.S.size() + (st.begin()->F);
		   cur = max(cur,val);
		}
		for(auto j : x.S){
			
			st.insert({v1[j].size(),j});
		}
		ans = max(ans,cur);
	}
	cout << ans << endl;
		}
		signed main()
		{
		//	test();
		solve();
		}

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

using namespace std;

//State
//dp[i]: The win or lose state of Player-1 when there 
//are only i stones in pile

//Intialization
//dp[0] = 0 (Lose) and dp[1..N] = 0

//Transitions
//if dp[i-a[k]]=0 then dp[i]=1 for some k E [0,N-1]

//Answer
//dp[K][N-1]

int main(){
	int N, K;
	cin >> N >> K;
	vector<int> dp(K+1, 0);
	vector<int> a(N);
	for(int i=0; i<N; i++){
		cin >> a[i];
	}
	
	dp[0] = 0;
	for(int i=1; i<=K; i++){
		for(int j=0; j<N; j++){
			if(a[j]<=i && dp[i-a[j]]==0){
				dp[i] = 1;
				break;
			}
		}
	}
	
	if(dp[K]==1) cout << "First" << endl;
	else cout << "Second" << endl;

}



Measured memory_bytes: 3792
#include <stdio.h>

int main(void)
{
        int n,s;

        scanf("%d",&n);

        s=(n%100)%10;

        if(s==3) printf("bon");
        else if(s==0 || s==1 || s==6 || s==8) printf("pon");
        else printf("hon");

        return 0;
}


Measured memory_bytes: 1704
import sys

def main():
    input = sys.stdin.readline
    n = int(input())
    a_list = list(map(int, input().split()))
    b_list = [0]*(n+1)
    MOD = 10**9 + 7

    for i in range(n):
        b_list[i+1] = b_list[i] + a_list[i]
    
    ans = 0
    for i in range(n):
        ai_sum = b_list[n] - b_list[i+1]
        ans += ai_sum * a_list[i]
        ans %= MOD
    print(ans)




    


if __name__ == '__main__':
    main()

Measured memory_bytes: 31460
n, m = map(int, input().split())
xyz = [list(map(int, input().split())) for i in range(n)]
l1, l2, l3, l4, l5, l6, l7, l8 = sorted(xyz, key=lambda x: x[0] + x[1] + x[2], reverse=True), sorted(xyz, key=lambda x: x[0] + x[1] - x[2], reverse=True), sorted(xyz, key=lambda x: x[0] - x[1] + x[2], reverse=True), sorted(xyz, key=lambda x: x[0] - x[1] - x[2], reverse=True), sorted(xyz, key=lambda x: -(x[0]) + x[1] + x[2], reverse=True), sorted(xyz, key=lambda x: -(x[0]) + x[1] - x[2], reverse=True), sorted(xyz, key=lambda x: -(x[0]) - x[1] + x[2], reverse=True), sorted(xyz, key=lambda x: -(x[0]) - x[1] - x[2], reverse=True)
def sum2(l):
    ans = 0
    cnt = 0
    for i in l:
        cnt += i[0]
    ans += abs(cnt)
    cnt = 0
    for i in l:
        cnt += i[1]
    ans += abs(cnt)
    cnt = 0
    for i in l:
        cnt += i[2]
    ans += abs(cnt)
    return ans
print(max(sum2(l1[:m]),sum2(l2[:m]),sum2(l3[:m]),sum2(l4[:m]),sum2(l5[:m]),sum2(l6[:m]),sum2(l7[:m]),sum2(l8[:m]),))

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

int main()
{
  string s;
  cin>>s;
  int rock=0;
  int paper=0;
  string str="";
  int count=0;
  for(int i=0;i<s.length();i++)
  {
    if(s[i]=='g'){
    if(paper<rock)
    {
      str+='p';
     // count++;
      paper++;
    }
    else
    {
      str+='g';
     // count--;
      rock++;
    }
    }
    else
    {
        if(paper<rock)
    {
      str+='p';
          //count++;
          paper++;
    }
    else
    {
      str+='g';
     // count--;
      rock++;
    }
    }

  }
  //cout<<str;
  for(int i=0;i<str.length();i++)
  {
      if(s[i]=='p' && str[i]=='g')
       count--;
      else if(s[i]=='g' && str[i]=='p')
        count++;
      else
      {

      }

  }
  cout<<count;
  return 0;
}


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

const int INF = INT_MAX / 2;

int N, A, B, C;
vector<int> l;

int dfs(int p, int a=0, int b=0, int c=0){
    if(p==N){
        if(a==0 || b==0 || c==0) return INF;
        return abs(a-A) + abs(b-B) + abs(c-C) -30;
    }
    vector<int> m(4);
    m[0] = dfs(p+1, a,      b,      c);
    m[1] = dfs(p+1, a+l[p], b,      c)      + 10;
    m[2] = dfs(p+1, a,      b+l[p], c)      + 10;
    m[3] = dfs(p+1, a,      b,      c+l[p]) + 10;

    return *min_element(m.begin(), m.end());
}

int main(){
    cin >> N >> A >> B >> C;
    l.resize(N);
    for (int i = 0; i < N; i++) cin >> l[i]; 
    cout << dfs(0) << endl;
}

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();
		long count = 1;
		long p = 1;
		for (int i = 1; i <= n; i++) {
			count = count * i % 1000000007;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 35664
using System;
class ProgramC
    {
        static void Main(string[] args)
        {
            
            //入力
            string[] input = Console.ReadLine().Split(' ');
            long a = long.Parse(input[0]);
            long b = long.Parse(input[1]);
            long c = long.Parse(input[2]);
            
            long left = c - a - b;
            long right = 4 * a* b;

            if(left <= 0)
            {
                Console.WriteLine("No");
                return;
            }
            
            //答え出力
            if(left * left > right)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        } 
    } 

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

using ll = long long;

ll S[200001];

int main() {
    ll N, K;
    cin >> N >> K;

    S[0] = 0;

    for (ll i = 1; i <= N; ++i) {
        ll a;
        cin >> a;
        S[i] = S[i - 1] + a;
    }

    for (ll i = 1; i <= N; ++i) {
        S[i] = (S[i] - i) % K;
    }

    unordered_map<ll, ll> M;
    ll ans = 0;

    for (ll i = 0; i <= N; ++i) {
        if (i >= K) {
            --M[S[i - K]];
        }
        ans += M[S[i]];
        ++M[S[i]];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 10056
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;
constexpr int MN = 1000001;
constexpr ll MOD = 1e9+7;

ll fact[MN] = { 1 }, ifact[MN] = { 1 };

inline ll pw(ll base, ll exp) {
	ll res = 1;
	while (exp) {
		if (exp & 1) (res *= base) %= MOD;
		exp >>= 1, (base *= base) %= MOD;
	}
	return res;
}

inline ll inv(ll x) { return pw(x, MOD - 2); }

inline ll nCr(int n, int k) { return fact[n]*ifact[k]%MOD*ifact[n-k]%MOD; }

int main() {
    if (fopen("in", "r")) freopen("in", "r", stdin), freopen("out", "w", stdout);
    ios_base::sync_with_stdio(0), cin.tie(0);

    int N; cin >> N;

    for (int i = 0; i < N; ++i) fact[i+1] = (i+1ll)*fact[i]%MOD, ifact[i+1] = inv(fact[i+1]);
    
    ll sum = 0, ans = 0;
    for (int i = N/2; i < N; ++i) {
        ll tmp = nCr(i-1, N-i-1)*fact[i]%MOD*fact[N-i-1]%MOD;
        (ans += i*(tmp-sum+MOD)) %= MOD;
        sum = tmp;
    }
    cout << ans;
}


Measured memory_bytes: 19212
S = {
	'a' => gets.chomp,
	'b' => gets.chomp,
	'c' => gets.chomp

}

player = "a"

while true do

	if S[player].empty? then
		puts player.upcase
		break;
	else
		s = S[player][0]
		S[player].slice!(0)
		player = s
		
	
	end

end

Measured memory_bytes: 1788
/*
	ITP1-2-C: Sorting Three Numbers
*/
#include	<iostream>
#include	<algorithm>

using namespace std;

int main(void) {
	int a[3];
	
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a+3);
	cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
	return 0;
}

Measured memory_bytes: 1176
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int> >v[57]; // [点] = {点,边idx}
long long dp[1<<20]; // [限制] 
int x[57]; // [边idx] = 限制bit or
// 暴力dfs 找简单路径
bool dfs(int now,int fa,int root,int pos){//当前结点，父节点，终结点，所在边编号
  if(now==root)
    return 1;
  for(auto it:v[now]){
    if(it.first!=fa&&dfs(it.first,now,root,pos)){
      x[it.second]^=1<<pos;
      return 1;
    }
  }
  return 0;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin>>n;
  for(int i=1;i<n;++i){
    int a,b;
    cin>>a>>b;
    v[a].emplace_back(b,i);
    v[b].emplace_back(a,i);
  }
  int m;
  cin>>m;
  for(int i=0;i<m;++i){
    int a,b;
    cin>>a>>b;
    dfs(a,0,b,i);//遍历a和b中间的所有结点，即遍历两点之间所有边
  }
  dp[0]=1;
  // 按边for
  for(int i=1;i<n;++i)
    for(int j=(1<<m)-1;j>=0;--j)//状压DP
      dp[j|x[i]]+=dp[j];
  cout<<dp[(1<<m)-1];
  return 0;
}


Measured memory_bytes: 8448
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=100050;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	int A,B,C;
	cin>>A>>B>>C;
	if(A==B)
		cout<<C<<endl;
	if(A==C)
		cout<<B<<endl;
	if(B==C)
		cout<<A<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int bangou(){
  
}
int main() {
  int counta=0,countb;
  int N;
  cin>>N;
  vector<int>S={1,2,3,4,5,6,7,8};
  S.resize(N);
  vector<int>P(N);
  vector<int>Q(N);
  vector<vector<int>>R;
  rep(i,N) cin>>P[i];
  rep(i,N) cin>>Q[i];
  int asunaro=1;
  for(int i=1;i<N+1;i++){
    asunaro=asunaro*i;
  }
  int osi=0;
  R.resize(asunaro);
  do {
        for (int i = 0; i < N; i++) {
            R[osi].push_back(S[i]);
        }
        osi++;
    }while (next_permutation(S.begin(),S.end()));
  rep(i,asunaro){
    if(R[i]==P){
      counta=i;
    }
    if(R[i]==Q){
      countb=i;
    }
  }
  cout<<abs(countb-counta);
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
long long a[200000];
int main(){
	long long n, k;
	cin >> k >> n;
	for(long long i=0;i<n;i++)
	 cin >> a[i];
	long long md = min(a[n-1]-a[0], k-a[n-1]+a[n-2]);
	for(long long i=1;i<n-1;i++)
	{
		md = min(md, a[i]+k-a[i+1]);
		md = min(md, k-a[i]+a[i-1]);
	}
	cout << md << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;

int main(){
	int N;
	cin >> N;
	vector<pair<int,int>> A(N);//first is fin,second is time.
	rep(i,0,N){
		cin >> A[i].second >> A[i].first;
	}
	sort(all(A));
	int time=0;
	rep(i,0,N){
		time += A[i].second;
		if(time > A[i].first){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

}


Measured memory_bytes: 1792
## print(type(range(19)))
hurui = list(range(101))
hurui2 =list(range(101))
## print(hurui)
counter = 2
while True:
    if counter > 100:
        break
    if hurui[counter] != 0:
        a = counter
        while True:
            if (a + counter) > 100:
                break
            a += counter
            hurui[a] = 0
            ## print(a)
    counter += 1
## print(list(set(hurui)))
sosu = list(set(hurui))

a, b, c = list(map(int, input().strip().split()))
ansa = []
ansb = []
for i in range(1, len(hurui2)):
    if (b % hurui2[i]) == 0:
        ansb.append(hurui2[i])
    if (a % hurui2[i]) == 0:
        ansa.append(hurui2[i])
    counter += 1
ans = list(set(ansa) & set(ansb))
# print(ansa)
# print(ansb)
# print(ans)
# print(sorted(ans))
print(sorted(ans, reverse=True)[c - 1])


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

void move(int x, int y);

int main(void)
{
	int i, j;
	int a, b;
	int data[20][20];
	
	while (scanf("%d %d", &a, &b)){
		if (a == 0 && b == 0) break;
		
		for (i = 0; i < 20; i++){
			for (j = 0; j < 20; j++){
				data[i][j] = 0;
			}
		}
		
		int n, x, y;
		scanf("%d", &n);
		for (i = 0; i < n; i++){
			scanf("%d %d", &x, &y);
			data[x][y] = -1;
		}
		data[1][1] = 1;
		
		for (i = 1; i <= a; i++){
			for (j = 1; j <= b; j++){
				if (data[i + 1][j] != -1 && data[i][j] != -1){
					data[i + 1][j] += data[i][j];
				}
				if (data[i][j + 1] != -1 && data[i][j] != -1){
					data[i][j + 1] += data[i][j];
				}
			}
		}
		
		printf("%d\n", data[a][b]);
	}
	
	return (0);
}

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

#define INF (int)(1e9)
#define MOD (int)((int)1e9+7)

int main(){
  int n, m = 0;

  cin>>n;

  m += n/25;
  n -= 25*(n/25);
  
  m += n/10;
  n -= 10*(n/10);
  
  m += n/5;
  n -= 5*(n/5);
  
  m += n;
  cout<<m<<endl;
  return 0;
}


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

const int N = 1e5 + 100;

int q, l, r, cnt[N];
bool mark[N];

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	for (int i = 2; i < N; i++)
		if(mark[i] == false) {
			for (int j = i << 1; j < N; j += i)
				mark[j] = true;
		}
	for (int i = 3; i < N; i++)
		cnt[i] = cnt[i - 1] + (mark[i] == false && mark[(i + 1) >> 1] == false);
	cin >> q;
	while(q--) {
		cin >> l >> r;
		cout << cnt[r] - cnt[l - 1] << '\n';
	}
	return 0;
}

Measured memory_bytes: 1152
s = input()
cnt = [0]*26
ans = ""
if s[0] == "z":
    print(-1)
    exit(0)
for i in range(len(s)):
    if cnt[int(ord(s[i])-ord("a"))] == 1:
        min = chr(ord("z")+1)
        for j in range(26):
            if cnt[j] == 0:
                if int(ord(s[i])) < ord(chr(j+ord("a"))) < ord(min):
                    min = chr(j+ord("a"))
        ans += min
        print(ans)
        exit(0)
    else :
        ans += s[i]
        cnt[int(ord(s[i])-ord("a"))] = 1
if ans == s :
    min = chr(ord("z") + 1)
    for j in range(26):
        if cnt[j] == 0:
            if ord(chr(j+ord("a"))) < ord(min):
                min = chr(j+ord("a"))
    if min == chr(ord("z") + 1):
        if s[0] == "z":
            print(-1)
            exit(0)
        else:
            for k in range(len(s)-1,-1,-1):
                ans = ans.strip(s[k])
                cnt[int(ord(s[k])-ord("a"))] -= 1
                if ord(s[k]) > ord(s[k-1]):
                    ans = ans.strip(s[k-1])
                    min = chr(ord("z") + 1)
                    for j in range(26):
                        if cnt[j] == 0:
                            if int(ord(s[k-1])) < ord(chr(j + ord("a"))) < ord(min):
                                min = chr(j + ord("a"))
                    ans += min
                    break
    else:
        ans += min
print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <cstring>
#include <tuple>
#include <vector>
#include <map>
#include <iterator>
#include <cmath>

using namespace std;
using lint = long long int;

struct node {
	lint value = 0;
	vector<node*> children;
	node* parent = nullptr;
};



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

	node root;
	node** nd = new node*[n];
	nd[0] = &root;
	for (int i = 1; i < n; i++) {
		nd[i] = new node();
	}

	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		nd[a-1]->children.push_back(nd[b-1]);
		nd[b - 1]->parent = nd[a - 1];
	}

	vector<pair<int, int>> process;
	for (int i = 0; i < q; i++) {
		int p, q;
		cin >> p >> q;

		process.push_back(make_pair(p, q));
	}

	sort(process.begin(), process.end(),
		[](const pair<int, int>& l, const pair<int, int>& r) {
			return l.first < r.first;
		});

	int processItr = 0;
	for (int i = 0; i < n; i++) {
		while (processItr < process.size() &&
			i == process[processItr].first - 1) {
			nd[i]->value += process[processItr].second;
			processItr++;
		}
		if (nd[i]->parent != nullptr)
			nd[i]->value += nd[i]->parent->value;
	}


	cout << nd[0]->value;
	for (int i = 1; i < n; i++) {
		cout << " " << nd[i]->value;
	}

	return 0;
}



Measured memory_bytes: 21232
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();

		int c = Math.abs(b - a);
		if (c % 2 == 1) {
			System.out.println("IMPOSSIBLE");
		} else {
			System.out.println(Math.min(a, b) + c / 2);
		}
	}
}


Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int main()
{
  int n;
  cin >> n;
  int a[200000], bone = 0;
  for (int i = 0; i < n; ++i)
  {
    cin >> a[i];
    bone ^= a[i];
  }
  for (int i = 0; i < n; ++i)
  	cout << (bone ^ a[i]) << ' ';
   return 0;
}

Measured memory_bytes: 4336
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>

long long PRIME = 1e9 + 7;
using namespace std;

vector<vector<int>> E;


int main(){ 
    long long N, Ma, Mb;
    cin >> N >> Ma >> Mb;

    vector<int> a(N), b(N), c(N);

    int sum_a = 0;
    int sum_b = 0;

    for(int i = 0; i < N; ++i){
        cin >> a.at(i) >> b.at(i) >> c.at(i);
        sum_a += a[i];
        sum_b += b[i];
    }

    if(sum_a < Ma || sum_b < Mb){
        cout << -1;
        return 0;
    }

    int big = 100000;
    vector<vector<int>> table(sum_a + 1, vector<int>(sum_b + 1, big));

    table[0][0] = 0;

    for(int i = 0; i < N; ++i){
        for(int num_a = sum_a; num_a >= a[i]; --num_a){
            for(int num_b = sum_b; num_b >= b[i]; --num_b){
                if(table[num_a - a[i]][num_b - b[i]] != big){
                    table[num_a][num_b] = min<int>(table[num_a][num_b], table[num_a - a[i]][num_b - b[i]] + c[i]);
                }
            }
        }

    }


    int max_num = min<int>(sum_a / Ma, sum_b / Mb);
    int min_c = big;

    for(int i = 1; i <= max_num; ++i){
        min_c = min<int>(min_c, table[Ma * i][Mb * i]);
    }

    if(min_c == big){
        cout << -1;
    }
    else{
        cout << min_c;
    }
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N;cin>>N;
    vector<string> s(N);
    vector<int> t(N);
    REP(i,N) cin>>s[i]>>t[i];
    string X;cin>>X;
    int ans=0;
    bool flag=false;
    REP(i,N){
        if(s[i]==X){
            flag=true;
        }
        else if(flag) ans+=t[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define x first
#define y second
using namespace std;
using ll = long long;
using ld = long double;
#define int ll


const int N = 1000;
const int K = 10;
string s;
int k, d[N], dp[N][K][2];

signed main() {
#ifdef LC
    assert(freopen("input.txt", "r", stdin));
#endif
    ios::sync_with_stdio(0), cin.tie(0);
	
	cin >> s >> k;
	for (int i = 0; i < (int)s.size(); ++i) {
		d[N - 1 - i] = s[(int)s.size() - 1 - i] - '0';
	}
	dp[0][0][0] = 1;
	for (int i = 0; i < N - 1; ++i) {
		for (int j = 0; j + 1 < K; ++j) {
			for (int c = 0; c < 10; ++c) {
				if (c <= d[i + 1]) {
					dp[i + 1][j + (c != 0)][c < d[i + 1]] += dp[i][j][0];
				}
				dp[i + 1][j + (c != 0)][1] += dp[i][j][1];
			}
		}
	}
	int x = dp[N - 1][k][0], y = dp[N - 1][k][1];
	cerr << x << " " << y << endl;
	cout << x + y << endl;
	return 0;
}


Measured memory_bytes: 384
def bubbleSort(A, N):
    cnt = 0
    flag = 1
    while flag:
        flag = 0
        for j in range(N - 1, 0, -1):
            if A[j] < A[j - 1]:
                A[j], A[j - 1] = A[j - 1], A[j]
                flag = 1
                cnt = cnt + 1
    return cnt


N = int(input())
A = [int(i) for i in input().split()]
cnt = bubbleSort(A, N)
for i in range(len(A)):
    if i:
        print(" ", end = "")
    print(A[i], end = "")
print()
print(cnt)



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

int x[1005], y[1005];

int main(){
	int w, h, n;
	cin >> w >> h >> n;
	
	for(int i = 0; i < n; i++) cin >> x[i] >> y[i];
	
	int ans = 0;
	for(int i = 1; i < n; i++){
		int dx = x[i]-x[i-1];
		int dy = y[i]-y[i-1];
		if(dx*dy >= 0) ans += max(abs(dx),abs(dy));
		else ans += abs(dx)+abs(dy);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"

int main(){
  int N;
  cin>>N;
  vector<int> com(26,100);
  for(int i=0;i<N;i++){
    string S;
    cin>>S;
    vector<int> cnt(26);
    for(int j=0;j<S.size();j++)
      cnt[S[j]-'a']++;
    for(int j=0;j<26;j++)
      com[j] = min(com[j],cnt[j]);
  }
  for(int i=0;i<26;i++)
    for(int j=0;j<com[i];j++)
      putchar('a' + i);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back


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

int n;
ll a[110000],b[110000];
int la=0,lb=0;
ll ans=1;

signed main(){
  init();
  cin>>n;
  rep(i,n){
    cin>>a[i];
  }
  rep(i,n){
    cin>>b[i];
  }
  vector<ll> v(n,INF);

  rep(i,n){
    if(la<a[i]){
      v[i]=a[i];
      la=a[i];
    }
  }

  rrep(i,n-1){
    if(lb<b[i]){
      if(a[i]<b[i])
        ans = 0;
      v[i]=b[i];
      lb=b[i];
    }
  }

  if(la!=lb)
    ans = 0;

  rep(i,n){
    if(v[i]!=INF) continue;
    ans*=min(a[i],b[i]);
    ans%=M;
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int sum = 0;
		int n = 0;
		int num = 0;
		while(sc.hasNext()){
			String[] st = sc.nextLine().split(",");
			num += Integer.parseInt(st[1]);
			sum += Integer.parseInt(st[0])*Integer.parseInt(st[1]);
			n++;
		}
		System.out.println(sum);
		System.out.println((int)Math.ceil((double)num/n));
		sc.close();
	}
}

Measured memory_bytes: 17192
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main(){
	int n;
	cin>>n;
	int val = 0;
	for(int i = 1;i<=n;i++){
		int x;
		cin>>x;
		if(x != i)
			val++;
	}
	if(val ==0 || val == 2)
		cout<<"YES";
	else
		cout<<"NO";
	
	return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
struct data_set
{
	std::string str;
	int appearance, length;
	data_set(const std::string&_str)
	{
		str = _str;
		for (auto&i : str)
		{
			if ('A' <= i && i <= 'Z')
			{
				i += 'a' - 'A';
			}
		}
		appearance = 1;
		length = static_cast<int>(str.length());
	}
};
int main()
{
	std::vector<data_set>data_sets;
	std::string word;
	std::cin >> word;
	data_sets.push_back(data_set(word));
	while (std::cin >> word)
	{
		bool new_word = true;
		for (auto&i : data_sets)
		{
			new_word &= i.str != data_set(word).str;
			if (!new_word)
			{
				i.appearance++;
				break;
			}
		}
		if (new_word)
		{
			data_sets.push_back(data_set(word));
		}
	}
	int mode = 0, longest = 0, mode_i, longest_i;
	for (int i = 0; i < data_sets.size(); i++)
	{
		if (mode < data_sets[i].appearance)
		{
			mode = data_sets[i].appearance;
			mode_i = i;
		}
		if (longest < data_sets[i].length)
		{
			longest = data_sets[i].length;
			longest_i = i;
		}
	}
	std::cout << data_sets[mode_i].str << ' ' << data_sets[longest_i].str << std::endl;
	return 0;
}


Measured memory_bytes: 3132
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<cassert>
using namespace std;
int inf = 1000000000;
int n, s;

int cnt = 0;

int func(string m, vector<bool> b, int num){
  if( m.size() == n ){
    int tmp = 0;
    for(int i=0; i<n; i++) tmp += m[i]-'0';
    if( tmp == s ) cnt++;
    // if( tmp == s ) cerr << m << endl;
    return 0;
  }

  for(int i=num+1; i<10; i++){
    if( b[i] ) continue;
    b[i] = true;
    func( m + to_string(i), b, i);
    b[i] = false;
  }
  return 0;
}

int main(void) {


  while(cin >> n >> s){
    if( n == 0 && s == 0 ) break;

    vector<bool> b(10, false);
    for(int i=0; i<10; i++){
      b[i] = true;
      func(to_string(i), b, i);
      b[i] = false;
    }
    cout << cnt << endl;
    cnt = 0;
  }

  return 0;
}


// EOF

Measured memory_bytes: 3244
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			long[] a = in.nextLongArray(n);
			long[] sorta = Arrays.copyOf(a, n);

			Arrays.sort(sorta);

			long ans = 0;

			for (int i = 0; i < n; i++) {
				long idx = lowerBound(sorta, a[i]);
				if ((i % 2 == 0 && idx % 2 == 1) || (i % 2 == 1 && idx % 2 == 0)) {
					ans++;
				}
			}

			out.println(ans/2);

		}

		public static long lowerBound(long[] a, long obj) {
			long l = 0,r = a.length - 1;
			while (r - l >= 0) {
				long c = (l + r) / 2;
				if (obj <= a[(int)c]) {
					r = c - 1;
				} else {
					l = c + 1;
				}
			}
			return l;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


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

int sum,N[1000];

void tum(int a)
{
    N[++sum]=a;
    
}

int num()
{
    sum--;
    
    return N[sum+1];
}


int main()
{
    int i,j;
    sum = 0;
    char n[100];
    while(scanf("%s",n)!=EOF)
    {
        if(n[0]=='+')
        {
            i=num();
            j=num();
            tum(i+j);
        }
	else if(n[0]=='-')
        {
            j=num();
            i=num();
            tum(i-j);
        }
	else if(n[0]=='*')
        {
            i=num();
            j=num();
            tum(i*j);
        }
	else
        {
            tum(atoi(n));
        }
        
        
    }
    printf("%d\n",num());
    
    return 0;
    
}




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

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int sum = 0;
    rep(i,n){
        sum += a[i]-1;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3644
import java.util.*;
import java.lang.Math;

public class Main{



public static void main(String[] args){
Scanner scanner1 = new Scanner(System.in);
Scanner scanner2 = new Scanner(System.in);
long d=scanner1.nextLong();
long t=scanner1.nextLong();
long s=scanner1.nextLong();

if(d>t*s) {System.out.println("No");}
else{System.out.println("Yes");}



}
}

Measured memory_bytes: 35632
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        // 宣言
        Scanner sc = new Scanner(System.in);
        // 入力値取得
        int a = sc.nextInt();
        int b = sc.nextInt() * 2;
        
        int ans = a - b;
        
        // ans < 0 の場合0を代入
        if(ans < 0){
            ans = 0;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21972
n = int(input())
while n!=0 :
    conv = dict()
    for i in range(n):
        k,v = input().split()
        conv[k] = v
    out = ""
    n2 = int(input())
    for i in range(n2):
        befo = input()[0]
        if (befo in conv.keys()):
            befo = conv[befo]
        out += befo
    print(out)
    n = int(input())
    


Measured memory_bytes: 5708
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<int,int> P;
typedef struct pair<int,P> P2;

const ll INF=100000000001;
int main() {

	int n,m;
	cin>>n>>m;
	int a[50];
	int b[50];
	for(int i=0;i<m;i++)cin>>a[i]>>b[i];
	int total=0;
	for(int i=0;i<m;i++){
		bool d[50][50]={};
		bool flg=true;
		for(int j=0;j<m;++j){
			if(i!=j){
				d[a[j]-1][b[j]-1]=true;
				d[b[j]-1][a[j]-1]=true;
			}
		}
		while(flg){
			flg=false;
			for(int i=0;i<n;++i){
				for(int j=0;j<n;++j){
					for(int k=0;k<n;++k){
						if(((i!=j)&&!d[i][j])&&(d[i][k]&&d[k][j])){
							d[i][j]=true;
							flg=true;
						}

					}
				}
			}
		}
		for(int i=0;i<n;++i){
			for(int j=0;j<n;++j){
				if((i!=j)&&!d[i][j])flg=true;
			}
		}
		if(flg)total++;
	}
	cout<<total<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        string[] n=System.Console.ReadLine().Split(' ');
        string m=n[0]+n[1];
        int x=int.Parse(m);
        double y=Math.Sqrt((double)(x));
        if(y==(int)y)
        System.Console.WriteLine("Yes");
        else
        System.Console.WriteLine("No");
    }
}

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

int main(){
    
string s ;
cin>>s;
string a[3] = {"Sunny" ,"Cloudy", "Rainy"};
for(int i = 0 ; i < 3 ; i++){
    
    if(a[i] == s){
        cout<<a[(i+1)%3]<<endl;
    }
}
return 0;

}



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

int *n;
int ans=0;
int N,i;

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

	sort(n,n+N);

	while(i<N){
		int cnt=0,next=n[i];
		while(i<N && n[i]==next){
			cnt++;
			i++;
		}
		ans+=cnt%2;
	}

	cout<<ans<<endl;
	delete[]n;
	return 0;
}

Measured memory_bytes: 640
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Fri Dec 28 23:34:29 2018
//
package main

import "fmt"

func main() {
	var A, B int
	fmt.Scan(&A, &B)

	grid := make([][]string, 100)
	for i := range grid {
		grid[i] = make([]string, 100)
		if i < 50 {
			for j := range grid[i] {
				grid[i][j] = "."
			}
		} else {
			for j := range grid[i] {
				grid[i][j] = "#"
			}
		}
	}

	for i := 0; i < B-1; i++ {
		a := 2 * (i / 50)
		b := (i % 50) * 2
		grid[a][b] = "#"
	}

	for i := 0; i < A-1; i++ {
		a := 2*(i/50) + 51
		b := (i % 50) * 2
		grid[a][b] = "."
	}

	fmt.Println(100, 100)
	for i := range grid {
		for j := range grid[i] {
			fmt.Print(grid[i][j])
		}
		fmt.Println()
	}
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,ans1=0;
    cin>>a>>b>>c;
    if (a==5) ans1++;
    if (b==5) ans1++;
    if (c==5) ans1++;
    if (ans1==2) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

  int n,ans=0;
  cin>>n;
  vector<int> x(n);

  arep(i,x) cin>>i,ans^=i;

  rep(i,0,n) cout<<(ans^x[i])<<' ';
  cout<<'\n';
  return 0;
}

Measured memory_bytes: 4752
S = list(input())
yymm=False
mmyy=False

if 0 < int("".join(S[2:])) <= 12:
    yymm = True

if 0 < int("".join(S[:2])) <= 12:
    mmyy = True

if yymm and not mmyy:
    print("YYMM")
elif not yymm and mmyy:
    print("MMYY")
elif yymm and mmyy:
    print("AMBIGUOUS")
else:
    print("NA")

Measured memory_bytes: 3060
//Shivam gupta (Codeforces handle : shivam_1999)

#include <bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define ll long long
#define ld long double
typedef vector<long long> vi;
typedef vector<vi> vvi;
typedef pair<long long, long long> pii;
typedef vector<pair<long long, long long>> vpii;
typedef map<long long, long long> mii;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(x) x.begin(), x.end()
#define sorta(x) sort(x.begin(),x.end())
#define sortd(v) sort(all(v), greater<ll>())
#define el cout << endl;
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define cpresent(container, element) (find(all(container), element) != container.end())
#define deb(x) cout << #x << x << endl;
#define fl(i,n) for(ll i=0;i<n;i++)
#define fls(i,x,n) for(ll i=x;i<n;i++)
#define flr(i,n)  for(ll i=n-1;i>=0;i--)
#define fla(i,v)  for(auto i:v)    
#define in(v) for(auto &i:v){cin>>i;}
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define tt    \
    int T;    \
    cin >> T; \
    while (T--)


int main()
{   fast
    ll n,k;
    cin >> n >> k;
    vi v(n);
    in(v)
    if(k>=n){
        cout << v[n - 1] - v[0] << endl;
    }
    else{
    vi dp(n, 0);
    fls(i,1,k){
        dp[i] = INT_MAX;
        fls(j,1,i+1){
            dp[i] = min(dp[i - j] + abs(v[i] - v[i - j]), dp[i]);
        }
    }
    fls(i,k,n){
        dp[i] = INT_MAX;
        fls(j,1,k+1){
            dp[i] = min(dp[i - j] + abs(v[i] - v[i - j]), dp[i]);
        }
    }
    cout << dp[n - 1] << endl;
    }
}

Measured memory_bytes: 4768
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 10000000000
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
typedef pair<double, double> doup;

ll singleChar(string s) {
    ll i;
    for(i=0; i<s.size(); i++) {
        if(s[i]!=s[0]) {
            return 0;
        }
    }
    
    return 1;
}

int main(void) {
    ll n, k, sum=0;
    cin >> n >> k;
    p ab[n];
    ll i;
    
    for(i=0; i<n; i++) {
        cin >> ab[i].first >> ab[i].second;
    }
    sort(ab, ab+n);
    
    
    for(i=0; i<n; i++) {
        sum+=ab[i].second;
        if(k<=sum) {
            cout << ab[i].first << endl;
            return 0;
        }
        
    }
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
#include<math.h>
#define rep(i, n) for (int i=0; i<n; ++i)
using namespace std;
typedef long long ll;

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

Measured memory_bytes: 256