akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
////////////////////////////////////////////////*kedar1514*////////////////////////////////////////////////(Template Start)*****
#define endl "\n"
#define ll long long
#define fo(i,n)                     for(i=0;i<n;i++)
#define Fo(i,n)                     for(i=1;i<=n;i++)
#define si(x)                       scanf("%d",&x)
#define sl(x)                       scanf("%lld",&x)
#define ss(s)                       scanf("%s",s)
#define pi(x)                       printf("%d\n",x)
#define pl(x)                       printf("%lld\n",x)
#define ps(s)                       printf("%s\n",s)
#define all(x)                      x.begin(),x.end()
#define allr(x)                     x.rbegin(),x.rend()
#define sortAll(x)                  sort(all(x))   
#define clearAll(arr)               memset(arr,0,sizeof(arr))
#define deb(sum)                    cout<<"deb = "<<sum<<endl;
#define pb                          push_back
#define mp                          make_pair
#define F                           first
#define S                           second
#define PI                          3.1415926535897932384626
typedef pair<int, int>              pii;
typedef pair<long long, long long>  pll;
typedef vector<int>                 vi;
typedef vector<long long>           vl;
typedef vector<pii>                 vpii;
typedef vector<pll>                 vpll;
#define kedar ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll powerMod(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
	if (n & 1)
	  res = (res * x) % mod;
	x = (x * x) % mod;
	n >>= 1;
  }
  return res;
}

ll power(ll x, ll n) {
  ll res = 1;
  while (n) {
	if (n & 1)
	  res = (res * x);
	x = (x * x);
	n >>= 1;
  }
  return res;
}

int gcd(int A, int B) {
    if(B==0)
        return A;
    else
        return gcd(B, A % B);
}
////////////////////////////////////////////////*kedar1514*////////////////////////////////////////////////(Template ends)*****
//  <<,
//  , cout<<<<endl;
int dp[100005];
vi gp[100005];

int dfs( int  a)
{
  int ret = 0;
  if(dp[a]!=-1) return dp[a];
  for (int i = 0; i < gp[a].size(); i++)
  {
    ret = max(ret,dfs(gp[a][i])+1);
  }
  return dp[a] = ret;
  
}

void solve()
{
  int n, m;
  cin>>n>>m;
  int x, y;
  for (int i = 0; i < m; i++)
  {
    cin>>x>>y;--x;--y;
    gp[x].push_back(y);
  }
  for (int i = 0; i < n; i++)
  {
    dp[i]=-1;
  }
  int ret=0;
  for (int i = 0; i < n; i++)
  {
    ret = max(ret,dfs(i));
  }
  cout<<ret;
}

int main(){
    kedar;
// <<
//  <<,
//  ,

    ll t=1;
    //cin>>t;
    while(t--)
    {     
        solve();
    }
    return 0;
}// <<
//  <<,
//  ,


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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int left = 0 ,right = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '(') {
      left += 1;
    } else {
      if (left != 0) {
        left -= 1;
      } else {
        right += 1;
      }
    }
  }
  cout << string(right, '(') + s + string(left, ')') << endl;
  return 0;
}


Measured memory_bytes: 3580
import itertools
import math

N = int(input())
xy = [list(map(int,input().split())) for i in range(N)]

l = list(range(N))
a = []

for i in itertools.permutations(l, N):
  a.append(list(i))
  
D = 0

for i in range(math.factorial(N)):
  d = 0
  for j in range(N-1):
    d += math.sqrt((xy[a[i][j]][0]-xy[a[i][j+1]][0])**2 + (xy[a[i][j]][1]-xy[a[i][j+1]][1])**2)
  else:
    D += d
    
print(D / math.factorial(N))
  

Measured memory_bytes: 10356
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define PB push_back
#define PF push_front
#define MP make_pair
typedef long long int ll;
const ll mod = 1e9+7;
const ll INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}

int main(){
  ll a,b;
  cin >> a >> b;
  
  rep(i,1000){
    if(a*i-i+1>=b){
      cout<<i<<endl;
      break;
    }
  }

  return 0;
}


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

void solve(long long N, long long H, long long W) {
  int h = max(0ll, (N-H+1));
  int w = max(0ll, (N-W+1));
  cout << h * w << endl;

}

int main() {

  long long N;
  scanf("%lld", &N);
  long long H;
  scanf("%lld", &H);
  long long W;
  scanf("%lld", &W);
  solve(N, H, W);
  return 0;
}


Measured memory_bytes: 256
use std::io::stdin;

