akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>

//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
typedef pair<int, int> P;
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<ll> &s, ll a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;

bool check(int a, int b, int c) {
    return a == b && b == c && c == a;
}

int main() {

    vector<vector<int>> board(3, vector<int>(3));
    rep(i, 3)rep(j, 3) cin >> board[i][j];

    bool a0_a1 = check(board[0][0] - board[0][1], board[1][0] - board[1][1], board[2][0] - board[2][1]);
    bool a1_a2 = check(board[0][1] - board[0][2], board[1][1] - board[1][2], board[2][1] - board[2][2]);
    bool a2_a0 = check(board[0][2] - board[0][0], board[1][2] - board[1][0], board[2][2] - board[2][0]);

    bool b0_b1 = check(board[0][0] - board[1][0], board[0][1] - board[1][1], board[0][2] - board[1][2]);
    bool b1_b2 = check(board[1][0] - board[2][0], board[1][1] - board[2][1], board[1][2] - board[2][2]);
    bool b2_b3 = check(board[2][0] - board[0][0], board[2][1] - board[0][1], board[2][2] - board[0][2]);

    if (a0_a1 &&
        a1_a2 &&
        a2_a0 &&
        b0_b1 &&
        b1_b2 &&
        b2_b3) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
using namespace std;
using ll = long long;
int main(void){
    ll n,h,w;
    cin >> n >> h >> w;
    int ans = 0;
    for(ll i=0;i<n;i++){
        ll a,b;
        cin >> a >> b;
        if(a>=h&&b>=w){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int x;
  cin >> x;
  cout << x / 3 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<list>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
#include<cmath>
#include<set>
using namespace std;
#define LL long long
int main()
{
	double L;
	cin>>L;
	L/=3;
	printf("%.12lf",L*L*L);
}

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

int main(){
  int N;
  cin >> N;
  int x;
  int a, b;
  
  for (int i = 0; i < N; i++){
    cin >> a >> b;
    x += b - a + 1;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

ll floor_sum(ll n, ll m, ll a, ll b) {
  ll ans = 0;

  if (a >= m) {
      ans += (n - 1) * n * (a / m) / 2;
      a %= m;
  }
  if (b >= m) {
      ans += n * (b / m);
      b %= m;
  }

  ll y = (a * n + b) / m;
  ll x = y * m - b;
  if (y == 0) return ans;

  ans += (n - (x + a - 1) / a) * y;
  ans += floor_sum(y, a, m, (a - x % a) % a);
  return ans;
}

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

  int t;
  cin >> t;
  vector<ll> n(t), m(t), a(t), b(t);
  for (int i = 0; i < t; i++) cin >> n[i] >> m[i] >> a[i] >> b[i];

  vector<ll> ans(t);
  for (int i = 0; i < t; i++) {
    ans[i] = floor_sum(n[i], m[i], a[i], b[i]);
  }

  for (auto &x: ans) cout << x << endl;

  return 0;
}


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

int main() {
    string s;
    int ans = 0;
    cin >> s;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] == '+') ans++;
        else ans--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if(b%a == 0) cout << a + b << endl;
  else cout << b-a << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long N, K;
long long tripow(long long x) {
	return x * x * x;
}
int main() {
	cin >> N >> K;
	long long ans = tripow(N / K);
	if (K % 2 == 0) ans += tripow((N + K / 2) / K);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define FORD(i, a, b) for (int i=(a); i>(b); i--)
#define PPC(x) __builtin_popcountll(x)
#define MSB(x) (31 - __builtin_clz(x))
#define SZ(x) ((int)(x).size())
#define BACK(x) prev((x).end())
#define HASK(x, y) ((x).find(y) != (x).end())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;
 
const int maxN = 1 << 20;

void solve()
{
	int n, m;
	scanf ("%d%d", &n, &m);
	printf("%d\n", (n+m-1) / m);	
}
 
int main()
{
	int t = 1;
	//scanf ("%d", &t);
	FOR(tid, 1, t+1)
	{
		//printf("Case #%d: ", tid);
		solve();
	}
	return 0;
}





Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
//-std=c++11
#define print(x) printf("%.12f",x);
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define repr(i, n) for(int i=n-1;i>=0;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Repr(i,a,b) for(int i=a;i>=b;i--)
#define pii pair < int, int >
#define iter ::iterator
#define forit(a) for(it=a.begin();it!=a.end();it++)
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod = inf + 7;
const int N = (int)2e5 + 5;

void solve(){
		int n;
		cin>>n;
		int a[n];
		int mx=-1e8,cnt=0;
		rep(i,n){
			cin>>a[i];
			cnt+=(a[i]>=mx);
			mx=max(mx,a[i]);	
		}
		cout<<cnt<<endl;
 
}


int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))
A += A
#print(A)
Aeven = []
for i in range(2*n):
    if i%2 == 0:
        Aeven.append(A[i])
    else:
        Aeven.append(-A[i])
Aodd = []
for i in range(2*n):
    if i%2 == 0:
        Aodd.append(-A[i])
    else:
        Aodd.append(A[i])
from itertools import accumulate
Aodd = [0]+list(accumulate(Aodd))
Aeven = [0]+list(accumulate(Aeven))
for i in range(n):
    if i%2 == 0:
        print(Aeven[i+n]-Aeven[i])
    else:
        print(Aodd[i+n]-Aodd[i])



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

long gcd(long a, long b) {
  if( a < b ) {
    std::swap(a, b);
  }
  while( b != 0 ) {
    a = a % b;
    std::swap(a, b);
  }
  return a;
}

int main(void) {

  long a, b;
  std::cin >> a >> b;
  std::cout << gcd(a, b) << std::endl;

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

template <class T> T mandist(int x1, int y1, int x2, int y2) {
    return abs(x2 - x1) + abs(y2 - y1);
}

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

    int H, W, D;
    cin >> H >> W >> D;
    vector<pair<int, int>> v(H * W + 1);
    REP(i, H) {
        REP(j, W) {
            int x;
            cin >> x;
            v[x] = {i, j};
        }
    }
    vector<ll> cost(H * W + 1);
    REP(i, H * W + 1) {
        if (i <= D)
            continue;
        cost[i] = cost[i - D] + mandist<ll>(v[i].first, v[i].second,
                                            v[i - D].first, v[i - D].second);
    }
    int Q;
    cin >> Q;
    REP(i, Q) {
        int l, r;
        cin >> l >> r;
        print(cost[r] - cost[l]);
    }

    return 0;
}

Measured memory_bytes: 2560
import java.util.*; 
import java.lang.*; 


public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                double A = scan.nextInt();
                double B = scan.nextInt();
                double H = scan.nextInt();
                double M = scan.nextInt();
                
                double hour = 30*H + 0.5*M;
                double min = 6*M;
                
                double kakudo = Math.abs(hour-min);
                
                if(kakudo>=180){
                    kakudo = 360 - kakudo;
                }
                
                double kaku = (kakudo * Math.PI)/180;
                
                double ans = Math.sqrt(A*A+B*B-2*A*B*Math.cos(kaku));
                        
                System.out.println(ans);
        }
}


Measured memory_bytes: 35664
#include <stdio.h>
#include <string.h>

int main(void)
{
	int k;
	char s[100];
	int n;
	
	scanf("%d",&k);
	scanf("%s",&s);
	
	n = strlen(s);
	
	if(n<=k){
		printf("%s",s);
	}else{
		printf("%.*s...",k ,s);
	}
	return 0;
}

Measured memory_bytes: 1732
// AOJ 3056 Equilateral Triangle
// 2018.3.15 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()   // 整数の入力（負数に対応）
{
	int n = 0, c = gc();
	if (c == '-') {
		c = gc();
		do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

typedef struct { double x, y; } PP;

#define INF			1e16

PP vset(double x, double y) { PP r; r.x = x, r.y = y; return r; }
PP vadd(PP p1, PP p2) { PP r; r.x = p1.x + p2.x, r.y = p1.y + p2.y; return r; }
PP vsub(PP p1, PP p2) { PP r; r.x = p1.x - p2.x, r.y = p1.y - p2.y; return r; }
PP vsmul(PP p, double k) { PP r; r.x = p.x * k, r.y = p.y * k; return r; }
PP vmul(PP p1, PP p2) {
	PP r;
	r.x = p1.x * p2.x - p1.y * p2.y, r.y = p1.x * p2.y + p1.y * p2.x; return r;
}
double dist(PP p1, PP p2) { return hypot(p1.x - p2.x, p1.y - p2.y); }

#define TAN30 0.57735026918962576450914878050196

int N;
PP pp[10010];

int main()
{
	int i, j;
	double delta, _sin, _cos, min, max, ans, u, v, t;
	PP q;

	N = in(); ans = INF;
	for (i = 0; i < N; i++) pp[i].x = in(), pp[i].y = in();
	pp[N] = pp[0];
	for (i = 0; i < N; i++) {
		max = min = 0;
		delta = -atan2(pp[i + 1].y - pp[i].y, pp[i + 1].x - pp[i].x);
		_cos = cos(delta), _sin = sin(delta);
		for (j = 1; j < N; j++) {
			q = vsub(pp[(i + j) % N], pp[i]);
			q = vmul(q, vset(_cos, _sin));
			t = fabs(q.y)*TAN30, u = q.x + t, v = q.x - t;
			if (u > max) max = u;
			if (v < min) min = v;
		}
		if (max - min < ans) ans = max - min;
	}
	printf("%.12lf\n", ans);
	return 0;
}


Measured memory_bytes: 2368
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

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



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

	cin >> N >> M;
	K = 1;
	while (N) {
		N--;
		K = min(K * 2, K + M);
	}
	cout << K << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

ll f() {
  int N; cin>>N;
  vector<ll> data(N);
  REP(i,N) cin>>data[i];
  sort(data.begin(), data.end());
  if(data[0] == 0LL) return 0LL;
  const ll INF = 1000000LL * 1000000LL * 1000000LL;
  ll ret = data[0];
  for(int i = 1; i < N; i++) {
    ll tmp = INF / ret * 2LL;
    if(data[i] > tmp) return -1LL;
    ret *= data[i];
    if(ret > INF) return -1LL;
  }
  return ret;
}

int main() {
  ll ret = f();
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 3616
N = int(input())
s = list(input())
S = [0]*N
for i in range(N):
    if s[i]=='o':
        S[i]=1
    else:
        S[i]=-1

P = [[1]*N,[1]*N,[-1]*N,[-1]*N]

if S[0]==1:
    P[0][1]=1
    P[0][N-1]=1
    P[1][1] = -1
    P[1][N - 1] = -1
    P[2][1] = 1
    P[2][N - 1] = -1
    P[3][1] = -1
    P[3][N - 1] = 1
else:
    P[0][1] = 1
    P[0][N - 1] = -1
    P[1][1] = -1
    P[1][N - 1] = 1
    P[2][1] = 1
    P[2][N - 1] = 1
    P[3][1] = -1
    P[3][N - 1] = -1

result = -1
for i in range(1,N-1):
    if i == N-2:
        for j in range(4):
            if S[i] * P[j][i] == 1:
                if P[j][i + 1] == P[j][i - 1]:
                    if S[i+1] * P[j][i+1] == 1:
                        if P[j][0] == P[j][i]:
                            result = j
                            break
                    else:
                        if P[j][0] == - P[j][i]:
                            result = j
                            break
            else:
                if P[j][i + 1] == - P[j][i - 1]:
                    if S[i+1] * P[j][i+1] == 1:
                        if P[j][0] == P[j][i]:
                            result = j
                            break
                    else:
                        if P[j][0] == - P[j][i]:
                            result = j
                            break
    for j in range(4):
        if S[i]*P[j][i]==1:
            P[j][i+1]=P[j][i-1]
        else:
            P[j][i + 1] = - P[j][i - 1]

if result == -1:
    print(result)
else:
    for i in range(N):
        if P[result][i]==1:
            print('S',end="")
        else:
            print('W',end="")


Measured memory_bytes: 9432
#include<bits/stdc++.h>
using namespace std;
namespace io{
    const int l=1<<20;
    char buf[l],*s,*t,c;
    inline void gc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,l,stdin);
            c=s==t?EOF:*s++;
        }else c=*s++;
    }
    template<class IT>inline void gi(IT &x){
        x=0;gc();while(c<'0'||c>'9')gc();
        while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
    }
    char buf0[20];int a;
    template<class IT>inline void pi(IT x){
        if(x<0){putchar('-');x=-x;}
        do buf0[++a]=x%10+48;while(x/=10);
        while(a)putchar(buf0[a--]);
        putchar('\n');
    }
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
typedef vector<int> vi;
typedef vector<ll > vl;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const ll zjc=1000000007ll,pp2=((zjc*zjc)<<1)-1ll;
const int N=200005;
inline ll expo(ll a,int b=1000000005){
	ll c=1ll;
	while(b){
		if(b&1)c=c*a%zjc;
		b>>=1; a=a*a%zjc;
	}
	return c;
}
int main(){
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n,a,b,i;ll p=1ll,q=1ll,r=1ll,s=1ll;
    scanf("%d%d%d",&n,&a,&b);
	rep(i,n-a+1,n)p=p*i%zjc;
	rep(i,n-b+1,n)r=r*i%zjc;
    rep(i,2,a)q=q*i%zjc;
    rep(i,2,b)s=s*i%zjc;
	printf("%lld",(expo(2ll,n)+pp2-(p*expo(q)+r*expo(s)))%zjc);
    return 0;
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream&
operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream&
operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream&
operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;

bool solve(int t, const vector<int> &D) {
    vector<int> arr(24);
    arr[12] = 1;
    auto can_place = [&] (int p) {
        rep(i, t) {
            if(arr[(p + i) % 24] > 0) return false;
            if(arr[(p - i + 24) % 24] > 0) return false;
        }
        return true;
    };
    function<bool(int)> dfs = [&] (int i) {
        if(i >= D.size()) return true;
        for(int d : {(12 + D[i]) % 24, (12 - D[i] + 24) % 24}) {
            if(can_place(d)) {
                arr[d]++;
                bool ok = dfs(i + 1);
                arr[d]--;
                if(ok) return ok;
            }
        }
        return false;
    };
    return dfs(0);
}

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

    int N; cin >> N;
    vector<int> D(N); cin >> D;
    for(int t = 12; t >= 1; t--) {
        if(solve(t, D)) {
            cout << t << endl;
            exit(0);
        }
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MO = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#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;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define rt return
#define ENDL cout<<endl
#define MAXE(a,b) a=max(a,b)
#define MINE(a,b) a=min(a,b)
#define s second
#define f first

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    CIN(N);CIN(M);
    vector<int> cnt(M,0);
    for(int a = 0;a < N;a++){
        CIN(K);
        for(int b = 0;b < K;b++){
            CIN(c);cnt.at(c-1)++;
        }
    }
    int ans = 0;
    for(int a = 0;a < M;a++){
        if(cnt.at(a) == N)ans++;
    }
    COUT(ans);
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i, N, M, X[100001];
	scanf("%d %d", &N, &M);
	for (i = 1; i <= N; i++) scanf("%d", &(X[i]));

	int tmp, ans = 0, count[2][100001] = {};
	for (i = 1; i <= N; i++) {
		count[0][X[i]]++;
		count[1][X[i]%M]++;
	}
	ans = count[1][0] / 2;
	count[1][0] %= 2;
	if (M % 2 == 0) {
		ans += count[1][M/2] / 2;
		count[1][M/2] %= 2;
	}
	for (i = 1; i < (M + 1) / 2; i++) {
		tmp = (count[1][i] < count[1][M-i])? count[1][i]: count[1][M-i];
		ans += tmp;
		count[1][i] -= tmp;
		count[1][M-i] -= tmp;
	}
	for (i = 1; i <= 100000; i++) {
		if (count[0][i] >= 2 && count[1][i%M] >= 2) {
			tmp = (count[0][i] < count[1][i%M])? count[0][i]: count[1][i%M];
			ans += tmp / 2;
			count[1][i%M] -= tmp / 2 * 2;
		}
	}

	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2864
from itertools import product
A,B,C,D = list(input().strip())
for x in product(("+","-"),repeat=3):
    if eval(A+x[0]+B+x[1]+C+x[2]+D)==7:
        print(A+x[0]+B+x[1]+C+x[2]+D+"=7")
        break

Measured memory_bytes: 61888
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let X = scan.word::<i64>();

    let mut map = HashMap::new();

    let mut n = 0_i64;
    let (A, B) = loop {
        let s = n.pow(5);
        if let Some(m) = map.get(&s) {
            break (n, m);
        }

        map.insert(X + s, n);
        map.insert(X - s, -n);

        n += 1;
    };

    println!("{} {}", A, B);
}


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

using namespace std;

#define FOR(i,s,e) for(int (i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)
#define RFOR(i,e,s) for(int (i)=(e);(i)>(int)(s);(i)--)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef pair<int, int> PII;
typedef priority_queue<int> PQI;
typedef priority_queue<PII> PQII;

const double EPS = 1e-10;
const ll INF = LLONG_MAX;
const int N = 1e5;
int w, h;
int n;
ll x[N], y[N], sx[N], sy[N], d[N];

int main() {
  scanf("%d%d ", &w, &h);
  scanf("%d ", &n);
  REP(i,n) {
    scanf("%lld%lld ", x+i, y+i);
    sx[i] = x[i];
    sy[i] = y[i];
  }
  sort(sx, sx+n);
  sort(sy, sy+n);

  ll res_d = INF, res_x, res_y;
  ll mx[4] = {sx[n/2], sx[n/2], sx[n/2-1], sx[n/2-1]};
  ll my[4] = {sy[n/2], sy[n/2-1], sy[n/2], sy[n/2-1]};
  REP(i,4) {
    REP(j,n) d[j] = abs(mx[i]-x[j]) + abs(my[i]-y[j]);
    sort(d,d+n);
    ll tmp_d = 0;
    REP(j,n) tmp_d += d[j];
    tmp_d *= 2LL;
    tmp_d -= d[n-1];
    if (tmp_d <= res_d) {
      res_d = tmp_d;
      res_x = mx[i];
      res_y = my[i];
    }
  }

  printf("%lld\n", res_d);
  printf("%lld %lld\n", res_x, res_y);

  return 0;
}

Measured memory_bytes: 5116
import sys
import copy
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
INF = 1000000000000

n = I()
a = LI()

m = 1000
c = 0
i = 0
while(i < n-1):
    if(c == 0):
        if(a[i] < a[i+1]):
            c = m // a[i]
            m = m % a[i]
    else:
        if(a[i] > a[i+1]):
            m = m + c * a[i]
            c = 0
    i = i+1

if(c != 0):
    m = m + c * a[n-1]

print(m)

Measured memory_bytes: 68468
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<utility>//swapでaとbの値を入れ替える
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
using namespace std;
int main() {
	int a, b;
	int ans = 0;
	cin >> a >> b;
	if (a * 500 >= b)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define inf 1e18
 
 
using namespace std;
signed main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif
    
    IOS;
    int n,i;
    cin>>n;
    int num=1e18;
    vi v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    sort(v.begin(),v.end());
    int prd=v[0];
    for(i=1;i<n;i++)
    {
        int a;
        a=v[i];
        if(prd==0) prd*=a;
        else
        {
            int x;
            x=num/prd+1;
            if(a>=x)
            {
                cout<<"-1";
                return 0;
            }
            prd*=a;
        }
    }
    cout<<prd;
}

Measured memory_bytes: 3976
#include <vector>
#include <array>
#include <algorithm>
#include <tuple>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <iomanip>

using namespace std;

int main(int argc, char const* argv[])
{
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a+b)*h/2 << endl;
    return 0;
}


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

#define get_variable_name(x) #x
#define debug(x) cout << #x << " = " << x << endl
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)

#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())
#define REVERSE(x) reverse( (x).begin(),(x).end())
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define PW(x) (1LL<<(x))

using namespace std;
using ll = int64_t;
using P = pair<int, int>;

template<class T,class U>
ostream& operator<<(ostream &os, const pair<T, U> &p) {
    os << get_variable_name(p) << " = (" << p.first <<", " << p.second << ")";
    return os;
}

template<class T>
ostream& operator <<(ostream& os, const vector<T> &v){
    cout << get_variable_name(v) << " = [";
    for(auto i : v) 
        os << " " << i;
    os << " ]";
    return os;
}


const int INF = 1e8;

int main() {
    ios::sync_with_stdio(false);

    vector<int> a;
    vector<int> v;
    int N, T;
    cin >> N >> T;
    a.resize(N);
    rep(i, N) {
        cin >> a[i];
    }
    int m = a[0];
    int ans = 0;
    int x = 0;
    for(int i = 1; i < N; i++) {
        if(a[i] < m) {
            m = a[i];
        } else if(a[i]-m > x) {
            ans = 1;
            x = a[i]-m;
        } else if(a[i]-m == x) {
            ans++;
        }
    }

    cout << ans << endl;
}


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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;

ll INF = LLONG_MAX / 10;

int num[2];

void dfs(int u, vector<vector<bool>>& a, vector<int>& c) {
	int N = a.size();
	rep(v, N) if (!a[u][v] && c[v] == -1) c[v] = !c[u], num[c[v]]++, dfs(v, a, c);
}

int main() {
	int N, M; cin >> N >> M;
	vector<vector<bool>> a(N, vector<bool>(N));
	while (M--) {
		int u, v; scanf("%d%d", &u, &v), u--, v--;
		a[u][v] = a[v][u] = true;
	}
	vector<int> c(N, -1);
	vector<i_i> unko;
	rep(u, N) if (c[u] == -1) {
		num[0] = 1, num[1] = 0;
		c[u] = 0, dfs(u, a, c);
		unko.pb({num[0], num[1]});
	}
	rep(u, N) rep(v, u) if (!a[u][v] && c[u] == c[v]) {
		cout << -1 << endl;
		return 0;
	}
	vector<bool> dp(N + 1);
	dp[0] = true;
	for (i_i yz: unko) {
		int y = yz.first, z = yz.second;
		vector<bool> _dp(N + 1);
		rep(x, N + 1) if (dp[x]) {
			if (x + y <= N) _dp[x + y] = true;
			if (x + z <= N) _dp[x + z] = true;
		}
		dp = _dp;
	}
	int mi = INT_MAX;
	rep(x, N + 1) if (dp[x]) {
		int y = N - x;
		mi = min(mi, x * (x - 1) / 2 + y * (y - 1) / 2);
	}
	cout << mi << endl;
}


Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

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

bool check(int i, int j, int h) {
    ll x = lcm(i, j);
    x = lcm(x, h);
    if(4LL*x%n == 0 && 4LL*x/n == x/i + x/j + x/h) {
        return true;
    }
    return false;
}


struct Sieve {
    int n;
    vector<int> f, primes;
    Sieve(int n=1):n(n), f(n+1) {
        f[0] = f[1] = -1;
        for(int64_t i=2; i<=n; ++i) {
            if(f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for(int64_t j = i*i; j <= n; j += i) {
                if(!f[j]) f[j] = i;
            }
        }
    }
    //素数判定
    bool isPrime(int x) {return f[x] == x;}
    //素数列挙
    vector<int > factorList(int x) {
        assert(x <= n);
        vector<int> res;
        while(x != 1) {
            res.emplace_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    //素因数分解　pair(素数, 素因数の数)
    vector<pair<int, int> > factor(int x) {
        vector<int> fl = factorList(x);
        if(fl.size() == 0) return {};
        vector<pair<int, int> > res(1, pair<int, int>(fl[0], 0));
        for(int p : fl) {
            if(res.back().first == p) {
                ++res.back().second;
            } else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
}pri(5000);


int main() {
    
    cin >> n;
    if(n%4 == 0) {
        int n_ = 3*n/4;
        cout << n_ << ' ' << n_ << ' ' << n_ << endl;
    } else if(n%4 == 2) {
        int n_ = n/2;
        cout << 2*n_ << ' ' << 2*n_ << ' ' << n_ << endl;
    } else {
        if(!(n%3)) {
            cout << n/3 << ' ' << 2*n << ' ' << 2*n << endl;
        } else {
            int w = *(pri.factorList(n).end()-1);
            rep(i, 3500/w) {
                rep(j, 3500) {
                    double v = 4.0/n;
                    v -= 1.0/(i+1)/w;
                    v -= 1.0/(j+1);
                    v = 1/v + 0.01;
                    if(v < 0) continue;
                    if(check((i+1)*w, j+1, (int)v)) {
                        cout << (i+1)*w << ' ' << j+1 << ' ' <<  (int)v << endl;
                        return 0;
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define endl '\n'
#define int ll

using namespace std;

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

const int M = 1e9 + 7;

char a[1005][1005];
int dp[1005][1005];

int32_t main()
{
	IO_OP;
	
	int h, w;
	cin >> h >> w;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			cin >> a[i][j];
	dp[1][1] = 1;
	for(int i=1;i<=h;i++) {
		for(int j=1;j<=w;j++) {
			if(i == 1 && j == 1) continue;
			if(a[i][j] == '#') continue;
			dp[i][j] = (dp[i][j-1] + dp[i-1][j]) % M;
		}
	}
	cout << dp[h][w] << endl;
}



Measured memory_bytes: 9088
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>
#include <random>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
ll dp[2020];
int main(void){
    ll s;
    cin >> s;


    dp[0] = 1;

    rep(i, 2020){
        for(ll j = i - 3; j >= 0; j--){
            dp[i] += dp[j];
            dp[i] %= MOD;
        }
    }

    cout << dp[s] << endl;
}


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

int main(){
  string s,t,u;
  cin>>s>>t;
  int a,b;
  cin>>a>>b>>u;
  
  if(u==s)a--;
  if(u==t)b--;
  
  cout<<a<<" "<<b<<endl;
  
  
  return 0;
}

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

int main()
{
  int n, a[100];

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

  int cnt = 1, ans = 0;
  for(int i = 0; i < n - 1; i++){
    if(a[i] == a[i+1]){
      cnt++; 
    }else{
      ans += cnt/2;
      cnt = 1;
    }
  }
  ans += cnt/2;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

ll d[MAXn], ans[MAXn];

int main()
{
    IOS();
    priority_queue<ii> pq;
    ll n, q;
    cin >> n >> q;
    for (int i = 1; i <= q; i++)
        cin >> d[i];
    d[0] = n;
    pq.push({d[q], 1});
    for (int i = q - 1; i >= 0; i--) {
        vector<ii> dt;
        while (SZ(pq) && pq.top().X > d[i]) {
            auto p = pq.top();
            pq.pop();
            while (SZ(pq) && pq.top().X == p.X) {
                p.Y += pq.top().Y;
                pq.pop();
            }
            dt.pb({p.X % d[i], p.Y});
            dt.pb({d[i], p.Y * (p.X / d[i])});
        }
        debug(i, dt);
        for (auto &p:dt)
            pq.push(p);
    }
    ll tt = 0;
    for (int i = n; i >= 1; i--) {
        while (SZ(pq) && pq.top().X >= i)
            tt += pq.top().Y, pq.pop();
        ans[i] = tt;
    }
    for (int i = 1; i <= n; i++)
        cout << ans[i] << endl;

}


Measured memory_bytes: 11992
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scan = new Scanner(System.in);

		Integer x = scan.nextInt();
		Integer a = scan.nextInt();
		Integer b = scan.nextInt();

		int ax = x - a;
		int bx = x - b;

		int axx = ax * ax ;
		int bxx = bx * bx ;

		if (axx < bxx) {
			System.out.println("A");
		} else {
			System.out.println("B");
		}
	}
}


Measured memory_bytes: 23636
s = input()
t = input()

maxi = 0

for i in range(0, len(s)-len(t)+1):
    temp = 0
    for j in range(len(t)):
        if s[i+j] == t[j]:
            temp += 1
    maxi = max(temp, maxi)

print(len(t) - maxi)

Measured memory_bytes: 72992
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

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

	int n;
	cin >> n;

	vector<int> ai(n + 1);
	for (int i = 1; i <= n; ++i) {
		cin >> ai[i];
	}

	int presses = 0;
	int curr_button = 1;
	vector<int> visited(n + 1);
	visited[1] = 1;
	while (curr_button != 2) {
		curr_button = ai[curr_button];
		if (visited[curr_button]) {
			cout << "-1\n";
			return 0;
		}

		visited[curr_button] = 1;
		++presses;
	}

	cout << presses << "\n";

	return 0;

}

Measured memory_bytes: 1024
use proconio::input;

fn main() {
  input! {
    n: isize,
    r: isize,
  };
  // r = s if n <= 10
  // r = s - 100x(10-k)
  
  if n >= 10 {
    println!("{}", r);
  } else {
    println!("{}", r + 100*(10-n));
  }
}


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

int main(){
  int res = 0;
  string S;
  cin >> S;
  int n = S.length();
  for (int i = 0; i < n / 2; i++) {
    if (S[i] != S[n -1 - i]) {
      res += 1;
    }
  }
  cout << res << '\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string.h>
#include<queue>
#include<algorithm>
#include<math.h>
#include<iterator>
using namespace std;

class isPall
{
public:
	string s;
	bool isPallindrone(int a,int b)
    {
	    int i,c=0;
	    int n=b-a+1;
	    for(i=0;i<(b-a+1)/2;i++)
	    {
		    if(s[i]==s[n-1])
		    {
			    c++;
			    n--;
		    }
		    else
			    return false;
	    }
	    return true;
    }
};

// bool isPallindrone(string s)
// {
// 	int i,c=0;
// 	int n=s.size();
// 	for(i=0;i<s.size()/2;i++)
// 	{
// 		if(s[i]==s[n-1])
// 		{
// 			c++;
// 			n--;
// 		}
// 		else
// 			return false;
// 	}
// 	return true;
// }

int main()
{
	isPall st;
	cin>>st.s;
	if(st.isPallindrone(0,st.s.size()-1)==1 && st.isPallindrone(0,((st.s.size()-1)/2)-1)==1 && st.isPallindrone(((st.s.size()+3)/2)-1,st.s.size()-1)==1)
	{
		cout<<"Yes"<<endl;
	}
	else
		cout<<"No"<<endl;
	// cout<<st.isPallindrone(0,st.s.size()-1)<<endl;
	// cout<<st.isPallindrone(0,((st.s.size()-1)/2)-1)<<endl;
	// cout<<"(st.s.size()-1)/2 = "<<(st.s.size()-1)/2<<endl;
	// cout<<st.isPallindrone(((st.s.size()+3)/2)-1,st.s.size()-1)<<endl;
	//cout<<isPallindrone(s)<<endl;
	return 0;
}

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

int main(){
	int N,M;
	cin >> N >> M;
	
	vector<int> gatefirst(M);
	vector<int> gatesecond(M);
	rep(i,M){
		int l,r;
		cin >> l >> r;
		gatefirst[i] = l;
		gatesecond[i] = r;
	}
	
	sort(gatefirst.begin(),gatefirst.end());
	reverse(gatefirst.begin(),gatefirst.end());
	sort(gatesecond.begin(),gatesecond.end());
	
	if (gatesecond[0] - gatefirst[0] < 0){
		cout << 0 << endl;
	}else{
		cout << gatesecond[0] - gatefirst[0] + 1 << endl;
	}
	
	return 0;
}



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

int main()
{
    ll D;
    cin >> D;
    vector<ll> C(26);
    for (size_t i = 0; i < 26; i++)
    {
        cin >> C[i];
    }

    vector<vector<ll>> S(D, vector<ll>(26));
    for (size_t i = 0; i < D; i++)
    {
        for (size_t j = 0; j < 26; j++)
        {
            cin >> S[i][j];
        }
    }
    vector<ll> LAST(26, 0);

    ll sum = 0;

    for (size_t i = 0; i < D; i++)
    {
        ll ti;
        cin >> ti;
        ti -= 1;
        sum += S[i][ti];

        for (size_t j = 0; j < 26; j++)
        {
            if (ti == j) {
                continue;
            }
            sum -= (C[j] * (i + 1 - LAST[j]));
        }
        LAST[ti] = i + 1;
        cout << sum << endl;
    }
}

Measured memory_bytes: 3664
import           Control.Monad
import qualified Data.Array.IArray as A
import qualified Data.Map          as M

main :: IO ()
main = do
  [n, c] <- getInts
  ds <- replicateM c getInts
  cs <- replicateM n getInts
  let dat = makeMap c ds
      cls = colorTab n c cs
  print $ solve c dat cls

getInts :: IO [Int]
getInts = map read . words <$> getLine

makeMap n xs = let idx = map (\[a, b] -> (a, b)) $ replicateM 2 [1..n]
               in M.fromList $ zip idx $ concat xs

colorTab :: Int -> Int -> [[Int]] -> A.Array (Int, Int) Int
colorTab n c xs = let idx = map (\[a, b] -> (a + b) `mod` 3) $ replicateM 2 [1..n]
                  in A.accumArray (+) 0 ((0, 1), (2, c)) $ zip (zip idx $ concat xs) $ repeat 1

solve c dat cls = foldr (\a b -> if null a then b else min (sum a) b) (2^30) ans
  where ans = do
          [i, j, k] <- replicateM 3 [1..c]
          if i == j || i == k || j == k
            then return []
            else return $ map (uncurry calc) $ zip [0..2] [i, j, k]
            where
              calc idx color = let ns = map (\(ix, cl) -> (cl, cls A.! (ix, cl))) $ zip (repeat idx) [1..c]
                               in foldr (\(cl, n) b -> b + (dat M.! (cl, color)) * n) 0 ns


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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define FORE( i, m, n ) FOR( i, m , n + 1 )
#define REP( i, n )     FOR( i, 0, n )
#define REPE( i, n )	FOR( i, 0, n + 1 )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define P				pair<string, int>
#define fi				first
#define se				second

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;
const int MAX_N = 100;

bool G[MAX_N][MAX_N];

signed main() {
	int r, g, b; cin >> r >> g >> b;

	if( ( r * 100 + g * 10 + b ) % 4 == 0 ) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	
}

Measured memory_bytes: 256
n = int(input())
a = []
ans = 0
flag = True
for i in range(n):
    A = int(input())
    a.append(A)
next = 0
for i in range(n-1,-1,-1):
    if next - a[i] >= 2:
        flag = False
        break
    if a[i] == 0:
        next = 0
        continue
    if next - a[i] == 1:
        next = a[i]
        continue
    next = a[i]
    ans += a[i]
if a[0] != 0:
    flag = False
if flag:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 11048
#include <iostream>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define ct(string) cout << string << endl
#define all(vec) vec.begin(), vec.end()

int gcd(int x, int y) {
    if (x%y == 0) return y;
    return gcd(y, x%y);
}

int main() {
    int x, y;
    cin >> x >> y;
    ct(gcd(x, y));
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    // 後ろからのdp、O(NM)、各部屋から一番期待値の大きいものが候補となる
    int N, M;
    cin >> N >> M;
    vector<int> graph[N];
    rep(i, M) {
        int s, t;
        cin >> s >> t;
        --s; --t;
        graph[s].push_back(t);
    }
    double dp[N];
    dp[N-1] = 0;
    for (int i = N-2; i >= 0; i--) {
        double cur = 0;
        for (int a : graph[i]) {
            cur += dp[a];
        }
        cur /= sz(graph[i]);
        dp[i] = cur + 1;
    }
    double ans = dp[0];
    // 一つの辺を塞ぐ
    auto temp = [&](int x, int y) {
        double dp[N];
        dp[N-1] = 0;
        for (int i = N-2; i >= 0; i--) {
            double cur = 0;
            for (int a : graph[i]) {
                if (i == x && a == y) continue;
                cur += dp[a];
            }
            if (i == x) cur /= (sz(graph[i]) - 1);
            else cur /= sz(graph[i]);
            dp[i] = cur + 1;
        }
        return dp[0];
    };
    for (int i = 0; i < N-1; i++) {
        if (sz(graph[i]) <= 1) continue;
        int y = graph[i][0];
        for (int a : graph[i]) {
            if (dp[y] < dp[a]) y = a;
        }
        ans = min(ans, temp(i, y));
    }
    printf("%.10f\n", ans);
    return 0;
    // ll, 0, -, 1i, for s&g, debug
}

Measured memory_bytes: 4940