akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
using namespace std;

int main()
{
    int N;
    int K;
    int R;
    int S;
    int P;
    
    string T;
    
    cin >> N;
    cin >> K;
    cin >> R;
    cin >> S;
    cin >> P;
    cin >> T;
    
    vector<int> ans(N+1);
    ans[0] = 0;
    
    long long int total = 0;
    
    for(int i=1; i<=N; i++){
        if(i > K){
            if(T[i-1] == 'r'){
                if(ans[i-K] == 1){
                    ans[i] = 4;
                }
                else{
                    ans[i] = 1;
                    total = total+P;
                }
            }
            else if(T[i-1] == 's'){
                if(ans[i-K] == 2){
                    ans[i] = 4;
                }
                else{
                    ans[i] = 2;
                    total = total+R;
                }
            }
            else{
                if(ans[i-K] == 3){
                    ans[i] = 4;
                }
                else{
                    ans[i] = 3;
                    total = total+S;
                }
            }
        }
        else{
            if(T[i-1] == 'r'){
                ans[i] = 1;
                total = total+P;
            }
            else if(T[i-1] == 's'){
                ans[i] = 2;
                total = total+R;
            }
            else{
                ans[i] = 3;
                total = total+S;
            }
        }
    }
    cout << total << endl;
    
    return 0;
}


Measured memory_bytes: 896
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

int h, w;
string c[500];
int DP[500][500];
int cost[400][400];

int main(){
	
	int ans = 0;
	
	cin >> h >> w;
	
	for(int i = 0; i < h; i++){
		cin >> c[i];
	}
	
	for(int left = 0; left < w - 1; left++){
		int right = left + 1;
		string str1 = "";
		string str2 = "";
		for(int i = 0; i < h; i++){
			string ss = "@";
			ss[0] = c[i][left];
			str1 = str1 + ss;
			ss[0] = c[i][right];
			str2 = str2 + ss;
		}
		
		for(int i = 0; i < h; i++){
			cost[0][i] = 0;
			cost[i][0] = 0;
		}
		
		for(int i = 0; i < h; i++){
			for(int j = 0; j < h; j++){
				if(i == 0 || j == 0){
					if(str1[i] == str2[j]){
						cost[i + 1][j + 1] = 1;
					}else{
						cost[i + 1][j + 1] = 0;
					}
				}else{
					if(str1[i] == str2[j]){
						cost[i + 1][j + 1] = 1 + cost[i][j];
					}else{
						cost[i + 1][j + 1] = 0 + cost[i][j];
					}
				}
				//cout << cost[i + 1][j + 1] << " ";
			}
			//cout << endl;
		}
		
		for(int i = h; i >= 0; i--){
			for(int j = h; j >= 0; j--){
				if(i == h && j == h){
					DP[h][h] = 0;
				}else if(i == h){
					DP[i][j] = DP[i][j + 1] + cost[i][j + 1];
				}else if(j == h){
					DP[i][j] = DP[i + 1][j] + cost[i + 1][j];
				}else{
					DP[i][j] = min(DP[i + 1][j] + cost[i + 1][j], DP[i][j + 1] + cost[i][j + 1]);
				}
			}
		}
		
		ans += DP[0][0];
		//cout << DP[0][0] << endl;
	}
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 1536
h, w = [int(i) for i in input().split()]
s = [["."] * (w + 2)] + [["."] + list(input()) + ["."] for _ in range(h)] + [["."] * (w + 2)]
for i in range(1, h + 1):
  for j in range(1, w + 1):
    if s[i][j] == ".":
      continue
    if s[i - 1][j] + s[i + 1][j] + s[i][j - 1] + s[i][j + 1] == "....":
      print("No")
      exit(0)
print("Yes")

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

int main(){
  int a,b;

  scanf("%d %d", &a, &b);
  if(a == b) printf("Draw\n");
  else if(a == 1) printf("Alice\n");
  else if(b == 1) printf("Bob\n");
  else if(a < b) printf("Bob\n");
  else printf("Alice\n"); 

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

    int k,x;
    cin >> k >> x;
    if (k*500>=x)
    {
        cout << "Yes" << endl;
    }    
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.stream.Collectors;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();

        final PriorityQueue<Pair> queue
                = new PriorityQueue<>(Comparator.comparingInt(Pair::getA));
        for(int i = 0 ; i < N ; i++){
            queue.add(new Pair(sc.nextInt(), i + 1));
        }

        final Solver solver = new Solver();
        solver.solve(queue);
    }
}

class Pair {
    final private int a;
    final private int b;

    public Pair(int a, int b) {
        this.a = a;
        this.b = b;
    }

    public int getA() {
        return a;
    }

    public int getB() {
        return b;
    }

    @Override
    public boolean equals(final Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof Pair)) {
            return false;
        }
        final Pair pair = (Pair) o;
        return getA() == pair.getA() &&
                getB() == pair.getB();
    }

    @Override
    public int hashCode() {
        return Objects.hash(getA(), getB());
    }
}

