akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

/*
,,,,
　　　　　　　　　　　　　　　　　　　　　　　　　　,.斗*''“i:i:{
　　　　　　　　　　　　　,.　｡. . . * : : : ''' : : : :” :”“ ''ｰ - 弋,,_
　　　　　 　 　 ,.斗*''“ : : : : : : : : : : : : : ' ' ' ' ' ' : : : : : : : : : : :”: '':* ｡ ,
　　　 ,.斗*''“ ” ＼：　　 ”・・． ' ' ' '　　　　　　　　 ' ' ' ' : : : : : : : : : : : : ”ミ*｡,,,,,,　　　　　　 　 　 　 ＿
　　く.　 ◎　 ﾞ:.ﾞ:..　ﾟ:,　:　───────────　　　--　　,,,,,,__ ' ' ' :.:.:.:.:.”≧s｡.　　＿,,,｡s*i:i:i:i:<
　　ﾏ*s｡ :,　 }　ﾟ:,　 :}　　　　　　　　　　　　　　　　　　　　　　　　　　　　”　''　-　”””：：”：：`*｡i:i:i:i:i:i:i;:’
　　　` .｡`　 ,　,ノ ／｡ ,,,_　　　　　　　　　　　　　　　　　　　　　　　　　　　　　＿＿`　　} }　　ﾉi:i:i:i:i:ﾂ
　　　　　 `　*　｡　　`*｡i:i:i::*=-　　　　　　　　　　　＿＿　　　　　　,,,....｡s*'i,:’　　　”`*｡＿,*’i:i:i:i:r’
　　　　　　　　　　　”　─ --　　　　｡｡｡｡｡　　 -　－`''''''''ヽ ─ '''”　　　｀ｰ“　　　　　　　`*｡i:i:i:i:i:i:
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*｡i:i:::
　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　　`*ﾟ:,
         fozubaoyou    no BUGs alive!
*/

typedef long long ll;
//{
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define dumo dump
#define sd pop_back
//}

#define debug_interval ','
#define dump_interval endl
#define debug_toggle 0

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cout<<endl;}
template<class...A> inline void debug_rest() {cout<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cout<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cout<<first,debug_rest(rest...);}
//}

int a,b,c;
string s,t;

int main(){
    cin>>a;
if(a>=1000)dump("ABD");
else dump("ABC"); 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define nl ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define pi acos(-1)

using namespace std;

int main() {
    nl // 

    vector<int> v(3);

    for(auto &x : v) cin >> x;
    sort(all(v));

    cout << (v[2] != v[0] + v[1] ? "No" : "Yes");


    return 0;
}

Measured memory_bytes: 3628
c=[list(map(int,input().split())) for _ in range(3)]

a0=0
b0=c[0][0]-a0
b1=c[0][1]-a0
b2=c[0][2]-a0

a1= c[1][0]-b0
a2= c[2][0]-b0
if a1 == c[1][1]-b1 == c[1][2]-b2\
and a2 == c[2][1]-b1 == c[2][2]-b2:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9212
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, n, ans = 1, a, m = 1e5, l = 1e18, c = 1e13;
  bool b = true;
  scanf("%lld", &n);
  for(i = 0; i < n; ++i) {
    scanf("%lld", &a);
    if(!a) {
      printf("0");
      return 0;
    }
    if(ans / m * a > c) b = false;
    else ans *= a;
    if(ans > l) b = false;
  }
  if(b)printf("%lld", ans);
  else printf("-1");
  return 0;
}

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

void reverse(int b, int e, long* A);

int main(void){
  int n;
  cin>>n;
  long A[n];
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  int q;
  cin>>q;
  int b,e;
  for(int i=0;i<q;i++){
    cin>>b>>e;
    reverse(b,e,A);
  }
  for(int i=0;i<n-1;i++){
    cout<<A[i]<<" ";
  }
  cout<<A[n-1]<<endl;
  return 0;
}


void reverse(int b,int e,long* A){
  long tmp[e-b+1];
  for(int i=b;i<e;i++){
    tmp[i-b]=A[i];
  }
  for(int i=b;i<e;i++){
    A[i]=tmp[e-i-1];
  }
}



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

int main()
{
    ll n,s;
    cin >> n;
    s = 0;
    
    for(ll i = 1; i <= n;){
        if(i%3 == 0 && i%5 == 0) i++;
        else if(i%3 == 0 && i%5 != 0) i++;
        else if(i%3 != 0 && i%5 == 0) i++;
        else {s += i;i++;}
    }
    cout << s;
}


Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String strArr[] = br.readLine().split(" ");
            long x = Long.parseLong(strArr[0]);
            long a = Long.parseLong(strArr[1]);
            long b = Long.parseLong(strArr[2]);
            long diff = a - b;
            if (diff >= 0) {
                System.out.println("delicious");
            } else {
                if (x < Math.abs(diff)) {
                    System.out.println("dangerous");
                } else {
                    System.out.println("safe");
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
           }
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60


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

	ll A, B, C;
	cin >> A >> B >> C;

	if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) cout << 0 << endl; // 長さが偶数の辺があればその辺を半分にすればよい
	else {
		ll ans = min(A*B, B*C);
		ans = min(ans, A*C);
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n, h, w;
        cin >> n >> h >> w;
        cout << (n - h + 1) * (n - w + 1) << '\n';
    }
}

