akhauriyash/Code-Regression huggingface dataset:
object Main {
  def main(args: Array[String]): Unit = {
    val in:String = scala.io.StdIn.readLine();
    val inArray = in.split(" ")
    val a = inArray(0).toInt;
    val b = inArray(1).toInt;
    val area = a * b;
    val len = 2 * (a + b)
    println(area + " " + len);
  }
}

Measured memory_bytes: 43564
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

string S;

void solve(){
    cin >> S;
    int ans=0,cnt=0;
    rep(i,3){
        if(S[i]=='R') cnt+=1;
        else {
            ans=max(ans,cnt);
            cnt=0;
        }
    }
    cout << max(ans,cnt) << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 3612
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n, k;
    cin >> n >> k;

    int ans = 0;
    while (n) {
        n /= k;
        ans++;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  int n;
  cin >> n;
  
  int a[n];
  rep(i,n)cin >> a[i];
  
  int ans=0;
  int target=1;
  int pre_index=-1;
  
  rep(i,n){
    if(a[i]==target){
      ans += i - pre_index -1;
      target +=1;
      pre_index = i;
    }
  }
  
  if(target != 1)ans += n - pre_index - 1;
  
  if(ans==0 && target==1)cout << -1 << endl;
  else cout << ans << endl;
}



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

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


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

    int N,K,S; cin >> N >> K >> S;
    rep(i,K){
        cout << S << " ";
    }
    rep(i,N-K){
        if(S==1000000000){
            cout << 1 << (i==N-K-1?"":" ");
        }else {
            cout << 1000000000 << (i==N-K-1?"":" ");
        }
    }
    cout << endl;
}

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

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

using namespace std;

const int INF = 1000000005;

int main() {
  while(1){
    int n;
    cin>>n;
    if(!n)break;
    vector<string> in(n+1);
    REP(i,n) cin>>in[i+1];
    in[0] = to_string(INF);
    int upper = INF;
    int lower = -INF;
    bool ok = true;
    REP(i,n) {
      if (in[i+1] == "x") {
        if ((i+1)%2) {
          if (in[i] != "x") {
            int vp = stoi(in[i]);
            upper = min(upper, vp-1);
          } else {
            ok = false;
            break;
          }
        } else {
          if (in[i] != "x") {
            int vp = stoi(in[i]);
            lower = max(lower, vp+1);
          } else {
            ok = false;
            break;
          }
        }
      } else {
        int v = stoi(in[i+1]);
        if((i+1)%2){
          if (in[i] != "x") {
            int vp = stoi(in[i]);
            if (vp <= v) {
              ok = false;
              break;
            }
          } else {
            lower = max(lower, v+1);
          }
        } else {
          if (in[i] != "x") {
            int vp = stoi(in[i]);
            if (vp >= v) {
              ok = false;
              break;
            }
          } else {
            upper = min(upper, v-1);
          }
        }
      }
    }
    if (!ok) {
      cout << "none" << endl;
    } else if (lower == upper) {
      cout << lower << endl;
    } else if (lower > upper) {
      cout << "none" << endl;
    } else {
      cout << "ambiguous" << endl;
    }
  }
  return 0;
}

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

using namespace std;

int n;
int a[100];

vector<int> d(1e5 + 1, -1);

int fun(int k){
	if(d[k] != -1) return d[k];
	int ch = 0;
	for(int i = 0; i < n; ++i){
		if(k < a[i]) break;
		if(!fun(k - a[i])){
			ch = 1; break;
		}
	}
	d[k] = ch;
	return ch;
}


int main(){
	int k; cin >> n >> k;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	cout << (fun(k)?"First":"Second");
}

Measured memory_bytes: 8316
N = int(input())
result = 0
for i in range(9):
    if N%(i+1) == 0:
        if N/(i+1)<=9:
            print('Yes')
            result += 1
            break
        else:
            pass
    else:
        pass
if result == 0:
    print('No')
else:
    None

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a); i<=(b); i++)
#define f first
#define s second
#define mp make_pair
#define pb push_back
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;
typedef pair<pi,ll> pii;

ll fw[500111];
ll n,q,a,b;
vector<ll> x;

ll lsone(ll a){ return (a&(-a)); }

void update(ll idx, ll val){
    idx++;
    while(idx<=n){
        fw[idx]+=val;
        idx+=lsone(idx);
    }
}

ll query(ll idx){
    idx++;
    ll sum=0;
    while(idx>0){
        sum+=fw[idx];
        idx-=lsone(idx);
    }
    return sum;
}

bool comp(pii a, pii b){
    return a.f.s < b.f.s;
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> q;
    REP(i,0,n-1){
        cin >> a;
        x.pb(a);
    }
    vector<pii> queries;
    vector<ll> ans(q);
    REP(i,0,q-1){
        cin >> a >> b;
        queries.pb({{a-1,b-1},i});
    }
    sort(queries.begin(),queries.end(),comp);
    vector<ll> ind(n+1,-1);
    ll cur=0;
    REP(i,0,n-1){
        a=x[i];
        if(ind[a]!=-1) update(ind[a],-1);
        ind[a]=i;
        update(i,1);
        while(cur<q && queries[cur].f.s==i){
            pii yeah=queries[cur];
            ans[yeah.s]=query(yeah.f.s);
            if(yeah.f.f>0) ans[yeah.s]-=query(yeah.f.f-1);
            cur++;
        }
    }
    for(auto i: ans) cout << i << endl;
}

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

