akhauriyash/Code-Regression huggingface dataset:
from collections import deque,defaultdict,Counter
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from bisect import bisect_left,bisect_right
from math import sqrt,gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode
import sys
sys.setrecursionlimit(10 ** 6)

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse=False):
    data.sort(key=lambda x:x[col],reverse=revese)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def mydictvaluesort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[1] )

def mydictkeysort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[0] )

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

n = I()
s = S()
t = S()

if s==t:
    print(n)
    exit()

for i in range(n):
    for j in range(n):
        if s[i:]==t[:-i]:
            print(n+i)
            exit()
print(2*n)
exit()

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

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

    for (int i = 0; i < N - 1; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            bitset<16> a(i);
            bitset<16> b(j);
            for (int k = 0; k < 16; k++)
            {
                if (a[k] != b[k])
                {
                    cout << k + 1 << " ";
                    break;
                }
            }
        }
        cout << endl;
    }
}


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

#define Int long long int
#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()

int main(){
    Int a,b,k;
    cin >> a >> b >> k;
    if(b+1-a>2*k){
        for(Int i=a;i<k+a;i++){
            cout << i << endl;
        }
        for(Int i=b-k+1;i<=b;i++){
            cout << i << endl;
        }
    }else{
        for(Int i=a;i<=b;i++){
            cout << i << endl;
        }
    }
}


