akhauriyash/Code-Regression huggingface dataset:
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, s, e) for(int i=s; i<e; i++)
#define REF(i, s, e) for(int i=s; i>e; i--)
typedef long long ll;
const ll INF = 1LL << 40;

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

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

	int n;
	cin >> n;

	vector<ll> a(n);
	FOR(i, 0, n) cin >> a[i];

	//dp[i][flip]: a[i-1]をflip(1:反転、0:反転しない)させたときのa(0 ~ i-1)の和の最大値
	vector<vector<ll>> dp(n+1, vector<ll>(2, -INF));
	dp[0][0] = 0;

	FOR(i, 0, n) {
		//a[i-1]の反転とa[i]の反転の組み合わせでa[i]の符号が決まる

		//a[i]を反転させない場合
		chmax(dp[i + 1][0], dp[i][0] + a[i]);
		chmax(dp[i + 1][0], dp[i][1] - a[i]);

		//a[i]を反転させる場合
		chmax(dp[i + 1][1], dp[i][0] - a[i]);
		chmax(dp[i + 1][1], dp[i][1] + a[i]);
	}
	
	//cout << "dp:" << endl;
	//FOR(i, 0, n+1) cout << dp[i][0] << "," << dp[i][1] << endl;
	//cout << endl;
    
    cout << dp[n][0] << endl;
}

Measured memory_bytes: 6528
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        for(int i=0; i<n; i++) {
            int[] it = new int[3];
            it[0] = scanner.nextInt();
            it[1] = scanner.nextInt();
            it[2] = scanner.nextInt();
            Arrays.sort(it);
            if(it[0]*it[0] + it[1]*it[1] == it[2]*it[2]) {
                System.out.println("YES");
            }else {
                System.out.println("NO");
            }
        }
    }
}

Measured memory_bytes: 34092
#include <iostream>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    int a[4], b[2];
    for(auto&& i : a){
        cin >> i;
    }
    for(auto&& j : b){
        cin >> j;
    }
    sort(rbegin(a), rend(a));
    sort(rbegin(b), rend(b));
    cout << accumulate(begin(a), begin(a) + 3, 0) + b[0] << "\n"; 
}


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

int main()
{
    int n;
    cin>>n;
    long long a[n],ans=0;
    for(int i=0; i<n; i++)
        cin>>a[i];
    for(int i=0; i<n; i++)
        for(int j=i+1; j<n; j++)
            ans+=a[i]*a[j];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
//setprecision(12)
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
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; }
typedef long long ll;
#define pint pair<int,int>
#define pll pair<ll,ll>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

