akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <tuple>
#include <cstdio>

// さんこう https://beta.atcoder.jp/contests/arc103/submissions/3300527
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define vec vector
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// さんこう :https://beta.atcoder.jp/contests/abc109/submissions/3153889
using namespace std;

typedef long long ll;

ll N;
ll X[1010];
ll Y[1010];
ll m;
string s = "RLUD";

ll ab(ll a) {
   return (a > 0) ? a : -a;
}

ll dist(ll a, ll b) {
   return ab(a) + ab(b);
}

int main() {
   cin >> N;
   for (ll i=0;i<N;i++) {
      cin >> X[i] >> Y[i];
   }
   ll guuki = (ab(X[0] + Y[0])) % 2;
   for (ll i=0;i<N;i++) {
      if ((ab(X[i] + Y[i])) % 2 != guuki) {
         puts("-1");
         return 0;
      }
   }
   m = 40;
   ll a[40];
   //さんこう: https://beta.atcoder.jp/contests/arc103/submissions/3304078
   if (guuki == 0) {
      a[0] = 1LL<<38;
   } else {
      a[0] = 1LL<<39;
   }
   rep(i,0,m-1) {
      a[i+1] = (a[i]+1)/2;
   }
   cout << m << endl;
   rep(i,0,m) cout << a[i] << " ";
   cout << endl;

   rep(i,0,N) {
      rep(j,0,m) {
         ll mi = 1LL << 42;
         int ret = -1;
         ll pat[] = {dist(X[i]-a[j], Y[i]), dist(X[i] + a[j],Y[i]), dist(X[i], Y[i]-a[j]), dist(X[i], Y[i]+a[j])};
         rep(k, 0, 4) {
            if (pat[k] < mi) {
               mi = pat[k];
               ret = k;
            }
         }
         switch(ret) {
            case 0: X[i]-=a[j]; break;
            case 1: X[i]+=a[j]; break;
            case 2: Y[i]-=a[j]; break;
            case 3: Y[i]+=a[j]; break;
         }
         cout << s[ret];
      }
      cout << endl;
   }
   return 0;
}


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

int main(void){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    ll x = a[0];
    rep1(i,n-1){
        x = a[i] - x;
    }
    assert(x % 2 == 0);

    vector<ll> res(n);
    res[0] = x;
    rep1(i,n-1){
        res[i] = (a[i-1] - res[i-1]/2)*2;
    }
    rep(i,n){
        cout << res[i] << (i < n-1 ? " " : "\n");
    }

    return 0;
}


Measured memory_bytes: 2944
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int n = sc.nextInt();
        int ans = (10000 - n) % 1000;
        System.out.println(ans);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

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

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

Measured memory_bytes: 32784
//#summon tourist
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    ll n=s.size();
    vl acc(n+1);
    acc[0]=0;
    vector<int> dp(1<<26);
    rep(i,1<<26){
        dp[i]=1e9;
    }
    dp[0]=0;
    ll now=0;
    rep(i,n){
        now=(ll)pow(2,s[i]-'a')+1e-5;
        acc[i+1]=acc[i]^now;
    }
    dp[0]=0;
    rep(i,n){
        ll k=1<<25;
        rep(j,27){
            chmin(dp[acc[i+1]],dp[acc[i+1]^k]+1);
            k/=2;
        }
        if(i==n-1){
            if(acc[n]==0){
                cout << 1 << endl;
            }
            else{
                cout << dp[acc[i+1]] << endl;
            }
        }
    }
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/

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

int gcm(int a,int b){
	int x=max(a,b),y=min(a,b);
	if(y==0) return x;
	else return gcm(y, x%y);
}

int main(){
	int a,b,k;
	cin>>a>>b>>k;
	int GCM=gcm(a,b);
	int i;
	for(i=GCM;k!=0;i--){
		if(GCM%i==0) k--;
	}
	cout<<(i+1);
	return 0;
}



Measured memory_bytes: 256
n,k=map(int,input().split())
alst=[0]+list(map(int,input().split()))

dis=[-1]*(n+1)
now=1
time=0
while 1 :
    if dis[now]>=0 : break
    dis[now]=time
    time+=1
    now=alst[now]

if time>k :
    print(dis.index(k))
else :
    head=dis[now]
    roop_unit=time-dis[now]
    work=(k-head)%roop_unit
    print(dis.index(head+work))

Measured memory_bytes: 32368
a, b, c, d = map(int,input().split())

# aとcの距離の絶対値ACを定義
if (a - c) >= 0:
    AC = (a-c)
else:
    AC = (c-a)

# BがAとCの間に入る場合のみ、AB間、BC間を定義
if a < b < c:
    AB = (b - a)
    BC = (c - b)
if c < b < a:
    AB = (a-b)
    BC = (b-c)

# AとCの距離がd以下ならYes！
if AC <= d:
    print('Yes')
# AB間、BC間ともにd以下ならYes！
elif AB <= d and BC <= d:
    print('Yes')
else:
    print('No')


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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

class UnionFind{
private:
  vector<int> par, rank;
public:
  UnionFind(int n){
	par.assign(n, 0);
	rank.assign(n, 0);
	for(int i=0;i<n;++i)
	  par[i] = i;
  }

