akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#define maxt 20001
#define min(a,b) a<b?a:b
using namespace std;
int main()
{
	int n,v[200],vs[maxt*2],t[200],ts[200],cur=0,m;
	double res=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&t[i]);
		if(i==0) ts[i]=t[i];
		else ts[i]=ts[i-1]+t[i];
		//printf(" %d ",ts[i]);
	}
	memset(v,0,sizeof(v));
	for(int i=0;i<n;i++){
		scanf("%d",&v[i]);
		//printf("%d\n",v[i]);
	}
	memset(vs,0,sizeof(vs));
	for(int i=0;i<=ts[n-1]*2;i++){
		if(i==ts[cur]*2){
			vs[i]=min(v[cur]*2,v[cur+1]*2);
			cur++;
		}
		else vs[i]=v[cur]*2;
		//printf("%d %d\n",i,vs[i]);
	}
	m=n;
while(m--){
	cur=-1;
	for(int i=ts[n-1]*2;i>=0;i--){
		if(cur<vs[i]){
			vs[i]=++cur;
		}
		else cur=vs[i];
	}
	cur=-1;
	for(int i=0;i<=ts[n-1]*2;i++){
		if(cur<vs[i]){
			vs[i]=++cur;
		}
		else cur=vs[i];
	}
}
	for(int i=0;i<=ts[n-1]*2;i++){
		res+=((double)vs[i]+vs[i-1])/8;
		//printf("%d %d %d %lf\n",i,vs[i],vs[i+1],res);
	}
	printf("%lf",res);
	return 0;
}

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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

int m,n,n1,n2;
vector<P> g[100010];
int col[100010],par[100010];

void dfs(int v,int c,int f){
  par[v]=f;
  col[v]=c;
  for(P e : g[v]){
    if(col[e.fi]!=-1)continue;
    if(e.se) dfs(e.fi,1-c,f);
    else dfs(e.fi,c,f);
  }
}