ll a,b,n;
ll f(ll x) {
    return floor(a*x/b)-a*floor(x/b);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> a >> b >> n;
    ll ans = f(min(b-1,n)); 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
s=input()
n=len(s)

ans1=0
ans2=0
for i in range(n):
    #黒始まり
    if i%2==1 and s[i]=="0":
        ans1+=1
    elif i%2==0 and s[i]=="1":
        ans1+=1
    #白始まり
    if i%2==1 and s[i]=="1":
        ans2+=1
    elif i%2==0 and s[i]=="0":
        ans2+=1

print(min(ans1,ans2))

Measured memory_bytes: 3188
#include<stdio.h>

int main(void){
  int x,y;
  int a,i;
  int max,min;
  int result,flag;
  
  while(scanf("%d%d",&x,&y)!=EOF){
    flag=0;
    if(x>y){
      max=x;
      min=y;
    }
    else{
      max=y;
      min=x;
    }
    for(i=1;i<=max;i++){
      if(max%i==0){
	a=max/i;
	if(min%a==0){
	  result=a;
	  flag++;
	  break;
	}
	else{
	  if(a*min==max && i!=1){
	    if(a<min)
	      result=a;
	    else
	      result=min;
	    flag++;
	  }
	}
      }
    }
    if(flag==0)
      result=1;
    printf("%d\n",result);
  }
  return(0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    vl as(3);
    cin>>as;
    ll k;
    cin>>k;
    sort(rng(as));
    reverse(rng(as));
    rep(i, k) as[0] *= 2;
    cout<<as[0] + as[1] + as[2]<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
    int sx,sy,tx,ty;
    while(~scanf("%d%d%d%d",&sx,&sy,&tx,&ty)){
        printf("L");
        for(int i=0;i<ty-sy+1;i++){
            printf("U");
        }
        for(int i=0;i<tx-sx+1;i++){
            printf("R");
        }
        printf("DR");
        for(int i=0;i<ty-sy+1;i++){
            printf("D");
        }
        for(int i=0;i<tx-sx+1;i++){
            printf("L");
        }
        printf("U");
        for(int i=0;i<ty-sy;i++){
            printf("U");
        }
        for(int i=0;i<tx-sx;i++){
            printf("R");
        }
        for(int i=0;i<ty-sy;i++){
            printf("D");
        }
        for(int i=0;i<tx-sx;i++){
            printf("L");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}
int main(){
    int n,y; cin >> n >> y;
    
    for(int i=0 ; i<=n ;i++){
        for(int j=0 ; j<=n-i ; j++){
            int k= n-j-i;
            if(1000*i+5000*j+10000*k == y) {
                //cout << k << " " << j << " " << i << endl;
                printf("%d %d %d\n",k,j,i);
                return 0;
            }
            
        }
    }
    //cout << -1 << " " << -1  << " " << -1 << endl;
    printf("%d %d %d\n",-1,-1,-1);
    return 0;
}






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


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; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
#define MP make_pair
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;

const int MAX=1e5+10;

int main(){
    //エラトステネスのふるいにより，それぞれ素数かどうかを求める
    vector<int> isPrime(MAX,1);
    isPrime[0]=0; isPrime[1]=0;
    for(int i=2; i<MAX; i++){
        if(isPrime[i]){
            for(int j=i*2; j<MAX; j+=i) isPrime[j]=0;
        }
    }

    //2017like?
    vector<int> a(MAX);
    for(int i=0; i<MAX; i++){
        if(i%2==0) continue;
        if(isPrime[i]&&isPrime[(i+1)/2]) a[i]=1;
    }

    vector<int> s(MAX+1,0);
    rep(i,MAX) s[i+1]=s[i]+a[i];

    int q; cin >> q;
    rep(i,q){
        int l,r; cin >> l >> r;
        cout<<s[r+1]-s[l]<<endl;
    }



}

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

int factorial(int n){
    if(n > 0){
        return n * factorial(n - 1);
    }
    else{
        return 1;
    }
}

int main(){
    int n;
    cin >> n;
    vector<int> A(n), X(n), Y(n);
    int a = 0;
    double sum = 0.0;
    for(int i = 0; i < n; i++){
        A[i] = i;
    }
    for(int i = 0; i < n; i++){
        cin >> X[i] >> Y[i];
    }
    //nextPermutation
    do{
        for(int i = 0; i < n - 1; i++){
            double dx = X[A[i]] - X[A[i + 1]];
            double dy = Y[A[i]] - Y[A[i + 1]];
            sum += sqrt(dx * dx + dy * dy);
            //cout << fixed << setprecision(10) << sum << endl;
        }
        a++;
    }while(next_permutation(A.begin(), A.end()));
    //cout << sum << " " << a << endl;
    double ans;
    ans = double(sum / a);
    cout << fixed << setprecision(10) << ans << endl;
    return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  	int N;
  	cin >> N;
    int p[N];

    for(int i=0;i<N;i++){
      cin >> p[i];
    }
    int check = 0;
    for(int i=0;i<N;i++){
      if(p[i]!=i+1) check++;
    }
    if(check>=3){
      cout << "NO" <<endl;
      return 0;
    }
    cout << "YES" <<endl;
 

  	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>

typedef long long int ll;


using namespace std;

int h,m,s;

int main(){
	while(1){
		cin>>h>>m>>s;
		if(h==-1&&m==-1&&s==-1)break;
		s=s+m*60+h*3600;
		s=120*60-s;
		h=s/3600;
		s%=3600;
		m=s/60;
		s%=60;
		printf("%02d:%02d:%02d\n",h,m,s);
		s=s+m*60+h*3600;
		s*=3;
		h=s/3600;
		s%=3600;
		m=s/60;
		s%=60;
		printf("%02d:%02d:%02d\n",h,m,s);
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
const int MAX = 100005;
vector<vector<pp>> graph(3*MAX,vector<pp>(0));
int n = MAX,s,t;

ll dijkstra(ll goal){
  priority_queue<pp,vector<pp>,greater<pp>> pq;
  pq.push(make_pair(0,s));
  vector<int> visited(3*n,0);
  while (!pq.empty()){
    auto now = pq.top();
    pq.pop();
    ll cost,node;
    tie(cost,node) = now;
    if(node == goal){
      return cost/3 ;
    }
    if(visited.at(node)==1){
      continue;
    }else{
      visited.at(node) = 1;
      for(auto next:graph.at(node)){
        ll next_cost,next_node;
        tie(next_cost,next_node) = next;
        pq.push(make_pair(cost+next_cost,next_node));
      }
    }
  }
  return -1;
} 
int main() {
  int n,m ;
  cin >> n >> m;
  rep(i,m){
    int v,u;
    cin >> v >> u;
    --v; --u;
    graph.at(v).push_back(make_pair(1,u+n));
    graph.at(v+n).push_back(make_pair(1,u+2*n));
    graph.at(v+2*n).push_back(make_pair(1,u));
  }
  cin >> s >> t;
  --s; --t;
  
  ll ans = dijkstra(t);
  if(ans == -1) cout << -1 << endl;
  else cout << ans << endl;
}
  
  
 

Measured memory_bytes: 17792
n = int(input())
A = []
maximum = 0
maximum_idx = 0
for i in range(n):
    a = int(input())
    A.append(a)
    if a > maximum:
        maximum = a
        maximum_idx = i

for i in range(n):
    if i != maximum_idx:
        print(maximum)
    else:
        print(sorted(A)[-2])


Measured memory_bytes: 68924
import java.util.*;
 
class Main{
    public static void main(String args[]){
        Scanner s=new Scanner (System.in);
        String now=s.nextLine();
        char ans[]=now.toCharArray();
        for(int i=0;i<now.length()-4;i++){
            if(now.substring(i,i+5).equals("apple")){
                ans[i]='p';
                ans[i+1]='e';
                ans[i+2]='a';
                ans[i+3]='c';
                ans[i+4]='h';
            }else if(now.substring(i,i+5).equals("peach")){
                ans[i]='a';
                ans[i+1]='p';
                ans[i+2]='p';
                ans[i+3]='l';
                ans[i+4]='e';
            }
        }
        System.out.println(new String(ans));
    }
}


Measured memory_bytes: 25896
import heapq

def main():

    INF = 1000000009
    n = int(input())
    e = [[] for _ in range(n)]
    for i in range(n):
        inf = list(map(int,input().split()))
        for j in range(n):
            if inf[j]!=-1:e[i].append([j,inf[j]])

    dp = [INF]*n
    finished = [False]*n
    dp[0] = 0
    pq = [[0,0]]
    heapq.heapify(pq)
    while pq:
        cost,v = heapq.heappop(pq)
        if dp[v]<cost:continue
        finished[v] = True
        for i in range(len(e[v])):
            u = e[v][i][0]
            ncost = e[v][i][1]
            if ncost < dp[u] and not finished[u]:
                dp[u] = ncost
                heapq.heappush(pq,[ncost,u])
    res = 0
    for i in range(n):res+=dp[i]
    print(res)


if __name__ == '__main__':
    main()




Measured memory_bytes: 6356
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define ifaxb(a, x, b) if (a < x && x < b)
#define toInt(x) (x - '0')
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define vvs vector<vs>
#define all(x) x.begin(), x.end()
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int C = 1; C <= N; C += 2) {
    int div = 0;
    for (int X = 1; X <= C; ++X) {
      if (C % X == 0) {
        div++;
      }
    }
    if (div == 8) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return (y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int n) {
	if (n == 0)return 1;
	return kai(n - 1)*n;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int n, a[100005], b[100005],aa[100005],bb[100005],cnt[200005],ans;
vector<pair<int, pair<int, int>>>vec;
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		vec.push_back({ a[i],{i,0} });
		vec.push_back({ b[i],{i,1} });
	}
	sort(vec.begin(), vec.end());
	int j = 0;
	for (int i = 0; i < vec.size(); i++) {
		if (i) {
			if (vec[i].first != vec[i - 1].first)j++;
		}
		if (vec[i].second.second == 0)aa[vec[i].second.first] = j;
		else bb[vec[i].second.first] = j;
	}
	for (int i = 0; i < n; i++) {
		cnt[aa[i]]++;
		cnt[bb[i] + 1]--;
	}
	ans = cnt[0];
	for (int i = 1; i < 2 * n; i++) {
		cnt[i] = cnt[i - 1] + cnt[i];
		ans = max(ans, cnt[i]);
	}
	cout << ans << endl;
	endre;
}


Measured memory_bytes: 12216
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		int N=sc.nextInt();
		long INF=Long.MAX_VALUE/3;
		long umin=+INF;
		long vmin=+INF;
		long umax=-INF;
		long vmax=-INF;
		for (int i=0;i<N;++i) {
			long x=sc.nextLong();
			long y=sc.nextLong();
			umin=Math.min(umin, x+y);
			umax=Math.max(umax, x+y);
			vmin=Math.min(vmin, x-y);
			vmax=Math.max(vmax, x-y);
		}
		long ans=Math.max(umax-umin, vmax-vmin);
		System.out.println(ans);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}

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

using namespace std;
typedef long long ll;
const int MAXN = 1000100;

int N;
int arr[MAXN];
int pprev[MAXN];
vector <int> nnext[MAXN];
int res[MAXN];

bool spec[MAXN];
set <int> s[MAXN];

int gmex (int i, int opt)
{
    int ans = 0;
    while (ans == opt || s[i].find(ans) != s[i].end())
        ans++;
    return ans;
}

void flood (int cloc)
{
    for (int neigh : nnext[cloc])
        if (!spec[neigh])
        {
            flood (neigh);
            s[cloc].insert(res[neigh]);
        }
    res[cloc] = 0;
    while (s[cloc].find(res[cloc]) != s[cloc].end())
        res[cloc]++;
}

bool gogo (int cloc)
{
    int cr = res[cloc];
    int cstart = cloc;
    do
    {
        int cprev = pprev[cloc];
        res[cprev] = gmex (cprev, res[cloc]);
        cloc = cprev;
    } while (cloc != cstart);
    return cr == res[cstart];
}

int main()
{
    ios_base::sync_with_stdio(0);

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

    int cloc = 0;
    for (int i = 0; i < N; i++)
        cloc = pprev[cloc];

    while (!spec[cloc])
    {
        spec[cloc] = true;
        cloc = pprev[cloc];
    }

    for (int i = 0; i < N; i++)
        if (spec[i]) flood (i);

    int clo = res[cloc];
    if (gogo (cloc))
    {
        cout << "POSSIBLE\n";
        return 0;
    }
    res[cloc] = gmex (cloc, clo);
    if (gogo (cloc))
    {
        cout << "POSSIBLE\n";
        return 0;
    }
    cout << "IMPOSSIBLE\n";
}

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

using namespace std;

int main(void) {
	int N,M;
	while (cin >> N >> M,N,M) {
		int res = -1;
		vector<int> data(N);
		for (int i = 0; i < N; ++i) {
			cin >> data[i];
		}
		for (int i = 0; i < N-1; ++i) {
			for (int j = i+1; j < N; ++j) {
				if (data[i]+data[j] <= M) {
					res = max(data[i]+data[j],res);
				}
			}
		}
		if (res < 0) {
			cout << "NONE" << endl;
		}
		else {
			cout << res << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 3124
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(int argc, char const *argv[]) {
  int n, res = 0, b;
  cin >> n;
  vector<int> a(n), c(n - 1);

  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b;
    res += b;
  }
  for (int i = 0; i < n - 1; i++) {
    cin >> c[i];
  }
  for (int i = 1; i < n; i++)
  {
    if(a[i-1]==a[i]-1){
      res += c[a[i - 1]-1];
    }
  }
  cout << res;

  return 0;
}


Measured memory_bytes: 256
//break_the_bond
//jatt_james_bond
#include <bits/stdc++.h>
#define int long long
// #define endl "\n"
using namespace std;
#define MAX 300009
#define IOS std::ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
bool comp(pair<int, int> &a, pair<int, int> &b)
{
    return a.first < b.first;
}

void solve()
{
    int n;
    cin >> n;
    if (n == 0){
        cout << 1;
    }else
    {
        cout << 0;
    }
}

int32_t main()
{
    IOS int testcases = 1;
    // cin >> testcases;
    while (testcases--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3608
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n,m,c=nii()
b=lnii()

cnt=0
for i in range(n):
  p=0
  a=lnii()
  for j in range(m):
    p+=a[j]*b[j]
  p+=c
  if p>0:
    cnt+=1

print(cnt)

Measured memory_bytes: 9036
#include <bits/stdc++.h>
using namespace std;
 
#define fst() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define f(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef long double ld;
const int MAXN=100005;

int a[100005];
int main()
{ 
	/*#ifndef ONLINE_JUDGE
  freopen("output.txt","w",stdout);
  freopen("input.txt","r",stdin);
  #endif */
  fst();
  int n,i,cost=0;
  cin>>n;
  f(i,1,n+1) cin>>a[i];
  a[0]=a[n+1]=0;
  f(i,1,n+2) cost+=abs(a[i]-a[i-1]);
  f(i,1,n+1)
  {
  	cout<<cost-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1])<<endl;
  } 
  return 0;
}

Measured memory_bytes: 1664
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}


int main(){
	FIO
	
	int n;
	cin >> n;
	int a[n], ans = 0;
	for(int i = 0; i < n; i++)cin >> a[i];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n - 1; j++){
			if(a[j] > a[j + 1]){
				swap(a[j], a[j + 1]);
				ans++;
			}
		}
	}
	cout << a[0];
	for(int i = 1; i < n; i++)cout << ' ' << a[i];
	cout << '\n' << ans << '\n'; 
	return 0;
}



Measured memory_bytes: 3164
import java.util.*;
class Main{
	public static void main(String[] args){
		Scanner s=new Scanner(System.in);
		int a=s.nextInt();
		int b=s.nextInt();
		int p[][]=new int[b][a/2];
		for(int i=0;i<b;i++){
			for(int j=0;j<a/2;j++)p[i][j]=s.nextInt();
		}
		while(true){
			int al[]=new int[a];
			for(int i=0;i<a;i++)al[i]=(int)(Math.random()*2);
			boolean chad=false;
			for(int i=0;i<b;i++){
				int roy=0;
				for(int j=0;j<a/2;j++)roy+=al[p[i][j]-1];
				if(a/8<=roy&&a/8*3>=roy);
				else chad=true;
			}
			if(!chad){
				for(int i=0;i<a;i++)System.out.print(al[i]);
				System.out.println();
				System.exit(0);
			}
		}
	}
}

Measured memory_bytes: 0
//Om Sree Sai Ram
#include "bits/stdc++.h"
using namespace std;

template <typename T> void max_self(T& a,T b)
{
  a = max(a,b);
}

const int nax = 305;
double p[nax][nax][nax], ex[nax][nax][nax];


int main() 
{


   //Didnot understand fully, just replicated errichto's code
int n;
cin>>n;
vector<int> ar(4);
for(int i=0;i<n;i++)
{
  int dat;
  cin>>dat;
  ar[dat]++;
}
//cout<<ar[1]<<" "<<ar[2]<<" "<<ar[3]<<endl;

// for(int i=0;i<=n;i++)
// {
//   for(int j=0;j<=n;j++)
//   {
//     for(int k=0;k<=n;k++)
//     {
//       p[k][j][i] = 0;
//       ex[k][j][i] = 0;
//     }
//   }
// }
//p[a][b][c] represents probability of reaching the state a,b,c
// a represents being cout of number of ones, twos an threes respectively
//ex[a][b][c] represents expectation of number of turns required to reach the state a,b,c.
p[ar[1]][ar[2]][ar[3]] = 1;
//ex[ar[1]][ar[2]][ar[3]] = 0;

//cout<<" check "<<endl;
//loop fromt n to 0 for each number because in between b,a can be greater then ar[2],ar[1]
for(int c=n;c>=0;c--)
{
  for(int b=n;b>=0;b--)
  {
    for(int a= n;a>=0;a--)
    {
      //cout<<" a = "<<a<<" b = "<<b<<" c = "<<c<<endl;
      double p_waste = double(n-(a+b+c))/(n);
      //extra expection contributed from this state
      //he applied gp formula for counting the expected number of steps that are wasted.Dont know about the +1 also. Should think about it later.
      double exp_waste = p_waste/(1-p_waste) +1;

      if(a+b+c>n)
      {
        continue;
      }
      if(a==0 && b==0 && c==0)
      {
        continue;
      }
      double curr_prob = p[a][b][c];
      //probablity of going to the next state
      double prob_go;
      ex[a][b][c] += curr_prob*exp_waste;
      if(c>=1)
      {
      prob_go = (double)c/(a+b+c);
      p[a][b+1][c-1] += curr_prob*prob_go;
      ex[a][b+1][c-1] +=  ex[a][b][c]*prob_go;
      }

      if(b>=1)
      {
        prob_go = (double)b/(a+b+c);
        p[a+1][b-1][c] += p[a][b][c]*prob_go;
        ex[a+1][b-1][c] += ex[a][b][c]*prob_go;
      }

      if(a>=1)
      {
        prob_go = (double)a/(a+b+c);
        p[a-1][b][c] += p[a][b][c]*prob_go;
        ex[a-1][b][c] += ex[a][b][c]*prob_go;
      }

    }
  }
}
cout.precision(10);
cout<<ex[0][0][0]<<endl;
//cout<<p[0][0][0]<<endl;

}


Measured memory_bytes: 438528
function Main(s) {
  s = s.split("\n");
  var x = s[1].split(" ").map(a => +a);
  const n = +s[0];
  var y = [...x].sort((a,b)=> a-b);
  var a = y[n/2-1], b = y[n/2];
  for(var i = 0; i < n; i++){
    console.log(x[i] <= a ? b : a);
  }
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 59096
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Roller Coaster
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n, k;
  scanf("%d%d", &n, &k);

  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int hi;
    scanf("%d", &hi);
    if (hi >= k) cnt++;
  }

  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

int main(){
  int N, D;
  cin >> N >> D;
  int d = D*2+1;
  cout << (N+d-1)/d << endl;
}

Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;


void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto uf = new UnionFind(N);
    auto edges = new int[][](N);
    foreach (i; 0..M) {
        s = readln.split.map!(to!int);
        uf.unite(s[0]-1, s[1]-1);
        edges[s[0]-1] ~= s[1]-1;
        edges[s[1]-1] ~= s[0]-1;
    }

    long g1, g2, g3;
    foreach (i; 0..N) {
        if (uf.find(i) == uf.find(0)) {
            g1 += edges[i].length.to!int;
        } else if (uf.find(i) == uf.find(1)) {
            g2 += edges[i].length.to!int;
        } else {
            g3 += edges[i].length.to!int;
        }
    }
    g1 /= 2;
    g2 /= 2;
    g3 /= 2;

    long s1 = -uf.table[uf.find(0)];
    long s2 = -uf.table[uf.find(1)];
    long s3 = N - s1 - s2;

    if (s1 < s2) {
        swap(s1, s2);
        swap(g1, g2);
    }

    long hoge = s1 + s3;
    long ans = hoge * (hoge-1) / 2 - g1 - g3 + s2 * (s2-1) / 2 - g2;
    ans.writeln;
}

class UnionFind {
    int N;
    int[] table;

    this(int n) {
        N = n;
        table = new int[](N);
        fill(table, -1);
    }

    int find(int x) {
        return table[x] < 0 ? x : (table[x] = find(table[x]));
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (table[x] > table[y]) swap(x, y);
        table[x] += table[y];
        table[y] = x;
    }
}


Measured memory_bytes: 12412
from collections import defaultdict
MAX = 3652425
n, q = map(int, input().split())
lst = [tuple(map(int, input().split())) for _ in range(n)]
restor = [0] * (MAX + 10010)
t0s = [0] * (MAX + 10010)
t1s = [0] * (MAX + 10010)
t2s = [0] * (MAX + 10010)
t3s = [0] * (MAX + 10010)
t1_cnt_save = defaultdict(int)
t3_cnt_save = defaultdict(int)
t1_cnt = 0
t3_cnt = 0
index = 0
for i, line in enumerate(lst):
  w, t ,x = line
  while index < MAX and w > restor[index]:
    t0s[index + 1] += t0s[index]
    t1_cnt -= t1_cnt_save[index + 1]
    t1s[index + 1] += t1s[index] + t1_cnt
    t3_cnt -= t3_cnt_save[index + 1]
    t3s[index + 1] += t3s[index] + 2 * t3_cnt
    t2s[index + 1] += t2s[index] + t3s[index + 1]
    restor[index + 1] = restor[index] + 1 + t0s[index] + t1s[index] + t2s[index]
    index += 1
  if w <= restor[index]:
    print(index)
    if t == 0:
      t0s[index] += 1
      t0s[index + x] -= 1
    elif t == 1:
      t1_cnt += 1
      t1_cnt_save[index + x] += 1
      t1s[index] += 1
      t1s[index + x] -= x
    elif t == 2:
      t3_cnt += 1
      t3_cnt_save[index + x] += 1
      t3s[index] += 1
      t3s[index + x] -= x * 2 - 1
      t2s[index] += 1
      t2s[index + x] -= x ** 2
  else:print("Many years later")

for _ in range(q):
  y = int(input())
  while index < y:
    t0s[index + 1] += t0s[index]
    t1_cnt -= t1_cnt_save[index + 1]
    t1s[index + 1] += t1s[index] + t1_cnt
    t3_cnt -= t3_cnt_save[index + 1]
    t3s[index + 1] += t3s[index] + 2 * t3_cnt
    t2s[index + 1] += t2s[index] + t3s[index + 1]
    restor[index + 1] = restor[index] + 1 + t0s[index] + t1s[index] + t2s[index]
    index += 1
  print(restor[y])



Measured memory_bytes: 868088
#include<bits/stdc++.h>
using namespace std;
int n;
const int N=100005;
int a[N],f[N],ans=1;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    f[1]=0;
    for(int i=2;i<=n;i++){
        if(f[i-1]==1){
            if(a[i-1]>a[i]) f[i]=0,ans++;
            else f[i]=1;
        }
        else if(f[i-1]==2){
            if(a[i-1]<a[i]) f[i]=0,ans++; 
            else f[i]=2;
        }
        else{
            if(a[i-1]>a[i]) f[i]=2;
            else if(a[i-1]<a[i]) f[i]=1;
            else f[i]=0;
        }
    }
    printf("%d\n",ans);
}

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

int main(){
    int n; cin >> n;
    vector<int> d(n);
    for(int i = 0; i < n; i++) cin >> d[i];
    sort(d.begin(), d.end());
    cout << d[n/2] - d[n/2 -1] << endl;
    return 0;
}


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

int main() {
  int S;
  cin >> S;
  
  // まず、下二桁を調べる
  if (S % 100 >= 1 && S % 100 <= 12) {
    // MMの場合
    if (S / 100 >= 1 && S / 100 <= 12) {
      cout << "AMBIGUOUS" << endl;
    } else {
      cout << "YYMM" << endl;
    }
  } else {
    // YYの場合
    if (S / 100 >= 1 && S / 100 <= 12) {
      cout << "MMYY" << endl;
    } else {
      cout << "NA" << endl;
    }
  }
}

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

int main() {
    ll h,w,k;
    std::cin >> h>>w>>k;
    
    vector<string> c(h);
    for (int i = 0; i < h; i++) {
        std::cin >> c[i];
    }
    ll ans = 0;
    for (int i = 0; i < (1<<h); i++) {
        for (int j = 0; j < (1<<w); j++) {
            ll cnt = 0;
            for (int ii = 0; ii < h; ii++) {
                for (int jj = 0; jj < w; jj++) {
                    if(i&(1<<ii))continue;
                    if(j&(1<<jj))continue;
                    if(c[ii][jj]=='#')cnt++;
                }
            }
            if(cnt==k)ans++;
        }
    }
    
    std::cout << ans << std::endl;
}

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

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll res;
    if((b-a)%2 == 0){
        res = (b-a)/2; 
    }
    else{
        res = min(a-1,n-b) + 1 + (b-a-1)/2;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
const int mo=1e9+7;
const int maxn=1e6+10;
int n,st[maxn],nt[maxn],to[maxn],si[maxn],topt;
long long pp[maxn],inv[maxn],dp[maxn],ans[maxn];
inline void add(int x,int y){to[++topt]=y; nt[topt]=st[x]; st[x]=topt;}
long long po(long long a,long long b)
{
	if (!b) return 1;
	if (b==1) return a;
	long long c=po(a,b/2);
	if (b&1) return c*c%mo*a%mo;else return c*c%mo;
}
void dfs1(int x,int fa)
{
	dp[x]=1; si[x]=1; int p=st[x];
	while (p)
	{
		if (to[p]!=fa) {dfs1(to[p],x); si[x]+=si[to[p]]; dp[x]=dp[x]*dp[to[p]]%mo*inv[si[to[p]]]%mo;}
		p=nt[p];
	}
	dp[x]=dp[x]*pp[si[x]-1]%mo;
}
void dfs2(int x,int fa,long long now)
{
	ans[x]=dp[x]*inv[si[x]-1]%mo*now%mo*inv[n-si[x]]%mo*pp[n-1]%mo;
	int p=st[x];
	while (p)
	{
		if (to[p]!=fa) 
		{
			dfs2(to[p],x,ans[x]*inv[n-1]%mo*po(dp[to[p]],mo-2)%mo*pp[si[to[p]]]%mo*pp[n-si[to[p]]-1]%mo);
		}
		p=nt[p];
	}
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<n;i++) {int x,y; scanf("%d%d",&x,&y); add(x,y); add(y,x);}
	pp[0]=1; for (int i=1;i<=n;i++) pp[i]=pp[i-1]*i%mo;
	inv[n]=po(pp[n],mo-2); for (int i=n-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mo;
	dfs1(1,0); dfs2(1,0,1);
	for (int i=1;i<=n;i++) printf("%lld\n",ans[i]);
return 0;
}

Measured memory_bytes: 26368
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,c,d;
  cin>>a>>b>>c>>d;
  long long m_1=a*c,m_2=a*d,m_3=b*c,m_4=b*d;
  cout<<max({m_1,m_2,m_3,m_4})<<endl;
}

Measured memory_bytes: 3628
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
L=get_i.sort
#N=10**3
#L=(0..10**3-1).to_a.sort{|x,y| y<=>x}
ans=0
1.upto(N-1) do|i|
    a=L[i]
    k=i+1
    num=0
    i.times do|j|
        b=L[j]
        while k<N
            if L[k]<a+b
                num+=1
            else
                break
            end
            k+=1
        end
        ans+=num
    end
end
puts ans

Measured memory_bytes: 3960
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <vector>
#include <list>
using namespace std;
#include <stdio.h>
#include <map> 
#include <algorithm>
#include <functional>
#include <algorithm>
#include <functional>
#include <array>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#include <cstdio>
#include <cinttypes>


int main()
{
	int K;
	cin >> K;
	std::vector<long int> table;
	long int d = 0;
	std::list<int> aaaa;

	int r = 0;
	while (1) {

		r++;
		d = d * 10 + 7;
		d %= K;

		if (d == 0) {
			printf("%d\n", r);
			break;
		}

		table.resize(std::max((long int)table.size(), d+1));

		if (table[d]) {
			printf("-1\n");
			break;
		}
		table[d] = 1;
	}



	return 0;
}



Measured memory_bytes: 16112
package main

import (
	"fmt"
	"sort"
)

type blue struct {
	x, y int
}
type blues []blue

func (vs blues) Len() int {
	return len(vs)
}
func (vs blues) Swap(i, j int) {
	vs[i], vs[j] = vs[j], vs[i]
}
func (vs blues) Less(i, j int) bool {
	return vs[i].x < vs[j].x
}

type red struct {
	x, y int
}
type reds []red

func (vs reds) Len() int {
	return len(vs)
}
func (vs reds) Swap(i, j int) {
	vs[i], vs[j] = vs[j], vs[i]
}
func (vs reds) Less(i, j int) bool {
	return vs[i].y < vs[j].y
}

func main() {
	var n int
	fmt.Scan(&n)
	rs := make(reds, n)
	bs := make(blues, n)
	for i := range rs {
		fmt.Scan(&rs[i].x, &rs[i].y)
	}
	for i := range bs {
		fmt.Scan(&bs[i].x, &bs[i].y)
	}

	sort.Sort(sort.Reverse(rs))
	sort.Sort(bs)

	cnt := 0
	used := make([]bool, n)
	for _, b := range bs {
		for i, r := range rs {
			if b.x > r.x && b.y > r.y && !used[i] {
				cnt++
				used[i] = true
				break
			}
		}
	}

	fmt.Println(cnt)
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void){
    int a, b;
    
    scanf("%d %d",&a, &b);
    
    if(a > b)
        printf("a > b\n");
    else if(a < b)
        printf("a < b\n");
    else
        printf("a == b\n");
    
    return 0;
}

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

int main(){
  long long a, b, x;
  cin >> a >> b >> x;
  if(a==0)cout << b/x+1<<endl;
  else cout << b/x-(a-1)/x <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;

int ans[101][10];

int pow(int a,int n){
	if(n <= 0){
		return 1;
	}
	return a * pow(a,n - 1);
}

int main(){
	int m;
	int flug = 0;
	while(scanf("%d",&m) != EOF){
		flug = 0;
		for(int j = 0; j < 10; j++){
			

			if((m / pow(2,j)) % 2 == 1){
				if(flug){
				printf(" ");
			}
				printf("%d",pow(2,j));
				flug = 1;
			}
		}
		printf("\n");
	}
	
	///////////////////////////////////
	//Sleep(200000);///////////////////// 提出するときは必ず外す！
	///////////////////////////////////
	return 0;

}

Measured memory_bytes: 1028
#include <iostream>
#include<string>
#include <stdio.h>

using namespace std;

int main(void){

    int y, m, d;
    scanf("%4d/%2d/%2d", &y, &m, &d);
    if(m <= 4){
        cout << "Heisei";
    }else{
        cout << "TBD";
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define endl '\n'
#define y1 holyshit
const int inf=0x3f3f3f3f;

int N,M;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>N>>M;
    cout<<(N*(N-1))/2+M*(M-1)/2;
    return 0;
}

Measured memory_bytes: 256
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

N = II()
H = ILI()
max = 0
cnt = 0
for i in range(N-1):
    if H[i] >= H[i+1]:
        cnt += 1
        if max < cnt:
            max = cnt
    else:
        if max < cnt:
            max = cnt
        cnt = 0
print(max)

Measured memory_bytes: 14480
#include<stdio.h>
int main(){
  int a,b;
  int c[5];
  int ans=0;
  scanf("%d",&a);
  scanf("%d",&b);
  for(int i=a;i<=b;i++){
    c[0]=i/10000;
    c[1]=(i-(c[0]*10000))/1000;
    c[2]=(i-(c[0]*10000)-(c[1]*1000))/100;
    c[3]=(i-(c[0]*10000)-(c[1]*1000)-(c[2]*100))/10;
    c[4]=(i-(c[0]*10000)-(c[1]*1000)-(c[2]*100)-(c[3]*10))/1;
    if(c[0] == c[4] && c[1] == c[3]){
      ans++;
    }
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

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

	int N;
	cin >> N;

	string ans = "APPROVED";
	for( int i = 0; i < N; ++i ) {
		int a;
		cin >> a;

		if( a%2 == 0 && !(a%3 == 0 || a%5 == 0) ) {
			ans = "DENIED";
			break;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=(1ull<<63)-1;
const int inf=(1ull<<31)-1;
ld n;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>n;
	cout<<(ld)(floor((n+1)/2))/n;
	return 0;
}

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

int n, k, p[101];
int dp[102][4][10]; //(1)日目,その日のパスタは(2),(3)日連続

int rec(int x, int y, int z){
	if(dp[x][y][z]>=0) return dp[x][y][z];
	
	int ret=0;
	
	if(z>=2) ret=0;
	else if(x==n+1) ret=1;	
	else{
		if(p[x]==0){ //その日のパスタは未定
			for(int i=1; i<=3; ++i){
				if(i==y) ret+=rec(x+1, i, z+1);
				else ret+=rec(x+1, i, 0);
					
			}
		}	
		else{
			if(y==p[x]) ret+=rec(x+1, p[x], z+1);
			else ret+=rec(x+1, p[x], 0);
		}
	}
	
	return dp[x][y][z]=ret%10000;
}

int main(){
	scanf(" %d %d", &n, &k);
	
	memset(p, 0, sizeof(p)); //初期化
	
	for(int i=0; i<k; ++i){
		int a, b;
		scanf(" %d %d", &a, &b);	
		p[a]=b; //a日目のpastaはb
	}
	
	memset(dp, -1, sizeof(dp));
	printf("%d\n", rec(1, 0, 0));
}

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

int main()
{
	int n;
	cin >> n;
	bool flg = false;
	int i;
	for(i = 1; i< 450;i++) {
		if(n*2 == i*(i+1)) {
			flg = true;
			break;
		}
	}
	if(!flg) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl << i+1 << endl;
	
	vector<int> ch(i*(i+1));
	for(int k = 0; k < i + 1; k++) {
		string s = to_string(i) + " ";
		if(k == 0) {
			for(int j = 1; j <= i; j++) {
				s += to_string(j) + " ";
				ch[j-1] = j;
			}
		} else {
			ch[k * i + 0] = k;
			int idx = 1;
			s += to_string(k) + " ";
			for(int l = 1; l <= k-1; l++) {
				s += to_string(ch[l*i + k-1]) + " ";
				ch[k * i + idx] = ch[l*i+ k-1];
				idx++;
			}
			int t = ch[(k-1)*i+i-1];
		
			for(; idx < i; idx++) {
				ch[k * i + idx] = ++t;
				s += to_string(ch[k * i + idx]) + " ";
			}
		}
		cout << s << endl;
	}
	
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if(N % 2 == 0){
  	cout << (N - 2) / 2 << endl;
  }else{
  	cout << (N - 1) / 2 << endl;
  }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

//素数判定
bool isPrime(int n) {
	if (n == 2)return true;
	if (n < 2 || n % 2 == 0)return false;

	for (int i = 3; i*i <= n; i += 2) {
		if (n%i == 0)return false;
	}
	return true;
}

int solve(int n) {
	int ans = 0, num = 0;
	for (int i = 2; num != n; i++) {
		if (isPrime(i)) {
			ans += i;
			num++;
		}
	}
	return ans;
}

int main() {
	while (true) {
		int n; cin >> n;
		if (n == 0)break;

		Cout(solve(n));
	}
}


Measured memory_bytes: 2980
class Problem
  MOD = 10007
  MAX = 10 ** 12
  attr_reader :a, :b, :c, :d, :memo, :cost

  def initialize(a, b, c, d)
    @a = a; @b = b; @c = c; @d = d
    @memo = { 0 => 0, 1 => @d }
    @cost = { 2 => @a, 3 => @b, 5 => @c}
  end

  def solve(n)
    return memo[n] if memo[n]
    mini = MAX
    candidates(n) do |to, cost|
      now = solve(to) + cost
      mini = now if now < mini
    end
    memo[n] = mini
  end

  def candidates(n)
    yield [0, d * n]
    [2, 3, 5].each do |i|
      j = cost[i]
      if i <= n
        yield [n / i, j + d * (n % i)]
      end

      if n % i != 0
        yield [(n + i - 1) / i, j + d * (i - n % i)]
      end
    end
  end
end

t = gets.to_i
t.times do
  n, a, b, c, d = gets.split.map(&:to_i)
  pr = Problem.new(a, b, c, d)
  puts pr.solve(n)
end


Measured memory_bytes: 17760
S = input()
for i in range(1,len(S)) :
    if S[i] == S[i-1] :
        print(i,i+1)
        break
    elif i >= 2 and S[i] == S[i-2] :
        print(i-1, i+1)
        break
else :
    print(-1,-1)


Measured memory_bytes: 3188
import numpy as np

N = int(input())
XY =  np.array([list(map(int,input().split())) for _ in [0]*N])

ans = 0
for m in range(1000):
    th = 2*np.pi*m/1000
    r = np.array([np.cos(th),np.sin(th)])
    check = XY.dot(r)>=0
    ans = max(ans,np.linalg.norm(np.sum(XY[check],axis=0)))
print(ans)

Measured memory_bytes: 16476
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), det = 100000;
		int rishi;
		for(int i = 0; i < n; i++){
			rishi = (det/100) * 5;
			if(rishi%1000 == 0){
				rishi /= 1000;
			} else {
				rishi = (rishi/1000) +1;
			}
			rishi *= 1000;
			det += rishi;
		}
		System.out.println(det);	
	}
}

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

int main() {
 int n,ans;cin >>n;
  int maxcnt=0;
  for(int i=1;i<=n;i++){
    int cnt=0;
    int a=i;
   while(a%2==0){
    a=a/2;
    cnt++;
   }
   if(cnt>=maxcnt){
     maxcnt=cnt;
     ans=i;
   }


 }

  cout << ans << endl;
}

Measured memory_bytes: 256