Measured memory_bytes: 256
//D
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using namespace std;
const int maxn = 1e5+10;
const int maxm = 2e6+10;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> Node;
int cnt,head[maxn],dis[maxn],p[maxn];
int n,m;
bool vis[maxn];
struct Edge{
	int from,to,w,next;
	Edge(){}
	Edge(int from,int to,int w,int next):from(from),to(to),w(w),next(next){} 
}edge[maxm];
void addedge(int from,int to,int w){
	edge[cnt] = Edge(from,to,w,head[from]);
	head[from] = cnt++;
}
void BFS(){
	queue<int>q;
	q.push(1);
	dis[1] = 0;
	vis[1] = 1;
	while(!q.empty()){
		int u = q.front();
		q.pop();
		for(int i = head[u];~i;i = edge[i].next){
			int v = edge[i].to;
			if(!vis[v]){
				vis[v] = 1;
				dis[v] = dis[u]+1;
				p[v] = u;
				q.push(v);
			}
		}
	}
}
int main(){
	memset(head,-1,sizeof(head));
	int n,m;
	cin >> n >> m;
	for(int i = 1;i <= m;i++){
		int f,t;
		cin >> f >> t;
		addedge(f,t,1);
		addedge(t,f,1);
	}
	BFS();
	bool ok = 1;
	for(int i = 2;i <= n;i++)if(!p[i])ok = 0;
	if(!ok)cout << "No";
	else{
		cout << "Yes\n";
		for(int i = 2;i <= n;i++)cout << p[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 11288
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
sum=0
for b in B:
    sum+=b
for i in range(N-1):
    if A[i+1]-A[i]==1:
        sum+=C[A[i]-1]
print(sum)


Measured memory_bytes: 38448
#include <iostream>
using namespace std;
int main(void){
  int a,b,c,d;
  int sta,en;
  cin >> a >> b >> c >> d;
  if(a > c){
    sta = a;
  } else {
    sta = c;
  }
  if(b > d){
    en = d;
  } else {
    en = b;
  }
  cout << ((sta - en > 0) ? 0 : en - sta) << endl;
  return 0;
}

Measured memory_bytes: 256
/**
 * @File   : atcoder.cpp
 * @Author : pasnger 
 * @Date   : 13/9/2020, 5:10:33 pm 
 */

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

#define INF 2e18
#define int long long
#define f(i, a, b) for(int i=(a); i<(b); (i)++)
#define fe(i, a, b) for(int i=(a); i<=(b); (i)++)
#define rf(i, a, b) for(int i=(a); i>(b); (i)--)
#define rfe(i, a, b) for(int i=(a); i>=(b); (i)--)
#define ff(ele, cont) for(auto (ele): (cont))
#define pb push_back;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef set<int> si;
typedef multiset<int> msi;

const int mxn = 1e6+4;
const int mod = 1e9+7;
const double pi = acos(-1);

#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__) 
void DBG() {
  cerr << "]\n";
}
template<typename T, typename ...Args> void DBG(T first, Args... args) {
  cerr << first; if (sizeof...(args))cerr<<", "; DBG(args...);
}

/////////////////////////// GLOBAL ///////////////////////////

/////////////////////////// GLOBAL ///////////////////////////

void solve() {
  int x;
  cin>>x;
  if(x==0) cout<<1<<"\n";
  else if(x==1) cout<<0<<"\n";
}


int32_t main() {
  #ifndef ONLINE_JUDGE
  clock_t tStart = clock();
  freopen("in.txt", "r", stdin);
  //freopen("output.txt","w",stdout);
  #endif 
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  // cin >> t;
  for (int tt=1;tt<=t;tt++) {
    //cout << "Case #"<<tt<<": ";
    solve();
  }
  #ifndef ONLINE_JUDGE
    cerr << "\nRun Time -> "<<(double)(clock()-tStart)/CLOCKS_PER_SEC <<" sec\n";
  #endif
}


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

int p[20005];
int a[20005];
int b[20005];

int main()
{
    int n;
    while (scanf("%d",&n)!=EOF)
    {
        int i;
        for (i=1;i<=n;i++)
            scanf("%d",&p[i]);
        for (i=1;i<=n;i++)
        {
            a[i]=i;
            b[i]=n-i+1;
        }
        for (i=1;i<=n;i++)
        {
            a[i]*=n+3;
            b[i]*=n+3;
        }
        for (i=1;i<=n;i++)
        {
            a[p[i]]+=i;
            b[p[i]]+=i;
        }
        for (i=1;i<n;i++)
            printf("%d ",a[i]);
        printf("%d\n",a[i]);
        for (i=1;i<n;i++)
            printf("%d ",b[i]);
        printf("%d\n",b[i]);
    }
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;

/*2進数配列+1*/
vector<int> twoadd(vector<int> v, int N){
    v[N-1]+=1;
    int ind = N-1;
    int j=N-1;
    for(j=N-1;j>=1;j--){
        if(v[j]>1){
            v[j-1]+=1;
            v[j]=0;
        }
    }
    return v;
}

/*フィボナッチ*/
long long fibonatti(long long d){
    long long count = 0;
    long long f1 = 1;
    long long f2 = 1;/*ここを変える*/
    long long temp;
    if(d == 1){
        count = f1;
    }else if(d == 2){
        count = f2;
    }else if(d==0){
        count = 1;
    }else{
        for(int i=0;i<d-2;i++){
            temp = f1+f2;
            f1 = f2;
            f2 = temp;
        }
        count = temp;
    }
    return count;
}

/*最大公約数*/
unsigned long long GCD(long long L,long long R){
    if(L>R){
        long long temp=R;
        R = L;
        L = temp;
    }
    unsigned long long pp=0,ppt=0;
    unsigned long long ans=0;
    if(R%L==0){
        ans = L;
    }else{
        while(true){
            ppt = pp;
            pp=R%L;
            if(pp == 0){
                ans = ppt;
                break;
            }
            R = L;
            L = pp;
        }
    }    
    return ans;    
}

/*最小公倍数*/
unsigned long long LCM(long long L,long long R){
    unsigned long long ans;
    unsigned long long gcd = GCD(L,R);
    ans = (L/gcd)*R;
    return ans;
}

/*Combination set*/
#define mod 1000000007
#define maxcomb 3000/*大きいものを求めるときはここを変える*/
vector<long long> fc(maxcomb+1);
vector<long long> ifc(maxcomb+1);
long long modpow(long long x,long long n){
    long long ans = 1;
    while(n > 0){
        if(n & 1) {
            ans = ans*x%mod;
        }
        x = x*x%mod;
        n >>= 1;
    }
    return ans;
}
void Conb(){
    fc[0]= 1;
    ifc[0]=1;
    for(long long i=0;i<maxcomb;i++){
        fc[i+1] = fc[i]*(i+1)%mod;//n!(mod)
        ifc[i+1] = ifc[i]*modpow(i+1,mod-2)%mod;//k!^{M-2} (mod)
    }
}
unsigned long long Combination(long long L,long long R){
    unsigned long long up=1,ans;
    Conb();
    if(L==0&&R==0){
        return 1;
    }else if(L<R||L<0){
        return 0;
    }else{
        long long t = ifc[L-R]*ifc[R]%mod;
        ans = t*fc[L]%mod;
    }
    return ans;
}
/*Combination set ここまで*/

/*ここから*/
int main() {
    int r;
    cin >> r;
    cout << 3*r*r << endl;
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  bool ans = false;
  if (s[0] != s[1] && s[1] != s[2] && s[2] != s[3]) ans = true;
  if (ans) puts("Good");
  else puts("Bad");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <deque>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <climits>

using namespace std;

int main(){
    int n; cin >> n;
    string s; cin >> s;
    char prev=' ';
    int ans=0;
    for(auto c : s){
        if(c!=prev) ++ans;
        prev=c;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;

#define PI acos(-1)
typedef long long ll;
#define INF 0x3f3f3f3f
int mod = 1000000007;

int main()
{
//	freopen("in.txt", "r", stdin);
	int n;
	while (~scanf("%d", &n))
	{
		set<int>S;
		map<int, int> mp, ma, mb, mc;
			int x;

		for (int i = 0; i < n; i++)
		{
			cin >> x;
			if (S.find(x) == S.end())
				ma[x] = 0;
			S.insert(x);
			mp[x] = 1;
			ma[x]++;
		}
		for (int i = 0; i < n; i++)
		{
			cin >> x;
			if (S.find(x) == S.end())
			{
				mp[x] = 0;
				mb[x] = 0;
			}
			S.insert(x);
			mp[x] |= 1<<1;
			mb[x]++;
		}
		for (int i = 0; i < n; i++)
		{
			cin >> x;
			if (S.find(x) == S.end())
			{
				mp[x] = 0;
				mc[x] = 0;
			}
			S.insert(x);
			mp[x] |= 1<<2;
			mc[x]++;
		}
		ll a, b, c;
		a = b = c = 0;
		for (auto i : S)
		{
			if (mp[i] & (1<<2))
			{
				c += b*mc[i];
			}
			if (mp[i] & (1<<1))
			{
				b += a*mb[i];
			}
			if (mp[i] & 1)
			{
				a += ma[i];
			}
			
			
		}
		cout<<c<<endl;
	}
    return 0;
}

Measured memory_bytes: 42496
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
#define ll long long
#define INF 100000000000
#define N 10000000
using namespace std;

int main() {
    ll n,k;
    cin>>n>>k;
    ll data[n];
    ll sum=0;
    
    for (ll i=0; i<n; i++) cin>>data[i];
    
    for(ll i=1; i<n; i++){
        if (data[i-1]+data[i]>k){
            ll p=data[i-1]+data[i]-k;
            if (data[i]<p) data[i]=0;
            else data[i]-=p;
            sum+=p;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

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

    ll H, W;
    cin >> H >> W;

    auto solve = [&]() {
        ll ans = INF;
        FOR(h, 1, H) {
            ll sa = W * h;
            ll sb = W * ((H - h) / 2);
            ll sc = W * round_up(H - h, 2LL);
            ll ma = max({ sa,sb,sc });
            ll mi = min({ sa,sb,sc });
            ans = min(ans, abs(ma - mi));
            sb = (H - h) * (W / 2);
            sc = (H - h) * round_up(W, 2LL);
            ma = max({ sa,sb,sc });
            mi = min({ sa,sb,sc });
            ans = min(ans, abs(ma - mi));
        }
        return ans;
    };
    ll ans = solve();
    swap(H, W);
    ans = min(ans, solve());

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

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


def solve():
    N = Scanner.int()
    cnt = [[0 for _ in range(10)] for _ in range(10)]
    for i in range(1, N + 1):
        front = int(str(i)[0])
        back = int(str(i)[-1])
        cnt[front][back] += 1
    ans = 0
    for i in range(1, 10):
        for j in range(1, 10):
            ans += cnt[i][j] * cnt[j][i]
    print(ans)


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 10792
A, B, C, X, Y = map(int, input().split())
ans = None
for ab_count in range(0, max(X, Y) * 2 + 1, 2):
    a_count = max(0, X - ab_count // 2)
    b_count = max(0, Y - ab_count // 2)
    amount = a_count * A + b_count * B + ab_count * C
    if ans is None:
        ans = amount
    else:
        ans = min(ans, amount)
print(ans)

Measured memory_bytes: 9140
//
//AtCoder Beginner Contest 158
//D
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;

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

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    int q;
    cin >> q;

    int rf=0;   //0:normal, 1:reverce
    vector<string> sadd(2);
    REP(i, q){
        int t;
        cin >> t;
        if (t==1) {
            if (rf==0) rf=1; 
            else rf=0;
        }
        if (t==2){
            int f;
            string c;
            cin >> f >> c;
            if ((f==1) && (rf==0)) sadd[0] = c + sadd[0];
            if ((f==1) && (rf==1)) sadd[1] = sadd[1] + c;
            if ((f==2) && (rf==0)) sadd[1] = sadd[1] + c;
            if ((f==2) && (rf==1)) sadd[0] = c + sadd[0];
        }
    }
    string ans = sadd[0] + s + sadd[1];
    if (rf==1) reverse(ans.begin(), ans.end());

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


Measured memory_bytes: 4396
def main():
    #0 input
    N = int(input())
    
    minimum = 100000    

    for a in range(1, N//2 + 1):
        #1 set A and b
        b = N-a

        #2 compute sum 
        digits_sum = 0
        
        while a != 0:
            digits_sum += a%10
            a = a//10
            
        while b != 0:
            digits_sum += b%10
            b = b//10
            
        #3 check min
        if digits_sum < minimum:
            minimum = digits_sum

    print(minimum)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  string s; cin >> s;
  set<char> se{s.begin(), s.end()};
  auto ans = (se.size() == 2) ? "Yes" : "No";
  cout << ans << CRLF;

  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-922337203685
#define LL_MAX (LL)922337203685
#define PI 3.14159265359

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	int A,B,Q;
	cin >> A >> B >> Q;
	vector<LL> s,t;
	for(int i=0; i<A; i++){
		LL tmp;
		cin >> tmp;
		s.push_back(tmp);
	}
	s.push_back(LL_MIN);
	s.push_back(LL_MAX);
	s.push_back(LL_MIN);
	s.push_back(LL_MAX);
	for(int i=0; i<B; i++){
		LL tmp;
		cin >> tmp;
		t.push_back(tmp);
	}
	t.push_back(LL_MIN);
	t.push_back(LL_MAX);
	t.push_back(LL_MIN);
	t.push_back(LL_MAX);
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	for(int i=0; i<Q; i++){
		LL x;
		cin >> x;
		auto itr1 = lower_bound(s.begin(), s.end(), x);
		auto itra = itr1-1;
		auto itr2 = lower_bound(t.begin(), t.end(), x);
		auto itrb = itr2-1;
		cout << min({abs(x-*itr1)+abs(*itr1-*itr2),
			abs(x-*itr1)+abs(*itr1-*itrb),
			abs(x-*itra)+abs(*itra-*itr2),
			abs(x-*itra)+abs(*itra-*itrb),
			abs(x-*itr2)+abs(*itr2-*itr1),
			abs(x-*itr2)+abs(*itr2-*itra),
			abs(x-*itrb)+abs(*itrb-*itr1),
			abs(x-*itrb)+abs(*itrb-*itra)}) << endl;
	}

	return 0;
}

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <algorithm>

using namespace std;

int main(){
	string s;
	int n,x=0,_x=0;
	cin >> n >>s;
    vector <int> ans(n+1,0);
	for(int i=0;i<n;i++) {
        if (s[i]=='I') _x++;
        if (s[i]=='D') _x--;
        x = max(_x,x);
    }
	cout<<x;
	
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<string> S(N);
    rep(i,N) cin >> S[i];
    map<string,int> m;
    int M=0;
    rep(i,N){
        ++m[S[i]]; chmax(M,m[S[i]]);
    }
    vector<string> ans;
    for (auto x:m) if (x.second==M){
        ans.emplace_back(x.first);
    }
    sort(all(ans));
    for (auto x:ans) cout << x << endl;
}

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

int main(){
    int n, l;
    vector<string> s;
    cin>>n>>l;
    for( int i=0; i<n; i++){
        string temp;
        cin>>temp;
        s.push_back(temp);
    }

    sort(s.begin(), s.end());
    for( int i=0; i<s.size(); i++){
        cout<<s[i];
    }

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int n,k,ans;
string s;
int main(){
	cin>>n>>k;
	cin>>s;
	for(int i=0;i<s.length()-1;i++)if(s[i]==s[i+1])ans++;
	cout<<min(n-1,ans+2*k);
}

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

using namespace std;

void fastio() {
	cin.tie(nullptr);
	cin.sync_with_stdio(false);
}

using LL = long long;
using LD = long double;

const LL MOD = 1e9+7;
const LL INF = LLONG_MAX;
const LL N = 1e6+1;

int main() {
	fastio();
	
	int x;
	cin >> x;

	cout << 10-(x/200) << "\n";

}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
//#include "ext/pb_ds/assoc_container.hpp" 
//#include "ext/pb_ds/tree_policy.hpp" 
using namespace std;
//using namespace __gnu_pbds;
#define ff first
#define ss second
#define ld long double
#define ll long long int
#define ull unsigned ll
#define ins insert
#define pb emplace_back
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define pii pair<int,int> 
#define pll pair<ll , ll>
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define fo(i,a,b) for(i=a; i<b; ++i)
#define foe(i,a,b) for(i=a; i<=b; ++i)
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define per1(i,n) for(i=n;i>=1;i--)
#define mod 1000000007
#define pi 3.141592653589793238460
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0)
//#define pbds tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif


int main(){
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ll t, i, j;
    t=1;
    while(t--){
        ll ini, k, d;
        cin>>ini>>k>>d;
        if(ini<0) ini = -1LL*ini;
 		
 		ll x = ini/d;

 		if(k>=x){
 			ll rem = k-x;
 			if(rem&1) {
 				cout<<min(ini-(x*d)+d, llabs(ini - ((x+1)*d)))<<'\n';
 			}
 			else cout<<ini - (x*d)<<'\n';
 		}
 		else{
 			cout<<ini - (k*d)<<'\n';
 		}
    }
    return 0;
}







Measured memory_bytes: 3676
#define _USE_MATH_DEFINES

#include <iostream>	//cin, cout
#include <vector>	//vector
#include <algorithm> //sort,min,max,count
#include <string>	//string
#include <ios>		//fixed
#include <iomanip>	//setprecision
#include <utility> //swap
#include <cstdlib>	//abs(int)
#include <cmath>	//sqrt
#include <sstream>	//stringstream,getline
#include <cmath>	//ceil,M_PI

using namespace std;

int main() {

	string S;
	cin >> S;

	if (S == "AAA" || S == "BBB") {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;

}

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

int n,u[100005],v[100005],w[100005],d[100005]={0},i;
bool used[100005]={0};
vector<pair<int,int>> path[100005];
	
void dfs(int x){
	used[x]=true;
	for(int j=0;j<path[x].size();j++){
		if(!used[path[x][j].first]){
			d[path[x][j].first]+=d[x]+path[x][j].second;
			dfs(path[x][j].first);
		}
	}
}

int main() {
	// your code goes here
	cin >> n;
	for(i=0;i<n-1;i++) {
		cin >> u[i] >> v[i] >> w[i];
		path[u[i]].push_back(make_pair(v[i],w[i]));
		path[v[i]].push_back(make_pair(u[i],w[i]));
	}
	dfs(1);
	for(i=1;i<=n;i++){
		if(d[i]%2==0) cout << "0" << endl;
		else cout << "1" << endl;
	}
	return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long mod =1e9+7;

int main (){
 int  N,M;
  cin >> N >> M ;
  
  vector<int> oks (N+1,true);
  for(int i=0;i<M;i++){
    int a;
    cin >> a;
    oks[a] = false;
  }
  
  vector<ll>dp(N+1);
  dp[0]=1;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<=min(N,i+2);j++){
      if(oks[j]){
        dp[j]+=dp[i];
        dp[j]%=mod;
      }
    }
  }
  
  cout << dp[N] << endl;
}

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

class Main {

    private static PrintWriter out;

    private static <T> void mprintln(T... ar) {
        for (T i : ar) {
            out.print(i + " ");
        }
        out.println();
    }

    public static void main(String[] args) throws FileNotFoundException {

        // Input from file
        // File inputFile = new File("JavaFile.txt");
        // File outputFile = new File("JavaOutputFile.txt");
        // FileReader fileReader = new FileReader(inputFile);
        // Here it ends

        MyScanner sc = new MyScanner();
        // MyScanner sc = new MyScanner(fileReader);

        out = new PrintWriter(new BufferedOutputStream(System.out)); // Output to console
        // out = new PrintWriter(new PrintStream(outputFile)); // Output to file

        getAns(sc);

        out.close();
    }

    /*
     *Don't use builtin function (Math.ceil)
     */

    static final long MOD = (long) (1e9 + 7);

    private static void getAns(MyScanner sc) {
        long r = sc.nl();
        out.println(3 * r * r);
    }

    static class MyScanner {

        BufferedReader br;
        StringTokenizer st;

        MyScanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }

        MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nn() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }

        char nc() {
            return nn().charAt(0);
        }

        int ni() {
            return Integer.parseInt(nn());
        }

        long nl() {
            return Long.parseLong(nn());
        }

        double nd() {
            return Double.parseDouble(nn());
        }

        int[] niArr0(int n) {
            int[] ar = new int[n];
            for (int i = 0; i < n; i++) {
                ar[i] = ni();
            }
            return ar;
        }

        int[] niArr1(int n) {
            int[] ar = new int[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = ni();
            }
            return ar;
        }

        long[] nlArr0(int n) {
            long[] ar = new long[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nl();
            }
            return ar;
        }

        long[] nlArr1(int n) {
            long[] ar = new long[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nl();
            }
            return ar;
        }
    }
}

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

typedef long long ll;

int V, E, src, snk;
vector<int> la, nxt, oppo, capa;
void init() {
    E = 0;
    la.clear(); nxt.clear(); oppo.clear(); capa.clear();
    la = vector<int>(V, -1);
}
void add(int u, int v, int c) {
    nxt.push_back(la[u]);
    la[u] = E++;
    oppo.push_back(v);
    capa.push_back(c);
}
vector<int> dist;
queue<int> q;
bool bfs() {
    dist = vector<int>(V, -1);
    q.push(src);
    dist[src] = 0;
    while(!q.empty()) {
        int u = q.front(); q.pop();

        for(int i = la[u]; i != -1; i = nxt[i]) {
            int v = oppo[i];
            if(capa[i] && dist[v] == -1) {
                q.push(v);
                dist[v] = dist[u] + 1;
            }
        }
    }
    return dist[snk] != -1;
}
vector<int> laa;
int dfs(int u, int f) {
    if(u == snk) return f;
    for(int i = laa[u]; i != -1; i = nxt[i]) {
        laa[u] = i;
        int v = oppo[i];
        if(capa[i] && dist[v] == dist[u] + 1) {
            if(int tmp = dfs(v, min(f, capa[i]))) {
                capa[i] -= tmp;
                capa[i ^ 1] += tmp;
                return tmp;
            }
        }
    }
    return 0;
}
ll dinic() {
    ll tf = 0;
    while(bfs()) {
        laa = la;
        while(int tmp = dfs(src, 2e9)) tf += tmp;
    }
    return tf;
}

int N;
int A[111];

int main() {
    scanf("%d", &N);

    for(int i = 1; i <= N; i++) {
        scanf("%d", &A[i]);
    }

    V = N + 1 + 2, src = V - 2, snk = V - 1;
    init();

    ll tot = 0;
    for(int i = 1; i <= N; i++) {
        if(A[i] >= 0) {
            add(src, i, A[i]);
            add(i, src, 0);
            tot += A[i];
        }
        else {
            add(i, snk, -A[i]);
            add(snk, i, 0);
        }
    }
    for(int i = 1; i <= N; i++) {
        for(int j = i; j <= N; j += i) {
            add(j, i, 2e9);
            add(i, j, 0);
        }
    }
    printf("%lld", tot - dinic());
}


Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
dx = tx - sx
dy = ty - sy

# path 1
print(dy*"U" + dx*"R", end="")
# path 2
print(dy*"D" + dx*"L", end="")
# path 3
print("L" + (dy+1)*"U" + (dx+1)*"R" + "D", end="")
# path 4
print("R" + (dy+1)*"D" + (dx+1)*"L" + "U", end="")
print()

Measured memory_bytes: 9112
# 20:56-

class Integer

  # O(log n)
  # before Ruby 2.3
  def pow(n , mod = nil )
    a = self
    res = 1
    while n > 0
      if (n & 1) != 0
        res *= a
        res %= mod if mod
      end
      a *= a
      a %= mod if mod
      n >>= 1
    end
    res
  end
end

class Facts

  def initialize(mod=10**9+7, n_max=1)
    @mod = mod
    @n_max = n_max
    @fact = [1, 1]
    @inv = [0,1]
    @factinv = [1, 1]
    setup_table(n_max) if 1 < @n_max
  end

  def cmb(n,r)
    return 0 if r < 0 || n < r
    setup_table(n) if @n_max < n
    @fact[n] * (@factinv[r] * @factinv[n-r] % @mod) % @mod
  end

  def factorial(n)
    setup_table(n) if @n_max < n
    @fact[n]
  end

  # nHk
  def hom(n,k)
    cmb(n+k-1, k)
  end

  def prm(n,k)
    setup_table(n) if @n_max < n
    @fact[n] * @factinv[n-k] % @mod
  end

  def catalan_number(n)
    cmb(2 * n, n) * @inv[n+1] % @mod
  end

  private
    # O(t)
    def setup_table(t)
      (@n_max+1).upto(t) do |i|
        @fact.push( @fact[-1] * i % @mod )
        @inv.push( -@inv[@mod % i] * (@mod / i) % @mod )
        @factinv.push( @factinv[-1] * @inv[-1] % @mod )
      end
      @n_max = t
    end
end

n, r = gets.to_s.split.map{|t| t.to_i }
a    = gets.to_s.split.map{|t| t.to_i }

e = a.select(&:even?).size
o = n - e

# p [o, e]
# 奇数が奇数個あれば、奇数。
# 偶数の選び方は2^e通り。
# 
f = Facts.new

i = 0
ans = 0
while i <= n
  ans += f.cmb(o, i)
  i += 2
end

t = 2.pow(e)
ans *= t
# p [t, ans]

if r == 1
  ans = 2.pow(n) - ans
end

puts ans 

Measured memory_bytes: 1788
#include <stdio.h>
int main(){

  int n,a[100],i,j,diff;

  scanf("%d",&n);


  int k;

  for(i=0;i<n;i++) scanf("%d",&a[i]);

  for(i=0;i<n-1;i++){
    for(j=0;j<n-i-1;j++){
      if(a[j]<a[j+1]){
        k=a[j];
        a[j]=a[j+1];
        a[j+1]=k;
      }
    }
  }

  diff=a[0]-a[n-1];

  printf("%d\n",diff);

  return 0;

}



Measured memory_bytes: 128
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int m;
	int[] n, d;

	void run(){
		for(;;){
			m=sc.nextInt();
			if(m==0){
				break;
			}
			n=new int[m];
			d=new int[m];
			for(int i=0; i<m-1; i++){
				n[i]=sc.nextInt();
				d[i]=sc.nextInt();
			}
			solve();
		}
	}

	void solve(){
		int[] dx={-1, 0, 1, 0};
		int[] dy={0, 1, 0, -1};
		P[] ps=new P[m];
		ps[0]=new P(0, 0);
		P min=new P(0, 0);
		P max=new P(0, 0);
		for(int i=0; i<m-1; i++){
			ps[i+1]=new P(ps[n[i]].x+dx[d[i]], ps[n[i]].y+dy[d[i]]);
			min.x=min(min.x, ps[i+1].x);
			min.y=min(min.y, ps[i+1].y);
			max.x=max(max.x, ps[i+1].x);
			max.y=max(max.y, ps[i+1].y);
		}
		// debug(min.x, min.y, max.x, max.y);
		println((max.x-min.x+1)+" "+(max.y-min.y+1));
	}

	class P{
		int x, y;

		P(int x, int y){
			this.x=x;
			this.y=y;
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
bool vis[100001];
ll dp[100001][2];
ll mod=1e9+7;
vector < int > adj[100000+1];
ll ans=0;
void dfs(int n)
   {
      vis[n]=1;
      dp[n][0]=1;
      dp[n][1]=1;
      for(int i=0;i<adj[n].size();i++)
      {
         int ne=adj[n][i];
         if(vis[ne]==0)
         {
         dfs(ne);
         dp[n][0]=(dp[n][0]%mod*(dp[ne][0]%mod+dp[ne][1]%mod))%mod;
         dp[n][1]=(dp[n][1]%mod*dp[ne][0]%mod)%mod;

         }
      }
      return ;

   }

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

    for(int i=0;i<n-1;i++){
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    for(int i=0;i<=n;i++){
        vis[i]=false;
        dp[i][0]=0;
        dp[i][1]=0;
    }
    dfs(1);
    ll ans=dp[1][0]+dp[1][1];
    cout<<ans%mod;
}


Measured memory_bytes: 11520
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int main()
{
	ll n, x;
	cin >> n >> x;
	vector<ll> a(n);
	ll ans = 0;
	rep(i, n) cin >> a[i];
	if (a[0] > x)
	{
		ans += a[0] - x;
		a[0] = x;
	}

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

	return 0;
}

Measured memory_bytes: 4060
#include<bits/stdc++.h>
#define int long long
#define maxn 100001
using namespace std;
int n, prime[maxn], d[maxn], a[maxn], f[2001][2001], ans, cnt;
int val1[maxn], val2[maxn];
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	 
	for(int i = 2; i <= 10000; i++){
		if(!d[i] && i != 2) prime[++cnt] = i;
		for(int j = i; j <= 10000; j += i) d[j] = 1;
	}
	cin >> n; 
	if (n==2) {
  		puts("4 7");
  		puts("23 10");
  		return 0;
  	}
	  cnt = 0;
	 for(int i = 1; i <= n ; i++)
    for(int j = 1; j <= n; j++)
      if (i + j & 1) {
      	if (!val1[i - j + n]) val1[i-j+n]=prime[++cnt];
      	f[i][j]=val1[i - j + n];
	  }
  for(int i = 1; i <= n; i++)
    for(int j = 1; j <= n ; j++)
      if (i + j & 1) {
      	if (!val2[i + j]) val2[i + j]=prime[++cnt];
      	f[i][j]*=val2[i + j];
	  }
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
		{
			if(i + j & 1) continue; ans = 1;
			if(f[i - 1][j]) ans = ans / __gcd(f[i - 1][j], ans) * f[i - 1][j];
			if(f[i + 1][j]) ans = ans / __gcd(f[i + 1][j], ans) * f[i + 1][j];
			if(f[i][j + 1]) ans = ans / __gcd(f[i][j + 1], ans) * f[i][j + 1];
			if(f[i][j - 1]) ans = ans / __gcd(f[i][j - 1], ans) * f[i][j - 1];
			f[i][j] = ans + 1;
		}
	for(int i  = 1; i <= n; i++){
		for(int j = 1; j <= n; j++) printf("%lld ", f[i][j]);
		puts("");
	}
	return 0;
}


Measured memory_bytes: 13568
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <queue>

using namespace std;

#define REP(I,A,B) for(int I = (A); I < (B); ++I)
#define MAX(A,B) ((A) > (B) ? (A) : (B));

int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

int solve(char * p) {

	if (*p == '\0')
		return 0;

	int cnt = 0;
	int rst = 0;
	if (*p == 'S') {
		rst = 1;
	} else {
		cnt = 1;
	}
	while(*(++p) != '\0') {
		if (*p == 'S') {
			rst++;
		} else {
			if (rst == 0)
				cnt++;
			else
				rst--;
		}
	}

	return rst + cnt;
}

int main() {
	char * p = new char[200001];
	cin >> p;

	cout << solve(p) << endl;
	return 0;
}

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

long long memo[120000];

long long fact(long n) {
	if (n == 1 || n == 0) return 1;
	if(memo[n] != 0) return memo[n];
	memo[n] = (n * fact(n -1)) % 1000000007;
	return memo[n];
}

int main() {
	long n; cin >> n;
	for (int i = 0; i < 120000; ++i ) memo[i] =0;
	long long ret = fact(n);
	cout << ret << endl;
	return 0;
}

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


// 重み付きUnionFind
// Atcoder People on a Line で Verfty
struct WeightUnionFind {
    static const int Max = 101010;
    int par[Max];
    int ws[Max];

    void init(int n) {
        for (int i = 0; i < n; ++i) {
            par[i] = -1;
        }
    }

    int find(int x) {
        if (par[x] < 0) {
            return x;
        }
        else {
            int parent = find(par[x]);
            ws[x] += ws[par[x]];
            return par[x] = parent;
        }
    }

    int weight(int x) {
        find(x);
        return ws[x];
    }

    void unite(int x, int y, int w) {
        w += weight(x);
        w -= weight(y);
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (par[y] < par[x]) {
            int tmp = x;
            x = y;
            y = tmp;
            w = -w;
        }
        par[x] += par[y];
        par[y] = x;
        ws[y] = w;
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int diff(int x, int y) {
        if (!same(x, y)) return -1e8;
        return weight(y) - weight(x);
    }
    int size(int x) {
        return -par[find(x)];
    }
};

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

    WeightUnionFind uf;
    uf.init(n);

    rep(i, q) {
        int t, x, y, z;
        cin >> t >> x >> y;
        if (t == 0) cin >> z;

        if (t == 0) {
            uf.unite(x, y, z);
        }
        else {
            if (uf.same(x, y)) {
                cout << uf.diff(x, y) << endl;
            }
            else {
                cout << "?" << endl;
            }
        }
    }

    return 0;
}



Measured memory_bytes: 3872
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

alias Key = Tuple!(long, "a", uint, "cs");
Key[10^^3] KS;

void main()
{
    auto nm = readln.split.to!(int[]);
    auto N = nm[0];
    auto M = nm[1];
    foreach (i; 0..M) {
        auto a = readln.split.to!(long[])[0];
        uint cs;
        foreach (j; readln.split.to!(int[])) cs |= (1<<(j-1));
        KS[i] = Key(a, cs);
    }
    auto DP = new long[][](10^^3, 2^^12);

    long solve(int i, uint s) {
        if (s == (1<<N)-1) return 0;
        if (i == M) return long.min;
        if (DP[i][s] != 0) return DP[i][s];

        auto r1 = solve(i+1, s);

        if ((KS[i].cs | s) == s) {
            DP[i][s] = r1;
            return r1;
        }

        auto r2 = solve(i+1, s | KS[i].cs) + KS[i].a;

        if (r1 < 0) {
            DP[i][s] = r2;
        } else if (r2 < 0) {
            DP[i][s] = r1;
        } else {
            DP[i][s] = min(r1, r2);
        }
        return DP[i][s];
    }

    auto r = solve(0, 0);
    writeln(r < 0 ? -1 : r);
}

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

namespace Atc_0041
{
    class Program
    {
        static void Main(string[] args)
        {
            var rStr = Console.ReadLine();

            int MM1 = int.Parse(rStr.Substring(0, 2));
            int MM2 = int.Parse(rStr.Substring(2, 2));

            if ((MM1 != 0 && 13 > MM1) &&
                (MM2 != 0 && 13 > MM2))
            {
                Console.WriteLine("AMBIGUOUS");
                return;
            }

            if ((MM1 != 0 && 13 > MM1))
            {
                Console.WriteLine("MMYY");
                return;
            }

            if ((MM2 != 0 && 13 > MM2))
            {
                Console.WriteLine("YYMM");
                return;
            }

            Console.WriteLine("NA");

        }
    }
}


Measured memory_bytes: 27324
#include <string>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,h[100005];
ll dp[100005];
 
int main()  {
  int N;
  std::cin >> N;
  using namespace std;
  string s,t,u;
  cin >> s;
  cin >> t;
  cin >> u;
  
  int ans=0;
  for(int i=0;i<N;i++){
	if(s[i]==t[i] && t[i]==u[i]){
		
	}
	else if(s[i]==t[i] && t[i]!=u[i]){
		ans++;
	}
	else if(s[i]!=t[i] && t[i]==u[i]){
		ans++;
	}
	else if(t[i]!=u[i] && s[i]==u[i]){
		ans++;
		
	}
	else {
		ans++;
		ans++;
	}
  }
  printf("%d\n",ans);
  
}

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

using namespace std;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '{';
    string sep;
    for (const auto &x : v)
        os << sep << x, sep = ", ";
    return os << '}';
}
template <typename T, size_t size>
ostream &operator<<(ostream &os, const array<T, size> &arr)
{
    os << '{';
    string sep;
    for (const auto &x : arr)
        os << sep << x, sep = ", ";
    return os << '}';
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T)
{
    cerr << ' ' << H;
    dbg_out(T...);
}

// #define DEBUG
#ifdef DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main()
{
    ios::sync_with_stdio(false);
#ifndef DEBUG
    cin.tie(nullptr);
#endif

    string noun;
    cin >> noun;
    if (noun.back() == 's')
    {
        cout << noun << "es" << endl;
    }
    else
    {
        cout << noun << "s" << endl;
    }
    return 0;
}


Measured memory_bytes: 3640