Measured memory_bytes: 31488
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;


vector<char> G[200];
int in[200];
int out[200];
int n;
// ツづ慊つクツつキツづ猟づづ個要ツ素ツつェツ連ツ個仰つウツづェツづつ「ツづゥツつゥツづつ、ツつゥツづーツ確ツつゥツづ淞づゥ
bool isConnected[200];

bool isAppeared[200];

void isConnectedAllElement(char s){
	if(isConnected[s])
		return;
	isConnected[s]=true;
	for(int i = 0; i < G[s].size(); i++){
		isConnectedAllElement(G[s][i]);
	}
}

int main(){

	while(cin>>n&&n!=0){
		char s;
		for(int i = 0; i < 200; i++)
			G[i].clear();
		fill(in,in+200,0);
		fill(out,out+200,0);
		fill(isAppeared,isAppeared+200,false);
		fill(isConnected,isConnected+200,false);

		for(int i = 0; i < n; i++){
			string str;
			cin>>str;
			G[str[0]].push_back(str[str.size()-1]);
			G[str[str.size()-1]].push_back(str[0]);
			s=str[0];
			in[str[0]]++;
			out[str[str.size()-1]]++;
			isAppeared[str[0]]=true;
			isAppeared[str[str.size()-1]]=true;
		}

		isConnectedAllElement(s);
		bool f=true;

		for(char i = 'a'; i<='z'; i++){
			if((!isAppeared[i])||(isConnected[i]))
				continue;
			else{
				f=false;
				break;
			}
		}
		if(!f){
			cout<<"NG"<<endl;
			continue;
		}

		for(char i = 'a'; i<='z'; i++){
			if(!isAppeared[i]){
				continue;
			}
			else if(in[i]==out[i]){
				continue;
			}
			else{
				f=false;
				break;
			}
		}
		if(f)
			cout<<"OK"<<endl;
		else
			cout<<"NG"<<endl;
	}


	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int, int>
#define vi vector<int>
#define pb emplace_back
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define x first
#define y second
#define rep(i, j, k) for(i=j; i<k; i++)
#define sep(i, j, k) for(i=j; i>k; i--)
const int N = 2e5+5, inf = 1e9+7;
int n, k, i, j;
int A[N];
int dp[N];
signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int i, j, a, b, ans = 0;
    cin>>n>>k;
    rep(i, 1, n+1) cin>>A[i];
    sep(i, n-1, 0){
        dp[i]=inf*inf;
        rep(j, i+1, min(i+k, n)+1)
            dp[i] = min(dp[i], dp[j]+abs(A[i]-A[j]));
    }
    cout<<dp[1];
}

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

template <typename T>
void print(const T &v);

