akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int MAX = 1000000;
const ll INF = (1LL << 31) - 1;
const double pi=acos(-1);
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};


int main(){
  int n,m,k;
  cin >> n >> m >> k;
  vector<set<int>>cant(n); 
  UnionFind tree(n);
  
  rep(i,m){
    int a,b;
    cin >> a >> b;
    cant[a-1].insert(b-1);
    cant[b-1].insert(a-1);
    tree.merge(a-1,b-1);
  }
  rep(i,k){
    int c,d;
    cin >> c >> d;
    if(tree.issame(c-1,d-1)){
      cant[c-1].insert(d-1);
      cant[d-1].insert(c-1);
    } 
  }
  rep(i,n){
    if(i!=0)cout<<" ";
    int ans=tree.size(i)-1;
    ans -= cant[i].size();
    cout << ans;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 24704
n,k=map(int,input().split())
a=[i for i in range(n+1)]
ans=0
left=0
right=0
for i in range(k):
  left+=a[i]
  right+=a[n-i]
ans+=right-left+1
for i in range(k,n+1):
  left+=a[i]
  right+=a[n-i]
  ans+=right-left+1
print(ans%(10**9+7))

Measured memory_bytes: 16888
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
#define MOD int(1e9 + 7)

int main()
{
    long long N;
    vector<long long> A;

    cin >> N;
    for (long long i = 0; i < N; i++)
    {
        long long t;
        cin >> t;
        A.push_back(-t);
    }

    sort(A.begin(), A.end());

    vector<long long> o{0, 0};
    for (long long i = 0; i < N; i++)
        o[i % 2] -= A[i];

    cout << o[0] - o[1] << endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())

"""
1. 1回目の割れ目をタテヨコ1かいどこかにいれる。
2. 残りは2つに別れたチョコの面積大きい方を極力2分割する。
   その時、両辺とも奇数の場合は、最小でも短辺分の長さの差が生まれる。
2の操作はO(1)で実施できるため、O(n)で実行可能であるから、
この問題に対して十分高速である。
"""

def split_choco(h, w):
    if h > w:
        h, w = w, h
    if h*w%2 == 0:
        return h*w//2, h*w//2
    else:
        assert w%2==1
        w1 = w//2
        w2 = w//2+1
        return h*w2, h*w1

# まずヨコ方向に割る
ans = float('inf')
for i in range(1, H//2+1):
    large = (H-i, W)
    choco = [i*W] + list(split_choco(*large))
    ans = min(ans, max(choco)-min(choco))
# まずタテに割る
for i in range(1, W//2+1):
    large = (H, W-i)
    choco = [i*H] + list(split_choco(*large))
    ans = min(ans, max(choco)-min(choco))
print(ans)
    


Measured memory_bytes: 9156
N,T = map(int, input().split())
CT = [list(map(int, input().split())) for i in range(N)]

ans = float("inf")

for i in range(N):
    c,t = CT[i]
    if t <= T:
        if ans > c:
            ans = c
            
if ans == float("inf"):
    print("TLE")
else:
    print(ans)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


void solve()
{
    int a;int b;cin>>a>>b;
    cout<<a*b<<endl;
}


int32_t main()
{
    rapido;
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int j = 0;
		int m[][] = new int[200][200];
		int X[] = new int[200];

		for (int i = 0; i < n; i++) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			X[i] = a;
			X[i + 1] = b;
		}

		for (int k = 2; k <= n; k++) {
			for (int i = 1; i <= n - k + 1; i++) {
				j = i + k - 1;
				m[i][j] = 10000000;
				for (int l = i; l <= j - 1; l++) {
					if (m[i][j] > m[i][l] + m[l + 1][j] + X[i - 1] * X[l] * X[j]) {
						m[i][j] = m[i][l] + m[l + 1][j] + X[i - 1] * X[l] * X[j];
						//System.out.println(m[i][j]);
					}
				}
			}
		}
		System.out.println(m[1][n]);
	}
}


Measured memory_bytes: 26788
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan=new Scanner(System.in);
    		
    		char[] s=scan.next().toCharArray();
    		if (s [0]== s [1]&& s [1]== s [2]) {
    			System.out.print("Yes");
    		}else if( s [1]== s [2]&& s [2]== s [3]) {
    			System.out.print("Yes");
    		}else {
    			System.out.print("No");
    		}
  
    				
 
     
    }
    }
// end 

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int x;
    cin>>x;
    if(x==0) cout<<1;
    else cout<<0;
}

Measured memory_bytes: 3620
#include<stdio.h>
int main(){
int a,b,c,d,e=0,f;
scanf("%d %d\n",&a,&b);
a=a+1;
for(c=0;c<b;c++){
scanf("%d ",&d);
e=e+d;
}
f=e/a;
if(e%a==0){
}
else{
f=f+1;
}
printf("%d\n",f);
return 0;
}


Measured memory_bytes: 2136
def main():
    height, width = map(int, input().split())
    grid = [list(map(int, input().split())) for _ in range(height)]
    answer = []
    for i in range(height - 1):
        for j in range(width):
            if grid[i][j] % 2:
                grid[i + 1][j] += 1
                grid[i][j] -= 1
                answer.append([i + 1, j + 1, i + 2, j + 1])
    for j in range(width - 1):
        if grid[-1][j] % 2:
            grid[-1][j + 1] += 1
            grid[-1][j] -= 1
            answer.append([height, j + 1, height, j + 2])
    print(len(answer))
    for ans in answer:
        print(" ".join(map(str, ans)))


if __name__ == '__main__':
    main()



Measured memory_bytes: 29804
#include <iostream>
#include <vector>

using namespace std;

int gcd(int a, int b) {
        if (a < b) {
                swap(a, b);
        }
        if (b == 0) return a;
        return gcd(b, a % b);
}

