akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main(void){
  int a[51],n,i,c = 0;
  cin >> n;
  for(i = 1; i < n + 1; i++){
    cin >> a[i];
    if(a[i] != i){
      c++;
    }
  }
  if(c == 0 || c == 2){
    cout << "YES";
  }
  else{
    cout << "NO";
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   998244353 // 1e9 + 7
#define MAXN 200100
using namespace std;
typedef vector<int> vi;
typedef set<int> se;
typedef pair<int,int> pii;
inline int mod(int n, int m){if(n%m==0)return m;
int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
int n;

int32_t main(){
    fastio;
    cin>>n;
	vector<int> a(n+1);
	vector<int> b(n);
	for(int i=0;i<n+1;i++)cin>>a[i];
	for(int i=0;i<n;i++)cin>>b[i];
	int res =0;
	for(int i=0;i<n;i++){
		int x=min(b[i],a[i]);
		a[i]-=x;
		b[i]-=x;
		int y = min(b[i],a[i+1]);
		b[i]-=y;
		a[i+1]-=y;
		res+=x+y;
	}
	cout<<res<<endl;
}

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

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> v[n+5];
  
  for(int i=0,l,r;i<m;i++)
    cin>>l>>r,v[l].push_back(r),v[r].push_back(l);
  
  for(int i=1;i<=n;i++)
    cout<<v[i].size()<<'\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#define ll long long
using namespace std;
int main(){
    ll n;
    cin>>n;
    map<ll,ll> amap;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        amap[a]++;
    }
    ll ans=0;
    for(const auto& item:amap){
        if(item.second>=item.first){
            ans+=item.second-item.first;
        }else{
            ans+=item.second;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
const int maxn = 2e5 + 5;
pll mons[maxn];
vector<ll> cor;
ll prefix[maxn];
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n; ll d, a; cin >> n >> d >> a;
    for (int i = 0; i < n; ++i)
        cin >> mons[i].first >> mons[i].second;
    sort(mons, mons + n);
    ll cur = -1, dmg = 0, sum = 0;
    for (int i  = 0; i < n; ++i) {
        int ptr = lower_bound(cor.begin(), cor.end(), mons[i].first) - cor.begin();
        mons[i].second -= (prefix[cor.size()] - prefix[ptr]);
        if (mons[i].second > 0) {
            cor.push_back(mons[i].first + 2LL * d);
            ll cnt = (mons[i].second / a) + (mons[i].second % a? 1LL: 0LL);
            sum += cnt;
            dmg = cnt * a;
            prefix[cor.size()] = prefix[cor.size() - 1] + dmg;
        }
    }
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 6644
#include<iostream>
#include<algorithm>
using namespace std;
int a,b;
int sum=0;
int main()
{
	cin>>a>>b;
	if(2>1+b) sum=1+b; else sum=2;
	for(int i=1;i<a;i++)
	{
		sum=min(sum+b,sum*2);
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

[[maybe_unused]] constexpr ll LL_MAX = numeric_limits<ll>::max();
[[maybe_unused]] constexpr ll LL_MIN = numeric_limits<ll>::min();
[[maybe_unused]] constexpr ull ULL_MAX = numeric_limits<ull>::max();

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

template <typename T>
void chmin(T& x, T y) {
    x = min(x, y);
}

template <typename T>
void chmax(T& x, T y) {
    x = max(x, y);
}

ll csum(ll x, ll y) {
    if (x > 0 && y > 0 && x > LL_MAX - y) {
        return LL_MAX;
    }
    if (x < 0 && y < 0 && x < LL_MIN - y) {
        return LL_MIN;
    }
    return x + y;
}

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

int main() {
	ll N;
	cin >> N;
	vector<ll> A(N);
	rep(i,0,N) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	ll ans = 0;
	vector<bool> table(1000001);
	rep(i,0,N) {
		if (table[A[i]] == false && (i == N-1 || A[i] < A[i+1])) {
			ans++;
		}
		if (i > 0 && A[i] == A[i-1]) {
			continue;
		}
		for (ll n = A[i]; n < table.size(); n += A[i]) {
			table[n] = true;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 4428
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

N = II()
A = [II() for i in range(N)]
n = 0
for i in range(N):
    a = A[n]
    if a == 2:
        print(i+1)
        break
    n = a-1
else:
    print(-1)

Measured memory_bytes: 7108
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

#define INF 1001001001
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

int main(){
    int n; cin >> n;
    string s;
    cin >> s;
    
    for(int i=0; i<s.size(); i++){
        
        if(s[i]+n>=91){
           s[i] = 'A'+ (s[i]+n-91);
            continue;
        }
        s[i] = s[i]+n;
    }
    
    cout << s << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define reg register
#define int long long
#define maxn 300010
#define max(a,b) ((a)>(b)?(a):(b))
#define getchar() (S==T&&(T=(S=B)+fread(B,1,1<<15,stdin),S==T)?EOF:*S++)
char B[1<<15],*S=B,*T=B;
int read()
{
	reg int s=0,f=1; reg char ch;
	for(;(ch=getchar())<'0'||ch>'9';ch=='-'?f=-f:0);
	for(;ch>='0'&&ch<='9';s=s*10+ch-'0',ch=getchar());
	return s*f;
}
void write(reg int x) {x<0?x=-x,putchar('-'):0,x>9?write(x/10):void(),putchar(x%10+'0');}
int n,t[maxn],sum[maxn],f[maxn],b[maxn],k[maxn],s[maxn];
struct DP
{
	int top=0,sum[maxn],f[maxn],b[maxn],k[maxn],s[maxn];
	int y(reg int i,reg int j) {return k[j]*i+b[j];}
	double slope(reg int i,reg int j) {return (b[j]-b[i])/(double)(k[i]-k[j]);}
	void dp()
	{
		for(reg int i=1;i<=n;i++) sum[i]=sum[i-1]+t[i];
		for(reg int i=1;i<=n;i++)
		{
			while(top&&y(i,s[top-1])>=y(i,s[top])) top--;
			f[i]=max(y(i,s[top])+(i*i+i)/2-sum[i],f[i-1]),k[i]=-i,b[i]=f[i]+(i*i-i)/2+sum[i];
			while(top&&slope(i,s[top-1])>=slope(s[top],s[top-1])) top--;
			s[++top]=i;
		}
	}
}f1,f2;
int y(reg int i,reg int j) {return k[j]*i+b[j];}
double check(reg int i,reg int j) {return (b[j]-b[i])/(double)(k[i]-k[j]);}
void solve(reg int l,reg int r)
{
	if(l==r) return void(f[l]=1ll-t[l]);
	reg int mid=l+r>>1,now=1,top=0,mx=-1<<30;
	solve(l,mid),solve(mid+1,r);
	for(reg int i=l-1;i<mid;i++)
	{
		k[i]=-i,b[i]=f1.f[i]+(i*i-i)/2+sum[i];
		while(top>1&&check(i,s[top-1])>=check(s[top],s[top-1])) top--;
		s[++top]=i;
	}
	for(reg int i=r;i>mid;i--)
	{
		while(now<top&&y(i,s[now+1])>=y(i,s[now])) now++;
		mx=max(mx,y(i,s[now])+(i*i+i)/2-sum[i]+f2.f[i+1]),f[i]=max(f[i],mx);
		
	}
	top=0,mx=-1<<30;
	for(reg int i=mid+1;i<=r;i++)
	{
		k[i]=-i,b[i]=f2.f[i+1]+(i*i+i)/2-sum[i];
		while(top>1&&check(i,s[top-1])>=check(s[top],s[top-1])) top--;
		s[++top]=i;
	}
	for(reg int i=l-1;i<mid;i++)
	{
		while(top>1&&y(i,s[top-1])>=y(i,s[top])) top--;
		mx=max(mx,y(i,s[top])+(i*i-i)/2+sum[i]+f1.f[i]),f[i+1]=max(f[i+1],mx);
	}
}
signed main()
{
	n=read();
	for(reg int i=1;i<=n;i++) t[i]=read();
	f1.dp(),std::reverse(t+1,t+n+1),f2.dp(),std::reverse(t+1,t+n+1),std::reverse(f2.f+1,f2.f+n+1);
	for(reg int i=1;i<=n;i++) sum[i]=sum[i-1]+t[i];
	solve(1,n);
	for(reg int m=read(),p,x;m--;) p=read(),x=read(),write(max(f1.f[p-1]+f2.f[p+1],f[p]+t[p]-x)),puts("");
	return 0;
}

Measured memory_bytes: 40064
N = int(input())
testimony = [[None for _ in range(N)] for _ in range(N)]
person = [None] * N

for i in range(N):
    person[i] = int(input())
    for _ in range(person[i]):
        j, good_or_bad = map(int, input().split())
        j -= 1
        testimony[i][j] = good_or_bad

ans = 0
for i in range(1, 1<<N):
    which_person = [None] * N
    for j in range(N):
        which_person[j] = i>>j & 1
    ok = True
    for j in range(N):
        if(which_person[j]): 
            for k in range(N):
                if testimony[j][k] == None: 
                    continue
                if testimony[j][k] != which_person[k]:
                    ok = False
    if ok:
        ans = max(ans, which_person.count(1))
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
void ABC161(void);
void ABC162(void);
void ABC163(void);
void ABC164(void);

int main(void){
    ABC161();
}

void ABC161(){
    int x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    int n;
    ll Y;
    cin >> n >> Y;

    for (int i = n; i >= 0; i--) {
        for (int j = 0; j <= n - i; j++) {
            int k = n - j - i;
            if (k < 0) {
                continue;
            }
            if (Y == 10000 * i + 5000 * j + 1000 * k) {
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }

    put("-1 -1 -1");    

    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define _GLIBCXX_DEBUG

int main(void){

    int A, B, C, K;
    int ans = 0;
    int temp;

    cin >> A >> B >> C >> K;

    // for(int i; i < K; i++){
    //     if(A > 0){
    //         ans++;
    //         A--;
    //     }

    //     else if(B > 0){
    //         B--;
    //     }

    //     else if(C > 0){
    //         ans--;
    //         C--;
    //     }
    // }

    if(K >= A){
        ans = A;
        temp = K - A;
    }

    else if(K < A){
        ans = K;
    }

    if(temp >= B){
        temp = temp - B;
    }

    if(temp > 0){
        ans = ans - temp;
    }



    cout << ans << endl;



}

Measured memory_bytes: 3632
#include<cstdio>
#include<iostream>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;

int main() {
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			printf("%dx%d=%d\n", i, j, i*j);
		}
	}
	return 0;
}

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

int main(void) {
  int n, q, cnt = 0;
  vector<int> S;
  
  cin >> n;
  for (int i = 0; i < n; i++) S.push_back([]{ int v; cin >> v; return v; }());
  
  cin >> q;
  for (int i = 0; i < q; i++) {
    int v;
    cin >> v;
    if (binary_search(S.begin(), S.end(), v)) cnt++;
  }
  
  cout << cnt << endl;
  
  return 0;
}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};

signed main(){
	ll N, M = 1;
	cin >> N;
	
	ll ans = N;
	reppp(i, 1, (int)sqrt(N)+1){
	    if( N % i == 0){
	        M = N / i;
	        ll ml = (ll)log10(M), nl = (ll)log10(i);
	        ll tmp = max(ml, nl);
	        if(tmp < ans){
	            ans = tmp + 1;
	        }
	    }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N;
  cin >> N;
  cout << 800 * N - 200 * (N / 15) << endl;
  return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import math
import itertools
INF = float("inf")


def solve(N: int, A: "List[int]"):
    A = [a-i-1 for i, a in enumerate(A)]
    A.sort()
    s = sum(A)-N*A[0]
    for i in range(len(A)):
        if i == 0:
            continue
        buf = (2*i+1-N-1)*(A[i]-A[i-1])
        if buf <= 0:
            s += buf
        else:
            break
    print(s)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


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

int main(){
    int n;
    cin >> n;
    if(n%2==0) cout << n/2 << endl;
    else cout << (n/2)+1 << endl;
return 0;
}


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

using namespace std;

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

void dfs(int x, int y) {
    field[x][y] = '0';

    for (int i = 0; i < 4; i++) {
        int nx = x + dx[i], ny = y + dy[i];
        if (nx >= 0 && nx < 12 && ny >= 0 && ny < 12 && field[nx][ny] == '1')
            dfs(nx, ny);
    }
}

int main() {
    while (scanf("%s", field[0]) != EOF) {
        for (int i = 1; i < 12; i++)
            scanf("%s", field[i]);
        
        int cnt = 0;
        for (int i = 0; i < 12; i++) {
            for (int j = 0; j < 12; j++) {
                if (field[i][j] == '1') {
                    cnt++;
                    dfs(i, j);
                }
            }
        }

        cout << cnt << endl;
    }

    return 0;
}


Measured memory_bytes: 3044
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int all = sc.nextInt();        //fre 次數
		int T = sc.nextInt();
		int route[] = new int[all];
		int time[] = new int[all];
		int min = 9999;
		for(int i = 0 ; i<all; i++) {
			route[i]=sc.nextInt();
			time[i]=sc.nextInt();
		}
		for(int i = 0 ; i<all;i++) {
			if(time[i]<=T) {
				if(route[i]<min) {
					min = route[i];
				}
			}
		}
		if(min!=9999) {
			System.out.println(min);
		}
		else {
			System.out.println("TLE");
		}
	}
}


Measured memory_bytes: 23636
# include "cstdio"
# include "iostream"
# include "cstring"

using namespace std;

const int maxm=1e5+10;

int Len,Stack[maxm],Top,tot=1,Root=1;
char S[maxm];

int main(){
	register int i,j;
	scanf("%s",S+1);
	Len=strlen(S+1);
	if(S[1]=='0' || S[Len]=='1'){
		printf("-1");
		return 0;
	}
	for(i=1;i<=Len;i++){
		if(S[i]=='1'){
			if(S[Len-i]=='0'){
				printf("-1");
				return 0;
			}
			Stack[++Top]=i;
		}
	}
	for(i=1;i<=Top;i++){
		printf("%d %d\n",i,i+1);
	}
	tot=Top+1;
	for(i=2;i<=Top;i++){
		for(j=Stack[i]-Stack[i-1]-1;j;j--){
			printf("%d %d\n",i,++tot);
		}
	}
	return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <utility>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <climits>
#include <map>
#include <unordered_map>
#include <string>
#include <ctime>
#include <unistd.h>

using namespace std;
#define ll long long
#define max(A, B) ((A) > (B) ? (A) : (B))
#define min(A, B) ((A) < (B) ? (A) : (B))
#define mp make_pair
#define pb push_back
#define fi first
#define sd second
#define fu(A, B, C) for(ll (A) = (B); (A) < (C); (A)++)
#define fu0(A, B) fu((A), 0, (B))
#define fd(A, B, C) for(ll (A) = (B); (A) >= (C); (A)--)
#define mem(A, B) memset((A), (B), sizeof((A)))
#define vd(A, B, C) vector<ll> (A)((B), (C))
#define v2d(A, B, C) vector<vector<int>> (A)((B), vector<int> (C));
#define all(x) (x.begin(), x.end())
#define endl "\n"
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;

ll gcd(int a, int b){if(!a)return b;return gcd(b%a,a);}

void perform() {
  int n, m; cin >> n >> m;
  vector<vector<int>> adj(n);
  fu0(i, m) {
    int u, v; cin >> u >> v;
    adj[u-1].pb(v-1);
    adj[v-1].pb(u-1);
  }
  vector<int> dist(n, INT_MAX); dist[0] = 0;
  queue<pi> q;
  vector<int> mark(n, 0); mark[0] = 1;
  q.push(mp(0, 0));
  while (!q.empty()) {
    pi val = q.front(); q.pop();
    //dist[val.sd] = min(dist[val.sd], val.fi);
    for (int i = 0; i < adj[val.sd].size(); i++) {
      if (!mark[adj[val.sd][i]]) {
        q.push(mp(val.fi+1,adj[val.sd][i]));
        dist[adj[val.sd][i]] = val.sd;
        mark[adj[val.sd][i]] = 1;
      }
    }
    //mark[val.sd] = 1;
  }
  fu0(i, mark.size()) {
    if (mark[i] != 1) {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
  fu(i, 1, dist.size()) {
    cout << dist[i]+1 << endl;
  }
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed;
  ll t = 1; //cin >> t;
  while(t--) {perform();}
}


Measured memory_bytes: 10856
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc =new Scanner (System.in);
		int h = sc.nextInt();
		int n = sc.nextInt();
		int[] A = new int[n];
		for(int i = 0;i<n;i++){
			A[i] = sc.nextInt();
			h -=A[i];
		}
		if(h<=0){
			System.out.println("Yes");	
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 49736
using System;
using System.Collections.Generic;
using System.Linq;

public class Program
{
    public static void Main(string[] args)
    {
        var bingo = Enumerable.Range(0, 3).Select(x => Console.ReadLine().Split(' ').Select(y => int.Parse(y)).ToArray()).ToArray();
        var card = new int[3, 3];
        var n = int.Parse(Console.ReadLine());
        for (int i = 0; i < n; i++)
        {
            var num = int.Parse(Console.ReadLine());
            for (int j = 0; j < 3; j++)
            {
                for (int k = 0; k < 3; k++)
                {
                    if (bingo[j][k] == num)
                    {
                        card[j, k] = 1;
                    }
                }
            }
            for (int j = 0; j < 3; j++)
            {
                if (card[j, 0] + card[j, 1] + card[j, 2] == 3)
                {
                    Console.WriteLine("Yes");
                    return;
                }
                if (card[0, j] + card[1, j] + card[2, j] == 3)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            if (card[0, 0] + card[1, 1] + card[2, 2] == 3)
            {
                Console.WriteLine("Yes");
                return;
            }
            if (card[2, 0] + card[1, 1] + card[0, 2] == 3)
            {
                Console.WriteLine("Yes");
                return;
            }
        }
        Console.WriteLine("No");
    }
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')'<<' ';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define OUTP(x) cout<<'('<<x.first<<','<<x.second<<')'<<endl;
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(T x,T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> T modinv(T x,const T mod){return modpow(x,mod-2,mod);}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),ALL(b));}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(ALL(a),ALL(b),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(ALL(a),ALL(b),inserter(c,c.end()));
}
template<class T> void getdiff(const T &a,const T &b,T &c) {
  set_difference(ALL(a),ALL(b),inserter(c,c.end()));
}
template<class T> T deg2rad(T deg) {return deg*2*M_PI/360;}
template<class T> T rad2deg(T rad) {return rad*360/(2*M_PI);}

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD=1e9+7;
const ll MAX=5e6;

int main() {
  int N;cin>>N;
  vector<int> PS(N),QS(N);
  REP(i,N) cin>>PS[i];
  REP(i,N) cin>>QS[i];
  vector<int> tmp(ALL(PS));
  sort(ALL(tmp));

  int a,b;
  int cnt = 1;
  do {
    if (tmp==PS) a = cnt;
    if (tmp==QS) b = cnt;
    cnt++;
  } while (next_permutation(ALL(tmp)));
  OUT(abs(b-a));

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
ll A,B;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>A>>B;
	cout<<max({A+B,A-B,A*B})<<endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//
#include<cmath>
#include<iomanip>

using namespace std;

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

typedef long long ll;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0,-1,0}; //次に行くところ
int dx[] = {0,1,0,-1}; //s上に同じ

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int x,y;
  cin >> x >> y;
  for (int i = 0; i <= 100; i++){
    for (int j = 0; j <= 100; j++){
      if (i+j != x){
        continue;
      }else if (i*2+j*4 == y){
        cout << "Yes\n";
        return 0;
      }
    }
  }
  
  cout << "No\n";
  
  return 0;
}

Measured memory_bytes: 3588
#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>
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 h,w,k,c[310][310];
string s[310];

void solve(){
  cin >> h >> w >> k;
  rep(i,w+2){
    c[0][i]=mod;
    c[h+1][i]=mod;
  }
  rep(i,h+2){
    c[i][0]=mod;
    c[i][w+1]=mod;
  }
  rep(i,h){
    cin >> s[i];
  }
  rep(i,h){
    rep(j,w){
      if(s[i][j]=='#') c[i+1][j+1]=mod;
    }
  }
  int m=1;
  rep(i,h){
    rep(j,w){
      if(s[i][j]=='#'){
        c[i+1][j+1]=m;
        int f=j+2,b=j;
        while(c[i+1][f]==0){
          c[i+1][f]=m;
          f+=1;
        }
        while(c[i+1][b]==0){
          c[i+1][b]=m;
          b-=1;
        }
        m+=1;

      }
    }
  }
  rep(i,h){
    if(c[i+1][1]!=0){
      int f=i+2,b=i;
      while(c[f][1]==0){
        rep(j,w) c[f][j+1]=c[i+1][j+1];
        f+=1;
      }
      while(c[b][1]==0){
        rep(j,w) c[b][j+1]=c[i+1][j+1];
        b-=1;
      }
    }
  }
  rep(i,h){
    rep(j,w){
      cout << c[i+1][j+1] << " ";
    }
    cout << "" << endl;
  }
}

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

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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(){
    string s; cin>>s;
    ll n=s.size();
    if(n%2==1) cout<<"No"<<endl;
    else{
        bool ifhi=true;
        rep(i,n/2) if(s[2*i]!='h' || s[2*i+1]!='i') ifhi=false;
        if(ifhi) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}

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

int main() {
  int A, P;
  cin >> A >> P;
  P += A * 3;
  int ans = P/2;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def solve(x, ls):
    y = 0
    m = x
    for i in range(1, 102):
        if i in ls:
            continue
        if abs(x - i) < m:
            y = i
            m = abs(x - i)
    return y


def main(istr, ostr):
    x, n = list(map(int, istr.readline().strip().split()))
    ls = list(map(int, istr.readline().strip().split()))
    result = solve(x, ls)
    print(result, file=ostr)


if __name__ == "__main__":
    import sys

    main(sys.stdin, sys.stdout)


Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  vector<ll> X(N);
  REP(i, N) cin >> X[i];
  ll ans = 0;
  REP(i, N - 1) { ans += min((X[i + 1] - X[i]) * A, B); }
  cout << ans << endl;
}

Measured memory_bytes: 4004
import sys
import math
from itertools import combinations

fin = sys.stdin.readline
N, D = [int(elem) for elem in fin().split()]
x_list = [[int(elem) for elem in fin().split()] for _ in range(N)]


def checkInteger(y, z):
    sum_all = 0
    for i in range(len(y)):
        sum_all += (y[i] - z[i]) ** 2
    return math.sqrt(sum_all).is_integer()


count_all = 0
for each_combi in combinations(x_list, 2):
    if checkInteger(each_combi[0], each_combi[1]):
        count_all += 1

print(count_all)


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll val[501],wt[501],n,W;
ll dp[101][100009];
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
void knapsack(ll pos,ll profit)
{
    if(pos==n)
        return;
    cout<<"pos "<<pos<<", "<<profit<<endl;
    if(dp[pos][profit]!=-1)
    {
        return;
    }
    if(pos==0)
    {
        dp[pos][profit] = 0;
        knapsack(pos+1,profit);
        dp[pos][profit+val[pos]] = wt[pos];
        knapsack(pos+1,profit+val[pos]);
    }
    else
    {
        dp[pos][profit] = dp[pos-1][profit] ;
        knapsack(pos+1,profit);
        dp[pos][profit+val[pos]] = dp[pos-1][profit]+wt[pos];
        knapsack(pos+1,profit+val[pos]);
    }

}
int main()
{
    ll i,j,k,l,r,t,cs;
    cin>>n>>W;
    for(i=0;i<n;i++)
    {
        cin>>wt[i]>>val[i];
    }
    //memset(dp,-1,sizeof dp);
    //knapsack(n-1,0);
    for(i=0;i<n;i++)
    {
        for(j=0;j<=100000;j++)
        {
            dp[i][j] = LLONG_MAX;
        }
    }
    dp[0][0] = 0;
    dp[0][val[0]] = wt[0];
    for(i=0;i<n-1;i++)
    {
        for(j=0;j<=100000;j++)
        {
            if(dp[i][j]!=LLONG_MAX)
            {
                dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
                dp[i+1][j+val[i+1]] = min(dp[i+1][j+val[i+1]],dp[i][j]+wt[i+1]);
            }
        }
    }
    ll ans=  0;
    /*for(i=0;i<n;i++)
    {
        for(j=0;j<=140;j++)
        {
            cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
        }
        cout<<endl<<endl;
    }*/
    for(j=0;j<=100000;j++)
    {
        if(dp[n-1][j]<=W)
        {
            ans = max(ans,j);
        }
    }
    cout<<ans<<endl;

}


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

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

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

    int n, m, ans = 0;
    cin >> n >> m;

    if (m / 2 <= n)
    {
        ans += m / 2;
        m -= ans * 2;
    }
    else
    {
        ans += n;
        m -= n * 2;
    }
    cout << ans + m / 4 << '\n';
    return 0;
}

Measured memory_bytes: 256
N,A,B = map(int, input().split())
S = input()

C,D = 0,0
for i,c in enumerate(S):
    if c == 'a':
        if C < A+B:
            print("Yes")
            C += 1
        else:
            print("No")
    elif c == 'b':
        if C < A+B and D < B:
            print("Yes")
            C += 1
            D += 1
        else:
            print("No")
    else:
        print("No")

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

int main(){
	
	string grid[3];

	for(int i=0;i<3;i++){
		cin>>grid[i];
	}
	vector<int> p(3);
	char curr = grid[0][0];
	
	char pcurr = curr;
	while(1){
	 p[pcurr-'a']++;
	 if(p[curr-'a']==(int)grid[curr-'a'].length()){
	 	putchar(toupper(curr));
	 	break;
	 }
	 pcurr = curr;
	 curr = grid[curr-'a'][p[curr-'a']];
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define PI 3.14159265359
int main(void){
	int a,b,C;
	long double h,S,L;
	scanf("%d %d %d",&a,&b,&C);
	h=(long double)b*sin(C*PI/180);
	S=(long double)a*h/2;
	L=(long double)a+b+sqrt((a*a)+(b*b)-(2*a*b*cos(C*PI/180)));
	printf("%Lf\n",S);
	printf("%Lf\n",L);
	printf("%Lf\n",h);
	return 0;
}


Measured memory_bytes: 2128
INF = float('inf')

def main():
    n, m, p = map(int,input().split())
    es = []
    for _ in range(m):
        e = list(map(int,input().split()))
        es.append([e[0]-1,e[1]-1,- e[2] + p])

    v_cost = [INF]*n
    v_cost[0] = 0
    for v in range(n*2):
        for e in es:
            frm = e[0]
            to = e[1]
            if v_cost[to] > v_cost[frm]+e[2]:
                v_cost[to] = v_cost[frm]+e[2]
                if v >= n:
                    v_cost[to] = -INF
        if v == n-1:
            prev = v_cost[-1]

    if prev != v_cost[-1]:
        return -1

    return max(0,-v_cost[-1])
   

if __name__ =="__main__":
    print (main())


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

int main(void){
    int n, m;
    cin>>n>>m;
    vector <vector<int> > v(m);
    rep(i, m){
        int k;
        cin>>k;
        rep(j, k){
            int a;
            cin>>a;
            --a;
            v[i].push_back(a);
        }
    }
    vector<int> p(m);
    rep(i, m) cin>>p[i];
    int ans=0;
    rep(id, (1<<n)){
        vector<int> idx(n);
        rep(j, n){
            if(id>>j&1) idx[j]=1;
        }
        int flag=0;
        rep(i, m){
            int num=0;
            rep(j, v[i].size()){
                num+=idx[v[i][j]];
            }
            if(num%2!=p[i]) {
                flag=1;
                break;
            }
        }
        if(flag==0) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
H, W, A, B = map(int, input().split())

# H行W列 左下から縦A横B

def mod(num):
    return num % (10 ** 9 + 7)
    
n = H + W + 1

fac = [0] * n
rev = [0] * n

fac[0] = 1

for i in range(1, n):
    fac[i] = mod(fac[i-1] * i)


# 逆元の計算 x**(-1) ≡ x**(10**9 + 5) (mod 10**9 + 7)
rev[n-1] = pow(fac[n-1], 10**9 + 5, 10**9 + 7)

for i in range(n - 2, 0, -1):
    rev[i] = mod(rev[i + 1] * (i + 1))

rev[0] = 1

t1 = [0] * (W - B)

for i in range(W - B):
    t1[i] = mod(fac[H - A - 1 + i + B] * mod(rev[B + i] * rev[H - A - 1]))
    
res = 0

for i in range(W - B):
    r = t1[i] * mod(fac[A - 1 + W - B - 1 - i] * mod(rev[A - 1] * rev[W - B - 1 - i]))
    res = mod(res + r)
    
print(res)


Measured memory_bytes: 28356
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Deque;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split("");
		String str2[] = br.readLine().split("");

		int a[] = new int[str.length];

		int ans = 0;
		for (int i = 0; i < 3; i++) {
			if (str[i].equals(str2[i])) {
				ans++;
			}
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 32828
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
const ll INF = 114514810;
const ll MOD = 1000000007;
const double EPS = 1e-8;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int n, l;
vi v;

int main()
{
	cin >> n >> l;
	v.push_back(0);
	REP(i, n)
	{
		int a; cin >> a;
		v.push_back(a);
	}
	v.push_back(0);
	priority_queue<P> que;
	FOR(i, 1, n+1)
	{
		if (v[i] > v[i - 1] && v[i] > v[i + 1])
		{
			que.push(P(v[i], i));
		}
	}
	int ans = 0;
	while (que.size())
	{
		P tmp = que.top();
		que.pop();
		int res = l - tmp.first;
		ans = res;
		int t = tmp.second;
		v[t] = 0;
		if (t > 1 && v[t - 1] > v[t - 2]) que.push(P(v[t - 1] - ans, t - 1));
		if (t < n&&v[t + 1] > v[t + 2]) que.push(P(v[t + 1] - ans, t + 1));
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 2068
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

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

    vector<vector<bool>> sw(m, vector<bool>(n, false));
    rep(i, m) {
        int k;
        cin >> k;
        rep(j, k) {
            int tmp_num;
            cin >> tmp_num;
            --tmp_num;
            sw[i][tmp_num] = true;
        }
    }

    vector<bool> exp(m);
    rep(i, m) {
        int tmp_bool;
        cin >> tmp_bool;
        exp[i] = tmp_bool;
    }

    int ans = 0;
    rep(i, (1<<n)) {
        vector<bool> actual(m, 0);
        rep(j, n) {
            if ( i&(1<<j) ) {
                rep(k, m) {
                    if ( sw[k][j] ) {
                        actual[k] = !actual[k];
                    }
                }
            }
        }
        bool ok = true;
        rep(k, m) {
            if ( exp[k] != actual[k] ) {
                ok = false;
                break;
            }
        }
        if ( ok ) {
//            cout << i << endl;
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define pb push_back

using namespace std;
using ll = long long;
using ld = long double;
int a,b,c;

int calc(char x)
{
    if (x=='r') return c;
    if (x=='p') return b;
    if (x=='s') return a;
}

int main()
{
    Phuong_;
    int n,k;
    cin >> n >> k;
    cin >> a >> b >> c;/// R, S, P;
    string t;
    cin >> t;
    t='0' +t;
    int sum=0;
    for(int i=1; i<=n; ++i)
    {
        if (i<=k)
        sum += calc(t[i]); else
        if (t[i]==t[i-k])
        {
            t[i]='0';
            continue;
        }else sum += calc(t[i]);
    }
    cout << sum;
    return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
ll inf=100000000000000000,mod=1000000007;
int main(){
    
	ios::sync_with_stdio(false);
	cin.tie(0);
    ll n,m;
    string s[10]={"0","1","2","3","4","5","6","7","8","9"};
    cin>>n>>m;
    string a,b;
    for(ll i=0;i<m;i++)
    {
        a+=s[n];
    }
    for(ll i=0;i<n;i++)
    {
        b+=s[m];
    }
    a=min(a,b);
    cout<<a<<endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//int n=sc.nextInt();
		long n=sc.nextLong();
		//long k=sc.nextLong();
		//String s=sc.next();
		//long[] array=new long[n];
		double sum=1,buff,max=0,min=0;
		//int[] array=new int[l];
		//String s="",m="",h="";

		for(long i=n;i>=1;i--) {
			buff=Math.sqrt(i);
			max=(long)buff;
			if(buff-max==0) {
				System.out.println(i);
				break;
			}

			//System.out.println(sum);
		}
		//Arrays.sort(array)
	}
}

//Arrays.sort(array, (a, b) -> Integer.compare(a[0], b[0]));




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

namespace AtCoder
{
    class AC073C
    {
#if true
        static void Main(string[] args)
        {
            string s1 = Console.ReadLine();
            string s2 = Console.ReadLine();

            Console.WriteLine(funcMain(s1,s2));
#if DEBUG
            Console.ReadKey();
#endif
        }

#else
        static void Main(string[] args)
        {
            test();
        }
#endif

        static private string funcMain(string arg1, string arg2)
        {
            string[] bufarray;
            bufarray = arg1.Split();
            int Ninzu = int.Parse(bufarray[0]);
            long OneTime = long.Parse(bufarray[1]);
            long TotalTime = 0;
            long NowTime = 0;

            foreach (string buf in arg2.Split())
            {
                long t = long.Parse(buf);
                TotalTime += Math.Min(t - NowTime,OneTime);
                NowTime = t;
            }
            TotalTime += OneTime;
            return TotalTime.ToString();
        }

        static private void test()
        {
            string arg1, arg2;
            arg1 = "2 4";
            arg2 = "0 3";
            Console.WriteLine("7" == funcMain(arg1, arg2));
            arg1 = "2 4";
            arg2 = "0 5";
            Console.WriteLine("8" == funcMain(arg1, arg2));
            arg1 = "4 1000000000";
            arg2 = "0 1000 1000000 1000000000";
            Console.WriteLine("2000000000" == funcMain(arg1, arg2));
            arg1 = "1 1";
            arg2 = "0";
            Console.WriteLine("1" == funcMain(arg1, arg2));
            arg1 = "9 10";
            arg2 = "0 3 5 7 100 110 200 300 311";
            Console.WriteLine("67" == funcMain(arg1, arg2));
            Console.ReadKey();
        }

    }
}


Measured memory_bytes: 28256
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

const int MAX = 100100;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll modPow(ll x, ll t) {
	//cout << x << " " << t << endl;
	if(t == 0) return 1;
	if(t == 1) return x;
	ll temp = 1, temp2 = modPow(x, t/2);
	if(t % 2 == 1) {
		temp = x * temp2 % MOD;
		temp = temp * temp2 % MOD;
	}
	else {
		temp = temp2 * temp2 % MOD;
	}
	return temp;
}

/*ll comb(ll n, ll k) {
	ll ans = 1;
	for(int i=n; i>k; i--) {
		ans *= i;
		ans %= MOD;
	}
	for(int i=n-k; i>=1; i++) {
		ans *= modPow(i, MOD-2);
		ans %= MOD;
	}
	return ans;
}*/

int main() {
	COMinit();
	int N,K;
	cin >> N >> K;
	vector<ll> A(N);
	rep(i,N) cin >> A[i];
	sort(A.begin(), A.end());
	ll mini = 0, maxi = 0;
	ll temp = 1;
	for(int i=K-1; i<N; i++) {
		//cout << i << " " << A[i] << " " << maxi << " " << temp << endl;;
		/*maxi += A[i] * temp;
		maxi %= MOD;
		temp *= i+1;
		temp %= MOD;
		temp *= modPow(i+1-(K-1), MOD-2);
		temp %= MOD;*/
		maxi += A[i] * COM(i,K-1);
		maxi %= MOD;
	}
	temp = 1;
	for(int i=N-K; i>=0; i--) {
		//cout << i << " " << A[i] << " " << mini << " " << temp << endl;;
		/*mini += A[i] * temp;
		mini %= MOD;
		temp *= N-i; 
		temp %= MOD;
		temp *= modPow(N-i-(K-1), MOD-2);
		temp %= MOD;
		*/
		mini += A[i] * COM(N-i-1,K-1);
		mini %= MOD;
	}
	ll ans = (maxi - mini) % MOD;
	if(ans < 0) ans += MOD;
	cout << ans << endl;


  return 0;
}

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

int main() {
    ll N, K, a, b;
    cin >> N >> K;
    vector<P> ab;
    rep(i,N) {
        cin >> a >> b;
        ab.push_back(make_pair(a, b));
    }
    sort(ab.begin(), ab.end());
    ll sum = 0;
    rep(i,N) {
        sum += ab.at(i).second;
        if (sum >= K) {
            cout << ab.at(i).first << endl;
            return 0;
        }
    }
}


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

int main(){
  int n,m;cin>>n>>m;
  int wa=0,ac=0;
  vector<int> data(n,0);
  vector<int> wacnt(n,0);
  
  while(m){
    int p;cin>>p;
    string s;cin>>s;
    
    if(!data.at(p-1)){
      if(s=="WA")wacnt.at(p-1)++;
      else {data.at(p-1)=1;ac++;wa+=wacnt.at(p-1);}
    }
    
    m--;
  }
  cout<<ac<<" "<<wa<<endl;
}

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

int main(){

	ios::sync_with_stdio(false);
	cin.tie(0);
	long long x,in=100,j=0;
	cin >> x;
	while (in<x){
		in = in*1.01;
		j++;
	}
	cout << j << "\n";
	return 0;
}

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

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  if(b-a <= 0) cout << "delicious" << endl;
  else if(b-a <= x) cout << "safe" << endl;
  else cout << "dangerous" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //const ll p = 1e9 + 7;
    //const ll p = 998244353;
    
    clock_t start = clock();
    
    ll d;
    cin >> d;
    vector<ll> c(26);
    for (ll i = 0; i < 26; i++) cin >> c[i];
    vector<vector<ll>> s(d, vector<ll>(26));
    for (ll i = 0; i < d; i++) {
        for (ll j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    
    random_device rand;
    vector<ll> ans(d);
    for (ll i = 0; i < d; i++) ans[i] = rand() % 26;
    
    auto calc_score = [&] () {
        vector<ll> v(26, -1);
        ll ret = 0;
        for (ll i = 0; i < d; i++) {
            v[ans[i]] = i;
            ret += s[i][ans[i]];
            for (ll j = 0; j < 26; j++) {
                ret -= c[j] * (i - v[j]);
            }
        }
        return ret;
    };
    
    ll score = calc_score();
    
    while (clock() - start <= 1.95 * CLOCKS_PER_SEC) {
        ll change_at1 = rand() % d, into1 = rand() % 26;
        ll change_at2 = rand() % d, into2 = rand() % 26;
        ll memo1 = ans[change_at1], memo2 = ans[change_at2];
        ll memo_score = score;
        ans[change_at1] = into1; ans[change_at2] = into2;
        score = calc_score();
        if (score < memo_score) {
            ans[change_at1] = memo1; ans[change_at2] = memo2;
            score = memo_score;
        }
    }
    
    for (ll i = 0; i < d; i++) cout << ans[i] + 1 << endl;
    xout << score << endl;
}

Measured memory_bytes: 3760