int main()
{
    int n, w;
    cin >> n >> w;
    vector<ll> weight(n), value(n);
    rep(i, n) cin >> weight[i] >> value[i];

    vector<vector<ll>> dp(n + 1, vector<ll>(w + 1, 0));

    for (int i = 0; i < n; i++) // i個目までの品物で最大の価値をとる
    {
        for (int j = 0; j <= w; j++) // 総重量jまでで最大の組み合わせを得る
        {
            if (j >= weight[i])
            {
                dp[i + 1][j] = max(dp[i][j - weight[i]] + value[i], dp[i][j]);
            }
            else
            {
                dp[i + 1][j] = dp[i][j];
            }
        }
    }
    // for (auto d : dp)
    // {
    //     print(d);
    // }
    cout << dp[n][w] << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


Measured memory_bytes: 80256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>

using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

LL gcd(LL a, LL b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}


int main(){
   int N;
   cin >> N;
   LL A[N];
   REP(i,N) cin >> A[i];
   int pos=0;
   int count=0;
   int tmp=0;
   int ans=0;
    int up=0;
   int down=0;
   int tmp_1=0;
   int tmp_2=0;
    while(true){
        up=pos;
        down=pos;
        tmp_1=0;
        tmp_2=0;
        if(pos == N) break;
        while(A[up]<=A[up+1] && up<N-1){
            ++up;
            ++tmp_1;
        }
        
        while(A[down]>=A[down+1] && down<N-1){
            ++down;
            ++tmp_2;
        }
        
        pos=max(up,down)+1;
        ++count;
        }
    
    cout <<  count;
}

Measured memory_bytes: 1024
import java.util.*;
import java.math.BigInteger;
import static java.math.BigInteger.*;

public class Main {

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

  void solve() {

    Scanner cin = new Scanner(System.in);
    
    long a = cin.nextLong();
    long b = cin.nextLong();
    long c = cin.nextLong();
    
    long k = cin.nextLong();
    
    long ans = 0;
    if( k % 2 == 0 ) {
    	ans = a - b;
    }
    else {
    	ans = b - a;
    }
    
    if( Math.abs(ans) > 1000L * 1000L * 1000L * 1000L * 1000L * 1000L ) {
    	System.out.println("Unfair");
    }
    else {
    	System.out.println(ans);
    }

    cin.close();

  }
  
  

}


Measured memory_bytes: 21716
import math
A,B,H,M=list(map(int,input().split()))

degA = (H%12 / 12 + (M%60/60)/12) * math.pi*2
degB = (M%60 / 60) * math.pi*2

ax = math.sin(degA)*A
ay = math.cos(degA)*A
bx = math.sin(degB)*B
by = math.cos(degB)*B

dis = math.sqrt((bx-ax)*(bx-ax)+(by-ay)*(by-ay))
print(dis)

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

public class Main implements Runnable {
    private static Boolean[][] dp;
    private static boolean calculate(int player, int stones, int[] arr){
        if(stones < 0){
            if(player == 0){
                return true;
            }
            return false;
        }
        if(stones == 0){
            if(player == 0) return false;
            return true;
        }
        if(dp[player][stones] != null) return dp[player][stones];
        if(player == 0){
            boolean res = false;
            for(int i = 0; i < arr.length; i++){
                res = res || calculate(1, stones - arr[i], arr);
            }
            dp[player][stones] = res;
            return res;
        } else {
            boolean res = true;
            for(int i = 0; i < arr.length; i++){
                res = res & calculate(0, stones - arr[i], arr);
            }
            dp[player][stones] = res;
            return res;
        }
    }
    public static void main(String[] args) {
        new Thread(null, new Main(), "Main", 1<<26).start();
    }

    private static int nextInt(BufferedReader br) throws IOException{
        return Integer.parseInt(br.readLine());
    }

    private static int[] nextIntArray(BufferedReader br, int n) throws IOException{
        StringTokenizer st = new StringTokenizer(br.readLine());
        int[] arr = new int[n];
        for(int i = 0; i < n; i++){
            arr[i] = Integer.parseInt(st.nextToken());
        }
        return arr;
    }

    @Override
    public void run() {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        // code goes here
        int[] in = new int[0];
        try {
            in = nextIntArray(br, 2);
        } catch (IOException e) {
            e.printStackTrace();
        }
        int n = in[0];
        int k = in[1];
        int[] arr = new int[0];
        try {
            arr = nextIntArray(br, n);
        } catch (IOException e) {
            e.printStackTrace();
        }
        dp = new Boolean[2][k + 1];
        if(calculate(0, k, arr))
            sb.append("First");
        else sb.append("Second");
        System.out.print(sb.toString());
    }

    static class Pair<A, B>{
        A first;
        B second;
        public Pair(A first, B second){
            this.first = first;
            this.second = second;
        }
    }
}


Measured memory_bytes: 39616
#
a, b = [int(s) for s in input().split()]
c = int(str(a)[:3])
d = int(str(b)[:3])
count = 0
for x in range(c, d + 1):
    x = str(x)
    y = int(x + x[1] + x[0])
    if a <= y <= b:
        count += 1
print(count)

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

int main(){
    int n,r,p,c;
    vector<int> cards;

    while(cin >> n >> r, n&&r){
        cards.clear();
        for(int i = 0; i < n; i++){
            cards.push_back(n - i);
        }
        while(r--){
            cin >> p >> c;
            vector<int> cpCards = cards;
            int pos = 0;
            for(int i = p - 1; i < p - 1 + c; i++){
                cards[pos] = cpCards[i];
                pos++;
            }
            for(int i = 0; i < p - 1; i++){
                cards[pos] = cpCards[i];
                pos++;
            }
        }
        cout << cards.front() << endl;
    } 
}

Measured memory_bytes: 1220
// Header {{{
#include <bits/stdc++.h>

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}
signed main() {
    ll H,W;
    cin>>H>>W;
    vector<vector<ll>> v(H, vector<ll>(W));
    vector<vector<ll>> ans;
    rep(y,0,H){
        rep(x,0,W){
            cin>>v[y][x];
            v[y][x] %= 2;
        }
    }
    rep(y,0,H-1){
        rep(x,0,W){
            if (v[y][x]==1){
                ans.push_back({y+1,x+1,y+2,x+1});
                v[y+1][x] += v[y][x];
                v[y][x] = 0;
                v[y+1][x] %= 2;
            }
        }
    }
    rep(x,0,W-1){
        if(v[H-1][x]==1){
            ans.push_back({H,x+1,H,x+2});
            v[H-1][x+1] += v[H-1][x];
            v[H-1][x] = 0;
            v[H-1][x+1] %= 2;
        }
    }
    cout<<ans.size()<<endl;
    for (auto e: ans){
        printf("%lld %lld %lld %lld\n", e[0],e[1],e[2],e[3]);
    }

    return 0;
}


Measured memory_bytes: 12848
n = int(input())
xyh = []
for _ in range(n):
    x, y, h = map(int, input().split())
    xyh.append((x, y, h))