int main()
{
        while (1) {

        string s;
        cin >> s;
        if (s ==  "-") break;
        int n;
        cin >> n;
        for (int i = 0; i < n; ++i) {
                int tmp;
                cin >> tmp;
                string st = s.substr(0, tmp);
                string se = s.substr(tmp, s.length()-tmp);
                s = se + st;
        }
        cout << s << endl;
        }



}



Measured memory_bytes: 3196
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime>

using namespace std;

char field[11][11],field2[11][11];

int main(void){
	while(1){
		int i,j;
		bool flag=false;
		for(j=0;j<11;j++){
			for(i=0;i<11;i++){
				field[i][j]='\0';
				field2[i][j]='\0';
			}
		}
		for(i=0;i<8;i++){
			if(scanf("%s",field[i])==EOF){
				flag=true;
				break;
			}
		}
		if(flag)break;
		for(j=0;j<8;j++){
			for(i=0;i<8;i++){
				field2[i][j]=field[j][i];
			}
		}
		for(j=0;j<8;j++){
			for(i=0;i<8;i++){
				if(field2[i][j]=='1' && field2[i+1][j]=='1' && field2[i][j+1]=='1' && field2[i+1][j+1]=='1')printf("A\n");
				if(field2[i][j]=='1' && field2[i][j+1]=='1' && field2[i][j+2]=='1' && field2[i][j+3]=='1')printf("B\n");
				if(field2[i][j]=='1' && field2[i+1][j]=='1' && field2[i+2][j]=='1' && field2[i+3][j]=='1')printf("C\n");
				if(field2[i+1][j]=='1' && field2[i+1][j+1]=='1' && field2[i][j+1]=='1' && field2[i][j+2]=='1')printf("D\n");
				if(field2[i][j]=='1' && field2[i+1][j]=='1' && field2[i+1][j+1]=='1' && field2[i+2][j+1]=='1')printf("E\n");
				if(field2[i][j]=='1' && field2[i][j+1]=='1' && field2[i+1][j+1]=='1' && field2[i+1][j+2]=='1')printf("F\n");
				if(field2[i][j+1]=='1' && field2[i+1][j+1]=='1' && field2[i+1][j]=='1' && field2[i+2][j]=='1')printf("G\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include "iostream"
#include "random"
#include "string"
#include "bitset"
#include "algorithm"
#include "map"
#include "queue"
#include "list"
#include "set"
#include "climits"
#include "iomanip"
#include "stack"
#include "functional"

using namespace std;

int N, M, K, L, R, H, W;

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

	cin >> N >> M >> K;
	while (N) {
		vector<int>v(200001);
		for (int i = 1; i <= N; i++) {
			cin >> L;
			if (L >= K) {
				v[i]++;
				v[i + M]--;
			}
		}
		int ans = 0;
		for (int i = 1; i < N; i++) {
			v[i] += v[i - 1];
			if (v[i])ans++;
		}
		cout << ans << endl;
		cin >> N >> M >> K;
	}
}


Measured memory_bytes: 3912
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Comp comp=new Comp();
        int n=sc.nextInt();
        int[][] nums=new int[n][2];
        for(int i=0;i<n;i++){
            for(int j=0;j<2;j++){
                nums[i][j]=sc.nextInt();
            }
        }
        Arrays.sort(nums,comp);
        int time=0;
        for(int i=0;i<n;i++){
            time+=nums[i][0];
            if(nums[i][1]<time){
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");

    }

}
class Comp implements Comparator {

    int index = 1;


    public int compare (Object a, Object b) {
        int[] int_a = (int[]) a;
        int[] int_b = (int[]) b;
        return (int_a[index] - int_b[index]);
    }

}

Measured memory_bytes: 110788
import itertools

N, M = map(int, input().split())
G = [[]  for _ in range(N)]
for i in range(M):
    a, b = map(lambda x: int(x) - 1, input().split())
    G[a].append(b)
    G[b].append(a)
pattern = [i for i in range(N)]

ans = 0
for i in itertools.permutations(pattern):
    flag = True
    if i[0] != 0:
        continue
    for j in range(len(i) - 1):
        now = i[j]
        next = i[j+1]
        if not next in G[now]:
            flag = False
    if flag:
        ans += 1
print(ans)

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

using namespace std;

#define ll long long

int main()
{
	ll N, M;
	cin >> N >> M;
	vector < int >H(N);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	vector < int >A(M), B(M);
	for (int i = 0; i < M; i++) {
		cin >> A[i] >> B[i];
		A[i]--;
		B[i]--;
	}

	vector < set < int >>connect(N);
	for (int i = 0; i < M; i++) {
		connect[A[i]].insert(B[i]);
		connect[B[i]].insert(A[i]);
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		int highest = 0;
 for (auto c:	connect[i]) {
			highest = max(highest, H[c]);
		}
		if (highest < H[i]) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 18568
#入力
#n≦2*10^5
n, k = map(int, input().split())
P = list(map(int, input().split()))

def expectations(d:int)->float:
    return (d+1) / 2
E = list(map(expectations, P))  #Expectations list O(n)

tmp = sum(E[:k])    #temporary
ans = tmp 
for i in range(n-k+1):
    if ans < tmp:
        ans = tmp 
    else:
        pass
    if i == n-k:
        pass
    else:
        tmp -= E[i]
        tmp += E[k+i]
print(ans)

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){

    ll a, b;
    cin >> a >> b;
    if((a+b)%2) ppp("IMPOSSIBLE");
    else ppp((a+b)/2);

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<string.h>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;



int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };


int my1, my2, ene = 0;
double N = 0;
int goal[2];
int M = 0;
vector<vector<int>>MV;


void input(void) {
	
	return;
}


int main(void) {
	bool card[10] = { false };
	int sum = 0;
	int remain = 0;
	int percent = 0;

	while (CI my1 >> my2 >> ene) {
		sum += my1 + my2;
		remain = 20 - sum;
		card[my1 - 1] = true;
		card[my2 - 1] = true;
		card[ene - 1] = true;
		for (int i = 0; i < 10; i++) {
			if (card[i] == false) {
				if (i + 1 > remain) {
					percent++;
				}
			}
		}
		if (percent > 3) {
			CO "NO" E
		}
		else {
			CO "YES" E
		}
		card[my1 - 1] = false;
		card[my2 - 1] = false;
		card[ene - 1] = false;
		remain = 0;
		sum = 0;
		percent = 0;
	}

	return 0;
}

Measured memory_bytes: 3044
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, a, b = map(int, readline().split())
    h = [0] * n
    for i in range(n):
        h[i] = int(readline())

    ok = 10 ** 18
    ng = 0

    c = a - b

    while abs(ng - ok) > 1:
        mid = (ng + ok) >> 1
        cnt = 0
        for x in h:
            if x > mid * b:
                cnt += (x - mid * b + c - 1) // c
        if cnt <= mid:
            ok = mid
        else:
            ng = mid

    print(ok)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74620
//A

#include <bits/stdc++.h>

using namespace std;

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

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

	int g = gcd(360,x);
	int lcm = (x/g)*(360/g)*g;
	cout << lcm/x << endl;

	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)


int main(){
  ll N;
  cin >> N;
  for(ll h=1; h<=3500; h++){
    for(ll n=1; n<=3500; n++){
      ll tmp = 4*h*n-N*n-N*h;
      if(tmp>0){
        if((h*n*N)%tmp==0){
          cout << h << " " << n << " " << (h*n*N)/tmp << endl;
          return 0;
        }
      }
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n;i++){
    if(a[i]==k){
      cout<<"POSSIBLE"<<endl;
      return 0;
    }
  }
  sort(a,a+n);
  if(a[n-1]<k){
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
  }
  int x=a[0];
  for(int i=0;i<n;i++)
    x=__gcd(x,a[i]);
  if(k%x==0) cout<<"POSSIBLE"<<endl;
  else cout<<"IMPOSSIBLE"<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace  std;
int main(){
    int n;
    cin >> n;
    vector<int> A(n-1), ans(n);
    for(int i = 0; i < n-1; i++){
        cin >> A[i];
        ans[A[i]-1]++;
    }
    for(int i = 0; i < n; i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 4852
#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<int> G[10];
long long memo[10][1000];
long long solve(int i, int used) {
    if (memo[i][used] != -1) return memo[i][used];
    if (used == (1 << N)-1) return 1;
    long long res = 0;
    for (auto x: G[i]) {
        if ((used & (1 << x)) == 0) {
            res += solve(x, used+(1 << x));
        }
    }
    return memo[i][used] = res;
}
int main () {
    for (int i = 0; i < 10; i++)
        for (int j = 0; j < 1000; j++) 
            memo[i][j] = -1;
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    cout << solve(0, 1) << endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	int pre = n / 100;
	int suf = n % 100;
	bool isYYMM = (1 <= suf && suf <= 12);
	bool isMMYY = (1 <= pre && pre <= 12);
	if(isYYMM && isMMYY) cout << "AMBIGUOUS" << endl;
	else if(isYYMM) cout << "YYMM" << endl;
	else if(isMMYY) cout << "MMYY" << endl;
	else cout << "NA" << endl;
}

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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int n, m, a;
    while(cin>>n>>m>>a, n) {
        vector<pair<int, pair<int,int> > > vpp;
        for(int i=0; i<m; ++i) {
            int h, p, q;
            cin >> h >> p >> q;
            vpp.push_back(make_pair(h,make_pair(p,q)));
        }

        sort(vpp.begin(), vpp.end());
        reverse(vpp.begin(), vpp.end());

        int a_h = 1000;
        int a_p = a;
        for(int i=0; i<vpp.size(); ++i) {
            if(a_h>=vpp[i].first) {
                a_h = vpp[i].first;
                if(vpp[i].second.first==a_p) a_p=vpp[i].second.second;
                else if(vpp[i].second.second==a_p) a_p=vpp[i].second.first;
            }
        }
        cout << a_p << endl;
    }
    return 0;
}

Measured memory_bytes: 3052
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#define inf 0x3f3f3f3f

using namespace std;

map<pair<int, int>, bool>black;
int h, w, n, a, b;
long long ans[10];
bool vis[6][6];

int main() {
	while (scanf("%d %d %d", &h, &w, &n) != EOF) {
		memset(ans, 0LL, sizeof(ans));
		ans[0] = ((long long)h - 2) * (w - 2);
		black.clear();
		while (n--) {
			scanf("%d %d", &a, &b);
			memset(vis, false, sizeof(vis));
			for (int i = -2; i <= 2; i++) for (int j = -2; j <= 2; j++)
					vis[i + 2][j + 2] = black[make_pair(a + i, b + j)];
			if (a - 2 >= 1 && b - 2 >= 1) {	//left up
				int now = 0;
				for (int i = -2; i <= 0; i++) for (int j = -2; j <= 0; j++)
						now += vis[i+2][j+2];
				ans[now]--;
				ans[now + 1]++;
			}

			if (a + 2 <= h && b - 2 >= 1) { //left down
				int now = 0;
				for (int i = 0; i <= 2; i++) for (int j = -2; j <= 0; j++)
						now += vis[i+2][j+2];
				ans[now]--;
				ans[now + 1]++;
			}

			if (a + 2 <= h && b + 2 <= w) { //right down
				int now = 0;
				for (int i = 0; i <= 2; i++) for (int j = 0; j <= 2; j++)
						now += vis[i+2][j+2];
				ans[now]--;
				ans[now + 1]++;
			}

			if (a - 2 >= 1 && b + 2 <= w) { //right up
				int now = 0;
				for (int i = -2; i <= 0; i++) for (int j = 0; j <= 2; j++)
						now += vis[i+2][j+2];
				ans[now]--;
				ans[now + 1]++;
			}

			if (a - 2 >= 1 && b >= 2 && b <= w - 1) { // up
				int now = 0;
				for (int i = -2; i <= 0; i++) for (int j = -1; j <= 1; j++)
						now += vis[i+2][j+2];
				ans[now]--;
				ans[now + 1]++;
			}

			if (a + 2 <= h && b >= 2 && b <= w - 1) { // down
				int now = 0;
				for (int i = 0; i <= 2; i++) for (int j = -1; j <= 1; j++)
						now += vis[i+2][j+2];
				ans[now]--;
				ans[now + 1]++;
			}

			if (b + 2 <= w && a >= 2 && a <= h - 1) { // right
				int now = 0;
				for (int i = -1; i <= 1; i++) for (int j = 0; j <= 2; j++)
						now += vis[i+2][j+2];
				ans[now]--;
				ans[now + 1]++;
			}

			if (b - 2 >= 1 && a >= 2 && a <= h - 1) { // left
				int now = 0;
				for (int i = -1; i <= 1; i++) for (int j = -2; j <= 0; j++)
						now += vis[i+2][j+2];
				ans[now]--;
				ans[now + 1]++;
			}

			if (b - 1 >= 1 && b + 1 <= w && a - 1 >= 1 && a + 1 <= h) { // center
				int now = 0;
				for (int i = -1; i <= 1; i++) for (int j = -1; j <= 1; j++)
						now += vis[i+2][j+2];
				ans[now]--;
				ans[now + 1]++;
			}
			black[make_pair(a, b)] = true;
			//for (int i = 0; i < 10; i++) printf("i=%d, %lld\n", i, ans[i]);
		}
		for (int i = 0; i < 10; i++) printf("%lld\n", ans[i]);
	}
	return 0;
}


Measured memory_bytes: 156544
#include <iostream>

using namespace std;

int main(){
    int n,cost[100001],h[100001];
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>h[i];
        if(i>=1){
            cost[i]=abs(h[i]-h[i-1]);                    
        }
        if(i>=2){
            cost[i]=min(cost[i-2]+abs(h[i]-h[i-2]),cost[i-1]+abs(h[i]-h[i-1]));
        }
    }
    cout<<cost[n-1]<<"\n";
return 0;
}

Measured memory_bytes: 4348
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define maxn 150
#define ll long long
using namespace std;
struct node{
	int to;
	ll f,m;
	node*next,*rev;
}*con[maxn];
void addedge(int x,int y,ll c)
{
	node*p=new node;
	p->to=y;
	p->f=0;
	p->m=c;
	p->next=con[x];
	con[x]=p;
	p=new node;
	p->to=x;
	p->f=0;
	p->m=0;
	p->next=con[y];
	con[y]=p;
	con[x]->rev=con[y];
	con[y]->rev=con[x];
}
int s,t,n,a[maxn],de[maxn];
bool tag[maxn],vis[maxn];
int dl[maxn*1000],head,tail;
bool bfs()
{
	bool tmp=false;
	head=1;tail=0;
	memset(vis,0,sizeof(vis));
	dl[++tail]=s;vis[s]=true;de[s]=0;
	while(head<=tail)
	{
		int v=dl[head];
		if(v==t) tmp=true;
		for(node*p=con[v];p;p=p->next)
		if(!vis[p->to]&&p->f<p->m)
		dl[++tail]=p->to,de[p->to]=de[v]+1,vis[p->to]=true;
		head++;
	}
	return tmp;
}
ll dinic(int v,ll e)
{
	if(tag[v]) return 0;
	if(v==t) return e;
	ll o=0,temp=0;
	for(node*p=con[v];p&&e;p=p->next) 
	if(de[p->to]==de[v]+1&&p->f<p->m) 
	{ 
		o=dinic(p->to,min(e,p->m-p->f));
		e-=o;
		temp+=o;
		p->f+=o;
		p->rev->f-=o;
	} 
	if(temp==0) tag[v]=true;
	return temp;
} 
int main() 
{ 
	scanf("%d",&n);
	s=0;t=n+1;
	ll ans=0;
	for(int i=1;i<=n;++i)
	scanf("%d",&a[i]);
	for(int i=1;i<=n;++i)
	if(a[i]>0) addedge(s,i,(ll)a[i]),ans+=(ll)a[i];
	else 
	{
	addedge(i,t,-a[i]);
	for(int j=2;i*j<=n;j++)
		if(a[i*j]>0)
			addedge(i*j,i,(ll)0x3f3f3f3f);
	}
	while(bfs())
	{
		memset(tag,0,sizeof(tag));
		ans-=dinic(s,(ll)0x3f3f3f3f);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		Scanner scan = new java.util.Scanner(System.in);

		InputStreamReader input = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(input);

		StringBuilder sb = new StringBuilder();

		String[] intStr = br.readLine().split(" ");
		//intStr = br.readLine().split(" ");
		int[] men = new int[intStr.length];
		for (int i = 0; i < intStr.length; i++) {
			men[i] = Integer.parseInt(intStr[i]);
		}

		Dice d = new Dice(men);

		String news = br.readLine();
		char[] meirei = news.toCharArray();

		for (char c : meirei) {
			switch (c) {
				case 'S':
					d.koroS();
					break;
				case 'N':
					d.koroN();
					break;
				case 'W':
					d.koroW();
					break;
				case 'E':
					d.koroE();
					break;
			}
		}
		System.out.println(d.men[0]);
	}

}

class Dice {
	int[] men = new int[6];

	Dice(int[] men) {
		for (int i = 0; i < men.length; i++) {
			this.men[i] = men[i];
		}
	}

	void koroS() {
		int temp = this.men[0];
		men[0] = men[4];
		men[4] = men[5];
		men[5] = men[1];
		men[1] = temp;
	}

	void koroN() {
		int temp = this.men[0];
		men[0] = men[1];
		men[1] = men[5];
		men[5] = men[4];
		men[4] = temp;
	}

	void koroW() {
		int temp = this.men[0];
		men[0] = men[2];
		men[2] = men[5];
		men[5] = men[3];
		men[3] = temp;
	}

	void koroE() {
		int temp = this.men[0];
		men[0] = men[3];
		men[3] = men[5];
		men[5] = men[2];
		men[2] = temp;
	}
}

Measured memory_bytes: 26304
/**
 *    Author:   Sambhu Show(JGEC)
 *    fb    :   https://www.facebook.com/sambhu.show.98
 *              #everyday counts.....(^_^)
**/
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define itc int t;cin>>t;while(t--)
#define ltc ll t;cin>>t;while(t--)
#define ll long long int
#define ld long double
#define pb push_back
#define vll vector<ll>
#define sll set<ll>
#define mpll map<ll ,ll>
#define sortd(arr) sort(arr,arr+n,greater<ll>())
#define revs(str) reverse(str.begin(), str.end());
#define memset(arr) memset(arr,0,sizeof(arr));//array elements to 0
//-----------------------#Sambhu.98(CF)-------------------------------//
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define frr(i,a,b) for(ll i=a;i>=b;i--)
ll const inf=1e18;
//-----------------------#sambhu_98(CC)------------------------//
bool isPrime(ll n)
{   if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n % 2 == 0 or n % 3 == 0)  return false;
    ll i = 5;
    while(i * i <= n) { 
        if (n % i == 0 or n % (i + 2) == 0)  
        return false;
        i = i + 6;}
        return true; }

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

ll countDivisors(ll n) 
{ ll cnt = 0; 
    for (ll i = 1; i <= sqrt(n); i++) { 
        if (n % i == 0) { 
            if (n / i == i) 
                cnt++; 
            else  
                cnt = cnt + 2; } } 
    return cnt; }
/*/\/\/\/\/\/\/\/\/\/\/\/\//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\*/
int main()
{
ll h,n;
cin>>h>>n;
ll arr[n];
ll sum=0;
fr(i,0,n-1)
{
cin>>arr[i];
sum+=arr[i];
}
if(sum>=h)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;



return 0;
}

Measured memory_bytes: 1024
import numpy as np

N = int(input())
h = np.array(list(map(int, input().split())))

#%%
def splitter(arr):
    '''
    Split arrays into sections that contain only non-zero values.\n
    Returns a list of tuples which are (start, open-end) of sections
    '''

    L = len(arr)
    sections = []
    l,r = 0,0

    while r < L:
        if arr[r] == 0:
            if l == r:
                l += 1
                r += 1
            else:
                sections.append((l,r))
                l = r

        else:
            if r == L-1:
                r += 1
                sections.append((l,r))

            else:
                r += 1

    return sections

#%%
def watering(arr):
    '''
    arr: np.array, that can contain both zero and nonzero values
    '''

    L = len(arr)

    if L == 1:
        return arr[0]

    # split into sections that contains only nonzero
    sections = splitter(arr)

    # already only 0s
    if not sections:
        return 0

    # for each section, decrement elements by 1 then recursive call this function
    operations = 0
    for l,r in sections:
        operations +=  1 + watering(arr[l:r] - 1)

    return operations


ans = watering(h)

print(ans)

Measured memory_bytes: 15240
import sys
sys.setrecursionlimit(10**9)
n = int(input())
arr = []
for i in range(n):
    arr.append([int(i) for i in input().split()])

dp = [[-1 for i in range(n+2)] for i in range(3)]

def cal(i,action):

    if i>=len(arr):
        return 0

    if dp[action][i]==-1:
        if action==0:
            dp[action][i] = max(cal(i+1,1)+arr[i][1],cal(i+1,2)+arr[i][2])

        elif action==1:
            dp[action][i] = max(cal(i+1,0)+arr[i][0],cal(i+1,2)+arr[i][2]) 
        
        else:
            dp[action][i] = max(cal(i+1,1)+arr[i][1],cal(i+1,0)+arr[i][0])
        
    return dp[action][i]
print(max(cal(0,0),cal(0,1),cal(0,2)))

Measured memory_bytes: 112740
#include <iostream>
#include <string.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

string str;

int main() {
    cin >> str;
    int c = INF;
    int f = -1;
    for (int i = 0; i < str.size(); i++) {
        if (str[i] == 'C') {
            c = min(c, i);
        } else if (str[i] == 'F') {
            f = max(f, i);
        }
    }
    if (c < f) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
}

Measured memory_bytes: 384
package main

import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

func Solve() {
  var N, K int
  NextInt(&N, &K)
  var P, C []int
  NextIntSlice(&P)
  for i := range P { P[i]-- }
  NextIntSlice(&C)
  V := make([]int, N)
  for i := range V { V[i]-- }
  L := make([][]int, N)
  for i := range V {
    if V[i] >= 0 { continue }
    V[i] = i
    p := P[i]
    c := C[p]
    l := 1
    for p != i {
      V[p] = i
      p = P[p]
      c += C[p]
      l++
    }
    L[i] = []int{l, c}
  }
  A := make([]int, N)
  for i := range A {
    lc := L[V[i]]
    A[i] = C[P[i]]
    k := K / lc[0]
    if k > 0 { A[i] = MaxInt(k * lc[1], A[i]) }
    p := i
    c := 0
    for j := 1; j < MinInt(lc[0], K + 1); j++ {
      p = P[p]
      c += C[p]
      A[i] = MaxInt(c, A[i])
      if j <= K % lc[0] {
        A[i] = MaxInt(c + k * lc[1], A[i])
      } else if k > 0{
        A[i] = MaxInt(c + (k - 1) * lc[1], A[i])
      }
    }
  }
  Write(MaxInt(A...))
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntSlice(A *[]int) {
  L := strings.Split(NextLine(), " ")
  if len(L) == 1 && L[0] == "" {
    (*A) = make([]int, 0)
    return
  }
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatSlice(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  if len(L) == 1 && L[0] == "" {
    (*A) = make([]float64, 0)
    return
  }
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(S ...interface{}) {
  fmt.Fprintln(writer, S...)
}
func WriteIntSlice(A []int) {
  B := make([]interface{}, len(A))
  for i, a := range A { B[i] = a }
  fmt.Fprintln(writer, B...)
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}

Measured memory_bytes: 2492
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n,m,ans=0;
    cin>>n>>m;
    char a[51][51];
    int b[51][51];
    memset(a,'.',sizeof(a));
    for(int i=1; i<=n; i++)
        for(int j=1; j<=m; j++) cin>>a[i][j];
    for(int i=1; i<=n; i++)
        for(int j=1; j<=m; j++) {
            if(a[i][j]=='.') {
                if(a[i][j+1]=='#') ans++;
                if(a[i][j-1]=='#') ans++;
                if(a[i-1][j]=='#') ans++;
                if(a[i+1][j]=='#') ans++;
                if(a[i-1][j-1]=='#') ans++;
                if(a[i-1][j+1]=='#') ans++;
                if(a[i+1][j-1]=='#') ans++;
                if(a[i+1][j+1]=='#') ans++;
                b[i][j]=ans;
                ans=0;
            } else b[i][j]=-1;
        }
    for(int i=1; i<=n; i++) {
        for(int j=1; j<=m; j++) {
            if(b[i][j]==-1) cout<<"#";
            else cout<<b[i][j];
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int a,b=0,n;
	
	cin>>n;
	
	a=n%10;
	
	if(a==9){
		b=1;
	}else{
		a=n/10;
		if(a==9){
			b=1;
		} 
	}
	
	if(b==1){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 01:55:56 2020

@author: liang
"""

import math
N = int(input())
key = int(math.sqrt(N))

ans = 10**12
for i in reversed(range(1,key+1)):
    if N%i == 0:
        ans = i-1 + N//i -1
        break
print(ans)

Measured memory_bytes: 8884
n = int(input())
D = map(int, input().split())

if n % 2 != 0:
    print(0)

sorted_D = sorted(D)
left = sorted_D[int((n - 1) / 2)]
right = sorted_D[int(n / 2)]

if left == right:
    print(0)

else:
    print(right - left)


Measured memory_bytes: 14556
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <cmath>
#include <algorithm>

using namespace std;
using ll = long long;

int main() {
  ll a, b;
  cin >> a >> b;

  list<ll> vec = {1};
  int i = 2;
  while (true) {
    if (sqrt(a) + 1 < i) {
      if (a != 1)
        vec.push_back(a);
      break;
    }
    else if (a / i * i == a) {
      vec.push_back(i);
      a /= i;
    }
    else
      ++i;
  }

  for (auto itr = vec.begin(); itr != vec.end();) {
    if (b / *itr * *itr == b)
      ++itr;
    else
      itr = vec.erase(itr);
  }

  vec.erase(unique(vec.begin(), vec.end()), vec.end());

  cout << vec.size() << endl;
}

Measured memory_bytes: 3716
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int dx[] = { 1,1,0,-1,-1,-1,0,1 };
int dy[] = { 0,1,1,1,0,-1,-1,-1 };

char map[8][8];

int count(int y, int x, char my, char enemy)
{
	int cnt = 0;

	for (int i = 0; i < 8; i++) {
		int ny = y + dy[i];
		int nx = x + dx[i];
		int temp = 0;

		while (true) {
			if (ny < 0 || ny >= 8 || nx < 0 || nx >= 8) {
				break;
			}

			if (map[ny][nx] == '.') {
				break;
			}
			else if (map[ny][nx] == enemy) {
				temp++;
			}
			else if (map[ny][nx] == my) {
				cnt += temp;
				break;
			}

			ny += dy[i];
			nx += dx[i];
		}
	}

	return cnt;
}

void change(int y, int x, char my, char enemy)
{
	map[y][x] = my;

	for (int i = 0; i < 8; i++) {
		bool flag = false;
		int count = 0;
		int ny = y + dy[i];
		int nx = x + dx[i];

		while (true) {
			if (ny < 0 || ny >= 8 || nx < 0 || nx >= 8) {
				break;
			}

			if (map[ny][nx] == '.') {
				break;
			}
			else if (map[ny][nx] == enemy) {
				count++;
			}
			else if (map[ny][nx] == my) {
				flag = true;
				break;
			}

			ny += dy[i];
			nx += dx[i];
		}

		if (flag == true) {
			ny = y + dy[i];
			nx = x + dx[i];

			for (int j = 0; j < count; j++) {
				map[ny][nx] = my;
				ny += dy[i];
				nx += dx[i];
			}
		}
	}
}

bool play(char my, char enemy)
{
	bool flag = false;
	int max_change = 0;
	int puty, putx;

	if (my == 'o') {
		for (int i = 0; i < 8; i++) {
			for (int j = 0; j < 8; j++) {
				if (map[i][j] == '.') {
					int cnt = count(i, j, my, enemy);

					if (cnt > max_change) {
						max_change = cnt;
						puty = i;
						putx = j;
						flag = true;
					}
				}
			}
		}
	}
	else {
		for (int i = 7; i >= 0; i--) {
			for (int j = 7; j >= 0; j--) {
				if (map[i][j] == '.') {
					int cnt = count(i, j, my, enemy);

					if (cnt > max_change) {
						max_change = cnt;
						puty = i;
						putx = j;
						flag = true;
					}
				}
			}
		}
	}

	if (flag == true) {
		change(puty, putx, my, enemy);
	}

	return flag;
}

int main()
{
	for (int y = 0; y < 8; y++) {
		for (int x = 0; x < 8; x++) {
			cin >> map[y][x];
		}
	}

	bool mami = true;
	bool charlotte = true;

	while (mami == true || charlotte == true) {
		mami = play('o', 'x');
		charlotte = play('x', 'o');
	}


	for (int y = 0; y < 8; y++) {
		for (int x = 0; x < 8; x++) {
			cout << map[y][x];
		}
		cout << endl;
	}

	return 0;
}

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

int main () {
    int a, b;
    cin >> a >> b;
    int big=max(a, b);
    int small=min(a, b);
    string mojiretsu=to_string(small);
    if (big>small) {
        for (int i=0; i<big; i++) {
            cout << mojiretsu;
        }
    cout << endl;
    }
    else {
        for (int i=0; i<big; i++) {
            cout << mojiretsu;    
        }
    cout << endl;
    }
}    

    

    

     


Measured memory_bytes: 3664
#include <iostream>
using namespace std;
 
struct Card {
    char suit, value;
};
 
void bubble(struct Card A[], long N){
    for (long i = 0; i < N; i++){
        for (long j = N - 1; j >= i; j--){
            if (A[j].value < A[j - 1].value) swap(A[j], A[j - 1]);
        }
    }
}
 
void selection(struct Card A[], long N){
    for (long i = 0; i < N; i++){
        long minj = i;
        for (long j = i; j < N; j++) if (A[j].value < A[minj].value) minj = j;
        swap(A[i], A[minj]);
    }
}
 
void print(struct Card A[], long N){
    for (long i = 0; i < N; i++){
        if (i > 0) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}
 
bool isStable(struct Card C1[], struct Card C2[], long N){
    for (long i = 0; i < N; i++) if (C1[i].suit != C2[i].suit) return false;
    return true;
}
 
int main(){
    Card C1[100], C2[100];
     
    long N;
    cin >> N;
 
    for (long i = 0; i < N; i++) cin >> C1[i].suit >> C1[i].value;
    for (long i = 0; i < N; i++) C2[i] = C1[i];
 
    bubble(C1, N);
    selection(C2, N);
 
    print(C1, N);
    cout << "Stable" << endl;
 
    print(C2, N);
    if (isStable(C1, C2, N)) cout << "Stable" << endl;
    else cout << "Not stable" << endl;
 
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N;cin >> N;
    vector<int> V(N),P(N),Q(N);
    REP(i,N) cin >> P[i];
    REP(i,N) cin >> Q[i];
    REP(i,N) V[i] = i+1;
    int cnt = 0,Pcnt,Qcnt;
    do{
        cnt++;
        REP(i,N){
            if(V[i] != P[i]) break;
            else if(i == N - 1){
                Pcnt = cnt;
            }
        }
        REP(i,N){
            if(V[i] != Q[i]) break;
            else if(i == N - 1){
                Qcnt = cnt;
            }
        }
    }while(next_permutation(V.begin(), V.end()));
    cout << abs(Pcnt - Qcnt) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>



int main() {
  int a;
  scanf("%d ", &a);
  while (a) {
    int count = 0;
    int b = 1;
    for (int n = 100; n >=2; n--) {
      while (n*(2*b+n-1) / 2<a) {
        b++;
      }
      if (n*(2*b + n-1) / 2 == a)
        count++;

    }
    printf("%d\n", count);
    scanf("%d", &a);

  }
  return 0;
}

Measured memory_bytes: 1188
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

signed main() {
	ll n, w;

	cin >> n;

	FOR(i, 1, 3501) {
		FOR(j, 1, 3501) {
			w = n * i * j;
			if ((4 * i * j - n * i - n * j) > 0 && w % (4 * i * j - n * i - n * j) == 0) {
				cout << i << " " << j << " " << w / (4 * i * j - n * i - n * j) << endl;
				return 0;
			}
		}
	}
}

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

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

int main(){
  long N;
  cin >> N;
  cout << N*2/gcd(N,2) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
//using namespace __gnu_pbds;

#define max_(x, y) (((x) > (y)) ? (x) : (y))
#define min_(x, y) (((x) < (y)) ? (x) : (y))
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
#define Mx 200001
#define inf 1e15
const double pi = 2 * acos (0.0);

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/


typedef long long  L;
const L MOD = 1e9+7;
//typedef tree<L,null_type,less<L>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

L a1,a2,a3,b1,b2,b3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,l,m,n,m1,m2,n1,n2,o,p1,p2,p3,p4,q,q1,q2,q3,q4,r,s,t,
u,v,y,z,sum,mx=-inf,mn=inf,flg,flg1,flg2,id1,id2,id3,id4,lim;
L inv[Mx],ifact[Mx];
template<typename T, typename T1>
T mod(T x, T1 p) {
    x %= p;
    if (x < 0)
        x += p;
    return x;
}
template<typename T>
T inverse(T x, T p) {
    x = mod(x, p);
    if (x == 1)
        return x;
    return mod((1LL * (-p / x) * (inv[p % x] % p)) , p); 
    // Since inverse of p % x is already calculated.
}
L bigmod(L a,L b,L M){
    if(b==0)return 1%M;
    L x=bigmod(a,b/2,M);
    x=(x*x)%M;
    if(b%2)x=(x*a)%M;
    return x;
}

L nCr(L a,L b){
    c=1;
    r=b;
    for(L i=a;b;i--,b--){
        c=(c*(i%MOD))%MOD;
    }
    c1=ifact[r];
    c=(c*c1)%MOD;
    return c;
}

void process(){
    ifact[0] = 1;
    for(L i = 1; i < Mx; i++) {
        inv[i] = inverse(i, MOD);
        ifact[i] = (1LL * ifact[i - 1] * inv[i]) % MOD;
    }
}
void solve(){
    process();
    d1=bigmod(2,n,MOD)-1;
    // cout<<d1<<endl;
    d2=(nCr(n,a1));
    // cout<<n<<" "<<a1<<" "<<d2<<endl;
    d3=(nCr(n,a2));
    // cout<<n<<" "<<a2<<" "<<d2<<endl;
    d2=(d2+d3)%MOD;
    d1=(d1-d2+MOD)%MOD;
    printf("%lld\n", d1);
}
int main()
{
    scanf("%lld%lld%lld",&n,&a1,&a2);
    solve();
    return 0;
}
/// lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue 


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

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main() {
	int n, a[105];
	cin >> n;
	rep(i, n) cin >> a[i];
	qsort(a, n, sizeof(int), asc);
	cout << a[n-1]-a[0] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
int a[114514];
using namespace std;
signed main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int sum=0;
    for(int i=0;i<n;){
        if(a[i]==2){
            cout<<sum+1<<endl;
            return 0;
        }
        else{
            i=a[i]-1;
            sum++;
        }
        if(sum>114514810){
            break;
        }
    }
    cout<<-1<<endl;
}

Measured memory_bytes: 1024