int main() {
        int N;
        cin >> N;
        vector<int> as(N);
        for(int i = 0; i < N ; i++) {
                cin >> as[i];
        }
        vector<int> left(N);
        vector<int> right(N);
        left[0] = 0;
        right[N-1] = 0;
        /*
        for(int i = 1; i< N; i++) {
                left[i] = gcd(left[i-1], as[i-1]);
        };
        for( int i = N - 2; i >= 0; i--) {
                right[i] = gcd(right[i+1], as[i+1]);
                }
        */
        for(int i = 1; i < N; i++) {
                left[i] = gcd(left[i-1], as[i-1]);
                right[N-1-i] = gcd(right[N-i], as[N-i]);
        }
        int m = 1;
        int mm;
        for(int i = 0 ; i < N; i++) {
                mm = gcd(left[i], right[i]);
                if (mm > m) {
                        m = mm;
                }
        }
        cout << m << endl;
        return 0;
}


Measured memory_bytes: 1408
from math import log, ceil
l = int(input())

d = max([d if 2**d <= l else 0 for d in range(100)])
n = d+1
m = 2*d
ans = []
for i in range(1, n):
    ans.append((i, i+1, 0))
    ans.append((i, i+1, 2**(i-1)))

while l > 2**d:
    for i in range(n-1, 0, -1):
        if l-2**(i-1) >= 2**d:
            ans.append((i, n, l-2**(i-1)))
            l -= 2**(i-1)
            m += 1
            break

print(n, m)
for a in ans:
    print(*a)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;

typedef pair<string, string> pss;
map<pss, int> m;

int main() {
	int N, F;
	cin >> N >> F;
	
	REP(i, N){
		int M; cin >> M;
		string str[10];
		REP(j, M) cin >> str[j];
		sort(str, str + M);
		
		REP(j, M) FOR(k, j + 1, M) m[pss(str[j], str[k])]++;
	}
	
	vector<pss> ans;
	for (map<pss, int>::iterator it = m.begin(); it != m.end(); ++it) {
		if((*it).second >= F )ans.push_back(it->first);
	}
	
	cout << ans.size() << endl;
	REP(i,ans.size())cout << ans[i].first <<" "<<ans[i].second << endl;
	
	return 0;
}

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

int main(){
  int n, k;
  cin >> n >> k;
  
  vector<int> l(n);
  for(int i=0;i<n;i++)
    cin >> l[i];
  
  sort(l.begin(), l.end(), greater<>());
  
  int ans=0;
  for(int i=0;i<k;i++)
    ans+=l[i];
  
  cout << ans;
  
  
  return 0;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    a, b = map(int, input().split())
    if (a - b) % 2 == 0:
        print(abs(a - b) // 2 + min(a, b))
    else:
        print('IMPOSSIBLE')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> ipair;

int main(){
    int n;
    cin >> n;
    priority_queue<int> takahashi;
    ll sum=0;
    for(int i=0; i<n; i++){
        int a,b;
        cin >> a >> b;
        takahashi.push(a+b);
        sum-=b;        
    }
    ll t=0;
    int i=0;
    while(!takahashi.empty()){
        int tmp=takahashi.top();takahashi.pop();
        if(i%2==0){
            t+=tmp;
        }
        i++;
    }
    cout << (ll)t+sum << endl;
}

Measured memory_bytes: 892
def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x
  
N = int(input())
lst = list(map(int, input().split()))
const = 10**9 + 7

def solve(arr):
    ab = lcm(arr)
    sum = 0
    for a in arr:
        sum += ab // a
    return sum % const

answer = solve(lst)

print(int(answer))


Measured memory_bytes: 5580
N = int(input())
S = input()

ans = 1
i = 0
j = 0
while i < (N-1):
  j += 1
  while S[i] == S[j]:
    if j == N-1: 
      print(ans)
      exit()
    else:
      j += 1
  ans += 1
  i = j
  
print(ans)

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

#define rng(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed

int main() {
  int n, a, b, c, ans = 0;
  //string s;
  cin >> a >> b >> c;
  //vector<int> v(n), c(n);
  //if(1) {}
  //((a == b)? "Yes" : "No")
  //for(int i = 0; i < n; i++){}
  cout << c << " " << a << " " << b << endl;
}

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

ll dp[105][10];
ll a[10][10];
const ll MOD=1e9+7;

int main(){
  int h,w,k;
  cin>>h>>w>>k;
  for(int bit=0;bit<1<<w-1;bit++){
    bool ok=true;
    rep(i,w-2){
      if((bit&1<<i)&&(bit&1<<i+1)) ok=false;
    }
    if(!ok) continue;
    rep(i,w){
	if(i==0&&!(bit&1<<i)||i==w-1&&!(bit&1<<i-1)||!(bit&1<<i)&&!(bit&1<<i-1))
	  a[i][i]++;
    if(i==0) continue;
	if(bit&1<<i-1) a[i][i-1]++;
    }
  }
  dp[0][0]=1;
  for(int i=1;i<=h;i++){
    rep(j,w){
      if(j>0) dp[i][j]=(dp[i][j]+dp[i-1][j-1]*a[j][j-1])%MOD;
      dp[i][j]=(dp[i][j]+dp[i-1][j]*a[j][j])%MOD;
      if(j<w-1) dp[i][j]=(dp[i][j]+dp[i-1][j+1]*a[j+1][j])%MOD;
    }
  }
  cout<<dp[h][k-1]<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<stack>
#include<cmath>
#include<vector>
using namespace std;
int n,m;
int p[100005]; 
int y[100005];
vector<int>v[100005];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&p[i],&y[i]);
		v[p[i]].push_back(y[i]);
	} 
	for(int i=1;i<=n;i++) sort(v[i].begin(),v[i].end());
	for(int i=1;i<=m;i++){
		printf("%06d",p[i]);
		int k=lower_bound(v[p[i]].begin(),v[p[i]].end(),y[i])-v[p[i]].begin()+1;
		printf("%06d\n",k);
	}
	return 0;
}