int main(){
  while(1){
    cin>>m>>n1>>n2;
    if(m==0&&n1==0&&n2==0)break;
    n=n1+n2;
    rep(i,n)g[i].clear();
    rep(i,m){
      int x,y;
      string s;
      cin>>x>>y>>s;
      x--;y--;
      if(s=="yes"){
        g[x].push_back(P(y,0));
        g[y].push_back(P(x,0));
      }else{
        g[x].push_back(P(y,1));
        g[y].push_back(P(x,1));
      }
    }
    memset(col,-1,sizeof(col));
    rep(i,n){
      if(col[i]!=-1)continue;
      dfs(i,0,i);
    }
    vector<vector<vector<int> > > vs(n,vector<vector<int> >(2,vector<int>()));
    rep(i,n){
      vs[par[i]][col[i]].push_back(i);
    }
    vector<vector<ll> > dp(2,vector<ll>(n1+1,0));
    vector<vector<vector<int> > > dpv(2,vector<vector<int> >(n1+1,vector<int>()));
    int crt=0,nxt=1;
    dp[crt][0]=1;
    rep(i,n){
      int sz0=vs[i][0].size();
      int sz1=vs[i][1].size();
      if(sz0+sz1==0)continue;
      rep(j,n1+1){
        dp[nxt][j]=0;
        dpv[nxt][j].clear();
      }
      rep(j,n1+1){
        if(dp[crt][j]==0||dpv[crt][j].size()!=j)continue;
        if(j+sz0<=n1){
          (dp[nxt][j+sz0]+=dp[crt][j])%=mod;
          dpv[nxt][j+sz0]=dpv[crt][j];
          rep(k,sz0)dpv[nxt][j+sz0].push_back(vs[i][0][k]);
        }
        if(j+sz1<=n1){
          (dp[nxt][j+sz1]+=dp[crt][j])%=mod;
          dpv[nxt][j+sz1]=dpv[crt][j];
          rep(k,sz1)dpv[nxt][j+sz1].push_back(vs[i][1][k]);
        }
      }
      swap(crt,nxt);
    }
    if(dp[crt][n1]!=1){
      cout<<"no"<<endl;
    }else{
      sort(all(dpv[crt][n1]));
      rep(i,dpv[crt][n1].size())cout<<dpv[crt][n1][i]+1<<endl;
      cout<<"end"<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 6396
#include <iostream>
#include <cstring>

using namespace std;

int main(void)
{
    int i, l;
    string s;

    cin >> s;

    l = s.size();

    for(i = 0; i < l; i++)
        if(s[i] == '?')
            s[i] = 'D';

    cout << s;

    return 0;
}


Measured memory_bytes: 3756
#include <iostream>
using namespace std;
int main(){
  int s; cin >> s; int ar[s+1]; ar[0] = 0; int sum = 0;
  for (int i = 1; i < s+1; i++)
  {cin >> ar[i]; sum += abs(ar[i-1]-ar[i]);}
  for (int i = 1; i < s; i++){
  cout << (sum - abs(ar[i-1]-ar[i])-abs(ar[i+1]-ar[i]))+abs(ar[i+1]-ar[i-1])+abs(ar[s]) << "\n";
  }
  cout << sum - abs(ar[s]-ar[s-1]) + abs(ar[s-1]) << endl;
  return 0; }

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <string>
using ll = long long;
using namespace std;

int main() {
    int N;
    cin >> N;
    string s;
    cin >> s;
    for(int i=0; i<=1; ++i) {
        for(int j=0; j<=1; ++j) {
            for(int k=0; k<=1; ++k) {
                vector<int> res(N, -1);
                res[0] = i, res[1] = j, res[N-1] = k;
                bool ok = true;
                for(int l=0; l<N; ++l) {
                    int next = (l+1)%N, prev = (l+N-1)%N;
                    if(s[l] == 'o') {
                        if(res[next] != -1) {
                            if(res[l] == 0) {
                                ok &= res[next] == res[prev];
                            } else {
                                ok &= res[prev] != res[next];
                            }
                        } else {
                            res[next] = (res[l] == 0 ? res[prev] : (res[prev]+1)%2);
                        }
                    } else {
                        if(res[next] != -1) {
                            if(res[l] == 0) {
                                ok &= res[next] != res[prev];
                            } else {
                                ok &= res[next] == res[prev];
                            }
                        } else {
                            res[next] = (res[l] == 0 ? (res[prev]+1)%2 : res[prev]);
                        }
                    }
                }
                if(ok) {
                    for(auto x : res) {
                        cout << (x == 0 ? 'S' : 'W');
                    }
                    cout << endl;
                    return 0;
                }
            }
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 1016
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static Reader;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int res = 0;
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var min = int.MaxValue;
        foreach (var item in a)
        {
            if (item < min)
            {
                res++;
                min = item;
            }
        }
        Console.WriteLine(res);
    }
}


static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] Buffer = new byte[BUF_SIZE];
    static int ptr = BUF_SIZE - 1;
    static void Move() { if (++ptr >= Buffer.Length) { Stream.Read(Buffer, 0, BUF_SIZE); ptr = 0; } }


    public static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; while (Buffer[ptr] < 48) Move();
            do { res = res * 10 + (int)(Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res;
        }
    }
}


Measured memory_bytes: 31964
n, m, x = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
ans = float('inf')
for i in range(1<<n):
  arr = [0] * (m+1)
  for j in range(n):
    if i&(1<<j)==0: continue
    for k, l in enumerate(a[j]):
      arr[k] += l
  if all(l >= x for l in arr[1:]):
    ans = min(ans, arr[0])
print(-1 if ans == float('inf') else ans)

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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

typedef long long ll;

int main(){
  ios::sync_with_stdio(0), cin.tie(0);
  
  int k;  cin >> k;
  ll rem = 0, cnt=1;
  while(cnt++){
    rem = (rem*10+7)%k;
    if(rem==0){
      cout << cnt-1 << "\n";
      return 0;
    }
    if(cnt==10000000)  break;
  }
  cout << "-1\n";
  return 0;
}

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

int main() {
  int A,B;
  bool AA=true;
  cin>>A>>B;
  for(int i=1;i<=1000;i++){
    int K=floor(i*0.08);
    int L=floor(i*0.1);
    if(A==K&&B==L){
      AA= false;
      cout<<i;
      break;
    }
  }
  if(AA) cout<<"-1";
 
}


Measured memory_bytes: 256
def q3():
    N, M, X = [int(i) for i in input().split(" ")]
    books = []
    for i in range(N):
        values = [int(i) for i in input().split(" ")]
        C = values[0]
        A = values[1:]
        books.append([C, A])
    
    def dfs(i, points, value, values):
        if i == N:
            for p in points:
                if p < X:
                    return
            values.append(value)
            return
        dfs(i + 1, list(points), value, values)
        for ind in range(len(points)):
            points[ind] += books[i][1][ind]
        dfs(i + 1, list(points), value + books[i][0], values)
    
    point = []
    for i in range(M):
        point.append(0)
    values = []
    dfs(0, point, 0, values)
    
    if not values:
        print(-1)
    else:
        print(min(values))

q3()


Measured memory_bytes: 9248
def solve():
    while 1:
        try:
            s = list(input())
            s.reverse()
            s = "".join(s)
            if len(s) < 5:
                raise EndLoop

            l = 0
            r = 5
            while r <= len(s):
                if s[l:r] == "maerd" or s[l:r] == "esare":
                    l += 5
                    r += 5
                elif s[l:r] == "remae":
                    if s[l:r + 2] == "remaerd":
                        l += 7
                        r += 7
                    else:
                        raise EndLoop
                elif s[l:r] == "resar":
                    if s[l:r + 1] == "resare":
                        l += 6
                        r += 6
                    else:
                        raise EndLoop
                else:
                    raise EndLoop

            print("YES")
            break
        except:
            print("NO")
            break


solve()

Measured memory_bytes: 3956
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
int main(){
    int s; cin >> s;
    vector<int> dp(s+1); dp[0] = 1;
    for(int i=1; i<=s; ++i){
        for(int j=0; j<=i-3; ++j){
            dp[i] += dp[j];
            dp[i] %= mod; 
        }
    }
    cout << dp[s] << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
string s;
int main() {
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

int main(){
 	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  int n,k;
  cin>>n>>k;
  char s[50];
  cin>>s;
  s[k-1]=tolower(s[k-1]);
  cout<<s;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
//#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[100100];
int main()
{
	ios::sync_with_stdio(false);
	ll n,x,y;
	ll sum=0;
	ll s;
	cin>>n>>x>>y;
	cin>>a[0];
	for(ll i=1;i<n;i++)
	{
		cin>>a[i];
		s=(a[i]-a[i-1])*x;
		if(s<y) sum+=s;
		else sum+=y;
	}
	cout<<sum<<endl;
return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int min = 100;
  
  for (int i = 0; i < N; i++) {
    int A_i;
    int m_i = 0;
    cin >> A_i;
    
    for (int j = 0; j < 100; j++) {
      if (A_i % 2 != 0) {
        break;
      }
      m_i ++ ;
      A_i = A_i/2 ;
    }
    
    if (m_i < min) {
      min = m_i;
    }
    
  }
      
  cout << min << endl;
}

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

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

    int a[n];

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

    for(int i=0; i<n; i++){
        h -= a[i];
    }

    if(h>0){
        cout << "No" << flush;
    }
    else{
        cout << "Yes" << flush;
    }

}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int k, s;
    cin >> k >> s;
    int ans = 0;
    REP(i,k+1) REP(j,k+1){
        int p = s - i - j;
        if (p >= 0 && p <= k) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 764
import sys
import math

input = sys.stdin.readline
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
txy = sorted([(math.atan2(y, x), x, y) for x, y in xy])
txy += txy
i = 0
ans = 0
for i in range(N):
    for j in range(i, 2 * N):
        if j - i > N:
            continue
        xs = sum(map(lambda x: x[1], txy[i:j]))
        ys = sum(map(lambda x: x[2], txy[i:j]))
        ans = max(ans, math.sqrt(xs*xs+ys*ys))
print(ans)


Measured memory_bytes: 68988
//#pragma GCC optimize ('O3')
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 1e5 + 5;
const int M = 5e5 + 5;
const int OO = 1e9;
const int mod = 1e9 + 7;

int n;

void init() {}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;

    cout << 8-n/200+2 << '\n';

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define iiii tuple<int, int, int, int>
#define iii tuple<int, int, int>
#define ii pair<int, int>
#define fi first
#define vi vector<int>
#define vvi vector<vector<int>>
#define se second

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve() {
    int n, m;
    cin >> n >> m;
    vi a(n + 1, 1);
    for (int i = 0; i < m; ++i) {
        int x;
        string s;
        cin >> x >> s;
        if (s == "WA" && a[x] > 0) a[x]++;
        if (s == "AC" && a[x] > 0) a[x] = -a[x];
    }
    int cor = 0, pen = 0;
    for (int i = 0; i < n + 1; ++i) {
        if (a[i] < 0) {
            cor++;
            pen += -a[i] - 1;
        }
    }
    cout << cor << ' ' << pen << '\n';
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}

Measured memory_bytes: 640
#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

const int MOD = 1e9 + 7;

void add(int &a, int b) {
	a += b;
	if (a >= MOD) {
		a -= MOD;
	}
}

void sub(int &a, int b) {
	a -= b;
	if (a < 0) {
		a += MOD;
	}
}

int mult(int a, int b) {
	return (a * 1ll * b) % MOD;
}

int b_pow(int a, int b) {
	if (!b) {
		return 1;
	}
	if (b & 1) {
		return mult(a, b_pow(a, b - 1));
	}
	return b_pow(mult(a, a), b >> 1);
}

const int N = 4010;
int dp[N][N], f[2 * N], rf[2 * N]; 

int C(int n, int k) {
	if (n < 0 || k < 0 || n < k) {
		return 0;
	}
	return mult(f[n], mult(rf[k], rf[n - k]));
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	f[0] = 1;
	for (int i = 1; i <= 8000; i++) {
		f[i] = mult(f[i - 1], i);
	}
	for (int i = 0; i <= 8000; i++) {
		rf[i] = b_pow(f[i], MOD - 2);
	}
	int n;
	cin >> n;
	vector<pair<int, int>> pr;
	for (int i = 1; i <= n; i++) {
		int a, b;
		cin >> a >> b;
		pr.pb({a, b});
		dp[2000 - a][2000 - b]++;
	}
	for (int i = 0; i <= 4000; i++) {
		for (int j = 0; j <= 4000; j++) {
			add(dp[i + 1][j], dp[i][j]);
			add(dp[i][j + 1], dp[i][j]);
		}
	}
	int ans = 0;
	for (auto it : pr) {
		add(ans, dp[it.F + 2000][it.S + 2000]);
	}
	for (auto it : pr) {
		sub(ans, C(2 * it.F + 2 * it.S, 2 * it.S));
	}
	ans = mult(ans, b_pow(2, MOD - 2));
	cout << ans << '\n';
}

Measured memory_bytes: 64752
#include <stdio.h>

/*  選択ソート(0オリジン) */
int selectionSort(int A[], int N) {
    int i, j, t, sw =0, minj;
    for(i=0;i<N-1;i++) {
        minj = i;
        for(j=i;j<N;j++) {
            if(A[j]<A[minj]) minj = j;
        }
        t=A[i]; A[i]=A[minj]; A[minj]=t;
        if(i!=minj) sw++;
    }
    return sw;
}

int main(void) {
    int A[100], N, i, sw;

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

    sw = selectionSort(A,N);

    for(i=0;i<N;i++) {
        if(i>0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",sw);

    return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using i64 = long long;



int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);

  int R;
  cin>>R;
  if (R<1200) cout<<"ABC\n";
  else if (R<2800) cout<<"ARC\n";
  else cout<<"AGC\n";
}


Measured memory_bytes: 256
N = int(input())
Points = [list(map(int, input().split())) for i in range(N)]
# X + Y の偶奇はすべて一致していなければならない
odds_even = set([(x + y) % 2 for x, y in Points])
if len(odds_even) != 1:
    print(-1)
    exit()

D = [2 ** i for i in range(39)]  # アームの長さ
D = D[::-1]  # 反転
if odds_even == {0}:  # 長さ1のアームを追加
    D.append(1)

print(len(D))
print(' '.join(map(str, D)))
# 最も長いアームから考える
for tX, tY in Points:
    nX, nY = 0, 0
    ans = ''
    for d in D:
        uX, uY = nX, nY + d  # 上
        rX, rY = nX + d, nY  # 右
        dX, dY = nX, nY - d  # 下
        lX, lY = nX - d, nY  # 左

        diff_U = abs(tX - uX) + abs(tY - uY)
        diff_R = abs(tX - rX) + abs(tY - rY)
        diff_D = abs(tX - dX) + abs(tY - dY)
        diff_L = abs(tX - lX) + abs(tY - lY)

        Diff = [diff_U, diff_R, diff_D, diff_L]
        Command = ['U', 'R', 'D', 'L']
        Next = [[uX, uY], [rX, rY], [dX, dY], [lX, lY]]

        min_diff_index = Diff.index(min(Diff))

        ans += Command[min_diff_index]
        nX, nY = Next[min_diff_index]

    print(ans)
   

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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new MyInputStream(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(MyInputStream cin)
        {
            var a = cin.ReadIntArray(3);
            if (a[0] == a[1]) WriteLine(a[2]);
            else if (a[0] == a[2]) WriteLine(a[1]);
            else WriteLine(a[0]);
        }
    }

    public class MyInputStream
    {
        private readonly System.IO.TextReader _stream;
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(System.IO.TextReader s, char separator = ' ')
        {
            this.separator = separator;
            this._stream = s;
            inputStream = new Queue<string>();
        }
        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
        public string ReadLine() { return _stream.ReadLine(); }
        public int ReadInt() { return int.Parse(Read()); }
        public long ReadLong() { return long.Parse(Read()); }
        public double ReadDouble() { return double.Parse(Read()); }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read(); return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt(); return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong(); return ret;}
    }
}



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

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

int a[15],cost;
int inf = 1100000000;
int ans = inf;

int v[15][15];

rep(i,n){
  rep(j,m+1) cin >> v[i][j];
}


rep(bit,1<<n){
  int cost =0;
  vector<int> d(m);
  rep(i,n){
    if(bit&1<<i){
      cost +=v[i][0];
      rep(j,m) d[j]+=v[i][j+1];
    }
  }
  bool ok = true;
  rep(i,m){
    if(d[i]<x) ok = false;
  }
  if(ok) ans = min(cost,ans);
  
}

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

Measured memory_bytes: 3644
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

struct TopologicalSort{
    int n;
    vector<set<int> > G;
    vector<bool> used;
    vector<int> indeg,p;

    TopologicalSort(){}
    TopologicalSort(int sz):n(sz),G(n),used(n),indeg(n),p(0){}

    void add_edge(int s,int t){
        G[s].insert(t);
    }

    void bfs(int s){
        queue<int> q;
        q.push(s);
        used[s]=1;
        while(!q.empty()){
            int v=q.front();q.pop();
            p.push_back(v);
            for(int u:G[v]){
                indeg[u]--;
                if(indeg[u]==0&&!used[u]){
                    used[u]=1;
                    q.push(u);
                }
            }
        }
    }

    vector<int>  build(){
        fill(used.begin(),used.end(),0);
        fill(indeg.begin(),indeg.end(),0);

        for(int i=0;i<n;i++)
            for(int v:G[i]) indeg[v]++;

        for(int i=0;i<n;i++)
            if(indeg[i]==0&&!used[i]) bfs(i);

        return p;
    }
};

signed main() {
    int N, M;
    cin >> N >> M;

    vector<int> table[N];

    TopologicalSort ts(N);
    for (int i = 0; i < M; i++) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        ts.add_edge(s, t);
        table[s].push_back(t);
    }

    auto p = ts.build();

    int dp[N];
    fill(dp, dp + N, 0);

    for (int node : p) {
        for (int next : table[node]) {
            dp[next] = max(dp[next], dp[node] + 1);
        }
    }

    int ret = -1;
    for (int i = 0; i < N; i++) {
        ret = max(ret, dp[i]);
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 18300
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin >> N;
    vl A(N), ID(10001), SA;
    rep(i, N) cin >> A[i];
    SA = A;
    sort(all(SA));
    rep(i, N) ID[SA[i]] = i;

    ll m = *min_element(all(A)), ans = 0;
    vc<bool> B(N);
    
    rep(i, N){
        if (B[i] or ID[A[i]] == i) continue;
        ll sum = 0, mv = INF, ti = i, cnt = 0;
        while(!B[ti]){
            B[ti] = true, sum += A[ti], cnt++;
            chmin(mv, A[ti]);
            ti = ID[A[ti]];
        }
        sum -= mv;

        ans += sum + min(2 * (mv + m) + (cnt - 1) * m, (cnt - 1) * mv);
    }
    

    cout << ans << endl;
}


Measured memory_bytes: 3312
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

map<long long, int> factors(long long n) {
  map<long long, int> res;
  for (long long i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}

int main() {
    ll N; cin >> N;
    if (N == 1) {
        cout << 0 << endl;
        return 0;
    }
    int ans = 0;
    for (auto kv : factors(N)) {
        int k = 1;
        while (kv.second >= k) {
            ans++;
            kv.second -= k;
            k++;
        }
    }
    cout << ans << endl;
}

struct boot {
    boot() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} boot_;


Measured memory_bytes: 3660
using System;
using System.Linq;
using System.Text;

namespace ITP1_3_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var sb = new StringBuilder();

            while (true)
            {
                var input = Console.ReadLine().Split(' ')
                    .Select(s => int.Parse(s))
                    .OrderBy(s => s)
                    .ToArray();
                if (input.All(n => n == 0))
                    break;
                sb.AppendLine(string.Format("{0} {1}", input[0], input[1]));
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 10376
using System;

class Program{
    public static void Main(){
        var N=int.Parse(Console.ReadLine());
        var s=Console.ReadLine().Split(' ');
        var A=new int[N];
        for(var i=0; i<N; i++){
            A[i]=int.Parse(s[i]);
        }

        var cnt=0;
        for(var i=0; i<N; i++){
            for(var j=N-1; j>i; j--){
                if(A[j]<A[j-1]){
                    cnt++;
                    var tmp=A[j];
                    A[j]=A[j-1];
                    A[j-1]=tmp;
                }
            }
        }

        for(var i=0; i<N; i++){
            if(i>=N-1){
                Console.WriteLine(A[i]);
            } else{
                Console.Write(A[i]+" ");
            }
        }
        Console.WriteLine(cnt);
    }
}

Measured memory_bytes: 9060
def judgeKaibun(list):
    for index, item in enumerate(list):
        if list[index] != list[(-1 * index) -1]:
            return "No"

    h = int((len(list)-1)/2)
    halflist = list[:h]
    for index, item in enumerate(halflist):
        if halflist[index] != halflist[(-1 * index) -1]:
            return "No"
    return "Yes"

s = list(input())
print(judgeKaibun(s))

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

namespace AtTest.ABC_148
{
    class E
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            long n = ReadLong();
            long res = 0;
            if (n % 2 == 1)
            {
                WriteLine(0);
                return;
            }
            long div = 10;
            while (div <= n)
            {
                res += n / div;
                div *= 5;
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
#include<stdlib.h>

int F[44];
int fibonacci(int);

int main(){
  int n, f;
  int i;

  scanf("%d", &n);
  if(n < 0 || 44 < n)
    exit(0);

  f = fibonacci(n);

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

  return 0;
}

int fibonacci(int n){
  if(n == 0 || n == 1)
    return F[n] = 1;
  if(F[n] != NULL)
    return F[n];
  return F[n] = fibonacci(n - 2) + fibonacci(n - 1);
}

Measured memory_bytes: 596
import sys

sys.setrecursionlimit(100000)


def dfs(v, p):
    result = sum(dfs(c, v) for c in edges[v] if c != p)
    if result >= 2:
        print('First')
        exit()
    return not result


n = int(input())
if n % 2:
    print('First')
    exit()

edges = [set() for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].add(b)
    edges[b].add(a)

print('First' if dfs(0, None) else 'Second')


Measured memory_bytes: 34832
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int a[100010];
int main()
{
    int n=read();long long ans=0;
    for(int i=1;i<=n;i++)a[i]=read();
    sort(a+1,a+n+1);
    if(n%2==0)
    {
	    int ul=n/2;
	    for(int i=n;i>=n-ul+2;i--)ans+=a[i]*2;
	    ans+=a[n-ul+1];
	    ans-=a[n-ul];
	    for(int i=n-ul-1;i>=1;i--)ans-=a[i]*2;
	    
	}
	else
	{
		int ul=(n+1)/2;
		for(int i=n;i>=n-ul+3;i--)ans+=a[i]*2;
		long long he=ans;
		he+=a[n-ul+2]+a[n-ul+1];
		for(int i=n-ul;i>=1;i--)he-=a[i]*2;
		ans+=a[n-ul+2]*2-a[n-ul+1]-a[n-ul];
		for(int i=n-ul-1;i>=1;i--)ans-=a[i]*2;
		ans=max(ans,he);
	}
	printf("%lld\n",ans);	
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(){
  int a,b,k;
  int i = 0;
  
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &k);
  
  int n = 1;
  int count = 0;
  int answer;
  for(n=100;n>= 1;n--){
    if(a%n == 0 && b%n == 0){
      count++;
        if(count == k){
          answer = n;
        }
    }
  }
  printf("%d",answer);
  
return 0;  
}


Measured memory_bytes: 128
#include <cstdio>

int main() {
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);

	if (a < b && a < c) { // a??????????°???????
		if (b < c) printf("%d %d %d\n", a, b, c);
		else printf("%d %d %d\n", a, c, b);
	}
	else if (b < a && b < c) { // b??????????°???????
		if (a < c) printf("%d %d %d\n", b, a, c);
		else printf("%d %d %d\n", b, c, a);
	}
	else { // c??????????°???????
		if (a < b) printf("%d %d %d\n", c, a, b);
		else printf("%d %d %d\n", c, b, a);
	}
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n,m,x; cin >> n >> m >> x;
    vl a(m);
    rep(i,m) cin >> a[i];
    int index = upper_bound(all(a),x) - a.begin();
    int res = min(index,m-index);
    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int m,f,b;
    cin >> m;
    cin >> f;
    cin >> b;
    if(m>b){
        cout << "0" << endl;  
    }
    else if(b-m<=f){
        cout << b-m <<endl;
    }
    else{
        cout << "NA" <<endl;
    }
        
}



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

namespace ABCProblems
{
    class Program
    {
        static void Main(string[] args)
        {
            //空白ずつ取得
            string[] input = Console.ReadLine().Split(' ');

            //整数a
            int a = int.Parse(input[0]);

            //整数b
            int b = int.Parse(input[1]);

            //整数c
            int c = int.Parse(input[2]);

            //aとbのみ等しい
            if(a == b && a != c)
            {
                Console.WriteLine("Yes");
            }

            //aとcのみ等しい
            else if (a == c && a != b)
            {
                Console.WriteLine("Yes");
            }

            //bとcのみ等しい
            else if (b == c && b != a)
            {
                Console.WriteLine("Yes");
            }

            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13140
/*
*   Author : Ligyagami // Tushar Goyal
*/

#include <bits/stdc++.h>

using namespace std;

#define en '\n'
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define PI 3.14159265358979323846

void solve()
{
    double R;
    cin>>R;

    cout<<fixed;
    cout<<setprecision(11);
    cout<<2*PI*R;
}

int main()
{
   fast;

   int T = 1;
   //cin>>T;

   while(T--)
    {
      solve();
    }

   return 0;

}



Measured memory_bytes: 3804
class Ans
    attr_accessor :N, :M
    
    def initialize(n:, m:)
        @N = n 
        @M = m
    end

    def solve
        if @N == @M
            'Yes'
        else
            'No'
        end
    end

end

N,M = gets.chomp.split.map(&:to_i)
ans = Ans.new(n: N,m: M)
puts ans.solve


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

int main(){
    int a[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> a[i][j];
        }
    }
    bool ans = true;
    for(int i=0;i<2;i++){ 
        for(int j=0;j<2;j++){
            if(a[i][j]-a[i][j+1] != a[i+1][j]-a[i+1][j+1]){
                ans = false;
            }
            if(a[i][j]-a[i+1][j] !=a[i][j+1]-a[i+1][j+1]){
                ans = false;
            }
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using db = double;
#define pb push_back

ll d;
ll ans = 0;
ll p[19];
#define dig(x, i) ((x) / p[i] % 10)

map<int,int> pm, pf;

void dfs(ll s, int n, int i, ll mul) {
	if (i * 2 + 1 == n) {
		ans += !s * mul * 10;
		return;
	}
	if (i < n / 2) {
		ans += !s * mul;
		return;
	}
	if (i < 19 && abs(s) > p[i + 1])
		return;
	for (auto j : (i == n - 1 ? pf : pm)) if (i <= 17 || j.first == 0)
		dfs(s - j.first * (p[i] - p[n - 1 - i]), n, i - 1, mul * j.second);
}

int main() {
	cin >> d;
	
	for (int i = 0; i <= 9; ++i)
		for (int j = 0; j <= 9; ++j) {
			++pm[i - j];
			if (i)
				++pf[i - j];
		}
	
	p[0] = 1;
	for (int i = 1; i < 19; ++i)
		p[i] = p[i - 1] * 10;
	
	for (int i = 2; i <= 24; ++i)
		dfs(-d, i, i - 1, 1);
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)
const int INF = (1<<30);
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

class HOGE{
  public:
    ll index;
    ll value;
    HOGE(ll index, ll value){
      this->index = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "index : " << index << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  string S;
  ll w;
  cin >> S;
  cin >> w;

  string ans;
  ll S_size = S.size();
  ll count = 0;
  while(count < S_size){
    ans = ans + S[count];
    count += w;
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
#include<functional>

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

using namespace std;

struct square{
	int x,y,a; // 左上の座標, 幅
	bool operator<(const square &S)const{ return a<S.a; }
};

int h,w;
int B[10][10];

vector<square> S;
int cnt[10][10]; // マス (i, j) を覆うことのできる正方形の個数

#define update_cnt(i,d) for(int y=S[i].y;y<S[i].y+S[i].a;y++) for(int x=S[i].x;x<S[i].x+S[i].a;x++) cnt[y][x]+=d

int hstar(int i){
	int n=0;
	static int val[100]; // i 番目以降の正方形で新たに覆えるマスの個数を大きい順に並べたもの
	for(;i<S.size();i++){
		val[n]=0;
		for(int y=S[i].y;y<S[i].y+S[i].a;y++) for(int x=S[i].x;x<S[i].x+S[i].a;x++) {
			if(B[y][x]==1) val[n]++;
		}
		n++;
	}
	sort(val,val+n,greater<int>());

	int a=0; // まだ覆っていないマスの数
	rep(y,h) rep(x,w) if(B[y][x]==1) a++;

	int res=0;
	for(i=0;a>0;i++){
		a-=val[i];
		res++;
	}
	return res;
}

int res;
void dfs(int i,int sum,int ub){
	if(sum+hstar(i)==ub) return;
	if(sum+hstar(i)>=res) return;

	if(i==S.size()){
		res=sum;
		return;
	}

	bool ok1=false,ok2=false;
	for(int y=S[i].y;y<S[i].y+S[i].a;y++) for(int x=S[i].x;x<S[i].x+S[i].a;x++) {
		if(B[y][x]==1) ok1=true;
		if(B[y][x]==1 && cnt[y][x]==1) ok2=true;
	}

	bool use=true,notuse=true;
	// 正方形 i を使うことで新たに覆えるマスがないなら使わない
	if(!ok1) use=false;
	// 正方形 i を使わないと絶対に覆えないマスができるようなら使う
	if(ok2) notuse=false;

	// いずれでもなければ両方試す
	update_cnt(i,-1);
	if(use){
		int tmp[10][10];
		memcpy(tmp,B,sizeof B);
		for(int y=S[i].y;y<S[i].y+S[i].a;y++) for(int x=S[i].x;x<S[i].x+S[i].a;x++) B[y][x]=i+2;
		dfs(i+1,sum+1,ub);
		memcpy(B,tmp,sizeof B);
	}
	if(notuse){
		dfs(i+1,sum,ub);
	}
	update_cnt(i,+1);
}

int main(){
	for(;scanf("%d%d",&w,&h),w;){
		rep(i,h) rep(j,w) scanf("%d",B[i]+j);

		S.clear();
		rep(i,h) rep(j,w) if(B[i][j]==1) {
			int a;
			for(a=1;i+a<=h&&j+a<=w;a++){
				bool ok=true;
				for(int y=i;y<i+a;y++) for(int x=j;x<j+a;x++) if(B[y][x]==0) ok=false;
				if(!ok) break;
			}
			S.push_back((square){j,i,a-1});
		}

		// 他の正方形に完全に覆われるような正方形を削除
		rep(i,S.size()){
			bool covered=false;
			rep(j,S.size()) if(i!=j) {
				if(S[j].x<=S[i].x
				&& S[j].y<=S[i].y
				&& S[i].x+S[i].a<=S[j].x+S[j].a
				&& S[i].y+S[i].a<=S[j].y+S[j].a) covered=true;
			}
			if(covered){
				S.erase(S.begin()+i);
				i--;
			}
		}
		sort(S.begin(),S.end()); // 小さい正方形から順に調べる

		rep(i,h) rep(j,w) cnt[i][j]=0;
		rep(i,S.size()) update_cnt(i,1);

		res=S.size()+1;
		for(int ub=1;;ub++){
			dfs(0,0,ub);
			if(res<S.size()+1) break;
		}
		printf("%d\n",res);
	}

	return 0;
}

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

int main(){

    int a,b,c;
    cin >>a >>b >> c;

    cout << max(0,c+b-a)<<endl;

    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60; //intじゃ扱えないことに注意！
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意！

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }

  set<int> B{};
  for(int i = 0; i < N; i++){
    B.insert(A[i]);
  }
  if(B.size() == N){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 10368
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

long long int gcd(long long int l, long long int r) {
	if (l > r)return gcd(r, l);
	else {
		if (r%l) {
			return gcd(l, r%l);

		}
		else {
			return l;
		}
	}
}

int main() {
	while (true) {
		int N;cin>>N;
		if(!N)break;
		ld ans=0;

		vector<pair<ld,ld>>ps(N);
		for (int i = 0; i < N; ++i) {
			ld x,y;cin>>x>>y;
			ps[i]=make_pair(x,y);
		}
		vector<int>used(N);
		ld nx=0;
		ld ny=0;
		ld nway = acos(-1.0) / 2;
		for (int i = 0; i < N; ++i) {
			int next_id(-1);
			ld amin(1e18);
			for (int j = 0; j < N; ++j) {
				if (!used[j]) {
					ld dx=ps[j].first-nx;
					ld dy=ps[j].second-ny;

					ld away=atan2(dy,dx)-eps;
					if(away<0)away+=2*acos(-1.0);

					if (away > nway) {
						away-=2*acos(-1.0);
					}
					ld score=nway-away+(abs(dx)+abs(dy))*0.000001;
					if (amin > score) {
						next_id=j;
						amin=score;
					}
				}
			}
			ans+=sqrt(powl(ps[next_id].first-nx,2)+powl(ps[next_id].second-ny,2));
			used[next_id]=true;
			nway = atan2(ps[next_id].second-ny,ps[next_id].first-nx);
			nx=ps[next_id].first;
			ny=ps[next_id].second;
		}

		cout<<setprecision(1)<<fixed<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3276
//84104971101048411497 - Can you guess what does this mean?
using namespace std;
#include <bits/stdc++.h>
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ll long long
#define maxN 200005
#define EPS 1e-9

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int n, x, a[maxN];
bool avail[maxN];

void _fill() {
    int x = 1;
    fto(i, 0, 2*n-2) {
        if (a[i] == 0) {
            while (!avail[x]) ++x;
            a[i] = x;
        }
    }
}

int main () {
    scanf("%d%d", &n, &x);
    if (n == 1) {
        puts("Yes");
        puts("1");
        return 0;
    }
    if (n == 2 && x == 2) {
        puts("Yes");
        puts("1 2 3");
        return 0;
    }
    if (x == 1 || x == 2*n-1) {
        puts("No");
        return 0;
    }

    memset(avail, true, sizeof avail);
    if (x == 2) {
        a[n-3] = 4; avail[4] = false;
        a[n-2] = 1; avail[1] = false;
        a[n-1] = 2; avail[2] = false;
        a[n] = 3; avail[3] = false;
//        fto(i, 1, 2*n-1) a[(i+n-3)%(2*n-1)] = i;
    }
    else if (x == 2*n-2) {
        a[n-3] = x-1; avail[x-1] = false;
        a[n-2] = x; avail[x] = false;
        a[n-1] = x+1; avail[x+1] = false;
        a[n] = x-2; avail[x-2] = false;
    }
    else {
        a[n-3] = x-2; avail[x-2] = false;
        a[n-2] = x+1; avail[x+1] = false;
        a[n-1] = x; avail[x] = false;
        a[n] = x-1; avail[x-1] = false;
        a[n+1] = x+2; avail[x+2] = false;
    }
//    fto(i, 0, 2*n-2) printf("%d ", a[i]);
//    puts("");

    int x = 1;
    fto(i, 0, 2*n-2) {
        if (a[i] == 0) {
            while (!avail[x]) ++x;
            avail[x] = false;
            a[i] = x;
        }
    }

    puts("Yes");
    fto(i, 0, 2*n-2) printf("%d ", a[i]);


    return 0;
}


Measured memory_bytes: 2432
#include <stdio.h>

#define QUEUE_SIZE 100000   /* ?????????????????\????????????????????§??° */
#define SUCCESS     1       /* ?????? */
#define FAILURE     0       /* ??±??? */

typedef struct {
    char name[255];
    int time;
} process;

typedef process data_t;            /* ???????????? */

data_t queue_data[QUEUE_SIZE]; /* ???????????????????????¬??? */
int queue_head;                /* ??????????????? */
int queue_num;                 /* ??????????????° */

int enqueue(data_t enq_data)
{
    if (queue_num < QUEUE_SIZE) {
        queue_data[(queue_head + queue_num) % QUEUE_SIZE] = enq_data;
        queue_num ++;
        return SUCCESS;
    } else {
        return FAILURE;
    }
}

int dequeue(data_t *deq_data)
{
    if (queue_num > 0) {
        *deq_data = queue_data[queue_head];
        queue_head = (queue_head + 1) % QUEUE_SIZE;
        queue_num --;
        return SUCCESS;
    } else {
        return FAILURE;
    }
}

int main(void)
{
    int i,n,q;
	int timer=0;
	data_t data;

    queue_head = queue_num = 0;     /* queue ????????¨??????????????????????????????????????°???????????? */
	
	scanf("%d%d", &n, &q);
	
	for(i = 0; i < n; i++){
		process p;
		scanf("%s%d", p.name, &p.time);
		enqueue(p);
	}
	
	while(queue_num > 0){
		dequeue(&data);
		
		if(data.time - q > 0){
			data.time = data.time - q;
			enqueue(data);
			timer += q;
		}else{
			printf("%s %d\n", data.name, timer + data.time);
			timer += data.time;
		}
	}
	
}

Measured memory_bytes: 25988