akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;

vector<bool> IsPrime;

void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}

int main(){
    int q;
    cin >> q;
    int l[q],r[q];
    REP(i,q)cin >> l[i] >> r[i];
    sieve(100000);
    int left[100001],right[100001];
    left[0]=0;
    left[1]=0;
    FOR(i,1,100001){
        if(IsPrime[i]&&IsPrime[(i+1)/2]){
            left[i]=left[i-1]+1;
        }
        else{
            left[i]=left[i-1];
        }
    }
    right[100000]=0;
    FORR(i,99999,0){
        if(IsPrime[i]&&IsPrime[(i+1)/2]){
            right[i]=right[i+1]+1;
        }
        else{
            right[i]=right[i+1];
        }
    }
    //int sum = 9592;
    REP(i,q){
        cout << left[r[i]]+right[l[i]]-right[0] << endl;
    }

    return 0;
}

Measured memory_bytes: 2176
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    a,b=input().split()
    s=a*int(b)
    t=b*int(a)
    if s<t:print(s)
    else:print(t)
main()

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

int main() {
	double a, b, c;
	cin >> a >> b >> c;
	if(a + b + c - max(max(a , b), c) == max(max(a , b), c)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

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

int n;
int k;

vector<int> v;

long long int gcd(long long int a, long long int b){
	if (a > b){
		swap(a, b);
	}
	while (a){
		swap(a, b);
		a %= b;
	}
	return b;
}



int main(){
	cin >> n >> k;
	long long int gc = 0;
	int mx = 0;
	for (int i = 0; i < n; i++){
		int a;
		scanf("%d", &a);
		gc = gcd(gc, a);
		mx = max(mx, a);
	}
	if (k <= mx&&k%gc == 0){
		puts("POSSIBLE");
	}
	else{
		puts("IMPOSSIBLE");
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
  long n,m,k;
  cin >> n >> m >> k;
  vl a(n),b(m);
  rep(i,n) cin >> a.at(i);
  rep(i,m) cin >> b.at(i);
  
  vl sum(n+1,0);
  vl d(m+1,0);
  rep(i,n){
    sum.at(i+1) = sum.at(i) + a.at(i);
    
  }
  rep(i,m) d.at(i+1) = d.at(i) + b.at(i);
  int ans = 0;
  rep(i,n+1){
    if(sum.at(i) > k) break;
    int cnt = i;
    long rest = k - sum.at(i);
    int iter = upper_bound(all(d), rest) - d.begin();
    //cout << cnt << " " << iter << " " << rest <<  endl;
    ans = max(ans, cnt + iter - 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 9592
n = $stdin.gets.chomp.to_i
arr = gets.chomp.split(' ').map(&:to_i)
ans = 1
max = 10**18
if arr.index(0)
  puts "0"
  exit
end
arr.each do |k|
	ans = ans * k
    if ans > max
    puts "-1"
    exit
    end
end
puts ans


Measured memory_bytes: 23484
#include <iostream>
#include<algorithm>
#include<set>
#include<queue>
#include<bitset>
#define rep(i,j,n) for(int i=j;i<n;i++)
using namespace std;
#define int long long
struct edge{long long to,cost;};
typedef pair<int,int>P;
#define inf 1000000007
string alph("abcdefghijklmnopqrstuvwxyz");
vector<int> es[114514];
signed main(){
    int n,t;cin>>n>>t;
    int pri[114514];
    rep(i,0,n)cin>>pri[i];
    int mini=pri[0];
    int d[114514];
    int j=0;
    rep(i,1,n){
        if(pri[i]<mini){
            mini=pri[i];
        }else {
            d[j++]=pri[i]-mini;
        }
    }
    sort(d,d+j);
    reverse(d,d+j);
    int ans=1;
    rep(i,1,j){
        if(d[i]==d[i-1])ans++;
        else break;
    }
    cout<<ans<<endl;
    return 0;
}


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

const int N = 100000;
char s[N+5][3];
char ans[N+5];
int cnt[3], aa[128];

bool get_ans(int st, int n){
    for (int i = st; i <= n; ++i){
        int x = aa[s[i][0]], y = aa[s[i][1]];
        if (cnt[x] == 0){
            if (cnt[y] == 0) return false;
            else { ++cnt[x]; --cnt[y]; ans[i] = s[i][0]; }
        }
        else {
            if (cnt[y] == 0){ ++cnt[y]; --cnt[x]; ans[i] = s[i][1]; }
            else if (cnt[x] != cnt[y]){
                if (cnt[x] < cnt[y]){ ++cnt[x]; --cnt[y]; ans[i] = s[i][0]; }
                else { ++cnt[y]; --cnt[x]; ans[i] = s[i][1]; }
            }
            else {
                ++cnt[x]; --cnt[y]; ans[i] = s[i][0];
                if (!get_ans(i+1, n)){ ++++cnt[y]; ----cnt[x]; ans[i] = s[i][1]; }
                else return true;
            }
        }
    }
    return true;
}

int main(){
    aa['A'] = 0; aa['B'] = 1; aa['C'] = 2;
    int n, a, b, c;
    scanf("%d %d %d %d", &n, &a, &b, &c);
    for (int i = 1; i <= n; ++i){
        scanf("%s", s[i]);
    }
    cnt[0] = a; cnt[1] = b; cnt[2] = c;
    if (get_ans(1, n)){
        printf("Yes\n");
        for (int i = 1; i <= n; ++i) printf("%c\n", ans[i]);
    }
    else printf("No\n");
    return 0;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N, H, W;
  cin >> H >> W >> N;
  cout << (N + (max(H, W) - 1)) / max(H, W) << endl;

  return 0;
}


Measured memory_bytes: 384
N,M,C = map(int,input().split())
B = list(map(int,input().split()))

ans=0
for i in range(N):
  ab=0
  A = list(map(int,input().split()))
  for j in range(M):
    ab += A[j] * B[j]
  if ab + C > 0:
    ans+=1
print(ans)

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

signed main(){
	int n,x = 0,y = 0;
	string s;
	cin >> n >> s;
	for(int i = 0;i < n;i++){
		if(s[i] >= 'A' && s[i] <= 'M') x++;
		else if(s[i] >= 'N' && s[i] <= 'Z') x--;
		else if(s[i] >= 'a' && s[i] <= 'm') y++;
		else y--;
	}
	string ans = "";
	for(int i = 0;i < x;i++) ans += 'A';
	for(int i = 0;i > x;i--) ans += 'N';
	for(int i = 0;i < y;i++) ans += 'a';
	for(int i = 0;i > y;i--) ans += 'n';
	cout << ans.size() << endl << ans << endl;
}


Measured memory_bytes: 3312
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 200011
#define mod 1000000007

int n, i;
pair<int, int> ninja[maxN];
pair<int, int> ord[maxN];
vector<int> n1, n2;

int best, last;
ll sum[maxN];

int main()
{
   // freopen("test.in","r",stdin);

    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> ninja[i].first >> ninja[i].second;
        n1.pb(ninja[i].first);
        n2.pb(ninja[i].second);
    }

    sort(n1.begin(), n1.end());
    sort(n2.begin(), n2.end());

    for (i = 1; i <= n; i++) {
        ninja[i].first = lower_bound(n1.begin(), n1.end(), ninja[i].first) - n1.begin() + 1;
        ninja[i].second = lower_bound(n2.begin(), n2.end(), ninja[i].second) - n2.begin() + 1;
    }

    sort(ninja + 1, ninja + n + 1);

    best = 0;
    for (i = 1; i <= n; i++) {
        best = max(best, ninja[i].second);
        ord[i].second = best;
    }

    best = n + 1;
    for (i = n; i >= 1; i--) {
        best = min(best, ninja[i].second);
        ord[i].first = best;
    }

    sum[0] = 1; last = 0;
    for (i = 1; i <= n; i++) {
        while (last < ord[i].second) {
            sum[last + 1] = sum[last];
            last++;
        }

        sum[ord[i].second] += mod + sum[ord[i].second] - (ord[i].first - 1 != 0 ? sum[ord[i].first - 2] : 0);
        sum[ord[i].second] %= mod;
    }

    cout << (mod + sum[last] - sum[last - 1]) % mod;

    return 0;
}


Measured memory_bytes: 6764
n= int(input())
s = input()
ans = 0
h = set()
for i in range(n-2):
  ten = set()
  if s[i] not in h:
    h.add(s[i])
    for j in range(i+1,n-1):
      if s[j] not in ten:
        ten.add(s[j])
        ans += len(set(s[j+1:]))
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define INF (1<<28)
#define DEKAI 1000000007
#define FDST int hogehogehoge;cin>>hogehogehoge;
//#define int long long

signed main(){
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(n,min(a,b))<<" "<<max(0-n+(a+b),0)<<endl;
	return 0;
}



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

typedef complex<double> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define EPS (1e-10)

int SX, SY, TX, TY;
int N;

double dot(P a, P b) {
  return a.real()*b.real() + a.imag()*b.imag();
}
double cross(P a, P b) {
  return a.real()*b.imag() - a.imag()*b.real();
}
bool intersect(P a1, P a2, P b1, P b2) {
  return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < 0 ) &&
         ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < 0 );
}

double dist(P a, P b, P c) {
  if (dot(b-a, c-a) < 0) return abs(c-a);
  if (dot(a-b, c-b) < 0) return abs(c-b);
  return abs(cross(b-a, c-a)) / abs(b-a);
}
double f(double d, double h) {
  if (h >= d) return d;
  double lo = d, hi = 1e10;
  rep(_, 200) {
    double mid = (lo + hi) / 2;
    double t = mid / (mid/h - 1);
    double g = sqrt(t*t - h*h) * (mid/h - 1);
    if (d >= g) lo = mid;
    else hi = mid;
  }
  return lo;
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  while (cin >> N) {
    if (N == 0) break;
    cin >> SX >> SY >> TX >> TY;
    double ans = 1e10;
    rep(i, N) {
      int lx, ly, rx, ry, h;
      cin >> lx >> ly >> rx >> ry >> h;
      if (intersect(P(SX, SY), P(TX, TY), P(lx, ly), P(lx, ry))) ans = 0;
      if (intersect(P(SX, SY), P(TX, TY), P(lx, ry), P(rx, ry))) ans = 0;
      if (intersect(P(SX, SY), P(TX, TY), P(rx, ry), P(rx, ly))) ans = 0;
      if (intersect(P(SX, SY), P(TX, TY), P(rx, ly), P(lx, ly))) ans = 0;
      if (lx<=min(SX,TX)&&ly<=min(SY,TY)&&rx>=max(SX,TX)&&ry>=max(SY,TY)) ans = 0;
      ans = min(ans, f(dist(P(SX, SY), P(TX, TY), P(lx, ly)), h));
      ans = min(ans, f(dist(P(SX, SY), P(TX, TY), P(lx, ry)), h));
      ans = min(ans, f(dist(P(SX, SY), P(TX, TY), P(rx, ly)), h));
      ans = min(ans, f(dist(P(SX, SY), P(TX, TY), P(rx, ry)), h));

      ans = min(ans, f(dist(P(lx, ly), P(lx, ry), P(SX, SY)), h));
      ans = min(ans, f(dist(P(lx, ry), P(rx, ry), P(SX, SY)), h));
      ans = min(ans, f(dist(P(rx, ry), P(rx, ly), P(SX, SY)), h));
      ans = min(ans, f(dist(P(rx, ly), P(lx, ly), P(SX, SY)), h));

      ans = min(ans, f(dist(P(lx, ly), P(lx, ry), P(TX, TY)), h));
      ans = min(ans, f(dist(P(lx, ry), P(rx, ry), P(TX, TY)), h));
      ans = min(ans, f(dist(P(rx, ry), P(rx, ly), P(TX, TY)), h));
      ans = min(ans, f(dist(P(rx, ly), P(lx, ly), P(TX, TY)), h));
    }
    cout << fixed << setprecision(20) << ans << "\n";
  }
  return 0;
}

Measured memory_bytes: 3136
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int N,M;
  cin>>N>>M;
  VI X(N);
  rep(i,N) cin>>X[i];
  VI Y(100100),Z(100100);
  rep(i,N) Y[X[i]]++;
  rep(i,100100) Z[i]=Y[i]/2;
  VI A(M),B(M);
  rep(i,100100) A[i%M]+=Y[i];
  rep(i,100100) B[i%M]+=Z[i];
  ll ans=0;
  rep(i,M/2+1){
    if(i==0 or i==M-i) ans+=A[i]/2;
    else{
      int tmp=min(A[i],A[M-i]);
      A[i]-=tmp;
      A[M-i]-=tmp;
      ans+=tmp+min(A[i],B[i]*2)/2+min(A[M-i],B[M-i]*2)/2;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 2176
#include <iostream>
#include <string.h>

using namespace std;

int main()
{
	string s1, s2;
	cin>>s1>>s2;
	
	if (s1.length()+1 == s2.length()){
		if (0==strncmp(s1.c_str(), s2.c_str(), s1.length())){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}


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

using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
const ll LIM = 1e13;
int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    cout << max(0LL,c - (a-b)) << endl;
    return 0;
}

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

using namespace std;

static const int N = 1000;

int n, p[N + 1], m[N + 1][N + 1];

int main(){
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> p[i - 1] >> p[i];

	for (int i = 1; i <= n; ++i) m[i][i] = 0;

	for (int l = 2; l <= n; ++l){
		for (int i = 1; i <= n - l + 1; ++i){
			int j = i + l - 1;
			m[i][j] = (1 << 21);
			for (int k = i; k <= j - 1; ++k)
			{
				m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
			}
		}
	}

	cout << m[1][n] << endl;
	return 0;
}

Measured memory_bytes: 3436
import math
b, c = map(int, input().split())
b_before_min = math.ceil(b / 0.08)
b_before_max = (b+1) / 0.08
c_before_min = math.ceil(c / 0.1)
c_before_max = (c+1) / 0.1

# maxは取り得ない値.0
if(c_before_min <= b_before_min and b_before_min < c_before_max):
    print(int(b_before_min))
elif(b_before_min <= c_before_min and c_before_min < b_before_max):
    print(int(c_before_min))
else:
    print(-1)


Measured memory_bytes: 3060
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let a = read::<i64>();
  let b = read::<i64>();
  if a <= b {
    println!("{}", a);
  } else {
    println!("{}", a - 1);
  }

}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;

int main(){
    int x, y; cin >> x >> y;
    int  a, b, c; cin >> a >> b >> c;
    vector<ll> p(a), q(b), r(c);
    rep(i,a) cin >> p[i];
    rep(i,b) cin >> q[i];
    rep(i,c) cin >> r[i];
    sort(RALL(p));
    sort(RALL(q));
    vector<ll> d(x+y+c);
    rep(i,x) d.push_back(p[i]);
    rep(i,y) d.push_back(q[i]);
    rep(i,c) d.push_back(r[i]);
    sort(RALL(d));
    ll ans = 0;
    rep(i,x+y){
        ans+=d[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 8832
#include<stdio.h>

int main(void) {
	int a, b, c;
	int sum=0, max;

	scanf("%d", &a);
	max = a;
	sum += a;
	scanf("%d", &b);
	sum += b;
	if(max<b){
		max = b;
	}
	scanf("%d", &c);
	if (max < c) {
		max = c;
	}
	sum += c;

	if (sum - max == max) {
		printf("Yes");
	}
	else {
		printf("No");
	}

	return 0;
}

Measured memory_bytes: 128
/******************************************
* AUTHOR : GURUTEJA *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second

void debug(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif 

}

  int main() {
    debug();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    if(n==1){
    	cout<<1<<endl;
    	return 0;
    }
    int i=2;
    while((i*2)<=n){
    	i*=2;
    }
    cout<<i<<endl;
    return 0;
  }

Measured memory_bytes: 3652
#include <bits/stdc++.h>
//#define int long long
using namespace std;
int main()
{
   int n;
   cin>>n;
   if(n%1000==0)
        cout<<0;
   else
   {
        int i=1000;
        while(i<n)
            i+=1000;
        cout<<i-n;
   
   }  
   return 0;
}

Measured memory_bytes: 3632
//
//  main.cpp
//  HelloWorld
//
//  Created by purple on 2020/04/13.
//  Copyright © 2020 Purple. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>

using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
 
    
    int c[3][3];
    
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin >> c[i][j];
        }
        
    }
    
    int a[3],b[3];
    bool c12,c21,c23,c32,c33;
    int flg = 0;
    
    for(int i=0; i<=c[0][0]; i++){
        a[0] = i;
        b[0] = c[0][0] - a[0];
        
        for(int j=0; j<=c[1][1]; j++){
            a[1] = j;
            b[1] = c[1][1] - a[1];
            a[2] = c[2][0] - b[0];
            b[2] = c[0][2] - a[0];
            
            //Check
            c12 = c[0][1] == a[0]+b[1];
            c21 = c[1][0] == a[1]+b[0];
            c23 = c[1][2] == a[1]+b[2];
            c32 = c[2][1] == a[2]+b[1];
            c33 = c[2][2] == a[2]+b[2];
            
            
            if(c12&&c21&&c23&&c32&&c33)
                flg++;
        }
        
    }
 
    if(flg)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
    
}


Measured memory_bytes: 256
X, Y, A, B, C = map(int, input().split())
pa = list(map(int, input().split()))
pb = list(map(int, input().split()))
pc = list(map(int, input().split()))

pa = sorted(pa)
pb = sorted(pb)
pc = sorted(pc)

pr = pa[-X:] + pb[-Y:]
pr = sorted(pr)

c = 0
r = 0
while True:
  c += 1
  if c > C:
    break
  if pr[r] < pc[-c]:
    pr[r] = pc[-c]
    r += 1
  else:
    break

print(sum(pr))

Measured memory_bytes: 23328
n = int(input())
s = list(map(int, input().split()))
t = []
if n % 2 == 0:
    for i in range(n // 2):
        t.append(s[-(i * 2 + 1)])
    for i in range(n // 2):
        t.append(s[i * 2])
else:
    for i in range(n // 2 + 1):
        t.append(s[-(i * 2 + 1)])
    for i in range(n // 2):
        t.append(s[i * 2 + 1])
print(*t)


Measured memory_bytes: 26180
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;

#define INF 1e18
#define int long long

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

    if(n > m / 2) {
        cout << m / 2 << endl;
        return 0;
    }

    cout << n + (m - 2 * n) / 4 << endl;
    return 0;
}


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

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}
// 最大公約数を求める(ユークリッドの互除法).
long long gcd (long long x, long long y) {
  if (y > x) swap(x,y);
  if (y == 0) return x;
  return gcd(x%y,y);
}


// 最小公倍数を求める(lcm(a,b) = a*b / gcd(a,b)). overflowに気をつけよう
ll lcm (long long  x, long long y) {
  ll t = gcd(x,y);
  return (x / t) * y;
}
int main() {
  int n;
  cin >> n;
  vector<ll> t(n);
  rep(i, n) cin >> t[i];

  ll p = t[0];
  rep(i, n) {
    p = lcm(p, t[i]);
  }

  cout << p << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] S=Console.ReadLine().Split(' ');
     int[] arr=S.Select(int.Parse).ToArray();
      int K=int.Parse(Console.ReadLine());
      for(int i=1;i<=K;i++){
       Array.Sort(arr);
        arr[2]=2*arr[2];
        
      }
      Console.WriteLine(arr.Sum());
    }
    
  }

}


Measured memory_bytes: 28256
# ARC072C - Sequence (ABC059C)
def modify_seq(seq: list, is_positive: bool) -> int:
    cur, cnt = 0, 0
    for i in seq:
        cur += i
        if is_positive and cur <= 0:
            cnt += abs(cur) + 1
            cur = 1
        elif not is_positive and cur >= 0:
            cnt += abs(cur) + 1
            cur = -1
        is_positive = not is_positive
    return cnt


def main():
    _, *A = map(int, open(0).read().split())
    print(min(modify_seq(A, True), modify_seq(A, False)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 14084
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/

int main()
{
    int n;
    cin >> n;
    set<int> a;
    int over = 0;
    rep(i, n)
    {
        int temp;
        cin >> temp;
        if (temp >= 3200)
            over++;
        else
            a.insert(temp / 400);
    }
    if (a.size() == 0)
    {
        cout << 1;
    }
    else
    {
        cout << a.size();
    }
    cout << " " << a.size() + over << endl;
    return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;
long long int INF = 1e18;
/*
int main(){
	while(true){
		int n, d;
		cin >> n >> d;
		
		if(n == 0){
			break;
		}
		
		vector<long long int> v[110];
		long long int S[110] = {};
		
		for(int i = 0; i < n; i++){
			int m;
			cin >> m;
			v[i].push_back(INF);
			for(int j = 0; j < m; j++){
				int num;
				cin >> num;
				v[i].push_back(num);
				S[i] += num;
			}
		}
		
		while(true){
			vector<P> vs;
			for(int i = 0; i < n; i++){
				vs.push_back(make_pair(S[i], i));
			}
			sort(vs.begin(), vs.end());
			bool flag = true;
			for(int i = 0; i < n; i++){
				int index = n - 1;
				if(i == vs[n - 1].second){
					index--;
				}
				if(vs[index].first - d <= S[i] - v[i][v[i].size() - 1]){
					S[i] -= v[i][v[i].size() - 1];
					v[i].pop_back();
					flag = false;
				}
			}
			if(flag){
				break;
			}
		}
		
		int SS = 0;
		for(int i = 0; i < n; i++){
			SS += v[i].size();
		}
		
		if(SS == n){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
	return 0;
}
*/
char S[80001];
int A, B[11];
 
int char_to_int(char c){
    return (int)c - (int)'0';
}
 
int main(){
    int N, i, j, ans;
    while(1){
        scanf("%s", S);
        for(N = 0; S[N] != '\0'; N++){}
        if(N == 1 && S[0] == '0'){
            return 0;
        }
        for(j = 0; j < 11; j++){
            B[j] = 0;
        }
        B[0] = 1;
        A = 0;
        ans = 0;
        for(i = N - 1; i >= 0; i--){
            if(i % 2 == 0){
                A = (A + char_to_int(S[i])) % 11;
            }
            else{
                A = (A - char_to_int(S[i]) + 11) % 11;
            }
            if(S[i] != '0'){
                ans += B[A];
            }
            B[A]++;
        }
        printf("%d\n", ans);
    }
}


Measured memory_bytes: 3192
import itertools

N,M,X = map(int,input().split())
CA = []
for _ in range(N):
    CA.append(list(map(int,input().split())))

ans = (10 ** 5) * 12 + 1

for choose in itertools.product([0,1], repeat=N):
    cnt_ca = 0
    ability = [0] * M
    money = 0
    for c in choose:
        if c == 1:
            money += CA[cnt_ca][0]
            for i in range(M):
                ability[i] += CA[cnt_ca][i+1]
        cnt_ca += 1
    if min(ability) >= X:
        ans = min(ans,money)

if ans == (10 ** 5) * 12 + 1:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9232
s=input()
o=["R","U","D"]
e=["L","U","D"]
i=0
for t in range(len(s)):
  if(i==1):
    break
  if(t%2==0):
    if(s[t] not in o):
      print("No")
      i=1
      break
  else:
    if(s[t] not in e):
      print("No")
      i=1
      break
if(i==0):
	print("Yes")


Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <cmath>
#include <sstream>
#include <algorithm>

using namespace std;

int main() {
	int n, k;
	int m = 1;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		if (m * 2 - m > k) {
			m += k;
		}
		else {
			m *= 2;
		}
	}
	cout << m << endl;
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

  string s;
  cin >> s;

  int res = 0;
  if (s == "SUN")
    res = 7;
  else if (s == "MON")
    res = 6;
  else if (s == "TUE")
    res = 5;
  else if (s == "WED")
    res = 4;
  else if (s == "THU")
    res = 3;
  else if (s == "FRI")
    res = 2;
  else
    res = 1;

  cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

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

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int a,b,c;
    cin >> a >> b >> c;

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;

void solve(){
  int n, d; cin >> n >> d;
  int x[n][d];
  int sum = 0;
  for(int i = 0; i < n; i++) for(int j = 0; j < d; j++) cin >> x[i][j];
  for(int i = 0; i < n - 1; i++){
    for(int j = i + 1; j < n; j++){
      double dis = 0;
      for(int k = 0; k < d; k++){
        dis += pow(x[i][k] - x[j][k], 2);
      }
      dis = pow(dis, 0.5);
      for(double i = 0; i < 1000; i++){
        if(i == dis){
          sum++;
          break;
        }
      }
    }
  }
  cout << sum << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(){
  int n,max=-1,i,j,c;
  char d[1000][1000];
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%s",d[i]);
  for(i=0;i<n;i++){
    for(j=c=0;j<n;j++){
      if(d[i][j]=='#')c++;
    }
    for(j=0;j<n;j++){
      if(d[j][i]=='#')break;
    }
    if(j==n)c--;
    if(max<c)max=c;
  }
  for(i=c=0;i<n;i++){
    for(j=0;j<n;j++){
      if(d[j][i]=='.')break;
    }
    if(j==n)c++;
  }//printf("%d %d\n",max,c);
  printf("%d\n",max+1?2*n-max-c:-1);
  return 0;
}
      


Measured memory_bytes: 640
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    string s, t;
    cin >> s >> t;
    ll c = 0;
    for (ll i = 0; i < s.size(); i++)
        c += s[i] == t[i];
    cout << c;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>

using namespace std;

double Length(double x1, double y1, double x2, double y2) {

    double X;

    X = sqrt(pow((x2-x1), 2) + pow((y2-y1), 2));

    return X;
}

int main () {

    double x1, y1;
    double x2, y2;

    cin >> x1 >> y1 >> x2 >> y2;

    double answer = Length(x1, y1, x2, y2);

    cout << fixed;
    cout << setprecision(5) << answer << endl; 

    return 0;

}



Measured memory_bytes: 3284
package main

import (
	"fmt"
	"math"
	"sort"
)

// solve (-1, 1)を事前にかけたものをソート
func solve(N int, M int, arr [][]int) int {
	var maxval int
	maxval = math.MinInt64
	for ix := -1; ix <= 1; ix += 2 {
		for iy := -1; iy <= 1; iy += 2 {
			for iz := -1; iz <= 1; iz += 2 {
				converted := make([]int, N)
				for i := 0; i < N; i++ {
					a := arr[i]
					converted[i] = a[0]*int(ix) + a[1]*int(iy) + a[2]*int(iz)
				}
				sort.Ints(converted)
				var val int
				val = 0
				for i := 0; i < M; i++ {
					val += converted[N-1-i]
				}
				if maxval < val {
					maxval = val
				}
			}
		}
	}
	return maxval
}

func main() {
	var (
		N int
		M int
	)

	fmt.Scan(&N)
	fmt.Scan(&M)
	arr := make([][]int, N)
	for i := 0; i < int(N); i++ {
		arr[i] = make([]int, 3)
		fmt.Scan(&arr[i][0])
		fmt.Scan(&arr[i][1])
		fmt.Scan(&arr[i][2])
	}
	res := solve(N, M, arr)
	fmt.Println(res)
}


Measured memory_bytes: 768
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.util.*;

public class Main
{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        BigDecimal base = new BigDecimal(1);
        BigDecimal mm = new BigDecimal(Math.pow(10,18));

        List<BigDecimal> list = new ArrayList<>();
        BigDecimal zero = new BigDecimal(0);
        for (int i = 0;i<n;++i)
        {
            BigDecimal a = sc.nextBigDecimal();
            if (a.equals(zero))
            {
                System.out.println(0);
                System.exit(0);
            }
            list.add(a);
        }

        for (BigDecimal a:list)
        {
            base = base.multiply(a);
            if (base.compareTo(mm) > 0)
            {
                base = new BigDecimal(-1);
                break;
            }
        }

        System.out.println(base);
        sc.close();
    }
}

Measured memory_bytes: 67956
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
P = iil()
mP = P[0]
ans = 0
for i in range(n):
    if mP >= P[i]:
        ans += 1
    mP = min(mP,P[i])

print(ans)

Measured memory_bytes: 25348
import sys
#import time
from collections import deque, Counter, defaultdict
#from fractions import gcd
import bisect
import heapq
#import math
import itertools
import numpy as np
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))

k = ri()
reses=[]
cnt = 1
tmp = 7
for i in range(k+1):
    res = tmp % k
    if res==0:
        print(cnt)
        sys.exit(0)
    tmp = res * 10 + 7
    cnt += 1
print(-1)

Measured memory_bytes: 27132
N=int(input())
A = list(map(int, input().split()))

mod = 10**9 + 7
S = [0 for i in range(N)]
S[0] = A[0] 
for i in range(1,N):
    S[i] = (S[i-1]+ A[i])%mod

ans = 0
for i in range(N-1):
    ans = (ans + S[i] * A[i+1])%mod

print(ans%mod)



Measured memory_bytes: 31512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
 
  int N;
  cin >> N;
 
  vector<int> A(N + 2, 0);
  for (int i = 1; i <= N; i++) {
    cin >> A.at(i);
  }
 
  int S = 0;
  for (int i = 0; i <= N; i++) S += abs(A.at(i) - A.at(i + 1));
 
  for (int i = 1; i <= N; i++) {
    int diff = abs(A.at(i - 1) - A.at(i)) + abs(A.at(i) - A.at(i + 1)) -
               abs(A.at(i - 1) - A.at(i + 1));
    cout << S - diff << "\n";
  }
  return 0;
}

Measured memory_bytes: 1664
n, a, b = map(int, input().split())

if (b-a)%2 == 0:
    print((b-a)//2)
else:
    if (a-1) <= (n-b):
        print(a-1 + 1 +(b-a-1)//2)
    else:
        print(n-b + 1 +(b-a-1)//2)

Measured memory_bytes: 3060
import heapq
N, M = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
  A[i] = -A[i]
heapq.heapify(A)
for _ in range(M):
  a = -heapq.heappop(A)
  a = (a//2) * -1
  heapq.heappush(A, a)
print(sum(A)*-1)

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

int g;

int func(int p[], int c, bool chk[]) {
  if (chk[p[c]]) {
    return c;
  }

  chk[p[c]] = true;
  return func(p, p[c], chk);
}

int dfs(vector<int> v[], int c, int r, int a[], bool flag) {
  if (v[c].size() == 0) {
    a[c] = 0;
    return 0;
  }

  vector<int> pool;
  bool has = false;
  for (int i = 0; i < v[c].size(); i++) {
    if (v[c][i] == r) {
      has = true;
    } else {
      pool.push_back(dfs(v, v[c][i], r, a, flag));
    }
  }
  sort(pool.begin(), pool.end());
  unique(pool.begin(), pool.end());
  for (int i = 0; i < pool.size(); i++) {
    if (pool[i] != i) {
      if (has && flag) {
        has = false;
        g = i;
        pool.push_back(i);
        sort(pool.begin(), pool.end());
        continue;
      }
      a[c] = i;
      return i;
    }
  }

  int ret = has && flag ? pool.size() + 1 : pool.size();
  if (has && flag)
    g = pool.size();

  a[c] = ret;
  return ret;
}

int main() {
  int N;
  int p[200000];
  vector<int> v[200000];

  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> p[i];
    v[--p[i]].push_back(i);
  }

  bool chk[200000];
  for (int i = 0; i < N; i++) {
    chk[i] = false;
  }
  chk[0] = true;
  int r = func(p, 0, chk);

  int a[200000];
  int a1 = dfs(v, r, r, a, false);
  if (a[p[r]] != a1) {
    cout << "POSSIBLE" << endl;
    return 0;
  }

  int a2 = dfs(v, r, r, a, true);
  if (a[p[r]] != a2 && g == a2) {
    cout << "POSSIBLE" << endl;
    return 0;
  }

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


Measured memory_bytes: 35712
import sys
fastinput=sys.stdin.readline
N,T=map(int,fastinput().split())
p=[int(_) for _ in fastinput().split()]
oyumin=0
oyumax=0
Showertime=0
for i in p:
    if i>oyumax:
        Showertime+=oyumax-oyumin
        oyumin=i
        oyumax=i+T
    else:
        oyumax=i+T
Showertime+=oyumax-oyumin
print(Showertime)

Measured memory_bytes: 25108
import Control.Monad (replicateM)
import Data.List (minimum, scanl', sort, sortBy)

main :: IO ()
main = do
  [n,x] <- map read . words <$> getLine 
  as    <- map read . words <$> getLine
  print $ f n x as

f :: Int -> Int -> [Int] -> Int
f n x as
  | x < minas = 0
  | x <= sas  = length $ takeWhile (<= x) $ scanl1 (+) as'
  | x <  2 * sas = length $ takeWhile (<= (2*sas - x)) $ scanl1 (+) sa
  | otherwise    = 0
  where
    minas = minimum as
    sas = sum as
    as' = sort as
    sa  = sortBy (flip compare) as

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v;
map<LL,LL>u;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
   cin>>n>>m;
   cout<<(n*(n-1))/2+(m*(m-1))/2<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
using namespace std;
 
const int N = 2e5 + 5;
const int mod = 1e9 + 7;

vector<int> adj[N];
int vis[N];

int cnt;

void dfs(int u){
	vis[u] = true;
	cnt++;
	for(auto v:adj[u])
		if(!vis[v])
			dfs(v);
}

int32_t main() {
	fast;
	int n,m;
	cin>>n>>m;
	for(int i=0; i<m; i++){
		int a,b;
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}	
	int res = 0;
	for(int i=1; i<=n; i++){
		if(!vis[i]){
			cnt = 0;
			dfs(i);
			res = max(cnt, res);
		}
	}
	cout<<res;	
}




Measured memory_bytes: 22328
#define _GLIBCXX_DEBUG
const double PI = 3.14159265358979323846;
#include <bits/stdc++.h>
using namespace std;

int main() {
    int64_t A, B, H, M;
    cin >> A >> B >> H >> M;
    vector<double> A_point(2), B_point(2);
    B_point[0] =  B * cos(2. * PI * (- M / 60.) + PI / 4.);
    B_point[1] =  B * sin(2. * PI * (- M / 60.) + PI / 4.);
    A_point[0] =  A * cos(2. * PI * ((- H * 5. - M / 60. * 5.)/ 60.) + PI / 4.);
    A_point[1] =  A * sin(2. * PI * ((- H * 5. - M / 60. * 5.)/ 60.) + PI / 4.);
    cout << fixed << setprecision(15) << sqrt(pow(A_point[0] - B_point[0], 2) + pow(A_point[1] - B_point[1], 2)) << endl;
    return 0;
}

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

using namespace std;
typedef long long  ll;
const int MAXN = 5*1e3 + 1;
int dp [MAXN][MAXN];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    int n;
    cin >> n;
    cin >> s;
    s="0"+s;
    string t=s;
    int ans=0;
    for(int i=1; i<=n; ++i)
        for(int j=i; j<=n; ++j)
        {
            if (s[i]==t[j]) dp[i][j]=max(1,dp[i-1][j-1] +1);
            if (j-dp[i][j]+1 <=i) ans=max(ans,j-i); else ans=max(ans,dp[i][j]);
        }
    cout << ans;
    return 0;
}


Measured memory_bytes: 96768
#include<stdio.h>
int main(void)
{
	int a,b;
	
	scanf("%d %d",&a,&b);
	
	if(a<=8 && b<=8)
	{
		printf("Yay!\n");
	}
	else
	{
		printf(":(\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        StringBuilder s = new StringBuilder(scanner.nextLine().trim()).reverse();

        while (s.length() > 0) {
            if (s.indexOf("maerd") == 0 || s.indexOf("esare") == 0) {
                s.delete(0, 5);
                continue;
            }
            if (s.indexOf("resare") == 0) {
                s.delete(0, 6);
                continue;
            }
            if (s.indexOf("remaerd") == 0) {
                s.delete(0, 7);
                continue;
            }
            System.out.println("NO");
            System.exit(0);
        }
        System.out.println("YES");
    }
}

Measured memory_bytes: 27596
// 最長共通部分列 問題
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

#define MAX_N 100
// 無効な値の定義
const int INV = -1;

int main(void)
{
    int n, u, num, v_num;
    int ary_adj[MAX_N];

    for(int i = 0; i < MAX_N; i++)
    {
        // 配列の初期化
        ary_adj[i] = 0;
    }

    cin >> n;

    for(int i = 0; i < n; i++)
    {
        cin >> u;
        cin >> num;

        for(int j = 0; j < num; j++)
        {
            // 隣接点を記憶する
            cin >> v_num;
            ary_adj[v_num] = 1;
        }

        // 結果の表示をする
        for(int k = 1; k <= n; k++)
        {
            if( k > 1 )
            {
                cout << " ";
            }

            if( ary_adj[k] == 1 )
            {
                cout << 1;
                ary_adj[k] = 0;
            }
            else
            {
                cout << 0;
            }
        }

        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3100
#include<cstdio>
#include<algorithm>
#include<functional>
#define F1 first.first
#define F2 first.second
#define F3 second
#define MM 10000000000000000
using namespace std;
void func(int);
typedef pair<int,int> P1;
typedef pair<P1,int> P2;
P2 p[200000];
int st[100002];
long long leng[100001];
int main(void)
{
	int n,i,j,a,b,c,q,k,n2,x,y;

	scanf("%d",&n);
	for(i=0;i<n-1;i++)	{
		scanf("%d %d %d",&a,&b,&c);
		p[i].F1=a;	p[i].F2=b;	p[i].F3=c;
		p[i+n-1].F1=b;
		p[i+n-1].F2=a;
		p[i+n-1].F3=c;
	}
	n2=(n-1)*2;
	sort(p,p+n2);
	st[1]=0;
	for(i=1;i<n2;i++)	{
		if(p[i].F1!=p[i-1].F1)	{
			a=p[i].F1;
			st[a]=i;
		}
	}
	st[n+1]=n2;
//	for(i=0;i<n2;i++)	{
//		printf(" %d %d %d\n",p[i].F1,p[i].F2,p[i].F3);
//	}
//	for(i=1;i<=n;i++)	printf("st=%d\n",st[i]);
	scanf("%d %d",&q,&k);
	for(i=1;i<=n;i++)	leng[i]=MM;
	leng[k]=0;
	func(k);
	for(i=0;i<q;i++)	{
		scanf("%d %d",&x,&y);
		printf("%lld\n",leng[x]+leng[y]);
	}
	return 0;
}
void func(int a)
{
	int i,p1,p2,xx,l2;
	p1=st[a];	p2=st[a+1];
	for(i=p1;i<p2;i++)	{
		xx=p[i].F2;
		l2=p[i].F3;
		if(leng[xx]>leng[a]+l2)	{
			leng[xx]=leng[a]+l2;
			func(xx);
		}
	}
}

Measured memory_bytes: 8320
/* ***********************************************
Author        :yang12138
Created Time  :2018年01月14日 星期日 20时01分49秒
File Name     :A.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)



int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    

	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);

	b-=a+1;
	if(b&1) printf("Alice\n");
	else printf("Borys\n");

    return 0;
}


Measured memory_bytes: 764
a, b = [s for s in input().split(" ")]
a = int(a)
b = int(b.replace(".", ""))
h = b // 100
t = (b - h * 100) // 10
o = (b - h * 100 - t * 10)
ah = a * h
at = a * t
ao = a * o

print((ah * 100 + at * 10 + ao) // 100)

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

ll k;
bool no(ll px,ll py,ll x,ll y){
    if(abs(px-x)+abs(py-y)<=2*k&&(abs(px-x)+abs(py-y))%2==0) return 0;
    if(abs(px-x)+abs(py-y)==k) return 0;
    return 1;
}

bool in(ll px,ll py,ll x,ll y){
    if(abs(px-x)+abs(py-y)<=k) return 1;
    else return 0;
}

int main(){
    ll i,j;
    ll x,y;
    cin>>k>>x>>y;

    ll xx=1,yy=1;

    if(x<0) {
        xx=-1;
        x=-x;
    }
    if(y<0){
        yy=-1;
        y=-y;
    }

    if(k%2==0&&(x+y)%2!=0) {
        cout<<-1<<endl;
        return 0;
    }

    vector<ll> vx,vy;

    ll px=0,py=0;
    while(no(px,py,x,y)){
        if(px!=x){ 
        if(px<x&&px+k<x) {
            px+=k;
            vx.pb(px);
            vy.pb(py);
        }
        else if(px>x&&px-k>x) {
            px-=k;
            vx.pb(px);
            vy.pb(py);
        }
        else {
            ll re=k-abs(px-x);
            px=x;
            if(py>y) py-=re;
            else py+=re;
            vx.pb(px);
            vy.pb(py);
        }
        }
        else{
            if(py<y&&py+k<y) {
            py+=k;
            vx.pb(px);
            vy.pb(py);
        }
        else if(py>y&&py-k>y) {
            py-=k;
            vx.pb(px);
            vy.pb(py);
        }
        else {
            ll re=k-abs(py-y);
            py=y;
            if(px>x) px-=re;
            else px+=re;
            vx.pb(px);
            vy.pb(py);
            }
        }
    }

    if(px!=x||py!=y){
        if(abs(px-x)+abs(py-y)==k) {
            vx.pb(x);
            vy.pb(y);
        }
        else {
            ll pM=px+py;
            ll pm=px-py;
            ll M=x+y;
            ll m=x-y;
            ll M1,m1;

            ll p=0;

            if(abs(pM+k-M)<=k) {
                M1=pM+k;
                p=1;
            }
            if(abs(pM-k-M)<=k) {
                M1=pM-k;
                p=1;
            }
            if(abs(pm+k-m)<=k) {
                m1=pm+k;
            }
            if(abs(pm-k-m)<=k) {
                m1=pm-k;
            }

            if(p==1){
                if(abs(m+k-pm)<=k) m1=m+k;
                else m1=m-k;
            }
            else {
                if(abs(M-k-pM)<=k) M1=M-k;
                else M1=M-k;
            }

            ll xm=(M1+m1)/2;
            ll ym=(M1-m1)/2;
            
            vx.pb(xm);
            vy.pb(ym);

            vx.pb(x);
            vy.pb(y);

        }
    }

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

    for(i=0;i<vx.size();i++){
        cout<<vx[i]*xx<<" "<<vy[i]*yy<<endl;
    }

    




    return 0;
}

Measured memory_bytes: 5604
Q, H, S, D = map(int, input().split())
N = int(input())
Q1 = Q * 4
H1 = H * 2
D1 = D / 2
if min(Q1, H1, S) > D1:
  ans = D * (N // 2) + min(Q1, H1, S) * (N % 2)
else:
  ans = min(Q1, H1, S) * N
  
print(ans)

Measured memory_bytes: 3064
def bellman_ford(es: list, s: int, inf: int) -> list:
    n = 0
    for e in es: n = max(n, e[0], e[1])
    n += 1
    dis = [inf] * n
    dis[s] = 0
    for t in range(n << 1):
        for e in es:
            if dis[e[0]] != inf and dis[e[1]] > dis[e[0]] + e[2]:
                dis[e[1]] = dis[e[0]] + e[2]
                if t + 1 >= n: dis[e[1]] = -inf
    return dis

if __name__ == '__main__':
    N, M = map(int, input().split())
    es = []
    for i in range(M):
        a, b, c = map(int, input().split())
        es.append((a - 1, b - 1, -c))
    INF = 1 << 60
    dis = bellman_ford(es, 0, INF)
    if dis[N - 1] == -INF: print("inf")
    else: print(-dis[N - 1])

Measured memory_bytes: 3316
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        k: i64,
    }

    let ans;
    if a >= k {
        ans = k;
    } else if b >= (k - a) {
        ans = a;
    } else {
        ans = a - (k - a - b);
    }

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


Measured memory_bytes: 2112