Measured memory_bytes: 7808
#include <stdio.h>

int main(void){
  int n, m, p;
  int veg_price[10001];
  int sum,idx,i;

  while(scanf("%d%d",&n,&m) && n && m){
    for(i = 1; i <= 10000; i++) veg_price[i] = 0;

    for(i = 0; i < n; i++){
      scanf("%d", &p);
      veg_price[p]++;
    }
		
    sum = 0;
    idx = 1;
    for(i = 10000; i >= 1 ; i--){
      while(veg_price[i]>0){
	veg_price[i]--;
	if(idx % m) sum += i;
	idx++;
      }
    }
		
    printf("%d\n", sum);
  }
  return 0;
}

Measured memory_bytes: 636
/*
      author : nishi5451
      created: 11.08.2020 00:47:57
*/

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


int main(){
    ll x,a,b;
    cin >> x >> a >> b;
    if(a-b>=0) cout << "delicious" << endl;
    else if(b-a<=x) cout << "safe" << endl;
    else cout << "dangerous" << endl;
    return 0;
}

Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;
int N, dp[100002][3];
int main(){
    scanf("%d", &N);
    for(int i=1, a, b, c; i<=N; i++){
        scanf("%d %d %d", &a, &b, &c);
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a;
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b;
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c;
    }
    printf("%d\n", max(dp[N][0], max(dp[N][1], dp[N][2])));
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 100001

int gcd(int a, int b) {
    if(a < b) swap(a, b);
    if (b==0) return a;
    return gcd(b, a%b);
}

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

    int minv = min(n*a, b);

    cout << minv << endl;



}



Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>

int main()
{
int i,x,y,k=0;

int a=2;
int b[7]={1,3,5,7,8,10,12};
int c[4]={4,6,9,11};
scanf("%d %d",&x,&y);
for(i=0;i<4;i++)
{
   if(x==c[i])
    {
     for(i=0;i<4;i++)
     {
      if(y==c[i])
      {
       printf("Yes"); 
	   k=5;
      }
     }
    }
}
for(i=0;i<7;i++)
{
   if(x==b[i])
    {
     for(i=0;i<7;i++)
     {
      if(y==b[i])
      {
       printf("Yes"); 
	   k=5;
      }
    }
    }
}
if(k!=5)
printf("No");
}

Measured memory_bytes: 128
#ifdef ONPC
    # define _GLIBCXX_DEBUG
#endif
#include <iostream>
#include <vector>
#include <cstdio>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <queue>
#include <unordered_set>
#include <complex>
#include <unordered_map>
#include <bitset>
#include <ctime>
#include <cassert>
#include <random>
#include <iomanip>

#ifdef ONPC
    #define deb(a) cerr << "      " << #a << " = " << a << endl;
#else
    #define deb(a)
#endif

#define sz(a) (a).size()

using namespace std;
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnd(time(0));

typedef long long ll;
typedef long double ld;



int solve()
{
    string n;
    if (!(cin >> n))
        return 1;
    int mx = 0, cur = 0;
    for (int i = 0; i < (int)n.size(); i++)
    {
        if (n[i] == 'A' || n[i] == 'T' || n[i] == 'G' || n[i] == 'C')
            cur++;
        else
            mx = max(mx, cur), cur = 0;
    }
    cout << max(mx, cur) << endl;
    return 0;
}

int32_t main()
{
    #ifdef ONPC
        freopen("in.txt", "r", stdin);
    #endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1e9;
    //cin >> T;
    while (T--)
    {
        if (solve())
            break;
        #ifdef ONPC
            cout << "\n__________________________" << endl;
        #endif
    }
    #ifdef ONPC
        cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
    #endif
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int maxn = 2e5 + 5;
int n , D,a[maxn],lab[maxn];
int FindLab(int u){return lab[u] < 0 ? u : lab[u] = FindLab(lab[u]);}

struct node{
    pair<ll,int> a,b;
    node(){a =  b = mp(1e18,-1);};
    void reset(){a = b = mp(1e18,-1);}
    void add(pair<ll,int> x , ll y = 0){
        x.first += y;
        if(a.second == x.second)a = min(a,x);
        else if(b.second == x.second)b = min(b,x);
        else if(a > x)b = a , a = x;
        else if(b > x)b = x;
        if(b<a)swap(a,b);
        assert(b.second != a.second || a.second == -1);
    }
}dp[maxn];
pair<ll,int> bezt[maxn];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> n >> D;
    for(int i = 1 ; i <= n ; ++i)cin >> a[i];
    fill_n(lab,maxn,-1);
    int cnt = n - 1;
    ll res = 0;
    while(cnt > 0){
        dp[0].reset();dp[n + 1].reset();
        fill_n(bezt,maxn,mp(1e18,0));;
        for(int i = 1 ; i <= n ; ++i){
            dp[i].reset();
            dp[i].add(dp[i-1].a,D);
            dp[i].add(dp[i-1].b,D);
            int  tmp = FindLab(i);
            if(dp[i].a.second != tmp)bezt[tmp] = min(bezt[tmp],mp(dp[i].a.first + a[i],dp[i].a.second));
            if(dp[i].b.second != tmp)bezt[tmp] = min(bezt[tmp],mp(dp[i].b.first + a[i],dp[i].b.second));
            dp[i].add(mp(a[i],tmp));
        }
        for(int i = n ; i >= 1 ; --i){
            dp[i].reset();
            dp[i].add(dp[i+1].a,D);
            dp[i].add(dp[i+1].b,D);
            int  tmp = FindLab(i);
            if(dp[i].a.second != tmp)bezt[tmp] = min(bezt[tmp],mp(dp[i].a.first + a[i],dp[i].a.second));
            if(dp[i].b.second != tmp)bezt[tmp] = min(bezt[tmp],mp(dp[i].b.first + a[i],dp[i].b.second));
            dp[i].add(mp(a[i],tmp));
        }
        vector<pair<ll,ii>> edge;
        for(int i = 1 ; i <= n ; ++i){
            if(lab[i] < 0){
                if(bezt[i].first < 1e18){
                    edge.pb(mp(bezt[i].first,mp(i,bezt[i].second)));
                }
            }
        }
        sort(edge.begin(),edge.end());
//        cout << edge.size() << endl;
        for(auto c : edge){
            int u , v;tie(u,v) = c.second;
            u = FindLab(u);v = FindLab(v);
            if(u==v)continue;
            res += c.first;if(lab[u]>lab[v])swap(u,v);lab[u]+=lab[v];lab[v]=u;
//            cout << u << " " << v << " " << c.first << endl;
            --cnt;
        }
    }
    cout << res;
}