  //find root of x
  int find(int x){
	if(par[x] == x)
	  return x;
	return (par[x] = find(par[x]));
  }

  void unite(int x, int y){
	x = find(x);
	y = find(y);
	if(x == y) return;

	if(rank[x] < rank[y])
	  par[x] = y;
	else{
	  par[y] = x;
	  if(rank[x] == rank[y])
		++rank[x];
	}
  }

  bool same(int x, int y){
	return find(x) == find(y);
  }
};

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

  int N, E1, E2; cin >> N >> E1 >> E2;
  UnionFind uf1(N), uf2(N);
  REP(i,E1){
	int u, v; cin >> u >> v;
	--u;
	--v;
	uf1.unite(u, v);
  }

  REP(i,E2){
	int u, v; cin >> u >> v;
	--u;
	--v;
	uf2.unite(u, v);
  }
  map<PII,int> cnt;
  REP(i,N)
	cnt[MP(uf1.find(i),uf2.find(i))]++;

  REP(i,N) cout << (i?" ":"") << cnt[MP(uf1.find(i),uf2.find(i))];
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 15104
import os
import sys
from collections import defaultdict

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
X, Y = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(N)]))

yx = defaultdict(lambda: set())
xy = defaultdict(lambda: set())
for x, y in zip(X, Y):
    xy[x].add(y)
    yx[y].add(x)


def connected(x=None, y=None, xret=None, yret=None):
    xret = xret if xret else set()
    yret = yret if yret else set()

    if x is not None:
        for y in xy[x]:
            if y in yret:
                continue
            yret.add(y)
            xret, yret = connected(y=y, xret=xret, yret=yret)
    if y is not None:
        for x in yx[y]:
            if x in xret:
                continue
            xret.add(x)
            xret, yret = connected(x=x, xret=xret, yret=yret)

    return xret, yret


x_counted = set()
y_counted = set()

# X と Y の二部グラフで、連結であるすべての組に辺を張る
ans = 0
for x in xy.keys():
    if x in x_counted:
        continue
    xs, ys = connected(x=x)
    # 辺数
    ans += len(xs) * len(ys)
    x_counted |= xs
    y_counted |= ys
# すでにある辺が重複してる
ans -= N
print(ans)


Measured memory_bytes: 116684
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = 1 << 20;
const int mod = 998244353;
int n, a[N];
char s[N];
ll f[N][5];
int main() {
	int a, b, c, ans = 0;
	cin >> a >> b >> c;
	ans += min(b, c) * 2;
	if (c >= b) { c -= b; b = 0; }
	else { b -= c, c = 0; };
	if (b > 0) ans += b;
	else {
		a++;
		ans += min(a, c);
	}
	cout << ans;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main (String[] args) {

//	パターン1（Aから順番に使って足していく）
//	変数を読み込む
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int K = sc.nextInt();

		int total = 0;  //合計を入れる変数

//	Aから順に、合計K枚になるまで足していく
		if(A >= K) {
			total = K;
			System.out.println(total);
			return;
		}
		else {  //A＜Kの場合は続く
			total = A;
		}

		if(B < K-A) {  //B<=K-AならK-A-B枚分引く
			total -= K-A-B;
			System.out.println(total);
		}
		else {  //B>K-Aならそのまま表示
			System.out.println(total);
			return;
		}
	}
}

Measured memory_bytes: 27048
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define ff first
#define ss second
#define pb push_back
#define N 11

int n, m, a;
ll ans = 0;
vector<int> s[N];
int p[N] = {}, k[N];
int b[N];
void per(int i)
{
	if(i == n)
	{
		int f = 1, l = 0;
		for (int w = 0; w < m; ++w)
		{
			l = 0;
			for(int j = 0; j < k[w]; ++j)
			{
				if(b[s[w][j] - 1])
					l++;
			}
			if(l % 2 != p[w])
			{
				f = 0;
				break;
			}
		}
		if(f)
			ans++;
		return;
	}
	b[i] = 0;
	per(i + 1);
	b[i] = 1;
	per(i + 1);
}

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

	cin >> n >> m;


	for (int i = 0; i < m; ++i)
	{
		cin >> k[i];
		for (int j = 0; j < k[i]; ++j)
		{
			cin >> a;
			s[i].pb(a);
		}
	}
	for (int i = 0; i < m; ++i)
	{
		cin >> p[i];
	}
	per(0);
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <deque>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

int main() {
  ios::sync_with_stdio(false);
  ll K;
  cin >> K;
  VL dist(K, INT_MAX);
  dist[1] = 1;
  deque<int> q;
  q.push_front(1);
  while(!q.empty()) {
    int x = q.front();
    q.pop_front();
    int b = (x * 10) % K;
    if(dist[x] < dist[b]) {
      dist[b] = dist[x];
      q.push_front(b);
    }
    int a = (x + 1) % K;
    if(dist[x] + 1 < dist[a]) {
      dist[a] = dist[x] + 1;
      q.push_back(a);
    }
  }
  cout << dist[0] << endl;
  
  return 0;
}


Measured memory_bytes: 1280
main = do
  getLine >>= putStrLn . compute . read

compute :: Int -> String
compute n = reverse $ take (length bs) $ loop n2
  where
    bs = takeWhile (n >) bases 
    n2 = pred n - last bs