fn main() {
    let mut n = String::new();
    stdin().read_line(&mut n).unwrap();
    let n: usize = n.trim().parse().unwrap();

    let mut l = [0; 200003];
    let mut r = [0; 200003];
    let array: Vec<usize> = (0..n).map(|_| {
        let mut a = String::new();
        stdin().read_line(&mut a).unwrap();
        a.trim().parse().unwrap()
    }).collect();
    for (i, &a) in array.iter().enumerate() {
        l[i + 1] = if a > l[i] { a } else { l[i] };
    }
    for (i, &a) in array.iter().rev().enumerate() {
        r[i + 1] = if a > r[i] { a } else { r[i] };
    }
    for i in 0..n {
        let li = i;
        let ri = n - i - 1;
        println!("{}", if l[li] < r[ri] { r[ri] } else { l[li] });
    }
}


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

int main() {
    int n;
    cin >> n;
    vector<int> w(n);
    for (int i = 0; i < n; i++) cin >> w[i];

    int ans = 10010;
    for (int i = 0; i < n - 1; i++) {
        int s1 = 0, s2 = 0;
        for (int j = 0; j <= i; j++) s1 += w[j];
        for (int j = i + 1; j < n; j++) s2 += w[j];

        ans = min(ans, abs(s1 - s2));
    }

    cout << ans << endl;
    return 0;

}

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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 1; i <= N; i += 2) {
    int tmp = 0;
    for (int j = 1; j <= i; j++) {
      if (i % j == 0) tmp++;
    }
    if (tmp == 8) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
 
signed main(void){
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    bool b=true;
    rep(i,n){
        int a; cin>>a;
        if(a%2==1)b=false;
    }
    cout<<(b?"second":"first")<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a,b,c;
    
    scanf("%d %d %d", &a, &b, &c);
    
    if((a < c && c < b) || (b < c && c < a)){
        puts("Yes");
    }else{
        puts("No");
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <random>
#include <complex>
#include <assert.h>

using namespace std;
typedef long long ll;
#define endl '\n'

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

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

int score;
int stone[10][5];
bool flag[10][5];

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

	while (1) {
		int H; cin >> H;
		if (H == 0) { break; }
		
		score = 0;
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 5; j++) {
				stone[i][j] = 0;
			}
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < 5; j++) {
				int k; cin >> k;
				stone[H - 1 - i][j] = k;
			}
		}

		bool f;
		while(1){
			f = false;
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < 5; j++) {
					flag[i][j] = false;
				}
			}
			for (int i = 0; i < H; i++) {// 隣り合うものにチェック
				for (int j = 1; j < 4; j++) {
					if (stone[i][j - 1] == stone[i][j] && stone[i][j] == stone[i][j + 1] && stone[i][j] != 0) {
						f = true;
						flag[i][j - 1] = true;
						flag[i][j] = true;
						flag[i][j + 1] = true;
					}
				}
			}
			for (int j = 0; j < 5; j++) {// 消去
				for (int i = 0; i < H; i++) {
					if (flag[i][j] == true) {
						score += stone[i][j];
						stone[i][j] = 0;
					}
				}
			}
			for (int j = 0; j < 5; j++) {// 消去
				for (int i = 0; i < H; i++) {
					if (stone[i][j] != 0) {
						int k = i;
						while (k > 0 && stone[k - 1][j] == 0) {
							stone[k - 1][j] = stone[k][j];
							stone[k][j] = 0;
							k--;
						}
					}
				}
			}
			if (f == false) {
				break;
			}
		}
		cout << score << endl;
	}

	return 0;
}


Measured memory_bytes: 3092
package main

import (
   "bufio"
   "fmt"
   "os"
   "sort"
)

func solution(n int, a []int) int {
   sort.Ints(a)
   memo := make([][3]int, n)
   for i := 0; i < n; i++ {
        memo[i][0] = a[i]
   }

   j := 0
   for i := 3*n - 1; i > n; i -= 2 {
        memo[j][2] = a[i]
        memo[j][1] = a[i-1]
        j++
   }

   out := 0
   for i := range memo {
        out += memo[i][1]
   }
   return out
}

func main() {
   r := bufio.NewReader(os.Stdin)
   var n int
   fmt.Fscan(r, &n)
   a := make([]int, 3*n)
   for i := range a {
        fmt.Fscan(r, &a[i])
   }
   fmt.Println(solution(n, a))
}

Measured memory_bytes: 9240
#include <iostream>
#include <algorithm>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
#include <cmath>
#include <cstring>
#define rep0(i, n) for (i = 0; i < n; i++)
#define rep(s, i, n) for (i = s; i < n; i++)
using namespace std;

long long dp[3001][3001][5];
int value[3001][3001];