Measured memory_bytes: 17392
#include<bits/stdc++.h>
using namespace std;
int a, b;
int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "a", stdout);
    // #endif
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}

Measured memory_bytes: 3624
s = input()
q = int(input())
a = []
# for j in range(q):
#     a.extend([list(map(str,input().split()))])
# # print(a)
# for i in a:
pre = ""
nex = ""
c = 1
TFC = [input().split() for _ in range(q)]
for i in TFC:
# for j in range(q):
#     i = list(map(str,input().split()))
    if i ==["1"]:
        c *= -1
        # s = s[::-1]
    elif i[0]=="2" and i[1]=="1":
        # s = i[2]+s
        if c == 1:
            pre=pre+i[2]
        else:
            nex = nex + i[2]
    elif i[0]=="2" and i[1]=="2":
        # s = s +i[2]
        if c ==1:
            nex = nex +i[2]
        else:
            pre = pre+i[2]
if c==-1:
    print(nex[::-1]+s[::-1]+pre)
else:
    print(pre[::-1]+s+nex)

Measured memory_bytes: 40436
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n;cin>>n;
	ll a[n],b[n],c[n-1];
	For(i,0,n){
		cin>>a[i];a[i]--;
	}
	For(i,0,n) cin>>b[i];
	For(i,0,n-1) cin>>c[i];

	ll ans = 0;
	For(i,0,n){
		ans+=b[a[i]];
		if(i<n-1){
			if(a[i+1]==a[i]+1) ans+=c[a[i]];
		}
	}
	cout<<ans<<endl;































	
}

Measured memory_bytes: 256
n = int(input())
num = [0]*(10**5+1)
for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            num[(i**2 + j**2 + k**2 + i*j + j*k + k*i)] += 1
for i in range(1,n+1):
    print(num[i])

Measured memory_bytes: 9764
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    a, b, c, d = nm()
    ans = - float('Inf')
    for i in [a, b]:
        for j in [c, d]:
            ans = max(ans, i * j)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9188
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n;
  cin >> n;
  vector<string> s(n);
  for (i64 i = 0; i < n; i++)
  {
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
  }
  map<string, i64> m;
  i64 ans = 0;
  for (i64 i = 0; i < n; i++)
  {
    ans += m[s[i]];
    m[s[i]]++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 18176
import java.util.*;
import java.lang.Math.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int hund=n/500;
		n=n%500;
		int t=n/5;
		int ans=hund*1000+t*5;
		System.out.println(ans);
	}
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