bases = scanl (+) 0 $ iterate (26 *) 26
{- 0から25までは1桁、そこから26^2までは2桁、となる -}

loop n = ['a'..'z'] !! fromIntegral q : loop p
  where (p,q) = divMod n 26


Measured memory_bytes: 3916
package main
import (
	"fmt"
	//"math"
	//"math/rand"
)
func main() {
	var A,B,C int
	fmt.Scan(&A,&B,&C)
	var p = A*10+B+C
	var q = B*10+A+C
	var r = C*10+A+B
	if p>=q && p>=r{
		fmt.Println(p)
	}else if q>=p && q>=r{
		fmt.Println(q)
	}else{
		fmt.Println(r)
	}
}

Measured memory_bytes: 1772
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 200000


int main() {
	long long a[N];
	f(i, N)a[i] = 0;
	long long n, k;
	long long x, y, z;
	long long s, ans;
	bool v = true;
	scanf("%lld", &n);
  ans=1000000000000000;
	f(i, 1000010) {
      if(n%(i+1)==0){
x=n/(i+1);
        ans=min(ans,x+i-1);
      }
	}
	printf("%lld\n", ans);


	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {

  int n,ma,mb;
  scanf("%d %d %d", &n, &ma, &mb);
  int a[n],b[n],c[n];
  for (int i = 0; i < n; i++) {
    scanf("%d %d %d", &a[i], &b[i], &c[i]);
  }
  int dp[n][401][401];
  for (int i = 0; i <= 400; i++) {
    for (int j = 0; j <= 400; j++) {
      dp[0][i][j] = -1;
    }
  }
  dp[0][0][0] = 0;
  dp[0][a[0]][b[0]] = c[0];
  int sum_a,sum_b,cost,min = -1;
  for (int chem = 1; chem < n; chem++) {
    for (int i = 0; i <= 400; i++) {
      for (int j = 0; j <= 400; j++) {
        dp[chem][i][j] = dp[chem-1][i][j];
      }
    }
    for (int i = 0; i <= 400; i++) {
      for (int j = 0; j <= 400; j++) {
        if (dp[chem-1][i][j] == -1) {
          continue;
        }
        sum_a = i+a[chem];
        sum_b = j+b[chem];
        cost = dp[chem-1][i][j]+c[chem];
        if (dp[chem][sum_a][sum_b] == -1 || dp[chem][sum_a][sum_b] > cost) {
          dp[chem][sum_a][sum_b] = cost;
        }
      }
    }
  }
  for (int i = 1; i <= 400; i++) {
    for (int j = 1; j <= 400; j++) {
      if (i*mb == j*ma && dp[n-1][i][j] != -1) {
        if (min == -1 || dp[n-1][i][j] < min) {
          min = dp[n-1][i][j];
        }
      }
    }
  }
  printf("%d\n", min);

  return 0;
}

Measured memory_bytes: 26856
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author lucasr
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		MyScanner in = new MyScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		ADontBeLate solver = new ADontBeLate();
		solver.solve(1, in, out);
		out.close();
	}

	static class ADontBeLate {
		public void solve(int testNumber, MyScanner sc, PrintWriter out) {
			int D = sc.nextInt();
			int S = sc.nextInt();
			int T = sc.nextInt();
			out.println(S * T >= D ? "Yes" : "No");
		}

	}

	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;

		public MyScanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
		}

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

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

	}
}



Measured memory_bytes: 32740
#include <bits/stdc++.h>
using namespace std;
template < typename T > std::string to_string( const T& n ){
	std::ostringstream stm ;
	stm << n ;
	return stm.str() ;
}


int main(void){
	int n,x;
	int tx,ty,tz;
	int ans = 0;
	cin >>n>>x;
	while(n!=0||x!=0){
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				for(int k = 1; k <= n; k++){
					if(i+j+k == x&&(i!=j && j!= k && k!= i))ans++;
				}
			}
		}
		cout <<ans/6<<"\n";
		ans = 0;
		cin >>n>>x;
	}
	return 0;
}


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