class Solver {
    public void solve(PriorityQueue<Pair> queue) {
        final List<Integer> ans = new ArrayList<>();
        while (!queue.isEmpty()) {
            final Pair p = queue.poll();
            ans.add(p.getB());
        }

        System.out.println(ans.stream().map(String::valueOf).collect(Collectors.joining(" ")));
    }
}



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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[5005];
bool dpL[5005][5005];
bool dpR[5005][5005];
ll S[5005][5005];

int main() {
    ll N, K;
    cin >> N >> K;
    REP(i, N) {
        cin >> A[i];
    }
    memset(dpL, 0, sizeof(dpL));
    dpL[0][0] = true;
    REP(i, N) {
        REP(j, K) {
            dpL[i + 1][j] |= dpL[i][j];
            ll n = j + A[i];
            if (dpL[i][j] && n < K)
                dpL[i + 1][n] = true;
        }
    }

    memset(dpR, 0, sizeof(dpR));
    dpR[N + 1][0] = true;
    REP(i, N) {
        REP(j, K) {
            dpR[N - i][j] |= dpR[N - i + 1][j];
            ll n = j + A[N - 1 - i];
            if (n < K && dpR[N - i + 1][j])
                dpR[N - i][n] = true;
        }
    }

    memset(S, 0, sizeof(S));
    REP(i, N + 1) {
        REP(j, K) {
            if (dpR[i + 1][j])
                S[i + 1][j + 1]++;
            S[i + 1][j + 2] += S[i + 1][j + 1];
        }
    }

    ll ans = 0;
    REP(i, N) {
        //! iを抜く
        bool need = false;
        REP(j, K) {
            if (need)
                break;
            if (!dpL[i][j])
                continue;
            //! K-A[i]以上K-1以下となる和が存在するか
            ll m = std::max(0LL, K - A[i]);
            ll l = std::max(m - j, 0LL);
            ll r = std::max(K - 1 - j, 0LL);
            if (S[i + 2][r + 1] - S[i + 2][l] > 0)
                need = true;
        }
        if (!need)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 244992
//#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cctype>
#include <cstdlib>      // srand,rand


using namespace std;
#define modd 1000000007



typedef pair<long long, long long> pl;


typedef string::const_iterator State;
class ParseError {};




#define ll long long




class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};


class SegmentTree {
private:
	int n;
	vector <ll> node;

public:
	// 元の配列　v をセグメントツリーで表現する。
	SegmentTree(vector<ll> v) {
		//最下段のノード数は元配列のサイズ以上になる最小の2冪->これをnとおく。
		//セグ木全体で必要なノード数は2n-1個である。
		int sz = v.size();
		n = 1; 
		while (n < sz)n *= 2;

	}

};




long long N, M, K, a, b, c, d, e, H, W, L,T;
ll A[300005] = {};
ll B[300005] = {};
ll C[100][3005] = {};
bool f, ff;
string S,SS;
set <long long>sll;
pl bufpl;
vector <long long>vl[100005];
vector <long long>vll;
vector <pl>vpl;
vector <string> vs;
set<ll> llset[50];
multiset<ll> llmset;


struct ST
{
	ll first;
	ll second;
	ll kaisuu;
	

	bool operator<(const ST& another) const
	{
		return first < another.first;//比較
	};

};



/*vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


ll minn, maxx;
double ansa;

ll zettai(ll aa) {

	if (aa < 0) {
		aa *= -1;
	}
	return aa;

}

ll D;


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


	c = 0;
	d = 0;
	e = 2000000000;
	for (ll i = a; i <= b; i++) {
		d = 0;
		for (ll j = i + 1; j <= b; j++) {
			e = min(e, (i * j) % 2019);
			d++;
			if (d > 2020)break;

		}
		c++;
		if (c > 2020) {
			break;
		}
	}

	cout << e << endl;
	
	//cout << fixed << setprecision(10) << ansa << endl;
	return 0;



}


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

long long a,b,c,x,y;

int main() {
    cin>>a>>b>>c>>x>>y;
    int l = min(x,y);

    int ans = 0;
    if(2*c<a+b) {
        ans+=2*c*l;
    }
    else {
        ans+=(a+b)*l;
    }
    if(x>y) {
        if(2*c<a) {
            ans+=2*c*(x-y);
        }
        else {
            ans+=a*(x-y);
        }
    }
    else {
        if(2*c<b) {
            ans+=2*c*(y-x);
        }
        else {
            ans+=b*(y-x);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.Text.RegularExpressions;

namespace Yuzuki
{
    class Yukari
    {
        static int n, m, x;
        static int[] cs;
        static int[,] As;
        public static void Main(string[] args)
        {
            input();
            int ans = int.MaxValue;
            for (int s = 1; s < 1<<n; s++)
            {
                int res = 0;
                int[] ac = new int[m];
                for (int i = 0; i < n; i++)
                {
                    if ((s >> i & 1) == 1)
                    {
                        res += cs[i];
                        for (int j = 0; j < m; j++)
                        {
                            ac[j] += As[i, j];
                        }
                    }
                }
                if (ac.All(x => Yukari.x <= x))
                {
                    ans = Min(ans, res);
                }
            }
            if (ans == int.MaxValue)
            {
                ans = -1;
            }
            Console.WriteLine(ans);
        }
        public static void input()
        {
            string[] buf = Console.ReadLine().Split();
            n = int.Parse(buf[0]);
            m = int.Parse(buf[1]);
            x = int.Parse(buf[2]);
            cs = new int[n];
            As = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                buf = Console.ReadLine().Split();
                cs[i] = int.Parse(buf[0]);
                for (int j = 0; j < m; j++)
                {
                    As[i,j] = int.Parse(buf[j+1]);
                }
            }
        }

    }
}

Measured memory_bytes: 28172
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
ii c[N];
ii nxt[N], pre[N];

ii max(const ii& x, const ii& y) {
  vector<int> A = {x.first, x.second, y.first, y.second};
  sort(A.begin(), A.end(), greater<int>());
  return ii{A[1], A[0]};
}

ii query(int x) {
  ii ret = {-1, -1};
  for (; x; x -= x & -x) {
    ret = max(ret, c[x]);
  }
  return ret;
}

void insert(int x, int y) {
  for (; x < N; x += x & -x) {
    if (y > c[x].second) {
      c[x].first = c[x].second;
      c[x].second = y;
    } else if (y > c[x].first) {
      c[x].first = y;
    }
  }
}

int main() {
  int n;
  scanf("%d", &n);
  vector<int> p(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &p[i]);
  }
  fill(c, c + N, ii{-1, -1});
  for (int i = 0; i < n; ++i) {
    pre[i] = query(n + 1 - p[i]);
    insert(n + 1 - p[i], i);
  }
  fill(c, c + N, ii{-1, -1});
  for (int i = n - 1; i >= 0; --i) {
    nxt[i] = query(n + 1 - p[i]);
    insert(n + 1 - p[i], n - 1 - i);
  }
  int64 ret = 0;
  for (int i = 0; i < n; ++i) {
    int L1 = pre[i].second;
    int L2 = pre[i].first;
    int R1 = n - 1 - nxt[i].second;
    int R2 = n - 1 - nxt[i].first;
    // trace(i, L1, L2, R1, R2);
    if (R1 != n) {
      ret += (int64)(i - L1) * (R2 - R1) * p[i];
    }
    if (L1 != -1) {
      ret += (int64)(R1 - i) * (L1 - L2) * p[i];
    }
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 3072
N = int(input())
H = list(map(int, input().split()))

maximum = 0
pos = -1
for i in range(N - 1):
    if H[i] < H[i + 1]:
        maximum = max(maximum, i - pos - 1)
        pos = i
# print(pos)
maximum = max(maximum, (N - 1) - pos - 1)
print(maximum)


Measured memory_bytes: 14252
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(n / 2);
	x %= mod;
	x *= x;
	x %= mod;
	if (n % 2 == 1)x *= 2;
	x %= mod;
	return x;
}
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
char a[501][501];
bool seen[1000][1000] = { false };
void dfs(int x,int y,int h,int w) {
	seen[x][y] = true;
	for (int i = 0; i < 4; i++) {
		int Nx = x + dx[i];
		int Ny = y + dy[i];
		if (Nx >= h || Ny >= w || seen[Nx][Ny] || a[Nx][Ny] == '#' || Nx < 0 || Ny < 0)continue;
		dfs(Nx, Ny,h,w);
	}
}
int main() {
	int n, m;
	cin>>n>>m;
	int sum = 0;
	rep(i, 0, m) {
		int a;
		cin >> a;
		sum += a;
	}
	int ans = n - sum;
	if (ans < 0)ans = -1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define X first
#define Y second
#define mod 1e9+7
#define pb push_back
#define mp make_pair
#define abs(x) ((x)>0?(x):(-(x)))
#define F(n) Fi(i,n)
#define Fi(i,n) Fl(i,0,n)
#define Fl(i,l,n) for(int i=l;i<n;i++)
#define memres(a) memset(a,0,sizeof(a))
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	ull n,f=10,c=0;
	cin>>n;
	if(n&1||n==2)cout<<0<<endl;
	else{
		while(n>=f){
			c+=(n/f);
			f*=5;
		}
	cout<<c<<endl;
	}
return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
typedef unsigned long long ll;
 
int main(void){
   ll N, sum;
   
   cin >> N;
   sum = 0;
   for(ll i = 1; i <= N; i++){
       if((i%3) != 0 && (i%5) != 0){
           sum += i;
       }
   }
 
    cout << sum << endl;
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<pll> robo(n);
    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        robo[i] = {a - b, a + b};
    }

    sort(robo.begin(), robo.end(), [](pll a, pll b) { return a.second < b.second; });

    int ans = 0;
    ll cur = -pow(10, 10);
    for (int i = 0; i < n; i++)
    {
        if (cur > robo[i].first)
            continue;
        ans++;
        cur = robo[i].second;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)x.size()
#define int ll

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		cout << 0 << '\n';
		exit(0);
	}
	cout << min(a * b, min(a * c, b * c)) << '\n';
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <map>
#include <vector>
#include <queue>
#define fi first
#define se second
using namespace std;
typedef long long i64;
typedef pair<int, i64> pii;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
int n, ans; int w(int i) { return i?w(i/10)+i%10:0; }
int main()
{
    n = read(), ans = 1e9;
    for(int i = 1; i < n; ++i) ans = min(ans, w(i)+w(n-i));
    printf("%d\n", ans);
    return 0;
}

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

int x[50][50], cx, cy, cz, sum, sum2, chain, h, w, gx, gy, pass, line; char a; string S, T; bool y;

void WHILE();
void PASS();
void ugoku(char W);
void IF();
bool hantei();

void ugoku(char W) {
	if (W == '^') {
		if (cz == 0 && x[cy - 1][cx] == 0) { cy--; }
		if (cz == 1 && x[cy][cx + 1] == 0) { cx++; }
		if (cz == 2 && x[cy + 1][cx] == 0) { cy++; }
		if (cz == 3 && x[cy][cx - 1] == 0) { cx--; }
		sum++;
	}
	if (W == 'v') {
		if (cz == 2 && x[cy - 1][cx] == 0) { cy--; }
		if (cz == 3 && x[cy][cx + 1] == 0) { cx++; }
		if (cz == 0 && x[cy + 1][cx] == 0) { cy++; }
		if (cz == 1 && x[cy][cx - 1] == 0) { cx--; }
		sum++;
	}
	if (W == '>') {
		cz += 1; cz %= 4; sum++;
	}
	if (W == '<') {
		cz += 3; cz %= 4; sum++;
	}
	if (W == '[') {
		IF();
	}
	if (W == '}') {
		PASS();
	}
	if (W == '{') {
		WHILE();
	}
}

void IF() {
	T = ""; chain = 0;
	for (int i = line + 1; i < line + 3; i++) { T += S[i]; }
	y = hantei();
	if(y==false){
		for (int i = line; i < S.size(); i++) {
			if (S[i] == '[') { chain++; }
			if (S[i] == ']') { chain--; }
			if (chain == 0) { line = i; break; }
		}
	}
}

void WHILE () {
	T = ""; chain = 0;
	for (int i = line + 1; i < line + 3; i++) { T += S[i]; }
	y = hantei();
	if (y == false) {
		for (int i = line; i < S.size(); i++) {
			if (S[i] == '{') { chain++; }
			if (S[i] == '}') { chain--; }
			if (chain == 0) { line = i; break; }
		}
	}
}

void PASS() {
	chain = 0;
	for (int i = line; i >= 0; i--) {
		if (S[i] == '}') { chain++; }
		if (S[i] == '{') { chain--; }
		if (chain == 0) { pass = i; break; }
	}
	line = pass - 1;
}

bool hantei() {
	if (T[0] == 'N' && cz == 0) { return true; }
	if (T[0] == 'E' && cz == 1) { return true; }
	if (T[0] == 'S' && cz == 2) { return true; }
	if (T[0] == 'W' && cz == 3) { return true; }
	if (T[0] == 'C') {
		if (cz == 0 && x[cy - 1][cx] == 1) { return true; }
		if (cz == 1 && x[cy][cx + 1] == 1) { return true; }
		if (cz == 2 && x[cy + 1][cx] == 1) { return true; }
		if (cz == 3 && x[cy][cx - 1] == 1) { return true; }
	}
	if (T[0] == 'T') { return true; }
	if (T[0] == '~') {
		if (T[1] == 'N' && cz != 0) { return true; }
		if (T[1] == 'E' && cz != 1) { return true; }
		if (T[1] == 'S' && cz != 2) { return true; }
		if (T[1] == 'W' && cz != 3) { return true; }
		if (T[1] == 'C') {
			if (cz == 0 && x[cy - 1][cx] != 1) { return true; }
			if (cz == 1 && x[cy][cx + 1] != 1) { return true; }
			if (cz == 2 && x[cy + 1][cx] != 1) { return true; }
			if (cz == 3 && x[cy][cx - 1] != 1) { return true; }
		}
	}
	return false;
}

int main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a;
			if (a == '#') { x[i][j] = 1; }
			if (a == 'g') { gx = j; gy = i; }
			if (a == 's') { cx = j; cy = i; }
		}
	}
	cin >> S;
	line = 0;
	while (line < S.size()) {
		ugoku(S[line]);
		line++;
		if (cx == gx && cy == gy) { goto F; }
		sum2++;
		if (sum2 > 1500000) { sum = -1; break; }
	}
	sum = -1;
F:;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3216
s = input()
n = len(s)
ans  =[0 for i in range(n)]
i = 0
while i < n:
    le = i
    while i+1 < n and s[i] == s[i+1]:
        i += 1
    length = i - le + 1
    if s[i] == 'L':
        ans[le]+=(length+1)//2
        ans[le-1] += length//2
    else:
        ans[i] += (length+1)//2
        ans[i+1] += length//2
    i += 1

print(*ans)

Measured memory_bytes: 48892
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<Int> used(n,0);
  Int ac=0,pn=0;
  for(Int i=0;i<m;i++){
    Int p;
    string s;
    cin>>p>>s;
    p--;
    if(used[p]<0) continue;
    if(s=="AC"){
      ac++;
      pn+=used[p];
      used[p]=-1;
    }else{
      used[p]++;
    }
  }
  cout<<ac<<" "<<pn<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;
const int N=55;
const int mod=1e9+7;
int n;
char str[2][N];

namespace utils{
	template <class T> inline void apn(T &x,const T y){x>y?x=y:0;}
	template <class T> inline void apx(T &x,const T y){x<y?x=y:0;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

int main(){
	n=nxi();
	scanf("%s%s",str[0]+1,str[1]+1);
	int s0,s1;
	if(str[0][1]!=str[1][1]) s0=0,s1=6;
	else s0=3,s1=0; 
	for(int i=2+(str[0][1]!=str[1][1]); i<=n; ++i){
		if(str[0][i]!=str[1][i]){
			s1=(s0*2ll+s1*3ll)%mod;
			s0=0;
			++i;
		}
		else{
			s0=(s1+s0*2ll)%mod;
			s1=0;
		}
	}
	printf("%d\n",s0+s1);
	return 0;
}


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

int main() {
  int h,w;
  cin >> h >> w;
  vector<vector<char>> a(h,vector<char>(w));
  rep(i,h){
    rep(j,w){
      cin >> a[i][j];
    }
  }
  
  vector<bool> exih(h,false);
  vector<bool> exiw(w,false);
  
  rep(i,h){
    rep(j,w){
      if(a[i][j]=='#'){
        exih[i]=true;
        exiw[j]=true;
      }
    }
  }
  
  rep(i,h){
    int out = 0;
    rep(j,w){
      if(exih[i]&&exiw[j]){
        cout << a[i][j];
        out ++;
      }
    }
    if(out>0)
     cout << endl;
  }
}

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

int main() {
    int h, n;
    cin >> h >> n;
    auto a = vector<int>(n);
    for (auto &a_i : a)
        cin >> a_i;
    auto sum = accumulate(a.begin(), a.end(), 0);
    cout << (sum >= h ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<vector>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define CEVCOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

vector<int> primes;

ll gcd(ll a, ll b){
  if(b == 0)  return a;
  return gcd(b , a % b);
}
void Prime_factorization(ll a){

  int end_num = (int)sqrtl((long double)a);
  for(int i = 2 ; i <= end_num + 1; i++){
    while(a % i == 0){
      a /= i;
      primes.push_back(i);
    }
  }
  if(a!=1) primes.push_back(a);
}

int main(void){

  ll A, B;  cin >> A >> B;
  ll GCD = gcd(A,B);
  primes.push_back(1);
  Prime_factorization(GCD);
  
  ll ans = 1;
  sort(primes.begin(),primes.end());
  for(int i = 1 ; i < primes.size() ; i++){
    if(primes[i] != primes[i - 1])
      ans += 1;
  }

  SCOUT(ans) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

main()

{
    int N, i, mehrab=0;
    scanf("%d",&N);

    int p[N];

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

    for(i=1; i<=N; i++)
    {
        if(p[i] != i)
        {
            mehrab++;
        }
    }

    if(mehrab <= 2)
    {
        printf("YES\n");
    }
    else
        printf("NO\n");

    return 0;

}


Measured memory_bytes: 1616
program alter_altar
    implicit none
    integer :: n, m = 0, l = 1, r
    character(200000) :: s
    read(*,*) n
    read(*,*) s
    r = n
    do
      do while (l <= n .and. s(l:l) == 'R')
        l = l + 1
      end do
      do while (r >= 1 .and. s(r:r) == 'W')
        r = r - 1
      end do
      if (l >= r) exit
      m = m + 1
      s(l:l) = 'R'
      s(r:r) = 'W'
    end do
    write(*,'(i0)') m
  end program alter_altar

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    vector<long long> acc(n + 1, 0);
    for (int i = 0; i < n; i++) acc[i + 1] = acc[i] + a[i];
    int ok = n;
    int ng = - 1;
    while (abs(ok - ng) > 1){
        int mid = (ok + ng) / 2;
        long long tmp = a[mid];
        while (1){
            int left = - 1;
            int right = n;
            while (abs(left - right) > 1){
                int center = (left + right) / 2;
                if (a[center] <= tmp * 2) left = center;
                else right = center;
            }
            if (left < mid){
                if (acc[left + 1] + a[mid] == tmp) break;
                tmp = acc[left + 1] + a[mid];
            }
            else {
                if (acc[left + 1] == tmp) break;
                tmp = acc[left + 1];
            }
        }
        if (tmp == acc.back()) ok = mid;
        else ng = mid;
    }
    cout << n - ok << endl;
}

Measured memory_bytes: 1408
import sys
input = sys.stdin.buffer.readline

class UnionFind:
    __slots__ = ["data"]
    
    def __init__(self, n=0):
        self.data = [-1]*(n+1)
    
    def root(self, x):
        if self.data[x] < 0:
            return x
        self.data[x] = self.root(self.data[x])
        return self.data[x]
    
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            if self.data[x] < self.data[y]:
                self.data[x] += self.data[y]
                self.data[y] = x
            else:
                self.data[y] += self.data[x]
                self.data[x] = y
    
    def same(self, x, y):
        return self.root(x) == self.root(y)
    
    def size(self, x):
        return -self.data[self.root(x)]
                


def main():
    n, m, k = map(int, input().split())
    fb = [0]*(n+1)
    uf = UnionFind(n)
    ans = []
    for _ in range(m):
        a, b = map(int, input().split())
        fb[a] += 1
        fb[b] += 1
        uf.unite(a, b)
    for _ in range(k):
        c, d = map(int, input().split())
        if uf.same(c, d):
            fb[c] += 1
            fb[d] += 1
    for i, nfb in enumerate(fb[1:], 1):
        ans.append(uf.size(i)-1-nfb)
    print(" ".join(list(map(str, ans))))


if __name__ == "__main__":
    main()

Measured memory_bytes: 15604
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, N = 1e6;

/*
  NOTE:
    a[0], a[1], ..., a[2^k-1]
    NTT: inverse = false
    INTT: inv = true
*/
const int M = 998244353, G = 3; // 998244353,1004535809,469762049 : G = 3

int qpow(int a, int b) {
	if(b == 0) return 1;
	int t = qpow(a, b/2);
	t = t * t % M;
	if(b & 1) return t * a % M;
	else return t;
}

int inv(int n) {
	return qpow(n, M - 2);
}

int pos[N];

void NTT(int* a, int k, bool inverse = false) {
	for(int i=1;i<(1<<k);i++) pos[i] = (pos[i>>1] >> 1) | ((i & 1) << (k - 1));
	for(int i=0;i<(1<<k);i++) if(pos[i] < i) swap(a[pos[i]], a[i]);
	for(int len = 2; len <= (1 << k); len <<= 1) {
		int omega = qpow(G, (M - 1) / len);
		if(inverse) omega = inv(omega);
		for(int i = 0; i < (1 << k); i += len) {
			int cur = 1;
			for(int j = i; j < i + len / 2; j++) {
				int l = a[j], r = a[j+len/2];
				a[j] = (l + r * cur % M) % M;
				a[j+len/2] = (l - r * cur % M + M) % M;
				cur = cur * omega % M;
			}
		}
	}
}

int a[N], b[N];

signed main()
{
	IO_OP;
	
	int n, m, k;
	cin >> n >> m >> k;
	int kk = 18;
	a[0] = m;
	b[0] = m - 1;
	b[1] = 1;
	NTT(a, kk);
	NTT(b, kk);
	for(int i = 0; i < (1 << kk); i++) {
		a[i] = a[i] * qpow(b[i], n-1) % M;
	}
	NTT(a, kk, true);
	int ans = 0;
	for(int i = 0; i <= k; i++) {
		ans += a[i] * inv(1 << kk) % M;
	}
	ans %= M;
	cout << ans << endl;
}





Measured memory_bytes: 9808
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

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

  vector<vvl> dp(N + 1, vvl(401, vl(401, 10000)));
  dp[0][0][0] = 0;

  ll a, b, c;
  rep(i, N){
    cin >> a >> b >> c;

    rep(ca, 400 - a){
      rep(cb, 400 - b){
		dp[i + 1][ca][cb] = min(dp[i + 1][ca][cb], dp[i][ca][cb]);
		dp[i + 1][ca + a][cb + b] = min(dp[i + 1][ca + a][cb + b], dp[i][ca][cb] + c);
      }
    }
  }
  
  ll ans = 10000;

  rep(ca, 401){
    rep(cb, 401){
      if((ca*Mb == cb*Ma) && (ca > 0)){
	ans = min(ans, dp[N][ca][cb]);
      }
    }
  }

  if(ans == 10000) cout << -1 << endl;
  else cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 53504
#include<cstdio>
#include<iostream>
using namespace std;
#define LL long long

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

    LL ans = 1;
    for( int i = 1; i <= n; ++i ) {
        ans *= i;
        ans = ans % 1000000007;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    static boolean[][] used;
    static int[] ans;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        long n = sc.nextLong();
        long a = sc.nextLong();
        if(a % n == 0){
            System.out.println(a/n);
            return;
        }
        ArrayList<Long> al = getPrimeList(a);
        long ans = 1;
        for(long v : al){
            if(v > a/n){
                break;
            }else{
                ans = Math.max(ans,v);
                if(a/v <= a/n){
                    ans = Math.max(ans,a/v);
                }
            }
        }
        System.out.println(ans);
    }
    
    private static ArrayList<Long> getPrimeList(long l){
        ArrayList<Long> ret = new ArrayList<Long>();
        long max = (long)Math.sqrt(l);
        for(long i = 2; i <= max; i++){
            if(l % i == 0)ret.add(i);
        }
        return ret;
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

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

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

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


Measured memory_bytes: 22864
#include <bits/stdc++.h>
#define AL(n) new int [(n) + 1]
#define FR(x) if (x) delete [] x;

struct tree {
	int V, E, root;
	int *to, *first, *next, *p, *dep;

	tree () : V(0), E(0), root(0), to(NULL), first(NULL), next(NULL), p(NULL), dep(NULL) {}
	~tree () {FR(to) FR(first) FR(next) FR(p) FR(dep)}

	inline int dmin(const int x, const int y) {return dep[x] < dep[y] ? x : y;}

	inline void addedge(int u, int v) {
		to[++E] = v, next[E] = first[u], first[u] = E;
		to[++E] = u, next[E] = first[v], first[v] = E;
	}

	void dfs(int x) {
		int i, y;
		for (i = first[x]; i; i = next[i])
			if ((y = to[i]) != p[x]) p[y] = x, dep[y] = dep[x] + 1, dfs(y);
	}

	inline bool check_two(int x, int y) {return p[x] == y || p[y] == x || p[p[x]] == y || p[p[y]] == x || p[x] == p[y];}

	void init(int V_, int root_) {
		int i, u, v; V = V_, E = 0, root = root_;
		to = AL(2 * (V - 1)), first = AL(V), next = AL(2 * (V - 1));
		memset(first, 0, (V + 1) << 2);
		for (i = 1; i < V; ++i) scanf("%d%d", &u, &v), addedge(u, v);
		p = AL(V), dep = AL(V), p[root] = dep[root] = 0, dfs(root);
		for (i = 1; i <= V; ++i)
			for (to[ u = first[i] ] == p[i] && (u = first[i] = next[u]); u; u = next[u])
				if (to[ next[u] ] == p[i]) next[u] = next[ next[u] ];
	}
} R, B;

const int N = 200054;

int n, X, Y, ans = 0;
bool key[N];

inline void up(int &x, const int y) {x < y ? x = y : 0;}

void play(int x, int lim) {
	if (B.dep[x] <= lim) return;
	up(ans, key[x] ? INT_MAX : B.dep[x]);
	for (int i = R.first[x]; i; i = R.next[i])
		play(R.to[i], lim + 1);
}

int main() {
	int i;
	scanf("%d%d%d", &n, &X, &Y);
	R.init(n, X), B.init(n, Y);
	for (i = 1; i <= n; ++i)
		if (!(i == X || B.check_two(i, R.p[i]))) key[i] = key[R.p[i]] = true;
	play(X, 0);
	printf("%d\n", ans < INT_MAX ? ans * 2 : -1);
	return 0;
}

Measured memory_bytes: 15616
#include<iostream>
#include<cstdio>
using namespace std;
int A,B;
int anna[5000];
int bruno[5000];
int ans;
int main()
{
	scanf("%d%d",&A,&B);
	for(int i=0;i<A;i++)scanf("%d",&anna[i]);
	for(int i=0;i<B;i++)scanf("%d",&bruno[i]);
	for(int s=0;s<B;s++){
		int nowb=s;
		for(int i=0;i<A;i++){
			if(anna[i]==bruno[nowb]){
				nowb++;
			}
		}
		ans=max(ans,nowb-s);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1228
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j,key;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);
  
  for(j=2;j<=n;j++){
    key=A[j];
    i=j-1;
    while(i>0 && A[i] > key){
      A[i+1] = A[i];
      i=i-1;
      
      
    }
    A[i+1]=key;
    trace(A,n);
  }


  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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 EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int M, D;
    cin >> M >> D;
    int ans = 0;
    for(int m = 1; m <= M; m++) {
        for(int d = 1; d <= D; d++) {
            int d1 = d % 10;
            int d2 = d / 10;
            if(d1 >= 2 && d2 >= 2 && d1 * d2 == m) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
while True:
    inter_test,end_test,re_test = map(int,raw_input().split())

    if [inter_test,end_test,re_test] == [-1,-1,-1]:
        break
    if inter_test == -1 or end_test == -1 :
        print 'F'
    elif inter_test+end_test >= 80 :
        print 'A'
    elif inter_test+end_test >= 65 :
        print 'B'
    elif inter_test+end_test >= 50 :
        print 'C'
    elif inter_test+end_test >= 30 :
        if re_test >= 50 :
            print 'C'
        else :
            print 'D'
    else :
        print 'F'

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

using namespace std;

typedef long long ll;

const ll MOD = 1e9 + 7;

// 二分累乗法による　a^b mod p
ll mod_pow(ll a,ll b,ll p){
    ll res = 1;
    while(b > 0){
        if(b & 1) res = res * a % p;
        a = a * a % p;
        b >>= 1;
    }
    return res;
}

vector<ll> fact;
// n! mod p
void mod_fact(ll n,ll p){
    fact.resize(n+1);
    fact[0] = 1;
    for(int i = 1; i <= n; i++) fact[i] = fact[i-1] * i % p;
}

// nCk mod p
ll mod_comb(ll n, ll k ,ll p){
    if(k > n) return 0;
    return fact[n] * mod_pow(fact[k]*fact[n-k]%p,p-2,p) % p;
}

int main(){
    ll n,k;
    cin >> n >> k;
    mod_fact(n,MOD);
    for(int i = 1; i <= k ; i++){
        ll ans = mod_comb(n-k+1,i,MOD) * mod_comb(k-1,i-1,MOD) % MOD;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/*
×¢Òâ·¶Î§£¡
short·¶Î§£º-32768~32767
unsigned short·¶Î§£º0~65535
int·¶Î§£º-2147483648~2147483647
uint·¶Î§£º0~4294967295
INT·¶Î§£º-9223372036854775808~9223372036854775807
UINT·¶Î§£º0~18446744073709551615
float·¶Î§£º-3.4e38~3.4e38£¬¾«¶È£º6~7Î»
double·¶Î§£º-1.7e308~1.7e308£¬¾«¶È£º15~16Î»
ldouble·¶Î§£º-1.2e4932~1.2e4932£¬¾«¶È£º18~19Î»
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define LL long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define FILL(a,v) memset((void*)a,v,sizeof(a))
#define FILL0(a) FILL(a,0)
#define FILL1(a) FILL(a,-1)
#define ALL(a) (a).begin(),(a).end()
#define Inf 1e9
#define Mod 1000000007
#define foreach(it,x) for(typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define RFOR(i,x) for(int i=x-1;i>=0;i--)
#define FFOR(i,a,b) for(int i=a;i<b;i++)
#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)
#define SZ(a) ((int)(a).size())
#define FI first
#define SE second
#define OVER(a) return puts(a),0
#define fastio ios::sync_with_stdio(0)
#define filei(f) freopen(f,"r",stdin)
#define fileo(f) freopen(f,"w",stdout)
using namespace std;
typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int Uint;
typedef long long INT;
typedef pair<INT,INT> PII;
typedef vector<int> vint;
typedef vector<INT> VINT;
typedef vector<pii> vpii;
typedef vector<PII> VPII;
typedef greater<int> gint;
typedef greater<INT> GINT;
typedef greater<pii> gpii;
typedef greater<PII> GPII;

int h,w,n;
int a[10007],p=1;
int out[107][107];

int main()
{
	scanf("%d%d%d",&h,&w,&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=0;i<h;i++)
	{
		if(i%2)
			for(int j=w-1;j>=0;j--)
			{
				out[i][j]=p;
				a[p]--;
				if(!a[p])p++;
			}
		else
			for(int j=0;j<w;j++)
			{
				out[i][j]=p;
				a[p]--;
				if(!a[p])p++;
			}
	}
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			printf("%d%c",out[i][j],j==w-1?'\n':' ');
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
int binary_search_index(Int Y, vi &q){
    int left = 0, right = q.size() - 1;
    while (right >= left) {
        int mid = left + (right - left) / 2;
        if (q[mid] == Y) return mid;
        else if (q[mid] > Y) right = mid - 1;
        else if (q[mid] < Y) left = mid + 1;
    }
    return -1;
}

int main() {
    Int N,X;
    cin >> N >> X;
    vi x = vi(N);
    rep(i,N){
        cin >> x[i];
    }
    Int ans =0;

    if(x.size() == 1){
        ans = abs(X-x[0]);

    }else if (x.size() == 2){
        ans = GCD(abs(X-x[0]),abs(X-x[1]));
    }else{
        ans = GCD(abs(X-x[0]),abs(X-x[1]));
        REP(i,2,N){
            ans = GCD(ans,abs(X-x[i]));
        }
    }


    cout << ans << endl;

    return 0;
}

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

long long gcd(long long x, long long y) {
  long long a=max(x, y);
  long long b=min(x, y);
  if (a%b==0) return b;
  return gcd(b, a%b);
}

int main() {
  
  long long a, b;
  cin >> a >> b;
  
  cout << a*b/gcd(a, b) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {

    string s; cin >>s;

    for (char i = 'a'; i <= 'z'; i++) {
        int count = 0;
        for (int j = 0; j < s.length(); j++) {
            if (s[j] == i) {
                count++;
            }  
        }
        if (count % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}





Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  long long int array[n], max = 1e18;
  long long int prod = 1;
  long long int flag = 0;
  long long int zero = 0;
  
  for (int i = 0; i < n; i++) {
    scanf("%lld", &array[i]);
    flag = (array[i] > max) ? 1 : flag;
    prod *= array[i];
    (array[i]) ? max /= array[i] : zero = 1;
  }

  (zero) ? puts("0") : ((flag) ? puts("-1") : printf("%lld\n", prod));

  return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  string s;
  cin >> s;
  int a = s.size();
  int z = 0;
  rep(i, s.size()) {
    if (s[i] == 'A') a = min(a, i);
    if (s[i] == 'Z') z = max(z, i);
  }

  cout << z - a + 1 << endl;
}


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

int main() {
    long n, max = 0, ans = 0, hight;
    cin >> n;
    vector<long> a(n);
    for(long i = 0; i < n; ++i){
        cin >> a[i];
        if(max < a[i]){
            max = a[i];
        }else if(max > a[i]){
            hight = max - a[i];
            ans += hight;
            max = a[i] + hight;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4828
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ABC089A
{
    class Program
    {
        static void Main(string[] args)
        {
            int N;
 
            N = int.Parse(Console.ReadLine());
 
            Console.WriteLine(N / 3);
 
            Console.ReadKey();
 
        }
    }
}

Measured memory_bytes: 11220
#include <stdio.h>
#include <math.h>

int main() {
    int n, score[1000];
    double ave, var, sd;
    while (1) {
        ave = 0.0, var = 0.0, sd = 0.0;
        scanf("%d", &n);                // student
        if (n == 0) {break;}            // program end
        for (int i=0; i<n; i++) {
            scanf("%d", &score[i]);     // score
            ave += score[i];
        }
        ave /= n;                       // average
        for (int j=0; j<n; j++) {
            var += pow((score[j] - ave), 2.0);
        }
        var /= n;                       // variance
        sd = sqrt(var);                 // standard deviation
        printf("%f\n", sd);
    }
    return 0;
}



Measured memory_bytes: 2088