void solve() {
    i64 n, m, k;
    cin >> n >> m >> k;
    vector<i64> a(n + 1), b(m + 1);
    for (i64 i = 1; i <= n; i++) cin >> a[i];
    for (i64 i = 1; i <= m; i++) cin >> b[i];
    partial_sum(all(a), begin(a));
    partial_sum(all(b), begin(b));

    i64 ans = 0;
    for (i64 i = 0; i <= n; i++) {
        i64 l = k - a[i];
        if (l < 0) break;
        i64 j = upper_bound(all(b), l) - begin(b) - 1;
        ans = max(ans, i + j);
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 6372
#include<bits/stdc++.h>
using namespace std ;
typedef  long long int ll ;
#define inf 9e18
#define mod 1000000007
#define mod1 998244353
#define mod2 999983
long long int power(long long int a,long long int n,long long int m) ;
long long int power(long long int a,long long int n,long long int m)
{  if(n==0)
   return 1 ;
   long long int x=power(a,n/2,m) ;
   if(n%2!=0)
    return (((a*x)%m)*(x)%m)%m ;
    else return (x*x)%m ;
}
//map<ll,ll>::iterator it ;

int main()
{ ll n,i,j,x,y,m,k,t,sum,count,cnt,b,c,d,j1,z,a,o,temp;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin>>n>>k ;
  ll arr[n+1] ;
  ll brr[n+1] ;
  ll crr[n+1] ;
  for(i=1;i<=n;i++)
    { cin>>arr[i] ;
       brr[i]=-1 ;
       crr[i-1]=-1 ;
    }
 x=0 ;
 i=1 ;
 while(x<k)
 {
     if(brr[i]!=-1)
      break ;
      crr[x]=i ;
      brr[i]=x ;
      i=arr[i] ;
      x++ ;


 }
 //cout<<x<<" " ;
 if(x==k)
 {
     cout<<i<<"\n" ;
     return 0;
 } ll drr[n+1] ;
   for(j=brr[i];j<x;j++)
   { //cout<<j<<" " ;
       drr[j-brr[i]]=crr[j] ; }

 cout<<drr[(k-brr[i])%(x-brr[i])] ;
   return 0; }



Measured memory_bytes: 9200
import numpy as np
H, W, K = map(int, input().split())

if W == 1:
    print (1)
    exit()
MOD = 10 ** 9 + 7

#dp-tableの作成
lst = [[0] * (W) for i in range(H+2)]
dp = np.array(lst)
dp[0][0] = 1

def check(h): #h番目のX, Y, Zを検索
    count = 0
    for i in range(2**(W-1)):
        flag2 = True
        flag = False #一つ前が橋のとき、フラグをTrueにする
        for j in range(W-1):
            if flag2: #どこかで連続橋になったらそれ以降計算しない
                # print (j, end = ' ')
                if (i >> j) & 1: #1を橋とする
                    if flag: #連続で橋の時
                        count += 1
                        # print ('A', end = ' ')
                        flag = True
                        flag2 = False
                        break
                    else: #一つ前が橋では無い時-->ここに橋をかける
                        dp[H+1][j] += dp[h-1][j+1]%MOD
                        dp[H+1][j+1] += dp[h-1][j]%MOD
                        flag = True
                else:
                    if j == W-2: #最後の一本が橋でない時
                        dp[H+1][j+1] = dp[h-1][j+1]%MOD
                    if not flag: #連続で橋がかからない時、まっすぐ下ろす
                        dp[H+1][j] = dp[h-1][j]%MOD
                    else:
                        pass
                    flag = False
        if flag2: #最後まで条件を満たしていたら、H+1に記録していたものを通常の場所に移す
            dp[h][:] += dp[H+1][:]%MOD
            dp[h][:] = dp[h][:]%MOD
            # print (dp[H+1])
        dp[H+1][:] = 0
        # print ()
    # print (i)
    # print (count)
    return 0;

for i in range(H):
    check(i+1)

# print (dp)
print (dp[H][K-1]%MOD)


Measured memory_bytes: 13452
#include "bits/stdc++.h"
using namespace std;

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

const int INF = 1000000007;

int main(void){
	string w; cin>>w;
	int alp[26]={0};

	for(int i=0;i<w.size();i++){
		alp['z'-w[i]]++;
	}
	bool can = true;
	for(int i=0;i<26;i++){
		if(alp[i] % 2 != 0) can = false;
	}

	if(can) printf("Yes\n");
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> G[16];
int n;
bool ok(int state){
    //cout<<state<<endl;
	for(int i=0;i<n;++i){
		if( ((1<<i)&state) > 0){
			for(int j=0;j<n;++j){
				if(G[i][j]!=-1){
					if(G[i][j]==0 && (state & (1<<j))!=0 ){
						return false;
					}
					if(G[i][j]==1 && (state & (1<<j))==0 ){
						return false;
					}					
				}
			}
		}
	}
	return true;
}
int main(){
	cin>>n;
	for(int i=0;i<n;++i){
		int Ai;cin>>Ai;
		G[i] = vector<int>(n,-1);
		for(int j=1;j<=Ai;++j){
			int num,honest;cin>>num>>honest;
			G[i][num-1] = honest;
		}
	}
    /*
    for(auto i:G){
      for(auto j:i){
        cout<<j<<" ";
      }
      cout<<endl;
    }
    */
	int res = 0;
	for(int state = 0;state < (1<<n);++state){
		if(ok(state)){
            //cout<<state<<endl;
			res = max(res,__builtin_popcount(state));
		}
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k;
	cin>>k;
	string st;
	cin>>st;
	if(k>=st.length())cout<<st;
	if(k<st.length()){
		for(int i=0;i<k;i++){
			cout<<st[i];
		}
		cout<<"...";
	}
	return 0;
}

Measured memory_bytes: 3608
n = int(input())
A = list(map(int,input().split()))
L = [0]*(n+1)
ans = 0
for i in range(n):
  L[i+1] = L[i]+A[i]
for i in range(1,n):
  ans += L[i]*A[i]
print(ans % (10**9+7))

Measured memory_bytes: 94124
num = int(input())
List = input().split(" ")
height = [int(n) for n in List]
dp = [0 for n in range(10 ** 5 * 2)]
a = 0
while dp[num-1] == 0:
  a+= 1
  if a == num:
    break
  if a == 1:
    dp[a] = abs(height[a]-height[a-1])
  else:
    dp[a] = min(abs(height[a]-height[a-1])+dp[a-1],abs(height[a]-height[a-2])+dp[a-2])
print(dp[num-1])

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

int main(){
  long long N,A,B;
  cin >> N >> A >> B;
  if((B-A)%2 ==0){
    cout << (B-A)/2 << endl;
  }
  else{
    cout << min((A+B-1)/2,(2*N-A-B+1)/2) << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define pi pair<int, int>
#define f first
#define s second

long long n, m;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> m;
	
	n = n % m;
	
	cout << min(n, m - n) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int K;
    scanf("%d",&K);


    printf("%d",a[K-1]);



    return 0;
}

Measured memory_bytes: 128
from functools import reduce
N,K = map(int,input().split())
A = list(map(int,input().split()))
M = max(A)
def gcd(a, b): 
    while b:
        a, b = b, a % b
    return a
m = reduce(gcd,A)
if K <= M and K % m == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 14596
using System;
class abc148_a{
  public static void Main(){
	int a = int.Parse(Console.ReadLine());
    int b = int.Parse(Console.ReadLine());
    if(a==1){
      if(b==2){
        Console.WriteLine(3);
      }
      else if(b==3){
        Console.WriteLine(2);
      }
    }
    if(a==2){
      if(b==1){
        Console.WriteLine(3);
      }
      else if(b==3){
        Console.WriteLine(1);
      }
    }
    if(a==3){
      if(b==1){
        Console.WriteLine(2);
      }
      else if(b==2){
        Console.WriteLine(1);
      }
    }
  }
}


Measured memory_bytes: 13140
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
collect = 0
for _ in range(n):
    a = list(map(int, input().split()))
    score = sum([n * m for n, m in zip(a, b)]) + c
    if score > 0:
        collect += 1

print(collect)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
map<vector<int>,int>ctr;
bool ispf(int x) {
	int s = sqrt(x);
	return s*s == x;
}
int main() {
	int n;
	cin >> n;
	for (int it = 1; it <= n; it++) {
		for (int x = 1; x*x <= it; x++) {
			for (int y = 1; y*y <= it; y++) {
				int a = x*x + y*y + x*y;
				int b = x+y;
				int c = a-it;
				int D = (b*b) - (4*c);
				if (ispf(D)) {
					int z1,z2;
					z1 = z2 = -1;
					int t1 = -b - sqrt(D);
					int t2 = -b + sqrt(D);
					if (t1 > 1 && t1%2 == 0)
						z1 = t1/2;
					if (t2 > 1 && t2%2 == 0)
						z2 = t2/2;
					vector<int>v;
					v.push_back(x);
					v.push_back(y);
					if (z1 != -1) {
						v.push_back(z1);
						// sort(temp.begin(), temp.end());
						// if (it == 20) {
						// 	cout << x << " " << y << " " << z1 << endl;
						// 	cout << b << "--" << c << "--" << D << endl;
						// }
						ctr[v]++;
						v.pop_back();
					}
					if (z2 != -1) {
						v.push_back(z2);
						// sort(temp.begin(), temp.end());
						// if (it == 20) {
						// 	cout << x << " " << y << " " << z2 << endl;
						// 	cout << b << "--" << c << "--" << D << endl;
						// }
						ctr[v]++;
						v.pop_back();
					}	
				}
			}
		}
		cout << ctr.size() << "\n";
		ctr.clear();
	}

	return 0;
}

Measured memory_bytes: 3608
n = int(input())
l = list(map(int, input().split()))
l.sort()
cnt = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if l[i] != l[j] and l[j] != l[k] and l[k] != l[i] and l[i] + l[j] > l[k]:
                cnt += 1
print(cnt)

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

int main(){
  ll n,h,hurimax=0,ans=0;
  cin >>n >> h;
  vector<ll> nage(n);
  ll huri[n];
  r(i,n){
    cin >> huri[i] >> nage[i];//0に投げダメージ　1にフリフリダメージ
    if(hurimax<huri[i])hurimax=huri[i];
  }
  sort(nage.begin(),nage.end());
  r(i,n){
    if(nage[n-1-i]>hurimax){
      h-=nage[n-1-i];
   ans++; 
    }
    if(h<=0)break;
  }
  if(h<=0)cout<<ans<<endl;//投げただけで倒せる
  else{
    ans+=(h+hurimax-1)/hurimax;
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr ll mod998=998244353;

int H1,H2,M1,M2,K;

int main(){
	cin>>H1>>M1>>H2>>M2>>K;
	int T=H2*60+M2-H1*60-M1;
	cout<<max(0,T-K)<<endl;
}


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

using namespace std;

int main()
{
	int a,b;
	
	cin>>a>>b;
	
	if(a==0||b==0){
		cout<<"Zero"<<endl;
		
		return 0;
	}
	
	if(a>0&&b>0){
		cout<<"Positive"<<endl;
		
		return 0;
	}
	
	if(a<0&&b<0){
		
		if((abs(b)-abs(a)+1)%2)
			cout<<"Negative"<<endl;
		else
			cout<<"Positive"<<endl;
		
		return 0;
	}
	
	if((a<0&&b>0)||(a>0&&b<0)){
		cout<<"Zero"<<endl;
		
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
n,m = map(int, input().split())
link = [[] for _ in range(n)]
for i in range(m):
    a,b,cost = list(map(int,input().split()))
    link[a-1].append([b-1,cost])
    link[b-1].append([a-1,cost])

for i in range(n-1):
    link[i+1].append([i,0])

from heapq import heappush, heappop,heappushpop,heapify
def dks(g,start,num_v):
    INF=float('inf')
    visited = set()
    hq = []
    heappush(hq, (0,start))
    cost = [INF] * num_v
    while hq:
        shortest, i = heappop(hq)
        if i in visited:
            continue
        visited.add(i)
        cost[i] = shortest
        for j, t in g[i]:
            if j in visited:
                continue
            heappush(hq, (shortest + t, j))
    return cost

ans=dks(link,0,n)
if ans[-1]!=float("inf"):
    print(ans[-1])
else:
    print(-1)

Measured memory_bytes: 106604
#include <stdio.h>

int main(void){
  int w,n;
  int a[30],b[30];
  int i;
  int l[30];
  int bf;
  char ch;

  while(1){
    bf = scanf("%d %d ",&w,&n);
    if( bf==EOF )
      break;
    for( i=0;i<w;i++ )
      l[i]=i+1;

    for( i=0;i<n;i++ ){
      scanf("%d",&a[i]);
      scanf("%c",&ch);
      scanf("%d",&b[i]);

      a[i]--; b[i]--;
      bf = l[ a[i] ];
      l[ a[i] ] = l[ b[i] ];
      l[ b[i] ] = bf;
    }
    for( i=0;i<w;i++ )
      printf("%d\n",l[i]);
  }
  return 0;
}

Measured memory_bytes: 0
import sys
N,M=map(int, sys.stdin.readline().split())
sc=[ map(int, sys.stdin.readline().split()) for _ in range(M) ]

if N==3: start,end=100,1000
elif N==2: start,end=10,100
elif N==1: start,end=0,10

for n in range(start,end):
    n=str(n)
    for s,c in sc:
        if n[s-1]==str(c):
            pass
        else:
            break
    else:
        print n
        quit()
else:
    print -1

Measured memory_bytes: 28396
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int D = sc.nextInt();
    	List<int[]> order = new ArrayList<>();
    	for (int i = 0; i < N; i++) {
    		int[] map = new int[D];
    		for (int j = 0; j < D; j++) {
    			map[j] = sc.nextInt();
    		}
    		order.add(map);
    	}
    	int count = 0;
    	for (int i = 0; i < N-1; i++) {
    		for (int j = i+1; j < N; j++) {
    			int[] f = order.get(i);
    			int[] b = order.get(j);
    			double total = 0.0;
    			for (int k = 0; k < D; k++) {
    				total += Math.pow((f[k] - b[k]), 2);
    			}
    			double root = Math.sqrt(total);
    			double ceil = Math.ceil(root);
    			if (root == ceil) {
    				count++;
    			}
     		}
    	}
    	System.out.println(count);
    }
}

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

int main()
{
ll n ;
cin >> n ;
vector<pair<ll,ll>> v;
vector<ll> vy;
vector<ll> comp;
rep(i,n){
  ll x , y ;
  cin >> x >>y  ;
  comp.push_back(x);
  comp.push_back(y);
  if(x>y)swap(x,y);
  v.emplace_back(x,y);
  vy.push_back(y);
}
sort(v.begin(),v.end());
sort(vy.begin(),vy.end());
ans=(v[n-1].first-v[0].first)*(vy[n-1]-vy[0]);
sort(comp.begin(), comp.end());
comp.erase(unique(comp.begin(), comp.end()), comp.end());
vector<vector<ll>> q(comp.size()+1);
rep(i,v.size()){
  ll compnum=lower_bound(comp.begin(), comp.end(), v[i].first) - comp.begin();
  q[compnum].push_back(i+1);
  compnum=lower_bound(comp.begin(), comp.end(), v[i].second) - comp.begin();
  q[compnum].push_back(i+1);
}
set<ll> s;
ll en=-1;
vector<bool> buf(n+1);
rep(i,comp.size()){
  while(s.size()!=n && en!=comp.size()-1){
    en++;
    for(auto k:q[en]){
      if(s.find(k)!=s.end())buf[k]=1;
      else s.insert(k);
    }
  }
  if(s.size()==n)ans=min(ans,(vy[n-1]-v[0].first)*(comp[en]-comp[i]));
  for(auto k:q[i]){
    if(buf[k])buf[k]=0;
    else s.erase(k);
  }
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 41180
package main

import (
	"fmt"
	"os"
)

func main() {
	var num int
	var pos [][]int

	fmt.Scan(&num)
	for i := 0; i < num; i++ {
		p := scanNums(3)
		pos = append(pos, p)
	}

	debug("pos = %v\n", pos)
	c := solve(pos)
	debug("center = %v\n", c)
	fmt.Printf("%d %d %d\n", c[0], c[1], c[2])
}

/**
 * 総当たりで求める
 * pos = [x, y, h]のslice
 * 0 <= x, y <= 100
 * 0 <= h <= 1e+09
 */
func solve(pos [][]int) []int {
	//座標を整理
	//高さごとに分ける
	pointMap := make(map[int][][]int)
	for _, p := range pos {
		h := p[2]
		if _, ok := pointMap[h]; ok {
			pointMap[h] = append(pointMap[h], p)
		} else {
			pointMap[h] = make([][]int, 0)
			pointMap[h] = append(pointMap[h], p)
		}
	}
	debug("pointMap = %v\n", pointMap)

	var cx, cy, ch int
CX:
	for x := 0; x <= 100; x++ {
	CY:
		for y := 0; y <= 100; y++ {
			//中心の候補
			//debug("(x,y) = (%d,%d)\n", x, y)
			//等しい高さの座標と中心との距離を測り矛盾がないか確認
			for h, pary := range pointMap {
				if h > 0 {
					p0 := pary[0]
					px := p0[0]
					py := p0[1]
					d0 := absInt(px-x) + absInt(py-y)
					for i, p := range pary {
						if i == 0 {
							continue
						} else {
							px = p[0]
							py = p[1]
							d := absInt(px-x) + absInt(py-y)
							if d0 != d { //矛盾する座標があった(中心への距離が等しくない）ので、中心とはいえない
								continue CY
							}
						}
					}
				}
			}
			//debug("center:(%d, %d)\n", x, y)
			//debug("check distance between points with same height:OK\n")

			//h>0の座標から中心の高さを推定
			//全ての座標からの高さが等しいか確認
			//矛盾があったら中心の推定やり直し
			ch = -10 //初期値
			for _, p := range pos {
				px := p[0]
				py := p[1]
				ph := p[2]
				if ph > 0 {
					d := absInt(px-x) + absInt(py-y)
					if ch < 0 {
						ch = d + ph
						//debug(" estimating center -> height ch=%d\n", ch)
					} else if ch != d+ph {
						//debug(" estimating center failed -> height ch:%d != %d\n", ch, d+ph)
						continue CY //推定やり直し
					}
				}
			}
			debug("estimate center height:OK ch=%d\n", ch)

			//h=0の座標との確認
			if points, ok := pointMap[0]; ok {
				for _, p := range points {
					px := p[0]
					py := p[1]
					d := absInt(px-x) + absInt(py-y)
					if ch > d { //h=0の座標の定義から矛盾
						continue CY
					}
				}
			}

			//問題なし。
			cx = x
			cy = y
			break CX
		}
	}
	return []int{cx, cy, ch}
}

/**
 * １行に空白区切りで数字を読み込み
 */
func scanNums(len int) (nums []int) {
	nums = make([]int, len)
	for i := 0; i < len; i++ {
		fmt.Scan(&nums[i])
	}
	return
}

//** DEBUG **/
const DEBUG_ENABLE = false

func debug(format string, a ...interface{}) (n int, err error) {
	if DEBUG_ENABLE {
		return fmt.Fprintf(os.Stdout, format, a...)
	} else {
		return 0, nil
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define Rushia_mywife ios::sync_with_stdio(0);cin.tie(0);
#define rep(i,head,n) for(int i=(head);i<n;i++)
#define int long long
#define F first
#define S second
#define pb push_back
#define p2(n) (1<<(n))
#define lg2(n) __lg(n)
using namespace std;
using pii = pair<long long,long long>;
using ld = long double;
mt19937 mt_rand(time(0));
const int mod = 1000000007;
const int hnum = 998244353;
const ld PI = acos(-1);
const int N = 2e5+10;

int n,k;
int a[N];

void solve(){
    cin >> n >> k;
    rep(i,0,n)
        cin >> a[i];
    rep(i,k,n){
        if(a[i]>a[i-k])
            cout << "Yes\n";
        else  
            cout << "No\n";
    }
}

signed main(){
    Rushia_mywife
    solve();
}

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

typedef long long ll;
typedef long double ld;

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

    char c;
    cin >> c;
    if(c >= 'A' && c <= 'Z') cout << "A";
    else cout << "a";
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(void){
    int a,b;
    cin >> a >> b;
    bool flag = false;
    int k = (b+a)/2;
    if(k-a == b-k){
        flag = true;
    }else if(a-k == k-b){
        flag = true;
    }

    if(flag){
        cout << k << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

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

using namespace std;

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

map<int,int> mp;

void factor(int x) {
  for (int i = 2; i * i <= x; i++) {
    while (x % i == 0) {
      x /= i;
      mp[i]++;
    }
  }
  if (x > 1) mp[x]++;
}

int main() {
  int i,N;

  cin >> N;
  REP(i,N+1) factor(i);

  int four = 0, two = 0, fteen = 0, tfour = 0, sfour = 0;
  for (auto a : mp) {
    if (a.second >= 2) two++;
    if (a.second >= 4) four++;
    if (a.second >= 14) fteen++;
    if (a.second >= 24) tfour++;
    if (a.second >= 74) sfour++;
  }

  int w = ((four * (four - 1)) / 2) * (two - 2);
  int x = tfour * (two - 1);
  int y = fteen * (four - 1);
  int z = sfour;

  cout << (w + x + y + z) << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
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
#define VL V<LL>::iterator
#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 MAX 1e18
#define MIN -1e18
#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;
int main()
{
    LL n,m,i,j,k,p,q,o,l,s,t,z=0,r;
    DL a,b,c;
    cin>>n>>b>>c;
    DL x=1000000000000000000.00;
    k=1;
    for(i=0; i<n; i++)
    {
        cin>>a;
        if(abs(c-(b-(a*0.006)))<x)
        {
            x=abs(c-(b-(a*0.006)));
            k=i+1;
        }

    }
    cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 256
//
// Created by kuroneko on 2019-09-07.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;

#define INF 1000000000000009LL
#define MOD 1000000007LL

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight):src(src), dst(dst), weight(weight) {}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

int main() {
    std::cout << std::fixed;
    std::cout << std::setprecision(10);
    int N; cin >> N;
    vector<ll> v(N);
    ll mul = 1;
    for (int i = 0; i < N; i++) {
        cin >> v[i];
    }

    double low = 0;
    for (int i = 0; i < N; i++) {
        low += 1.0 / v[i];
    }
    cout << 1.0 / low << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
input1 = input().rstrip().split(" ")
sunuke = [0 for i in range(int(input1[0]))]
array = []
for i in range(int(input1[1])):
    okashi = input()
    okashisunuke = input().rstrip().split(" ")
    for i in range(int(okashi)):
        sunuke[int(okashisunuke[i])-1] += 1
print (sunuke.count(0))

Measured memory_bytes: 9140
import java.util.*;

/**
 * Main
 */
public class Main {
  Scanner sc;

  public static void main(String[] args) {
    (new Main()).run();
  }

  public void run() {
    this.sc = new Scanner(System.in);
    long n = sc.nextLong();
    long sq = (long) (Math.floor(Math.sqrt(n)));
    long one = sq;
    long pair = -1;
    for (; one > 0; one--) {
      if (n % one == 0) {
        pair = n / one;
        break;
      }
    }
    System.out.println(one + pair - 2);
  }
}

Measured memory_bytes: 21844
N, T = map(int, input().split())
TList = list(map(int, input().split()))

ans = T
whenFinish = T
for t in TList:
    if t >= whenFinish:
        ans += T
        whenFinish = t + T
    else:
        ans += T - (whenFinish - t)
        whenFinish = t + T

print(ans)

Measured memory_bytes: 85456
# input()
# int(input())
# map(int,input().split())
# list(map(int,input().split()))
# [input() for _ in range(n)]

n = int(input())
a = list(map(int,input().split()))

ans = 1
for i, v in enumerate(a):
  ans *= v
  if ans > 10**18:
    ans=-1
    break

if 0 in a:
  ans = 0

print(ans)


Measured memory_bytes: 21768
#include<bits/stdc++.h>
using namespace std;
int main()
{


    string st;
    cin>>st;
    int cont =0;
   char ch = st.at(0);
    for(int i=1;i<st.size();i++)
    {
        if(ch!=st.at(i))
        {
            cont++;
            ch = st.at(i);
        }

    }

    cout<<cont<<endl;


    return 0;
}



Measured memory_bytes: 512
n, m, x, y = map(int, input().split())
xl = list(map(int, input().split()))
yl = list(map(int, input().split()))
mx = max(xl) + 1
my = min(yl)
for i in range(x + 1, y + 1):
    if mx <= i <= my:
        print("No War")
        exit()
print("War")


Measured memory_bytes: 3060
def solve():
    n = int(input())
    a = list(int(x) for x in input().split())

    memo = [[None] * n for _ in range(n)]
    for i, aa in enumerate(a):
        memo[i][i] = aa

    for l in range(n - 2, -1, -1):
        for r in range(l + 1, n):
            memo[l][r] = max(a[r] - memo[l][r - 1], a[l] - memo[l + 1][r])

    print(memo[0][n - 1])


if __name__ == '__main__':
    solve()

# [l,r]を
# l:=配列aの右端から左にシフト
# r:=lと一致する位置からn-1まで右にシフト
# と考えると、l==rは既にメモ化済みなので、l=n-2以前、r=l+1以降を調べればよい
# 漸化式で使う値は、
# lがより右にいるときの計算結果（前のループで計算済み）と
# rがより左にいるときの計算結果（一番左でもl==rなので計算済み）
# なので、参照する値がNoneになることはなく、Noneのチェックは不要になる

# listにした


Measured memory_bytes: 179676