for cx in range(101):
    for cy in range(101):
        H = None
        maxH = 10**12
        for x, y, h in xyh:
            if h>0:
                if H is None:
                    H = h+abs(x-cx)+abs(y-cy)
                elif H!=h+abs(x-cx)+abs(y-cy):
                    break
                if H>maxH:
                    break
            else:
                maxH = min(maxH, abs(x-cx)+abs(y-cy))
                if H is not None and H>maxH:
                    break
        else:
            print(cx, cy, H)
            exit()

Measured memory_bytes: 42988
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>

int main(void) {
  long long int x;
  long long int a,b;
  scanf("%lld", &x);
  //scanf("%d", &b):
  int m;
  int tmp;
  int flag=0;

  for(int i = 0;i<120;i++){
    a = i;
    tmp = a;
    a = a*a*a*a*a;
    b = a-x;
    if(b > 0){

      for(int j = 1;j<120;j++){
        int c = 0;
        c = b-(j*j*j*j*j);
        if(c == 0){
          m = j;
          flag =1;
          break;
        }
        }
        if(flag == 1){
          break;
      }
    }
    else{
    for(int k = -1;k > -120;k--){
      int d = 0;
      d = b-(k*k*k*k*k);
      if(d == 0){
        m = k;
        flag =1;
        break;
      }
    }
    if(flag == 1){
      break;
    }
  }

  }
  printf("%d %d\n",tmp,m);



  return 0;
}


Measured memory_bytes: 1736
def get_divisor(n: int) -> list:
    divisor = []
    for i in range(1, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            divisor.append(i)
            if n // i != i:
                divisor.append(n // i)
    # divisor.sort() # if you want sorted divisors
    return divisor


n = int(input())
divisor = get_divisor(n)
ans = 0
for x in divisor:
    if n == x:
        continue
    m = n // x - 1
    if n // m == n % m:
        ans += m

print(ans)


Measured memory_bytes: 9208
#include <cstdio>

char ar[13];
int nums[10];
int main(){
    while(scanf("%s\n",ar)!=-1){
        for(int i=0;i<10;i++){
            nums[i]=ar[i]-'0';
        }
        for(int i=0;i<9;i++){
            for(int j=0;j<10-i-1;j++){
                nums[j]=(nums[j]+nums[j+1])%10;
            }
        }
        printf("%d\n",nums[0]);
    }
}

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

using namespace std;

typedef long long int lli;
typedef vector<lli> vi; 

int main() {
    lli qnt;
    cin >> qnt;
    vi locals;
    lli item;
    for(lli i = 0; i < qnt; ++i) {
        cin >> item;
        locals.push_back(item);
    }
    lli best = INT_MAX;
    for(int i = 0; i < 100; ++i) {
        int aux = 0;
        for(auto x: locals) {
            aux += pow(x-i,2);
        }
        if(aux < best) {
            best = aux;
        }
    }
    cout << best << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll ,P> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n, m, d[105][105];
    vector<P3> es;
    cin >> n >> m;
    REP(i,n) fill(d[i], d[i]+n, IINF/3);
    REP(i,m){
        int a, b, c;
        cin >> a >> b >> c;
        a--;b--;
        d[a][b] = c;
        d[b][a] = c;
        es.push_back({c,{a,b}});
    }
    REP(k,n)REP(i,n)REP(j,n){
        d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
    }
    int cnt = 0;
    REP(i,m){
        int a, b, c;
        a = es[i].second.first;
        b = es[i].second.second;
        c = es[i].first;
        if(d[a][b] < c) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while (true) {
        int maze[20][20];
        int dp[20][20];
        Fill(dp, 0);
        Fill(maze, 0);
        dp[0][0] = 1;
        int a, b; cin >> a >> b;
        a--; b--;
        if (a == -1 && b == -1) return 0;
        int n; cin >> n;
        rep(i, n) {
            int x, y; cin >> x >> y;
            x--; y--;
            maze[y][x] = -1;
        }
        reps(y, b) reps(x, a) {
            if (maze[y+1][x] != -1) dp[y+1][x] += dp[y][x];
            if (maze[y][x+1] != -1) dp[y][x+1] += dp[y][x];
        }
        cout << dp[b][a] << endl;
    }
    return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int P, W, G, Y; //　色の判定
  int sum, N;
  sum = 0; P = 0; W = 0; G = 0; Y = 0;
  string arare;
  cin >> N;
  
  for(int i = 0; i < N;  i++){
    cin >> arare;

    
  if(arare == "P") {
    if(P == 1)
     continue;
    
   P = 1;
   sum++; 
  } //ピンクの判定
  
   if(arare == "W") {
    if(W == 1)
     continue;
    
   W = 1;
   sum++; 
  } // 白の判定
  
   if(arare == "G") {
    if(G == 1)
     continue;
    
   G = 1;
   sum++; 
  } //緑の判定
  
   if(arare == "Y") {
    if(Y == 1)
     continue;
    
   Y = 1;
   sum++; 
  } //黄色の判定
    
	
 }
   if (sum == 3 || 4){
      if (sum == 4)
     cout << "Four" << endl;
     // 四色の時
     
   if(sum == 3 && sum != 4) cout << "Three" << endl;
    //三色の時
 
   }
  
  
}

Measured memory_bytes: 256
abcd = str(input())

op_cnt = len(abcd) - 1
for i in range(2**op_cnt):
    op = ["-"] * op_cnt
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt-1 - j] = "+"

    ans = int(abcd[0])
    for j in range(1, len(abcd)):
        if op[j-1]=="+":
            ans += int(abcd[j])
        else:
            ans -= int(abcd[j])

    if ans==7:
        for j in range(len(abcd)):
            if j==len(abcd)-1:
                print(abcd[j], "=7", sep="")
            else:
                print(abcd[j], op[j], end="", sep="")
        break


Measured memory_bytes: 61972
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define mod 1000000007
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define ll long long int 
#define PI 3.1415926535897932384626

using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	string s;
	cin>>s;
	if(n%2)
	cout<<"No\n";
	else
	{
	     string st1=s.substr(0,n/2);
	     string st2=s.substr(n/2,n);
	     if(st1==st2)
	     cout<<"Yes";
	     else
	     cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 3528
use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::str::*;

use std::string::*;

struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }

    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }

    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let s: String = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();

        return s.parse::<T>().ok().unwrap();
    }

    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