int main()
{
    memset(dp, 0, sizeof(dp));
    memset(value, 0, sizeof(value));

    int R, C, K;
    cin >> R >> C >> K;

    int i, j, k, r, c, v;
    rep0(i, K)
    {
        cin >> r >> c >> v;
        value[r-1][c-1] = v;
    }

    dp[0][0][1] = value[0][0];

    rep0(i, R)
    {
        rep0(j, C)
        {
            rep0(k, 4)
            {
                //to down
                dp[i + 1][j][0] = max(dp[i][j][k], dp[i + 1][j][0]);
                dp[i + 1][j][1] = max(dp[i][j][k] + value[i + 1][j], dp[i + 1][j][1]);

                dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
                dp[i][j + 1][k + 1] = max(dp[i][j + 1][k + 1], dp[i][j][k] + value[i][j + 1]);
            }
        }
    }

    long long ans = 0;
    rep0(k, 4) ans = max(ans, dp[R - 1][C - 1][k]);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
    long long int a;
    double b;
    long long int seki;
    cin>>a>>b;

    long long int c=((b+0.001)*100);
    seki=(a*c)/100;

    cout<<(long long int)(seki)<<endl;

}


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

using namespace std;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string a[6] = {"A","B","C","D","E","F"};
	string x,y;
	cin >> x >> y;
	int inX;
	int inY;
	for(int i = 0;i < 6;i++){
		if(x == a[i]){
			inX = i;
		}
		if(y == a[i]){
			inY = i;
		}
	}
	if(inX < inY){
		cout << "<" << endl;
	}else if(inX > inY){
		cout << ">" << endl;
	}else{
		cout << "=" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

void Compare(int a, int b)
{
	if(a>b){
		cout << "a > b" << endl;
	}else if(a<b){
		cout << "a < b" << endl;
	}
	else{
		cout << "a == b" << endl;
	} 
}

int main(void)
{
	int a,b;
	
	cin >> a >> b;
	
	Compare(a,b);
	
}

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

class Main{
	public static void main(String[] args){
		solve();
	}
	public static void solve(){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int x = sc.nextInt()+10000;
		int y = sc.nextInt()+10000;
		int[] xdp = new int[20000];
		int[] ydp = new int[20000];
		int xnow = 1;
		int ynow = 1;
		xdp[10000] = 1;
		ydp[10000] = 1;
		boolean flag = true;
		boolean judge = true;
		int count = 0;
		for(int j=0;j<s.length();j++){
			if(s.charAt(j)=='F'){
				count++;
			}
			else{
				ArrayList<Integer> list = new ArrayList<Integer>();
				if(count!=0){
						if(flag){
							if(judge){
								for(int i=0;i<20000;i++){
									if(xdp[i] == xnow){
										list.add(i);
									}
								}
								for(int i=0;i<list.size();i++){
									int z = list.get(i);
									xdp[z+count] = xnow + 1;
								}
							}
							else{
								for(int i=0;i<20000;i++){
									if(xdp[i] == xnow){
										list.add(i);
									}
								}
								for(int i=0;i<list.size();i++){
									int z = list.get(i);
									xdp[z+count] = xnow + 1;
									xdp[z-count] = xnow + 1;
								}
							}
							xnow++;
						}
						else{
							for(int i=0;i<20000;i++){
								if(ydp[i] == ynow){
									list.add(i);
								}
							}
							for(int i=0;i<list.size();i++){
								int z = list.get(i);
								ydp[z+count] = ynow + 1;
								ydp[z-count] = ynow + 1;
							}
							ynow++;
						}
				}
				flag = !flag;
				judge = false;
				count = 0;
			}
		}
		ArrayList<Integer> list = new ArrayList<Integer>();
		if(count!=0){
						if(flag){
							if(judge){
								for(int i=0;i<20000;i++){
									if(xdp[i] == xnow){
										list.add(i);
									}
								}
								for(int i=0;i<list.size();i++){
									int z = list.get(i);
									xdp[z+count] = xnow + 1;
								}
							}
							else{
								for(int i=0;i<20000;i++){
									if(xdp[i] == xnow){
										list.add(i);
									}
								}
								for(int i=0;i<list.size();i++){
									int z = list.get(i);
									xdp[z+count] = xnow + 1;
									xdp[z-count] = xnow + 1;
								}
							}
							xnow++;
						}
						else{
							for(int i=0;i<20000;i++){
								if(ydp[i] == ynow){
									list.add(i);
								}
							}
							for(int i=0;i<list.size();i++){
								int z = list.get(i);
								ydp[z+count] = ynow + 1;
								ydp[z-count] = ynow + 1;
							}
							ynow++;
						}
				}


		if(xdp[x] == xnow && ydp[y] == ynow){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 64044
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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() {
  int N;
  cin >> N;
  vector<int> L(N);
  rep(i, N) cin >> L[i];

  sort(all(L), greater<int>());
  int other = 0;
  repp(i, 1, N - 1) { other += L[i]; }
  string ans = (other > L[0] ? "Yes" : "No");
  cout << ans << endl;
}

Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

ll MOD = 1000000007;

ll binPowMod(ll a, ll b) {
    a %= MOD;
    ll res = 1;
    while (b > 0) {
        if (b & 1LL) res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1LL;
    }
    return res;
}

ll add(ll a, ll b) {
    return (a + b) % MOD;
}

ll sub(ll a, ll b) {
    return (a - b + MOD) % MOD;
}

ll mul(ll a, ll b) {
    return a * b % MOD;
}

int n, k;
ll f[MAXN], rev[MAXN], sum[MAXN];

ll C(int n, int k) {
    return mul(mul(f[n], rev[n-k]), rev[k]);
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> k;
    f[0] = 1;
    rev[0] = binPowMod(f[0], MOD-2);

    ll res = 0;
    sum[0] = 0;
    FOR(i,1,n) sum[i] = sum[i-1] + i;
    FOR(i,k,n+1) {
        ll l = sum[i-1], r = sum[n];
        if (i < n) r -= sum[n-i];
        // cout << l << ' ' << r << endl;
        if (l <= r) res = add(res, r-l+1);
    }

    cout << res;

    return 0;
}


Measured memory_bytes: 5176
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/STACK: 20000000005")
*/

using namespace std;

const int N = 2e5 + 5;

int n;
int a[N];

int ans;

main()
{
    //freopen ("in.in", "r", stdin);freopen ("out.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin >> n;
    for (int i = 1; i < n; i++)
        cin >> a[i];
    a[0] = a[1];
    a[n] = a[n - 1];
    for (int i = 1; i <= n; i++)
        ans += min (a[i - 1], a[i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <cstring>
#include <ostream>
#include <cmath>
using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using ll = long long;

template <typename T>
std::ostream& operator << (std::ostream& os, std::vector<T> v) {
  for (int i = 0; i < int(v.size()); ++i) {
    os << v[i] << "\n";
  }
  return os;
}

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

  ll H, W;

  cin >> H >> W;

  ll ans = ll(1e18);
  
  // 横
  for (int i = 1; i <= H / 2; ++i) {
    // 縦
    ll a = W * i, b = (H - i) * (W / 2), c = (H - i) * (W - W / 2);
    ans = std::min(ans, std::max({a, b, c}) - std::min({a, b, c}));

    // 横
    a = W * i, b = W * ((H - i) / 2), c = W * ((H - i) - (H - i) / 2);
    ans = std::min(ans, std::max({a, b, c}) - std::min({a, b, c}));
  }

  // 縦
  for (int i = 1; i <= W / 2; ++i) {
    // 縦
    ll a = H * i, b = H * ((W - i) / 2), c = H * ((W - i) - ((W - i) / 2));
    ans = std::min(ans, std::max({a, b, c}) - std::min({a, b, c}));

    // 横
    a = H * i, b = (W - i) * (H / 2), c = (W - i) * (H - (H / 2));
    ans = std::min(ans, std::max({a, b, c}) - std::min({a, b, c}));
  }

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

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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1e9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;


int main() {

    set<int> s;
    int n;
    cin >> n;

    fo(i, n) {
        int a;
        cin >> a;

        if ( s.find(a) == s.end() ) s.insert(a);
        else s.erase(a);
    }

    cout << s.size() << endl;

    return 0;
}

Measured memory_bytes: 8200
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

int main()
{
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    rep(i,n) cin >> s[i];
    sort(s.begin(), s.end());
    rep(i,n) cout << s[i];
    cout << endl;
            
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int N, M;
	double asumisu, mizuhasu, dachaann;
	int i;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	mizuhasu = 1.0 / (1 << M);
	asumisu = 0;
	dachaann = mizuhasu;
	for (i = 1; i <= 10000; i++) {
		asumisu += i * dachaann;
		dachaann *= 1.0 - mizuhasu;
	}
	printf("%.0f\n", (1900 * M + 100 * (N - M)) * asumisu);
	return 0;
}


Measured memory_bytes: 128
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
    static final Scanner     sc = new Scanner(System.in);
    static final PrintStream so = System.out;

    public static void main(String[] args) {
        int N = nint();
        int[] a = nints(N, 1, 0);
        int[] ball = new int[N+1];
        int m = 0;
        
        for (int i = N; i >= 1; i--) {
            int count = 0;
            for (int j = i+i; j <= N; j+=i) {
                count += ball[j];
            }
            if (count % 2 != a[i]) {
                ball[i] = 1;
                m++;
            }
        }
        
        so.println(m);
        for (int i = 1; i <= N; i++) {
            if (ball[i] == 1) {
                so.println(i);
            }
        }
    }

    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nsToChars() {
        return sc.next().toCharArray();
    }

    private static long[] nlongs(int n) {
        return nlongs(n, 0, 0);
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static long[] nlongs(int n, int padL, int padR) {
        long[] a = new long[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nlong();
        return a;
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = nstr();
        return a;
    }

    private static char[][] nsToChars2D(int h, int w) {
        return nsToChars2D(h, w, 0);
    }

    private static char[][] nsToChars2D(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nsToChars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}


Measured memory_bytes: 73716
from heapq import heappop, heappush
import sys
input = sys.stdin.readline

N = int(input())
H = list(map(int,input().split()))

for i in range(1,N):
  dif = H[i] - H[i-1]
  if dif >= 0: continue
  elif dif == -1: H[i] += 1
  else:
    print('No')
    exit()
print('Yes')

Measured memory_bytes: 14168
#include <iomanip>
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int A, B;
  cin >> A >> B;
  bool answer[3] = {true, true, true};
  answer[A - 1] = false;
  answer[B - 1] = false;
  for (int i = 0; i < 3; ++i) {
    if (answer[i]) {
      cout << i + 1 << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#pragma region GNUC
//以下を参考にした
//https://yukicoder.me/wiki/auto_vectorization
#ifdef __GNUC__
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#endif
#pragma endregion

#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>

#include <string>
#include <cstring>
#include <vector>
#include <valarray>
//#include <array>//x C++ (G++ 4.6.4)

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <cassert>//assert();
#include <fstream>
#include <random>
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)

/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#define PII pair<int,int>
/////////
using namespace::std;
#pragma region Math
// 最大公約数
template<class T>
inline T gcd(T a, T b){return b ? gcd(b, a % b) : a;}
//inline T gcd(T a, T b){return b == 0 ? a : gcd(b, a % b);}

// 最小公倍数
template<class T>
inline T lcm(T a, T b){return a / gcd(a, b) * b;}
//inline T lcm(T a, T b){return a * b / gcd(a, b);}

template<class T>
T pow(T x,int n){
	T mul = x;
	T ans = (T)1;
	while(n){
		if(n&1){
			ans *= mul;
		}
		mul *= mul;
		n >>= 1;
	}
	return ans;
}
#pragma endregion //math

void solve(){
	int N,L;
	cin >> N >> L;
	vector<string> S(N);
	for(int i=0;i<N;++i){
		cin >> S[i];
	}
	sort( S.begin(), S.end() );
	for(int i=0;i<N;++i){
		cout << S[i];
	}
	cout << endl;
}

signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	//std::cout << std::fixed;//小数を10進数表示
	//cout << setprecision(16);//小数点以下の桁数を指定
	
	solve();
}


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

int main()
{
  int n, s;
  while (cin >> n >> s && !(n == 0 && s == 0)) {
    vector<bool> arr(10, true);
    for (int i = 0; i < n; i++) {
      arr[i] = false;
    }

    int ans = 0;
    do {
      int m = 0;
      for (int i = 0; i < 10; i++) {
        if (!arr[i]) {
          m += i;
        }
      }
      if (m == s) {
        ans++;
      }
    } while (next_permutation(arr.begin(), arr.end()));
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
// base. https://atcoder.jp/contests/nikkei2019-2-qual/submissions/8355827

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n, k;
  cin >> n >> k;

  vector<P> a(n); // At first, we consider only first 2N. They are compared with N later.
  rep(i, n) {
    a[i].fr = k; ++k;
  }
  for (int i = n/2; i < n; ++i) {
    a[i].sc = k; ++k;
  }
  for (int i = 0; i < n/2; ++i) {
    a[i].sc = k; ++k;
  }

  // Now, first 2N are used. I want to calculate the sum.
  vector<triple> s;
  rep(i, n) {
    s.emplace_back(a[i].fr + a[i].sc, a[i].fr, a[i].sc);
  }
  sort(all(s));

  // s is sorted. We check s with last N.
  rep(i, n) {
    ll c, fr, sc;
    tie(c, fr, sc) = s[i];
    if (c > k + i) {
      cout << -1 << endl;
      return 0;
    }
  }

  rep(i, n) {
    ll c, fr, sc;
    tie(c, fr, sc) = s[i];
    cout << fr << " " << sc << " " << k+i << endl;
  }
}


Measured memory_bytes: 7024
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;

int sqr(int x){
    int B=x, S=1;
    while(B>S+1){
        int MID=(B+S)/2;
        if(MID*MID>x) B=MID;
        else S=MID;
    }
    return S;
}
int d[400000],memo[400000],rui[400000];
int ans[400000];
int main(){
    int N; cin>>N;
    for(int i=0;i<N;i++){
        int x; cin>>x;
        d[x]++;
    }
    vector<int> q;
    int S=sqr(N);
    int SUM=0;
    for(int i=1;i<=N;i++){
        
        if(d[i]>0) {memo[d[i]]++; SUM++;}
    }
    
    //for(int i=1;i<=N;i++) cout<<"MEMO"<<i<<' '<<memo[i]<<endl;
    for(int i=N;i>=1;i--) rui[i]=memo[i]+rui[i+1];
    //cout<<"SUM"<<SUM<<endl;
    for(int i=1;i<=N;i++) {
        ans[i]=SUM/i;
        SUM+=rui[i+1];
    }

    //for(int i=1;i<=N;i++) cout<<i<<' '<<ans[i]<<endl;

    int count=N;

    for(int i=N;i>=1;i--){
        if(ans[i]!=ans[i+1]) {
            for(int j=ans[i];j>ans[i+1];j--) {
                cout<<i<<endl;
                count--;
            }
        }
    }

    if(count>0) for(int i=0;i<count;i++) cout<<0<<endl;
    
    


    

}

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

using namespace std;

int main()
{
    int t,c1=0,c2=0,c3=0,c4=0;
    cin>>t;
     while(t--)
      {string s;
       cin>>s;
       if(s=="AC")
        {c1++;
        }
       else if(s=="WA")
        {c2++;
        }
       else if(s=="TLE")
        {c3++;
        }
       else
        {c4++;
        }
      }
      cout<<"AC"<<" "<<"x"<<" "<<c1<<endl;
      cout<<"WA"<<" "<<"x"<<" "<<c2<<endl;
      cout<<"TLE"<<" "<<"x"<<" "<<c3<<endl;
      cout<<"RE"<<" "<<"x"<<" "<<c4<<endl;

    return 0;
}

Measured memory_bytes: 3644
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var h = long.Parse(Console.ReadLine());

        long sum = 1;
        for (long i = h; i >= 1; i = (long)Math.Floor((double)i / 2))
        {
            sum *= 2;
        }

        Console.WriteLine(sum - 1);
    }
}

Measured memory_bytes: 13140
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

typedef pair<int, int> pii;

using namespace std;

int main()
{
	string T, P;
	cin >> T >> P;

	int ft[100000];
	ft[0] = -1;
	ft[1] = 0;
	for (int i = 2, j = 0; i <= P.size();)
	{
		if (P[i - 1] == P[j])
		{
			ft[i++] = ++j;
		}
		else if (j > 0)
		{
			j = ft[j];
		}
		else
		{
			ft[i++] = 0;
		}
	}

	int i = 0, j = 0;
	while (i < T.size())
	{
		if (T[i] == P[j])
		{
			i++;
			j++;

			if (j == P.size())
			{
				cout << i - P.size() << endl;
				j = ft[j];
			}
		}
		else if (j == 0)
		{
			i++;
		}
		else
		{
			j = ft[j];
		}
	}

	return 0;
}

/*int main()
{
	string T, P;
	cin >> T >> P;

	int ft[100000];
	ft[0] = 0;
	for (int i = 1, j = 0; i < P.size(); i++)
	{
		if (P[i] != P[j])
		{
			ft[i] = 0;
			j = 0;
		}
		else
		{
			ft[i] = ++j;
		}
	}

	int i = 0, j = 0;
	while (i < T.size())
	{
		if (T[i] == P[j])
		{
			i++;
			j++;

			if (j == P.size())
			{
				cout << i - P.size() << endl;
				j = ft[j - 1];
			}
		}
		else if (j == 0)
		{
			i++;
		}
		else
		{
			j = ft[j - 1];
		}
	}

	return 0;
}*/


Measured memory_bytes: 3972
// D - 756

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

vector<pair<ll, ll>> prime_factorize(ll n) {
	vector<pair<ll, ll> > result;
	for (ll p=2; p*p<=n; p++) {
		if (n % p != 0) continue;
		ll num = 0;
		while (n % p == 0) {
			num++;
			n /= p;
		}
		result.push_back(make_pair(p, num));
    }
    if (n != 1) {
    	result.push_back(make_pair(n, 1));
    }
    return result;
}

int dp[100][76]; // dp[i][s]: i個目までを用いて約数の個数をsにできる組み合わせの数

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

	if (N == 1) {
		cout << 0 << endl;
		return 0;
	}

	map<int, int> primes;

	for (int i=2; i<=N; i++) {
		vector<pair<ll, ll>> pf = prime_factorize(i);

		for (auto p: pf) {
			primes[p.first] += p.second;
		}
	}

	vector<pair<int, int>> prime_cnt;
	for (auto itr : primes) {
		int prime = itr.first;
		int cnt = itr.second;
		//cout << itr.first << " " << itr.second << endl; // **** debug ****
		prime_cnt.push_back(make_pair(prime, cnt));
	}

	dp[0][1] = true;
	for (int i=0; i<prime_cnt.size(); i++) {
		int cnt = prime_cnt[i].second;

		// i+1個目の素数を加えない
		for (int s=1; s<=75; s++) {
			dp[i+1][s] = dp[i][s];
		}

		// i+1個目の素数を1つ以上用いる
		for (int s=1; s<=75; s++) {
			for (int x=1; x<=cnt; x++) {
				if (s * (x+1) <= 75) dp[i+1][s * (x+1)] += dp[i][s];
			}
		}
	}

	int ans = dp[prime_cnt.size()][75];

	// **** debug ****
	/*
	for (int i=0; i<prime_cnt.size(); i++) {
		cout << "i=" << i << endl;
		for (int s=1; s<=75; s++) {
			cout << " " << dp[i][s];
		}
		cout << endl;
	}
	*/

	cout << ans << endl;

	return 0;
}

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

int main() {
	// your code goes here
	int n,k;cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	int sum=0;
	for(int i=0;i<k;i++){
		sum+=a[i];
	}
	cout<<sum<<endl;
	return 0;
}

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

int max_sum(int a[],int as,int b[],int bs,int m){
	int j=bs-1;
	int res=0;
	for(int i=0;i<as;i++){
		while(0<=j && m<a[i]+b[j])j--;
		if(j==-1)break;
		res=max(res,a[i]+b[j]);
	}
	return res;
}

int p[1000],p2[1000*1001/2];
int main(){
	int n,m;
	while(cin>>n>>m,n||m){
		int ans=0;
		for(int i=0;i<n;i++){
			cin>>p[i];
			if(p[i]<=m)ans=max(ans,p[i]);
		}
		sort(p,p+n);
		int n2=0;
		for(int i=0;i<n;i++){
			for(int j=i;j<n;j++){
				int a=p[i]+p[j];
				p2[n2++]=a;
				if(a<=m)ans=max(ans,a);
			}
		}
		sort(p2,p2+n2);
		ans=max(ans,max_sum(p,n,p2,n2,m));
		ans=max(ans,max_sum(p2,n2,p2,n2,m));
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3140
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]
s = 0
cnt = 0

for i in range(n-m+1):
    for j in range(n-m+1):
        for x in range(m):
            for y in range(m):
                if a[i+x][j+y] == b[x][y]:
                    s += 1
        if s == m ** 2:
            cnt += 1
        else:
            s = 0
if cnt > 0:
    print('Yes')
else:
    print('No')

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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)

typedef long long ll;
typedef pair<int,int> p;

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

int main(){
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    if (a==b) {
        cout << c << endl;
    } else if (b==c) {
        cout << a << endl;
    } else if (c==a) {
        cout << b;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

int main() {
    int N,R;
    cin>>N>>R;
    if(N<10){

        cout<<R+100*(10-N)<<endl;

    }
    else{
        cout<<R<<endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>
 
using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
 
 
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;
}
 
//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
 
void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

ll gcd(ll m, ll n) {
	if (n == 0)return m;
	return gcd(n, m % n);
}//gcd

ll lcm(ll m, ll n) {
	return m / gcd(m, n) * n;
}

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

	ll a,b;

	cin>>a>>b;

	cout<<lcm(a,b)<<endl;
	return 0;
}




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

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    vector<int> a(n+2,0);
    rep(i,n) cin >> a[i+1];
    
    int sum = 0;
    rep(i,n+1){
        sum += abs(a[i]-a[i+1]);
    }
    
    rep(i,n){
        cout << sum
                + abs(a[i] - a[i+2])
                - abs(a[i] - a[i+1])
                - abs(a[i+1] - a[i+2]) << endl;
    }
    
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
    int N, M;
    cin >> N >> M;
    vector<int> dp(1<<N, 1'000'000'000);
    dp[0] = 0;

    while(M--) {
        int a, b;
        cin >> a >> b;
        int tmp = 0;
        while(b--) {
            int c;
            cin >> c;
            --c;
            tmp += (1<<c);
        }
        for(int i=0; i<(1<<N); i++) {
            dp[i|tmp] = min(dp[i|tmp], dp[i] + a);
        }
    }

    if(dp.back() == 1'000'000'000) {
        cout << -1 << endl;
    } else {
        cout << dp.back() << endl;
    }
    return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
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; }

int main()
{
    int A, B;
    char op;

    cin >> A >> op >> B;

    if (op == '+')
    {
        cout << A + B << "\n";
        return 0;
    }

    cout << A - B << "\n";

    return 0;
}


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

int main(void) {
	int N;
	cin >> N;
	vector<int> Btn(N);

	for (int i = 0; i < N; i++)
	{
		cin >> Btn.at(i);
	}

	Btn.at(1) = -1;

	int jump = 1;
	int count = 0;
	int j = 0;
	while (1)
	{
		j = Btn.at(jump - 1);
		Btn.at(jump - 1) = 0;
		jump = j;
		count++;
		if (Btn.at(jump - 1) == -1)
		{
			cout << count << endl;
			break;
		}
		else if (Btn.at(jump - 1) == 0)
		{
			cout << -1 << endl;
			break;
		}
	}

	return 0;
}

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

#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define mp make_pair
#define input freopen("input.txt","r",stdin);
#define output freopen("output.txt","w",stdout);
#define fast_io ios::sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);
#define fix cout << fixed << setprecision(15);
//#define left left228
//#define right right228
//#define next next228
#define rank rank228
//#define prev prev228
#define y1 y1228
#define dout if(debug) cout
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int> ;
using pll = pair<ll, ll>;
using pci = pair<char, int>;
using vi = vector<int> ;
using vll = vector<ll> ;
using vpii = vector<pii> ;
const ll infll = 1e18 + 3;
const int maxn = 1e6 + 77;
const int nmax = 1e6 + 577;
const ll basell = 1e18 + 3;
const int mod = 1e9 + 7;
const ld eps = 1e-7;
const int inf = 1009000999;
const int nv = 100505;
const int baseint = 1000200013;
const ld PI = acos(-1.0);
inline bool EQ(ld a, ld b) { return fabs(a-b) < 1e-9; }
inline bool IF(int a, int b, int c) { return (a >= b && a <= c); }
inline bool IFS(int a, int b, int c) { return (a > b && a < c); }
template<typename T> inline istream &operator>> (istream &_in, vector<T> &_v) { for (auto &_i : _v) { _in >> _i; } return _in; }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
//typedef pair<int, int> pt;
//#define x first
//#define y second
//ifstream cin("input.txt");
//ofstream cout("output.txt");
/*
sort(a, a + n, [&](pair<pt, int> a, pair<pt, int> b){if (a.x.x != b.x.x)
        return a.x.x < b.x.x; return a.x.y > b.x.y;});
for(int c : s)
for(int &i : a) cin >> i;
for(int c = 'a'; c <= 'z'; ++c)
vector<vector<ll>> dp(n, vector<ll>(n+2));
__int128;
char 0 = int 48;
char c = cin;
int h = (int)c - 48;
*/

/*char memory[(int)1e8];

char memorypos;

inline void * operator new(size_t n){
    char * ret = memory + memorypos;
    memorypos += n;
    return (void *)ret;
}

inline void operator delete(void *){}
*/

ll a[3000];

ll dp[3000][3000];

ll dfs(int x,int y) {
    if (x > y) {
        return dp[x][y] = 0;
    }
    if (dp[x][y] != -1) {
        return dp[x][y];
    }
    return dp[x][y] = max(a[x] - dfs(x + 1, y), a[y] - dfs(x, y - 1));
}

int inline solve() {
    //input;//,output;
    //fix;
    fast_io;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        fill(dp[i], dp[i] + n, -1);
    }
    cout << dfs(0, n - 1);
    return 0;
}

int32_t main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    solve();
    return 0;
}
/*
6
2 1 6 3 4 5
2 1 3 4 5 6
6 0
1 7 8 2 4 6
 * */

Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e9+7;
const ll N = 1000;





int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll T;
	cin>>T;
	FOR(t,0,T){
		ll a,b,c,d;
		cin>>a>>b>>c>>d;
		if(a<b){pri("No");continue;}
		if(d<b){pri("No");continue;}
		if(c>=b){pri("Yes");continue;}
		ll g=gcd(b,d);
		ll maxx = b - g + (a%g);
		if(maxx>c)pri("No");
		else pri("Yes");
	}
}

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


int main(){

    int a[3][3];

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

    int n,te;
    cin >> n;
    
    for(int k=0;k<n;k++){
        cin >> te;

        for(int i=0;i<3;i++){
            for(int l=0;l<3;l++){
                if(te==a[i][l]){
                    a[i][l]=0;
                }
            }
        }
    }

    bool ans=false;
    if(a[0][0]==0&&a[0][1]==0&&a[0][2]==0){
        ans=true;
    }
    if(a[1][0]==0&&a[1][1]==0&&a[1][2]==0){
        ans=true;
    }
    if(a[2][0]==0&&a[2][1]==0&&a[2][2]==0){
        ans=true;
    }

    if(a[0][0]==0&&a[1][0]==0&&a[2][0]==0){
        ans=true;
    }
    if(a[0][1]==0&&a[1][1]==0&&a[2][1]==0){
        ans=true;
    }
    if(a[0][2]==0&&a[1][2]==0&&a[2][2]==0){
        ans=true;
    }

    if(a[0][0]==0&&a[1][1]==0&&a[2][2]==0){
        ans=true;
    }
    if(a[0][2]==0&&a[1][1]==0&&a[2][0]==0){
        ans=true;
    }
    
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256