int main(){
	int n;
	while(true){
		cin >> n;
		if(!n)break;
		for(int i = 0; i < n; i++){
			int a,b,c,d,e,f,g,h;
			cin >> a >> b >> c >> d >> e >> f >> g >> h;
			int sum1 = 0,sum2 = 0,sum3 = 0,sum4 = 0;
			sum1 = a * e - b * f - c * g - d * h;
			sum2 = a * f + b * e + c * h - d * g;
			sum3 = a * g + c * e - b * h + d * f;
			sum4 = a * h + d * e + b * g - c * f;
			cout << sum1 << " " << sum2 << " " << sum3 << " " << sum4 << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3096
import numpy as np
n,m=map(int,raw_input().split())
a=[]
b=[]
for k in range(m):
    aa,bb=map(int,raw_input().split())
    a.append(aa)
    b.append(bb)
a=np.array(a)
b=np.array(b)

for k in range(1,n+1):
    print(len(np.where(a==k)[0])+len(np.where(b==k)[0]))


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

string S;
long long sum = 0;

void solve() {

  for(int bit = (1<<(S.size()-1)); bit < (1<<(S.size())); bit++) {
  int start = 0;
  int end = 1;
  for(int i = 0; i < S.size(); i++) {
    end = (1<<i);
    if(bit & end) {
      sum += stoll(S.substr(start, i + 1 - start).c_str());
      start = i + 1;
    }
  }
  }

  cout << sum << endl;
}

int main() {
  cin >> S;
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int main() {

    int N; cin >> N;
    vector < int > A(N);
    REP(i,N) cin >> A[i];

    ll ans = 0;
    int x = 0;
    int cnt = 0;
    int l = 0, r = 0;
    while (l < N && r < N) {
        if ((x ^ A[r]) == (x + A[r])) {
            cnt++;
            x ^= A[r];
            r++;
            ans += cnt;
        } else {
            cnt--;
            x ^= A[l];
            l++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    out((x-a)%b);
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
// #define INF 9223372036854775807
# define INF 1e9
using namespace std;

int main(){
  int T, X;
  cin >> T >> X;
  double ans;
  ans = double(T) / double(X);
  cout << setprecision(20) << ans << endl;
}


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

 
int data[10];

bool dfs(int b, int c, int n) {
	if (n == 10){
		return true;
	}
   	else if (data[n] < b && data[n] < c)
		return false;
 
    	if (data[n] > b){
		return dfs(data[n], c, n+1);
	}
   	else if (data[n] > c){
		return dfs(b, data[n], n+1);
	}
}
 
int main() {
    int N;
    cin >> N;
 
    while(N--){
       for (int i = 0; i < 10; i++) {
            cin >> data[i];
        }
	if (dfs(0, 0, 0)){
		 cout << "YES\n";
	}else{
		 cout << "NO\n";
	}
    }
    return 0;
}


Measured memory_bytes: 1124
n = int(input())
s = list(map(int,input().split()))

tmp = [0]*8
r = 0
for i in s:
    if i <= 399:
        tmp[0] = 1
    elif i <= 799:
        tmp[1] = 1
    elif i <= 1199:
        tmp[2] = 1    
    elif i <= 1599:
        tmp[3] = 1        
    elif i <= 1999:
        tmp[4] = 1
    elif i <= 2399:
        tmp[5] = 1
    elif i <= 2799:
        tmp[6] = 1
    elif i <= 3199:
        tmp[7] = 1
    else:
        r += 1

if sum(tmp) == 0:
    ans_min = 1
else:
    ans_min = sum(tmp)
ans_max = sum(tmp) + r

print(ans_min, ans_max)

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

int main()
{
    int k;
    std::cin >> k;
    std::string s;
    std::cin >> s;
    if (s.size() <= k)
    {
        std::cout << s << std::endl;
    }
    else
    {
        std::cout << s.substr(0, k) << "..." << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
int main()
{
    int i,j,H,W;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0 && W==0){
              break;
        }else{
              for(i=0;i<H;i++){
                   for(j=0;j<W;j++){
                           printf("#");
                   }
              printf("\n");
              }
         printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 572
//
// imos 2D algorithm
//
// c.f.
//   https://imoz.jp/algorithms/imos_method.html
//
// verified
//   AOJ Course DSL_5_B Cumulative Sum - The Maximum Number of Overlaps
//     http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_5_B&lang=jp
//


#include <iostream>
#include <vector>
using namespace std;

const int MAX_X = 1001;
const int MAX_Y = 1001;

using Point = pair<int,int>;          // 2 次元座標
using Rectangle = pair<Point,Point>;  // 長方形の (左上, 右下)

int imos(const vector<Rectangle> &recs) {
    vector<vector<int> > nums(MAX_X+1, vector<int>(MAX_Y+1, 0));
    for (auto rec : recs) {
        nums[rec.first.first][rec.first.second]++;
        nums[rec.first.first][rec.second.second]--;
        nums[rec.second.first][rec.first.second]--;
        nums[rec.second.first][rec.second.second]++;
    }
    for (int x = 0; x < MAX_X; ++x) 
        for (int y = 0; y < MAX_Y; ++y)
            nums[x][y+1] += nums[x][y];
    for (int y = 0; y < MAX_Y; ++y)
        for (int x = 0; x < MAX_X; ++x)
            nums[x+1][y] += nums[x][y];
    int res = 0;
    for (int x = 0; x <= MAX_X; ++x)
        for (int y = 0; y <= MAX_Y; ++y)
            res = max(res, nums[x][y]);
    return res;
}


int main() {
    int N; cin >> N;
    vector<Rectangle> recs(N);
    for (int i = 0; i < N; ++i)
        cin >> recs[i].first.first >> recs[i].first.second >> recs[i].second.first >> recs[i].second.second;
    cout << imos(recs) << endl;
}



Measured memory_bytes: 8296
import sys
input = sys.stdin.readline
from collections import deque

N = int(input())
A = [list(reversed(list(map(lambda x:int(x)-1,input().split())))) for i in range(N)]
B = {i:row for i,row in enumerate(A)}

end = 0
for k in range(8000):
    used = set()
    dels = []
    for i,q in B.items():
        if not q: continue
        if i in used: continue
        j = q[-1]
        if j in used: continue
        if A[j][-1] == i:
            A[j].pop()
            A[i].pop()
            used.add(i)
            used.add(j)
            if not A[i]:
                end += 1
                dels.append(i)
            if not A[j]:
                end += 1
                dels.append(j)
    if not used:
        print(-1)
        exit()
    if end == N:
        print(k+1)
        exit()
    for i in dels:
        del B[i]

print(N*(N-1)//2)

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

const int inf = 1e9;
const ll linf = 1e18;

int main()
{
    int a, b; cin >> a >> b;
    cout << ((a <= 9 && b <= 9) ? a * b : -1) << endl;
    return 0;
}

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

int main() {
  int N, L;
  cin >> N >> L;
  int ans = (N * L) + (N * (N + 1) / 2) - N;
  ans -= L - 1;
  if(L <= -N) ans -= N;
  else if(L <= 0) ans -= 1 - L;
  else ans -= 1;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

typedef long long ll;
const int INF = 1e9+10;
const int MAX_N = 1e5;
using namespace std;
int n;
pair<int,int> A[MAX_N+10];//value,idx


void solve(){
    sort(&A[1],&A[1] + n);
    int count = 0;
    for(int i=1;i<=n;i++){
        if(i%2 != A[i].second%2)count++;
    }
    printf("%d",count/2);
}

int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        int tmp;
        scanf("%d",&tmp);
        A[i] = make_pair(tmp,i);
    }
    solve();
    printf("\n");
    return 0;
}

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

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    if(check(s.substr(0, n / 2)) &&
        check(s.substr(n / 2 + 1, n / 2)) &&
        check(s)){
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3632
s = input()
len_s = len(s)
s_array = [int(i) for i in s]

mod = 2019
mod_array = [0]*mod

num = 0
mod_array[0] += 1
for i in range(len_s):
    num = pow(10, i, mod) * s_array[len_s - i - 1] + num
    num %= mod
    mod_array[num] += 1

ans = 0
for i in mod_array:
    ans += (i * (i - 1)) / 2

print(int(ans))

Measured memory_bytes: 85240
#include<stdio.h>
#include<stdbool.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#define rep(i,n) for(int i=0; i <(n); i++)

int compint(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}
int main(){
  int n;
  int a[100001];
  scanf("%d",&n);
  rep(i,n){
    scanf("%d",&a[i]);
  }
  int count=0;
  int light=1;
  int cnt[100001]={0};
  do{
    light=a[light-1];
    count++;
    cnt[light]++;
  }while(light!=2&&cnt[light]<2);
  rep(j,n){
    if(cnt[j]>1){
      printf("-1\n");
      return 0;
    }
  }
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 2480
#include <stdio.h>

using namespace std;

int main(){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if((x >= r && x <= W-r) && (y >= r && y <= H-r))
		printf("Yes\n");
	else{
		printf("No\n");
	}
}



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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()

int main(){
    int n,m; cin >>n >> m;
    vector<ll> a(n);
    vector<ll> s(n+1);
    map<ll, ll> mp;
    for(int i = 0; i < n; ++i){
    	  cin >> a[i];
    }
    ++mp[0];
    for(int i = 0; i < n; ++i){
    	  s[i+1] = s[i]+a[i];
          s[i+1]%= m;
          ++mp[s[i+1]];
    }
    ll ans = 0;
    for(auto itr : mp){
    	  ans += itr.second * (itr.second-1) /2;     
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
s = input()
for i in range(1, 101):
    s_del_end = s[:len(s) - i]
    len_s_del_end = len(s_del_end)
    if s_del_end[:len_s_del_end // 2] == s_del_end[len_s_del_end // 2:] and len_s_del_end % 2 == 0:
        print(len_s_del_end)
        exit()


Measured memory_bytes: 9036
#include <iostream>
#include <cmath>
using namespace std;
const double PI = acos(-1);

void solve(long long r){
    double area = pow(r, 2) * PI;
    cout << area / PI << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long r;
    scanf("%lld",&r);
    solve(r);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  int N;
  int H[110000]={};
  cin >> N;   
  
  int count = 0;
  int result = 0;
  
  cin >> H[0]; 
  for(int i=1;i<N;++i){
    cin >> H[i];
    
    if(H[i]<=H[i-1]){
      count++;
    }else{
      if(count > result) result = count;
      count = 0;
    }
  }
  if(count > result) result = count;
  
  cout << result << endl;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    int ct1=0;
    for(int i=1;i<=n;i++){
        int ct=0;
        for(int j=1;j<=i;j++){
            if(i%j==0){
                ct++;
            }
        }
        if(ct==8 && i%2==1){
            ct1++;
        }
    }
    cout << ct1 << endl;
}


Measured memory_bytes: 256
# AOJ 0034 Railway Lines

while line = gets
  dat = line.split(",").map(&:to_i)
  lengths, v1, v2 = dat[0..9], dat[10], dat[11]

  distances = [0]
  lengths.each.with_index(1) do |l, i|
    distances[i] = distances[i - 1] + l
  end

  x = v1.to_f / (v1 + v2) * lengths.reduce(0, :+)

  distances.each_with_index do |d, i|
    if x <= d
      puts i
      break
    end
  end
end

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

using namespace std;

#define loop(i,n) for(ll i = 0; i < n; i++)
#define loopr(i,x,y) for(ll i = x; i < y; i++)
#define push_back pb ;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<string> VS;
typedef vector<P> VP;
typedef vector<V> VV;
typedef map<ll,ll> MP;
typedef set<ll> SET;
typedef multiset<ll> MSET;

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n;
    
    cin>>n;
    
    ll arr[n];
    
    ll val = 0;
    
    loop (i, n) {
    	cin>>arr[i];
    	
    	val ^= arr[i];
	}
	
	for (int i = 0; i < n; i++) {
		cout<<(val ^ arr[i])<<" ";
	}
}

Measured memory_bytes: 5088
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 200001;
const int MOD = 1000000007;
int dp[50][51][2501];
        signed main() {
  int n,a;
  cin>>n>>a;
  int x[n];for(int i=0;i<n;i++)cin>>x[i];
  dp[0][0][0]=1;
  dp[0][1][x[0]]=1;
  for(int i=1;i<n;i++){
          for(int j=0;j<=n;j++){
                  for(int k=0;k<=2500;k++){
                          dp[i][j][k]=dp[i-1][j][k];
                          if(k-x[i]>=0&&j>0)dp[i][j][k]+=dp[i-1][j-1][k-x[i]];
                  }

          }
  }
  int ans=0;
  for(int i=1;i<=n;i++){
          ans+=dp[n-1][i][i*a];
        //  cerr<<dp[n-1][i][i*a]<<endl;
  }
  cout<<ans<<endl;

      }


        


Measured memory_bytes: 49024
n = int(input())
s = input().split()

arare = 0
if "P" in s:
    arare += 1
if "W" in s:
    arare += 1
if "G" in s:
    arare += 1
if "Y" in s:
    arare += 1

if arare == 3:
    print("Three")
else:
    print("Four")


Measured memory_bytes: 2940
#include <cstdio>
#include <cmath>

#define EPS 1e-10
int n,m;
double x[101],y[101],r[101];
double tx[101],ty[101],sx[101],sy[101];


struct vektor{
	double x,y;
	vektor(){}
	vektor(double xx,double yy){
		x=xx;
		y=yy;
	}

	double det(vektor p){
		return x*p.y-y*p.x;
	}
	double dot(vektor p){
		return x*p.x+y*p.y;
	}
	double len(){
		return sqrt(x*x+y*y);
	}
};


bool check(int v){
	for(int i=0;i<n;i++){
		double dt=sqrt((tx[v]-x[i])*(tx[v]-x[i])+(ty[v]-y[i])*(ty[v]-y[i]));
		double dr=sqrt((sx[v]-x[i])*(sx[v]-x[i])+(sy[v]-y[i])*(sy[v]-y[i]));
		if((dt-r[i])*(dr-r[i])<=0.0)return true;
		if(dt-r[i]>0 && dr-r[i]>0){
			vektor a=vektor(x[i]-sx[v],y[i]-sy[v]);
			vektor b=vektor(x[i]-tx[v],y[i]-ty[v]);
			vektor s=vektor(tx[v]-sx[v],ty[v]-sy[v]);
			double rr=fabs(s.det(a)/s.len());
			if(rr<=r[i]+EPS && s.dot(a)*b.dot(s)<=0)return true;
		}
	}
	return false;
}
int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<n;i++){
			scanf("%lf %lf %lf",&x[i],&y[i],&r[i]);
		}
		scanf("%d",&m);
		for(int i=0;i<m;i++){
			scanf("%lf %lf %lf %lf",&tx[i],&ty[i],&sx[i],&sy[i]);
			printf("%s\n",check(i)?"Safe":"Danger");
		}
	}
	return 0;
}

Measured memory_bytes: 1052
# include "iostream"
# include "cmath"
# include "cstdio"

using namespace std;

const int maxm=1e5;

int N;
long long DP[maxm],H[maxm];

int main(){
	register int i;
	scanf("%d",&N);
	for(i=1;i<=N;i++) scanf("%lld",H+i);
	DP[2]=abs(H[2]-H[1]);
	for(i=3;i<=N;i++){
		DP[i]=min(DP[i-1]+abs(H[i]-H[i-1]),DP[i-2]+abs(H[i]-H[i-2]));
	}
	printf("%lld",DP[N]);
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
  int a,b,c,x,p=0;
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  scanf("%d", &x);
  
  for(int i=0;i<=a;i++){
    for(int k=0;k<=b;k++){
      for(int l=0;l<=c;l++){
        if(i*500+k*100+l*50==x) p++;
      }}}
  printf("%d\n", p);
  return 0;
}

Measured memory_bytes: 128
#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    6月で水色になるぞ〜!!!
*/

// from std...
use std::cmp::{
    max, min,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;
use std::ops::*;
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, Integer};
use num_rational::Rational;
use num_traits::{one, zero, One, Zero};
use permutohedron::Heap;
use petgraph::unionfind::UnionFind;
use proconio::{fastout, input, is_stdin_empty, marker::*};
use rand::random;

pub const MOD: usize = 1000000007;
pub const MAX: usize = 1usize << 63usize;
pub const MIN: i64 = i64::MIN;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 'a' as u8;

// code...
// #[fastout]
fn main() {
    input! {
        mut n: usize,
    }
    let mut ans = String::new();

    while n != 0 {
        n -= 1;
        let r = n % 26;
        // dbg!(r);
        ans.push((r as u8 + A) as char);
        n -= r;
        n /= 26;
    }

    let ans = ans.chars().rev().collect::<String>();
    println!("{}", ans);
}


Measured memory_bytes: 2112
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

long long gcd(long long a, long long b) {
	long long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

long long lcm(long long a, long long b) {
	return a * b / gcd(a, b);
}

int main() {
	vector<int>data(100);
	for (int i = 0; i < 3; i++ ) {
		int a;
		cin >> a;
		a--;
		data[a] = 1;
	}
	int ans = 0;
	for (int i = 0; i < 100; i++) {
		ans += data[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<bitset>
using namespace std;

int n,k;
int a[5005];

int C(int x)
{
    bitset<5005> dp;
    if(a[x]>=k) return 1;
    dp.reset();
    dp[0]=1;
    for(int i=0;i<n;++i)
    {
        if(i==x) continue;
        dp|=(dp<<a[i]);
    }
    for(int i=k-1;i>=k-a[x];--i)
        if(dp[i]) return 1;
    return 0;
}

int main()
{
    while(~scanf("%d %d",&n,&k))
    {
        for(int i=0;i<n;++i)
            scanf("%d",&a[i]);
        sort(a,a+n);
        int l=0,r=n;
        while(l<r)
        {
            int mid=(l+r)/2;
            if(C(mid)) r=mid;
            else l=mid+1;
        }
//        int lo = -1, hi = n;
//    while(hi-lo>1){
//        int m = (lo+hi)/2;
//        if(C(m)) hi = m;
//        else lo = m;
//    }
    //return hi;
        //if(!C(l)) l--;
        printf("%d\n",l);
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>

using namespace std;

int main() {
    for (int i=1; i<=9; i++) {
        for (int j=1; j<=9; j++) {
            cout << i << "x" << j << "=" << i*j << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2996
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>

#define REP(i,n) (int i = 0; i < (n); i++)
#define FOR(i,a,b) (int i=(a); i < (b); i++)
#define INF 100000000000
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    double n;
    cin >> n;

    cout << n * 2 * 3.14 << endl;
    return 0;
}

Measured memory_bytes: 3784
#include<bits/stdc++.h>
using namespace std;
typedef long long int uli;
const int mx=2e3;
char r[mx],s[mx][10],e[mx][10];
char op[20],msg[100];
char x[10],y[10];

string sq[mx],eq[mx];
string mq[mx];

bool match(char* ip,char* p){
   for(int i=0;i<8;i++){
      if(p[i]=='?')continue;
      if(p[i]!=ip[i])return false;
   }
   return true;
}
int main(){
   int n,m;
   while(scanf("%d %d",&n,&m)==2){
      if(n==0 && m==0)break;
      for(int i=0;i<n;i++){
         scanf("%s %s %s",op,s[i],e[i]);
         r[i]=op[0];
      }
      int cnt=0;
      for(int i=0;i<m;i++){
         scanf("%s %s %s",x,y,msg);
         bool ok=false;
         for(int j=0;j<n;j++){
            if(match(x,s[j]) && match(y,e[j])){
               if(r[j]=='p') ok=true;
               else ok=false;
            }
         }
         if(ok){
            sq[cnt]=string(x);
            eq[cnt]=string(y);
            mq[cnt++]=string(msg);
         }
      }
      printf("%d\n",cnt);
      for(int i=0;i<cnt;i++){
         printf("%s %s %s\n",sq[i].c_str(),eq[i].c_str(),mq[i].c_str());
      }
   }
   return 0;
}

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


int main() {

	string s;
	cin >> s;

	int count[2] = { 0 };

	//始まりが0の場合
	for (int i = 0; i < s.size(); i++) {
		if ((i%2==0 && s[i]=='1')||(i % 2 == 1 && s[i] == '0'))
			count[0]++;

		if ((i % 2 == 0 && s[i] == '0') || (i % 2 == 1 && s[i] == '1'))
			count[1]++;
	}

	cout << min(count[0], count[1]) << endl;

	return 0;
}

Measured memory_bytes: 512
from collections import deque

n = int(input())
rs = deque([int(input()) for i in range(n)])

maxv, minv = -(10**10), 10**10

while len(rs) > 0:
    now = rs.popleft()
    maxv = (now-minv) if maxv < (now-minv) else maxv
    minv = now if now < minv else minv
    #if maxv < (now-minv):
    #    maxv = (now-minv)
    #if now < minv:
    #    minv = now
print(maxv)



Measured memory_bytes: 15340
#include <bits/stdc++.h>
#define ll long long 
#define all(v) v.begin() , v.end()
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define tr(con) for(auto it = con.begin(); it!= con.end() ; it++)
#define INF 1e9+7   // 1 * 10^9+ 7
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define fo(i,n) for(ll i=0;i<n;i++)
using namespace std;

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, d  ,x;
	cin >>  n >> d; 
	int a[n][d];
	for(int i=0;i<n;i++)
		for(int j=0;j<d;j++)
			cin >> a[i][j];
	ll res = 0;
	ll count = 0;
	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			for(int k=0;k<d;k++){
				res += (a[i][k] - a[j][k]) * (a[i][k] - a[j][k]);
			}
			float sq = (float)sqrt(res);
			if(sq - floor(sq) ==0) count ++;
			res = 0;
		}
	}
	cout << count ;
	return 0;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    use std::cmp::min;

    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut pv = vec![0u32; n];
    for i in 0..n - 1 {
        pv[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    pv[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let mut ans = 0;
    let mut mp = pv[0];
    for i in 0..pv.len() {
        if pv[i] <= mp {
            ans += 1;
        }
        mp = min(mp, pv[i]);
    }

    println!("{}", ans);
}


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

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

int main(){
	int m;
	cin >> m;
	for(int i = 0;i < m;i++){
		int a[10][10];
		for(int j = 0;j < 10;j++){
			for(int k = 0;k < 10;k++) cin >> a[j][k];
		}
		for(int j = 0;j < 1024;j++){
			int b[10][10] = {},t[10][10];
			for(int k = 0;k < 10;k++){
				for(int l = 0;l < 10;l++){
					t[k][l] = a[k][l];
				}
			}
			for(int k = 0;k < 10;k++){
				if((j >> k) & 1){
					b[0][k] = 1;
					for(int l = 0;l < 4;l++){
						int nx = dx[l],ny = k + dy[l];
						if(ny >= 0 && ny < 10){
							t[nx][ny] = (t[nx][ny] + 1) % 2;
						}
					}
				}
			}
			for(int k = 0;k < 9;k++){
				for(int l = 0;l < 10;l++){
					if(t[k][l]){
						b[k + 1][l] = 1;
						for(int n = 0;n < 5;n++){
							int nx = k + 1 + dx[n],ny = l + dy[n];
							if(nx >= 0 && nx < 10 && ny >= 0 && ny < 10){
								t[nx][ny] = (t[nx][ny] + 1) % 2;
							}
						}
					}
				}
			}
			bool flag = true;
			for(int k = 0;k < 10;k++){
				if(t[9][k]) flag = false;
			}
			if(flag){
				for(int k = 0;k < 10;k++){
					for(int l = 0;l < 10;l++) {
						cout << (!l ? "" : " ") << b[k][l];
					}
					cout << endl;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2976
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
 
const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    cout << modpow(m, n, MOD) << endl;
}


Measured memory_bytes: 3096
// #include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <map>
#include <math.h>
#include <algorithm> // std::sort, std::min, std::next_permutation, std::lower_bound
#include <iomanip> // std::setprecision
#include <cmath> // std::ceil
#include <numeric> // std::gcd, std::lcm
#include <limits> // std::numeric_limits<long int>::max()
#include <unordered_map>
#include <map>
#include <cmath> // std::atan2
#include <deque>
#include <queue>

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

int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> k(M);
  vector<vector<ll> > s(M); 
  rep(i, M) {
    cin >> k[i];
    rep(j, k[i]) {
      ll tmp;
      cin >> tmp;
      s[i].push_back(tmp);
    }
  }
  vector<int> p(M);
  rep (i, M) cin >> p[i];

  ll ans = 0;
  for (ll bit = 0; bit < (1<<N); ++bit) {
    ll bulbcount = 0;
    rep (i, M) {
      ll oncount = 0;
      for (const auto sj : s[i]) {
        if ((bit>>(sj-1))&1 != 0) oncount++;
      }
      if (oncount%2 == p[i]) bulbcount++;
      cerr << i <<" "<< bit <<" "<< oncount <<" "<< bulbcount << endl;
    }
    if (bulbcount == M) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
import math

D,G = map(int,input().split())
pc = [list(map(int,input().split()))for _ in range(D)]

minimam=float('INF')

digit = "0"+str(D)+"b"

for i in range(2**D):
  pattern = str(format(i,digit))
  #この完答パターンのときの完答に伴う問題数と得点を算出する
  point = 0
  count = 0
  for j in range(D):
    if pattern[j]=="1":
      count += pc[j][0]
      point += pc[j][0]*100*(j+1)+pc[j][1]
  #ポイントがGに未達の場合、残りの問題を解いてみて、Gに到達するか検証。
  #到達する場合でなおかつ問題数が最小であれば記録する。
  last0 = pattern.rfind("0")
  r = G -point
  if r > 0:
    if last0==-1:
      continue
    tmp = math.ceil(r/(100*(last0+1)))
    if tmp < pc[last0][0]:
      minimam = min(minimam,tmp+count)
  else:
    minimam = min(minimam,count)

print(minimam)

Measured memory_bytes: 3188
int main(void){
    char sa[100]={'\0'};
    char sb[100]={'\0'};
    char sc[100]={'\0'};
    int yoa=0,yob=0,yoc=0;
    int la,lb,lc;
    char key;
    scanf("%s",sa);la=strlen(sa);sa[la]='A';
    scanf("%s",sb);lb=strlen(sb);sb[lb]='B';
    scanf("%s",sc);lc=strlen(sc);sc[lc]='C';
    key=sa[yoa];
    yoa++;
    while(!(key=='A'||key=='B'||key=='C')){
      
        switch(key){
            case 'a':
            if(yoa==la){
                printf("A");
                return 0;
            }
            key=sa[yoa];
            yoa++;
            break;
            case 'b':
            if(yob==lb){
                printf("B");
                return 0;
            }
            key=sb[yob];
            yob++;
            break;
            case 'c':
            if(yoc==lc){
                printf("C");
                return 0;
            }
            key=sc[yoc];
            yoc++;
            break;
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 1636