fn prime_factorization(n: i64) -> HashMap<i64, i64> {
    let mut n = n;
    let mut res = HashMap::new();
    let mut i = 2;
    while i * i <= n {
        while n % i == 0 {
            n /= i;
            let count = res.entry(i).or_insert(0);
            *count += 1;
        }
        i += 1;
    }

    if n > 1 {
        res.insert(n, 1);
    }

    return res;
}

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let k: i64 = sc.read();
    let a: i64  = sc.read();
    let b: i64 = sc.read();

    let ans = (0..10000).map(|i| i * k).filter(|x| a <= *x && *x <= b).count();
    if ans > 0 {
        println!("OK");
    } else {
        println!("NG");
    }
}

Measured memory_bytes: 2164
#include <cstdio>
#include <iostream>
using namespace std;
int a[100010];
int main()
{
    int n;
    while(cin>>n)
    {
        int k=0,r=0;
        for(int i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
            if(a[i]%4==0)k++;
            else if(a[i]%2==0)r++;
        }
        if(k>=n/2)printf("Yes\n");
        else
        {
            if(r%2!=0)
            {
                r--;
                if(k+1>=(n-k-r))printf("Yes\n");
                else printf("No\n");
            }
            else
            {
                if(k+1>=(n-k-r))printf("Yes\n");
                else printf("No\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()



int main(void){
    int N,X;
    cin >> N >> X;
    int L[N];

    rep(i,N){
        cin >> L[i];
    }

    int D = 0;
    int t = 0;
    while(D<=X){
        D = D + L[t];
        /* cout << D << endl; */
        t++;

        if(t > N){
            D = N;
            break;
        }
    }

    cout << t << endl;
	
    return 0;
}


Measured memory_bytes: 256
import numpy as np
N, D = map(int, input().split())
Xs = []
while True:
  Xs.append(list(map(int, input().split())))
  if len(Xs) == N:
    break
result = []
Xi = 1
tmp = []
for x in Xs:
  tmp.append(x)
  for n in range(N):
    if Xs[n] in tmp:
      l = np.linalg.norm(np.array(x) - np.array(Xs[n]))
      if l.is_integer() and l > 0:
        result.append(l)
print(int(len(result)))


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

int main()
{
	int N;
	cin >> N;

	for (int i = 0; i <= N; i+=4)
	{
		for (int l = 0; l <= N; l+=7)
		{
			if (i + l == N)
			{
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
/********************************
*** ******** ********** *********
*** * ****** ********* * ********
*** ** ***** ******** *** *******
*** *** **** ******* ***** ******
*** **** *** ****** ******* *****
*** ***** ** ***** +++++++++ ****
*** ****** * **** *********** ***
*** *******  *** ************* **
*** ******** ** *************** *
**********_**********************
* |   /  / \  \     /    /\     *
* |  /  |   |  \   /    /  \    *
* | /   |   |   \ /    /    \   *
* |+\   |   |    |    /______\  *
* |  \  |   |    |   |        | *
* |   \  \_/     |   |        | *
********************************/
#include<bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define KING 1000000002
#define queen 1000002
#define fi first
#define se second
#define se second
#define lsb(i) (i & -i)
#define Pi 3.141592653589793238
#define nl cout<<'\n'
#define TEST cout<<"TEST",nl
#define all(a) a.begin(), a.end()
#define remax(a, b) (a = ((a<b) ? b : a))
#define remin(a, b) (a = ((a<b) ? a : b))
#define pr pair<lli,lli>
#define pb push_back
#define eb emplace_back
#define precise(a) cout<<fixed<<setprecision(a)
#define mp make_pair
#define vi vector<lli>
#define vpi vector<pr> 
#define P pair<lli,pr>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define NA(i,s,n) for(lli i=s;i<n;i++)
using namespace std;

lli power(lli x,lli y,lli p) { 
	lli res = 1;	 
	x = x % p; 
	while (y > 0) 
	{ 
		if (y & 1) 
			res = (res*x) % p; 
		y = y>>1; 
		x = (x*x) % p; 
	} 
	return res; 
} 

const lli N = 1e5 + 1;
lli a[N], dp[N], n, k;

lli fun(lli pos){
    if(pos==n-1) return 0;
    if(dp[pos]!=-1) return dp[pos];
    lli res = 1e14;
    NA(i,1,k+1) {
        if(pos+i < n) remin(res, abs(a[pos]-a[pos+i])+fun(pos+i));
    }
    return dp[pos] = res;
}

void solve(){
    memset(dp, -1, sizeof dp);
    cin >> n >> k;
    NA(i,0,n) cin >> a[i];
    cout << fun(0) ;
    return;
}
int main(){
    fastIO;
    lli t = 1;
    // cin>>t;
    NA(i,0,t){
        solve();
    }
    return 0;

}


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

int main() {
	array<int, 4> a, b;
	while (1) {
		for (auto& A : a) cin >> A;
		for (auto& B : b) cin >> B;
		if (!cin) break;
		
		int hit = 0, blow = 0;
		for (int i = 0; i < 4; ++i) {
			for (int j = 0; j < 4; ++j) {
				if (a[i] == b[j]) {
					if (i == j) {
						hit++;
					}
					else {
						blow++;
					}
					break;
				}
			}
		}
		cout << hit << ' ' << blow << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    for(int i=k;i<=n;i++)
    {   
        ll mn=(ll)(i*(ll)(i-1))/2;

        double mx=((double(i/double(2.0)))*((2*(n-i+1)+(i-1))));
         ll mxx=mx;
        //cerr<<mxx<<" "<<mn<<endl;
        ans=((ans+(mxx%mod-mn%mod+mod)) + 1);
        //cout<<ans<<endl;
    }
    cout<<(ans+1)%mod<<endl;
    
}
return 0;
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
from operator import itemgetter

N = int(input())

SP = []
for n in range(1, N+1):
    [S, P] = [i for i in input().split()]
    SP.append((n, S, int(P)))

sorted_SP = sorted(SP, key=itemgetter(2), reverse=True)
sorted_SP = sorted(sorted_SP, key=itemgetter(1))

for n in range(N):
    print(sorted_SP[n][0])


Measured memory_bytes: 3060
import bisect

def main():
    high, width = map(int, input().split())
    data = [list(input()) for i in range(high)]
    ans_list = [[0 for i in range(width)] for j in range(high)]

    for i in range(high):
        for j in range(width):
            if data[i][j] == '.':
                ans_list[i][j] = ans_list[i][j - 1] + 1
        for j in range(width - 1)[::-1]:
            if data[i][j] == '.':
                ans_list[i][j] = max(ans_list[i][j], ans_list[i][j + 1])

    # for i in range(high):
    #     print(ans_list[i])
    # print('---')

    ans_list2 = [[0 for i in range(width)] for j in range(high)]

    for j in range(width):
        for i in range(high):
            if data[i][j] == '.':
                ans_list2[i][j] = ans_list2[i - 1][j] + 1
        for i in range(high - 1)[::-1]:
            if data[i][j] == '.':
                ans_list2[i][j] = max(ans_list2[i][j], ans_list2[i + 1][j])

    ans = 0

    for i in range(high):
        for j in range(width):
            kari = ans_list[i][j] + ans_list2[i][j] - 1
            ans = max(ans, kari)

    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 246792
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair

using namespace std;



int main()
{
   FAST/**/
   
   ll n,m;
   cin>>n>>m;
   
   vector<ll> v[3*n];
   for(ll i=0;i<m;i++)
   {
       ll a,b;
       cin>>a>>b;
       
       a--,b--;
       v[a].pb(b+n);
       v[a+n].pb(b+2*n);
       v[a+2*n].pb(b);
   }
   
   ll s,t;
   cin>>s>>t;
   s--;
   t--;
   
   bool vis[3*n];
   memset(vis,0,sizeof(vis));
   
   ll dis[3*n];
   memset(dis,-1,sizeof(dis));
   queue<ll> q;
   q.push(s);
   vis[s] = 1;
   dis[s] = 0;
   
   while(q.size()>0)
   {
       ll temp = q.front();
       q.pop();
       
       for(auto it = v[temp].begin();it!=v[temp].end();it++)
       {
           if(vis[*it])
                continue;
           dis[*it] = dis[temp] + 1;
           q.push(*it);
           vis[*it] = 1;
       }
   }
   
   if(dis[t] == -1)
   {
       cout<<-1;
       return 0;
   }
   cout<<dis[t]/3;
   
   
   return 0;
}

Measured memory_bytes: 19328
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int N, K;
vector<long long> a;

int main() {
    while (cin >> N >> K) {
        a.resize(N);
        for (int i = 0; i < N; ++i) cin >> a[i];

        vector<long long> S(N+1, 0);
        for (int i = 0; i < N; ++i) S[i+1] = S[i] + a[i];

        vector<long long> v;
        for (int i = 0; i < N; ++i)
            for (int j = i+1; j <= N; ++j)
                v.push_back(S[j] - S[i]);
        sort(v.begin(), v.end(), greater<long long>());


        long long res = 0;
        vector<bool> dame(v.size(), false);
        for (int d = 60; d >= 0; --d) {
            int num = 0;
            for (int i = 0; i < v.size(); ++i) {
                if (dame[i]) continue;
                if (v[i] & (1LL<<d)) ++num;
            }
            if (num >= K) {
                res += (1LL<<d);
                for (int i = 0; i < v.size(); ++i) {
                    if ( !(v[i] & (1LL<<d)) ) dame[i] = true;
                }
            }
        }
        cout << res << endl;
    }
}
                                                                                   


















Measured memory_bytes: 6516
#include <bits/stdc++.h>
using namespace std;
int solve(int **arr,int day,int flag,int n,int **dp){
	if(day == n)return 0;
	if(dp[day][flag]!=-1)return dp[day][flag];
	int maxi = INT_MIN;
	if(flag == 0){
		maxi = max(maxi,arr[day][1] + solve(arr,day+1,1,n,dp));
		maxi = max(maxi,arr[day][2] + solve(arr,day+1,2,n,dp));
	}
	else if(flag == 1){
		maxi = max(maxi,arr[day][0] + solve(arr,day+1,0,n,dp));
		maxi = max(maxi,arr[day][2] + solve(arr,day+1,2,n,dp));
	}
	else if(flag == 2){
		maxi = max(maxi,arr[day][0] + solve(arr,day+1,0,n,dp));
		maxi = max(maxi,arr[day][1] + solve(arr,day+1,1,n,dp));
	}
	else{
		maxi = max(maxi,arr[day][0] + solve(arr,day+1,0,n,dp));
		maxi = max(maxi,arr[day][1] + solve(arr,day+1,1,n,dp));
		maxi = max(maxi,arr[day][2] + solve(arr,day+1,2,n,dp));
	}
	return dp[day][flag] = maxi;
}
int main() {
	// your code goes here
	int n;
	cin>>n;
	int **arr = new int*[n];
	int **dp = new int*[n];
	for(int i =0 ;i<n;i++){
		dp[i] = new int[3];
		for(int j = 0;j<=3;j++)
			dp[i][j] = -1;
	}
	for(int i =0 ;i<n;i++){
		arr[i] = new int[3];
		for(int j = 0;j<3;j++)
			cin>>arr[i][j];
	}
	cout<<solve(arr,0,3,n,dp)<<endl;
	return 0;
}

Measured memory_bytes: 19208
import sys
input = sys.stdin.readline
from collections import *

N, T = map(int, input().split())
A = list(map(int, input().split()))
min_acc = [A[0]]

for i in range(1, N):
    min_acc.append(min(min_acc[-1], A[i]))
    
M = 0

for i in range(1, N):
    M = max(M, A[i]-min_acc[i-1])

ans = 0

for i in range(1, N):
    if A[i]-min_acc[i-1]==M:
        ans += 1

print(ans)

Measured memory_bytes: 59924
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
 char c[10]; 
int main(){
	int a,b;
	cin>>a>>b;
	scanf("%s",c);
	if(c[a]!='-'){
		cout<<"No"<<endl;
		return 0;
	}
	int t=0;
	for(int i=1;i<strlen(c);i++){
		if(c[i]<'0' || c[i]>'9'){
			t++;
		}
	}
	if(t>1){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}
	
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 1000000
#define MOD 1e9
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define endl '\n'
using namespace std;
/* ----------------------------------------------------------------------------------- */

#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, a, n) for (int i = a; i <= n; i++)
#define inputArray(a,n) rep(i, 0, n) cin >> a[i];
#define copyArray(a,temp,n) rep(i, 0, n) temp[i]=a[i];
#define printArray(a,n) rep(i, 0, n) cout << a[i] << " "; cout << endl;

/* ----------------------------------------------------------------------------------- */

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)

#define dbgA2(A, n, m) {cout<<"--> "<<#A<<" = \n";rep(i, 0, n){rep(j, 0, n){cout<<A[i][j]<<" ";}cout<<"\n";}cout<<"\n";}
#define dbgA(A, n) {cout<<" --> "<<#A<<" = (";rep(i, 0, n)cout<<A[i]<<" ";cout<<")\n";}
#define dbg(args...) {string sss(#args);sss+=',';cout<<" --> ";debugger::call(all(sss), args);cout<<"\n";}

/* ----------------------------------------------------------------------------------- */

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }

struct debugger {
	typedef string::iterator si;
	static void call(si it, si ed) {}
	template<typename T, typename ... aT>
	static void call(si it, si ed, T a, aT... rest) {
		string b;
		for(; *it!=','; ++it)
			if(*it!=' ')
				b+=*it;
		cout << b << "=" << a << " ";
		call(++it, ed, rest...);
	}
};
  
/* ----------------------------------------------------------------------------------- */


void solve() {
	string str, a = "", b = "";
	cin >> str;
	int lenOne = ((str.length() - 1) / 2.0);
	int lenTwo = ((str.length() + 3) / 2.0);

	for (int i = 0; i < lenOne; i++) {
		a += str[i];
	}
	for (int i = lenTwo - 1; i < str.length(); i++) {
		b += str[i];
	}

	if(a == b) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}

int main() {
	solve();

	// __test {
	// 	solve();
	// }
}

Measured memory_bytes: 3636
#include<iostream>

using namespace std;

int main()
{
	int n, a, b;
	cin >> n >> a >> b;
	if (n == 1)
	{
		if (a == b) cout << "1";
		else cout << "0";
	}
	else
	{
		if (a > b) cout << "0";
		else
			cout << (long long)(b - a)*(n - 2) + 1;
	}
	return EXIT_SUCCESS;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,D;
  int SUM=0;
  int S=0;
  int a;
  vector<int> f(1001);
  cin >> N >> D;
  
  for (int i=0;i<N;i++){
  	cin >> a;
    f.at(a)+=1;
  }
  for (int k=0;k<1001;k++){ 
      S+=f.at(k);
      SUM+=f.at(k)*k;
      if(D<=S){
        SUM=SUM-k*(S-D);
        k=1002;
      }
            
  }
  cout << SUM << endl;
  return 0;
    
}

Measured memory_bytes: 3604
#!python3

def resolve():
    s = int(input())

    c = []
    for i in range(2):
        a, b = divmod(s, 60)
        s = a
        c.append(str(b))
    c.append(str(a))
    c.reverse()
    print(":".join(c))

if __name__ == "__main__":
    resolve()



Measured memory_bytes: 5600
#include "bits/stdc++.h"
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    //pair c++ で検索検索！
    vector<pair<int,int>> br(n);
    for(int i=0;i<n;++i){
      cin >> br.at(i).second >> br.at(i).first;
    }
    sort(br.begin(),br.end());
    int sum = 0;
    for(int i=0;i<n;++i){
      sum += br.at(i).second;
      if(br.at(i).first < sum){
        cout << "No" << endl;
        break;
      }
      if(i==n-1){
        cout << "Yes" << endl;
      }
    }
  } 
}


Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  int n,k,c;cin >> n >> k >> c;
  string s;cin >> s;
  int x = 0;
  vector<int> v;
  rep(i,n) {
    if(s[i] == 'o') {
      v.push_back(i);
      x++;
      i += c;
    }
  }
  if(x > k) {
    cout << "\n";
    return 0;
  }

  int j = v.size() - 1;
  vector<int> res;
  for(int i = n - 1;i >= 0;--i) {
    if(s[i] == 'o') {
      if(v[j] == i) res.push_back(i);
      j--;
      i -= c;
    }
  }

  reverse(res.begin(), res.end());
  rep(i,res.size()) cout << res[i]+1 << "\n";
  
  return 0;
}


Measured memory_bytes: 3448
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map { it.toLong() }
    val S = mutableListOf<Long>(A[0])
    A.forEachIndexed { index, l ->
        if (index > 0) S.add(S[index - 1] + l)
    }

    var d_min = Long.MAX_VALUE
    var p = 0; var r = 2
    for (q in 1 until N - 2) {

        var d_l = Long.MAX_VALUE
        left@ for (i in p until q) {
            val d = Math.abs((S[q] - S[i]) - S[i])
            if (d_l > d) {
                d_l = d
                p = i
            } else break@left
        }

        var d_r = Long.MAX_VALUE
        right@ for (i in r until N) {
            val d = Math.abs((S.last() - S[i]) - (S[i] - S[q]))
            if (d_r > d) {
                d_r = d
                r = i
            } else break@right
        }

        val d_p0 = S[p]; val d_qp = S[q] - S[p]; val d_rq = S[r] - S[q]; val d_Nr = S.last() - S[r]
        val max = Math.max(Math.max(d_p0, d_qp), Math.max(d_rq, d_Nr))
        val min = Math.min(Math.min(d_p0, d_qp), Math.min(d_rq, d_Nr))
        d_min = Math.min(d_min, max - min)
    }

    println(d_min)
}

Measured memory_bytes: 83932
N, Q = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

memo = [0]*N
for i in range(Q):
    p, x = map(int, input().split())
    memo[p-1] += x

import queue
q = queue.Queue()
q.put((-1, 0))

while not q.empty():
    p, v = q.get()
    for c in G[v]:
        if c == p: continue
        memo[c] += memo[v]
        q.put((v, c))

print(' '.join(map(str, memo)))

Measured memory_bytes: 142232