akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;

#define MAX 10000
#define NIL -1

struct Node{
  int p,l,r;
};

struct Node T[MAX];

int k;

void pre(int n){
  if(n == NIL) return;
  cout << " " << n;
  pre(T[n].l);
  pre(T[n].r);
}

void in(int n) {
  if(n==NIL) return;
  in(T[n].l);
  cout << " " << n;
  in(T[n].r);
}

void post(int n) {
    if(n==NIL) return;
    post(T[n].l);
    post(T[n].r);
    cout << " " << n;
}

int main(){
int a,b,c,root;
cin >> k;

for(int i=0;i<k;i++) T[i].p=NIL;

for(int i=0;i<k;i++){
  cin >> a;
  cin >> b;
  cin >> c;

  T[a].l=b;
  T[a].r=c;
  if(b!=NIL) T[b].p=a;
  if(c!=NIL) T[c].p=a;
}

for(int i=0;i<k;i++) if(T[i].p==NIL) root=i;

cout << "Preorder" << endl;
pre(root);
cout << endl;

cout << "Inorder" << endl;
in(root);
cout << endl;

cout << "Postorder" << endl;
post(root);
cout << endl;


  return 0;
}



Measured memory_bytes: 3104
n,k = map(int,input().split())
a = list(map(int,input().split()))

a.sort(reverse=True)
mask = (1<<k)-1
dp = 1
min_n = 10**10
for i in a:
    if(i >= k):
        min_n = i
        continue
    dp |= (dp<<i)
    if(dp > mask):
        min_n = i
        dp &= mask
         
ans = 0
for i in a:
    ans += (i < min_n)

print(ans)

Measured memory_bytes: 73700
require 'tsort'

n, m = gets.split.map &:to_i

g = Hash[*(0..n-1).map{|i| [i, []]}.flatten(1)]
class << g
    include TSort
    alias :tsort_each_node :each_key
    def tsort_each_child(i, &block)
        self[i].each do |j|
            block.call(j)
        end
    end
end

m.times do
    i, j = gets.split.map &:to_i
    g[i] << j
end

puts g.tsort.reverse

Measured memory_bytes: 14108
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

const int MAX_V = 101;
int d[MAX_V][MAX_V]; // cost of edge(u, v)
int V;  // number of nodes
void warshall_froid(){
    rep(k, V){
        rep(i, V){
            rep(j, V){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int H, W;
vvi c;
vvi a;

int main(int argc, char const* argv[])
{
    cin >> H >> W;
    V = 10;
    rep(i,10){
        rep(j,10){
            int cost;
            cin >> cost;
            d[j][i] = cost;
        }
    }
    rep(i, H){
        vi in(W);
        rep(j, W) cin >> in[j];
        a.pb(in);
    }
    warshall_froid();
    ll ans = 0;
    rep(i, H){
        rep(j, W){
            if(a[i][j] == -1) continue;
            else ans += d[1][a[i][j]];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
fun main() {
    val (n, m) = next2Int()
    val h = nextIntArray(n)
    val good = (1..n).toMutableSet()
    repeat(m) {
        val (a, b) = next2Int()
        if (h[a - 1] >= h[b - 1]) {
            good.remove(b)
        }
        if (h[b - 1] >= h[a - 1]) {
            good.remove(a)
        }
    }
    println(good.size)
}

val sc = java.util.Scanner(System.`in`)
fun next(): String = sc.next()
fun nextInt() = sc.nextInt()
fun next2Int() = Pair(nextInt(), nextInt())
fun next3Int() = Triple(nextInt(), nextInt(), nextInt())
fun nextIntArray(size: Int) = IntArray(size) { nextInt() }
fun nextLong() = sc.nextLong()
fun nextLine(): String = sc.nextLine()
fun nextList() = nextLine().split(" ")
fun printYesNo(isYes: Boolean) = println(if (isYes) "Yes" else "No")
fun printString(action: StringBuilder.() -> Unit) = println(buildString(action))


Measured memory_bytes: 69376
line = gets.chomp
len = line.length
count = [0, 0]
l_idx = nil
ans = [0] * len

(0...len).each do |idx|
  if line[idx] == "R"
    l_idx = nil unless l_idx.nil?
    count[idx % 2] += 1
    next
  end

  if l_idx.nil?
    l_idx = idx
    ans[l_idx - 1] = count[(l_idx - 1) % 2]
    ans[l_idx] = count[l_idx % 2]
    count = [0, 0]
  end

  ans[l_idx - ((idx - l_idx) % 2)] += 1
end

puts ans.join(" ")


Measured memory_bytes: 3196
#include<iostream>
using namespace std;
string s;
int c;
int main(){
getline(cin,s);
while(c<s.length()){
if(s[c]!='0'&&s[c]!='1')
if(c>0) s.erase(c-1,2),c--;
else s.erase(c,1);
else c++;}
cout<<s<<endl;}

Measured memory_bytes: 256
check = []
for i in range(3):
    a,b = map(int,input().split())
    check.append(a)
    check.append(b)
if check.count(1) == 1 and check.count(2) == 2 and check.count(3) == 2 and check.count(4) == 1: 
    print("YES")
else:
    print("NO")

Measured memory_bytes: 9132
#include <iostream>

using namespace std;
typedef pair <int,int> P;

int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  int W, H, N;
  P px, py;
  cin >> W >> H >> N;
  px.first = 0; px.second = W;
  py.first = 0; py.second = H;

  for (int i=0; i<N; ++i) {
    int x, y, a;
    cin >> x >> y >> a;
    if (1 == a) {
      if (x > px.first) px.first = x;
    } else if (2 == a) {
      if (x < px.second) px.second = x;
    } else if (3 == a) {
      if (y > py.first) py.first = y;
    } else { //4 == a
      if (y < py.second) py.second = y;
    }
  }

  int x = px.second - px.first;
  int y = py.second - py.first;
  if (0 > x || 0 > y)
    cout << 0 << "\n";
  else
    cout << x*y << "\n";
  return 0;
}

Measured memory_bytes: 256
import numpy as np
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))

c = []
for i, j in enumerate(a):
    c += [i + 1] * j
c = np.array(c).reshape(H, W)

for i in range(1, H, 2):
    c[i, :] = c[i, ::-1]

for r in range(H):
    row = c[r, :]
    print(*row, sep=' ')


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int A,B,C,X,Y; cin >> A >> B >> C >>X >> Y;

    if(A+B <= 2*C) {cout << A*X+B*Y << endl; return 0;}
    else{
        if(X>=Y) {cout << min(X*2*C, Y*2*C+(X-Y)*A) << endl; return 0;}
        else {cout << min(Y*2*C, X*2*C+(Y-X)*B) << endl; return 0;}
    }
}


Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String args[]){
		Scanner s = new Scanner(System.in);
		String indata = s.next();
		int a = Integer.parseInt(indata);
		indata=s.next();
		int b = Integer.parseInt(indata);
		indata = s.next();
		int c = Integer.parseInt(indata);
		if(a<b&&b<c)System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 26048
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void){
  cout << std::fixed << std::setprecision(16);
  cin.tie(0);
  std::ios::sync_with_stdio(false);

  int n,m;
  cin>>n>>m;
  std::vector<int> count(n+1);
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    count[a]++;
    count[b]++;
  }
  for(int i=0;i<=n;i++){
    if(count[i]%2!=0){
      cout<<"NO"<<endl;
      return 0;
    }

  }
  cout<<"YES"<<endl;

  return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;


void recursive_comb(int *indexes, int s, int rest, std::function<void(int *)> f) {
  if (rest == 0) {
    f(indexes);
  } else {
    if (s < 0) return;
    recursive_comb(indexes, s - 1, rest, f);
    indexes[rest - 1] = s;
    recursive_comb(indexes, s - 1, rest - 1, f);
  }
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(int *)> f) {
  int indexes[k];
  recursive_comb(indexes, n - 1, k, f);
}

ll modPow(ll x, ll n) {
    if(n==0) return 1;
    ll res = modPow(x*x%MOD, n/2);
    if(n&1) res=res*x%MOD;
    return res;
}
ll mul(ll l, ll r) {
    ll ret =1;
    for(int i=0; i<l-r+1; ++i) {
        ret*=i+r;
        ret%=MOD;
    }
    return ret;
}
ll com(ll n, ll k) {
    ll ret1 = mul(n,n-k+1);
    ll ret2 = mul(k,1);
    ll ret3 = modPow(ret2, MOD-2);
    return ret1*ret3%MOD;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
   int ans = INF;
   int a,b,c,x,y; cin >> a >> b>> c >> x >>y;
   rep(i,max(x,y)+1) {
     int tmp = i*c*2;
     if(x>i) tmp += (x-i)*a;
     if(y>i) tmp += (y-i)*b;
     chmin(ans,tmp);
   }
   cout << ans << "\n";
}



Measured memory_bytes: 256
use proconio::input;

fn main() {
    input!(a: u32, b: u32, c: u32, x: u32, y: u32);
    let z = x.min(y);
    println!(
        "{}",
        ((a + b).min(2 * c) * z + a * (x - z) + b * (y - z)).min(2 * c * x.max(y))
    );
}


Measured memory_bytes: 2140
#include <iostream>

using namespace std;

int main(void)
{
    int a, b, c;
    int cnt;
    
    cin >> a >> b >> c;
    
    for (int n=a; n<=b; n++)
    {
        if (c % n == 0)
            cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3124
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    public static void Main( )
    {
        var input = Console.ReadLine( ).Split( ).Select( int.Parse ).ToArray( );
        int N = input[ 0 ];
        int X = input[ 1 ];
        var x = Console.ReadLine( ).Split( ).Select( int.Parse ).ToArray( );

        int gcdOfAll = 0;
        for ( int i = 0; i < x.Length; i++ )
        {
            var distance = Math.Abs( X - x[ i ] );
            gcdOfAll = GCD( gcdOfAll, distance );
        }
        Console.WriteLine( gcdOfAll );

    }

    public static int GCD( int larger, int smaller )
    {
        if ( smaller == 0 ) return larger;
        return GCD( smaller, larger % smaller );
    }

}

Measured memory_bytes: 38420
#include<vector>
#include<iostream>
#include<string>

using ll = long long;
const long long mod = 1000000007;
int main(){
    int n,m;
    std::string s;
    std::cin >> n >> s;
    m = s.size();
    std::vector<ll> dp(n+1,0);
    dp.at(0)++;
    for(int i=0; i<n; i++){
        std::vector<ll> nxt(n+1,0);
        for(int j=0; j<n; j++){
            nxt.at(j+1) += dp.at(j);
            nxt.at(j+1) %= mod;
            nxt.at(std::max(j-1,0)) += j==0?dp.at(j):dp.at(j)*2%mod;
            nxt.at(std::max(j-1,0)) %= mod;
        }
        dp = nxt;
    }
    std::cout << dp.at(m) << std::endl;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    ll k,n;
    cin>>k>>n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    ll mi=k+a[0]-a[n-1];
    for (int i = 0; i < n-1; i++)
    {
        mi=max(mi, a[i+1]-a[i]);
    }
    cout<<k-mi<<endl;
    
    return 0;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n - 1)]
px = [list(map(int, input().split())) for _ in range(q)]

graph = [[] for _ in range(n + 1)]
for a, b in ab:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (n + 1)
for p, x in px:
    value[p] += x


def dfs(v, p, add):
    value[v] += add
    for x in graph[v]:
        if x == p:
            continue
        dfs(x, v, value[v])


dfs(1, 0, 0)

ans = value[1:]
print(*ans)


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

    int count=0;
    int maxmum=0;

    for (int i=0;i<s.size();i++) {
        if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'){
           count++;
           maxmum=max(count,maxmum);
        }
        else {
            count=0;
        }
    }
    cout <<maxmum<<endl;

}

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

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

    vector<vector<long long>> vec(10, vector<long long>(10));

    for (long long i = 1; i <= 9; i++)
    {
        for (long long j = 1; j <= 9; j++)
        {
            long long res = 0;
            for (long long k = 1; k <= N; k++)
            {
                if (k % 10 == i)
                {
                    long long l = k;
                    while(1)
                    {
                        if (l / 10 == 0)
                        {
                            break;
                        }
                        l = l / 10;
                    }

                    if (l % 10 == j)
                    {
                        res++;
                    }
                }
            }
            vec.at(i).at(j) = res;
        }
    }

    long long ans = 0;
    for (long long i = 1; i < 10; i++)
    {
        for (long long j = 1; j < 10; j++)
        {
            ans += vec.at(i).at(j) * vec.at(j).at(i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

ll ans,n,m;
ll d[111][111];
bool u[111];

void dfs(int k) {
  ll sum=0;
  rep(i,n) {
    if(!u[i]) continue;
    ll M=MAX;
    rep(j,n) {
      if(i==j) continue;
      if(u[j]) M=min(M,d[i][j]);
    }
    if(!M) return;
    if(M!=MAX) sum+=M;
  }
  ans=max(ans,sum);
  if(k==n) return;
  REP(i,k,n) {
    u[i]=1;
    dfs(i+1);
    u[i]=0;
  }
}

void Main() {
  cin >> n >> m;
  rep(i,m) {
    int x,y,z;
    cin >> x >> y >> z;
    x--,y--;
    d[x][y]=d[y][x]=z;
  }
  dfs(0);
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3320
/*"Everything in the universe is balanced. Every disappointment
   you face in life will be balanced by something good for you!
                Keep going, never give up."            */

#include "bits/stdc++.h"
using namespace std;

#define ll long long
const ll N=1e6+9;
const ll mod=1e9+7;

ll a[N];

void solve()
{    
    ll n, m ,W;
    string s,t;
    cin >> s >> t;
    n = s.size() ;
    m = t.size() ;

    vector<vector<int>> dp(n+1, vector<int>(m+1,0)) ;
    for(int i = 1; i<=n; i++){
    	for(int j=1; j<=m; j++){
    			if(s[i-1]==t[j-1]) {
    				dp[i][j] = dp[i-1][j-1]+1;
    			}
    			else dp[i][j] = max(dp[i-1][j],dp[i][j-1]) ;
    			//cout<<dp[i][j]<<" ";
    	}
    	//cout<<"\n";
    }

    string ans = "" ;

    ll r=n,c=m;
	while(1)
	{
		if(s[r-1]==t[c-1])
		{
			ans+=s[r-1];
			r--;
			c--;
		}
		else
		{
			if(dp[r-1][c]>dp[r][c-1])
			{
				r--;
			}
			else c--;
		}
		//cout<<r<<" "<<c<<" "<<ss<<nl;
		if(r<1 || c<1)break;
	}
    reverse(ans.begin(),ans.end());
    cout<< ans; 

}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t=1;
    //pre();
    //cin>>t;
    while(t--)
    {
      solve();
    }  
}


// Xorawar

Measured memory_bytes: 38552
#!/usr/bin/env python3
import sys
from pprint import pprint

MOD = 1000000007  # type: int

def solve(N: int, M: int, S: "List[int]", T: "List[int]"):
    dp = [[0] * (M + 1) for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0] = 1
    for j in range(M + 1):
        dp[0][j] = 1
    for i in range(N):
        for j in range(M):
            dp[i + 1][j + 1] = dp[i + 1][j] + dp[i][j + 1]
            if not S[i] == T[j]:
                dp[i + 1][j + 1] -= dp[i][j]
            dp[i + 1][j + 1] %= MOD
    #pprint(dp)
    ret = dp[N][M]
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    S = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    T = [ int(next(tokens)) for _ in range(M) ]  # type: "List[int]"
    solve(N, M, S, T)

if __name__ == '__main__':
    main()


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

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

const long long INF = 1LL << 60;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int s; cin>>s;
  
  int a=s/100;
  int b=s%100;
  
  if(a>0 and a<13 and b>0 and b<13) {
    cout<<"AMBIGUOUS";
  } else if(a>0 and a<13) {
    cout<<"MMYY";
  } else if(b>0 and b<13) {
    cout<<"YYMM";
  } else {
    cout<<"NA";
  }
}

Measured memory_bytes: 3616
#include<stdio.h>
int main(void)
{
	int n,c[200][3],sum,i,j,k,ca[200][3];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		for(j=0;j<3;j++){
		    scanf("%d",&c[i][j]);
			ca[i][j]=c[i][j];
		}
	}
	for(i=0;i<3;i++){
		for(j=0;j<n-1;j++){
			for(k=j+1;k<n;k++){
				if(c[j][i]==c[k][i]){
					ca[j][i]=0;
					ca[k][i]=0;
				}
			}
		}
	}
	for(i=0;i<n;i++){
		sum=0;
		for(j=0;j<3;j++){
			sum+=ca[i][j];
		}
		printf("%d\n",sum);
	}
	return 0;
}


Measured memory_bytes: 2048
chomp($n = <>);

while(<>){
	chomp;
	push(@s, $_);
	push(@org, $_);
}

@s = sort {$b <=> $a} @s;

for (0 .. ($n - 1)){
	if($s[0] == $org[$_]){
		print "$s[1]\n";
	}else{
		print "$s[0]\n";
	}
}


Measured memory_bytes: 44668
#include <iostream>
#include <vector>
#include <unordered_map>
#include <numeric>

using namespace std;

int main() {
    long n,x,m;
    cin >> n >> x >> m;

    int k = log2(n) + 1;
    vector tb(k+1, vector(m, -1LL));
    vector sum(k+1, vector(m, 0LL));
    unordered_map<long,bool> mp;

    for (long i=0; i<m; i++) tb[0][i] = i*i % m;
    iota(sum[0].begin(), sum[0].end(), 0);

    for (int i=0; i<k; i++) {
        for (int j=0; j<m; j++) {
            if (tb[i][j] == -1) tb[i+1][j] = -1;
            else {
                sum[i+1][j] = sum[i][j] + sum[i][tb[i][j]];
                tb[i+1][j] = tb[i][tb[i][j]];
            }
        }
    }

    long ans = 0;
    for (int i=0; i<=k; i++) {
        if ((n>>i) & 1) {
            ans += sum[i][x];
            x = tb[i][x];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 58624
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;

int main(int argc, const char * argv[]) {
    int N;
    int M;
    int P[100001];
    int Y[100001];
    vector<int> v[100001];
    
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        cin >> P[i] >> Y[i];
        v[P[i]].push_back(Y[i]);
    }
    
    for (int i = 0; i < N; i++) {
        sort(v[i + 1].begin(), v[i + 1].end());
    }
    
    for (int i = 0; i < M; i++) {
        printf("%012lld\n",
               (long long)(P[i]) * 1000000 + int (lower_bound( v[P[i]].begin(), v[P[i]].end() , Y [i]) - v[P[i]].begin()) + 1);
    }
    
    return 0;
}

Measured memory_bytes: 7808
#include <iostream>

int main(){
  int a, b;
  
  std::cin >> a >> b;
  if(a == b){
    std::cout << "a == b" << std::endl;
  }
  else if(a < b){
    std::cout << "a < b" << std::endl;
  }
  else {
    std::cout << "a > b" << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3056
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("x = %d\n", x);
#define debug2(x, y) printf("x = %d, y = %d\n", x, y);
#define debug3(x, y, z) printf("x = %d, y = %d, z = %d\n", x, y, z);
#define debug4(x, y, z, t) printf("x = %d, y = %d, z = %d, t = %d\n", x, y, z, t);
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

const int MAXN = 100005;

int n, A[MAXN], DP[MAXN], ans;

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

    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }

    DP[n - 1] = 0;

    for (int i = n - 2; i >= 0; i--) {
        if (A[i] >= A[i + 1]) {
            DP[i] = DP[i + 1] + 1;
        } else {
            DP[i] = 0;
        }

        ans = max(ans, DP[i]);
    }

    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h> 
using namespace std; 
  
// Driver program to test methods of graph class 
int main() 
{
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n - 1);
    
    for(int i = 0; i < n; i++){
        int tmp;
        cin >> tmp;
        a.at(i) = tmp - 1;
    }
    
    for(int i = 0; i < n; i++){
        cin >> b.at(i);
    }
    
    for(int i = 0; i < n - 1; i++){
        cin >> c.at(i);
    }
    
    int answer = 0;
    
    for(int i = 0; i < n; i++){
        answer += b.at(a.at(i));
        if(i != 0){
            if(a.at(i - 1) + 1 == a.at(i)){
                answer += c.at(a.at(i - 1));
            }
        }
    }
    
    cout << answer << endl;
    
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s;
    cin >> s;
    
    for(int i = 0; i < s.length(); ++i){
        if(i % 2 == 0){
            if(s[i] == 'L'){
                cout << "No\n";
                return 0;
            }
        }
        else{
            if(s[i] == 'R'){
                cout << "No\n";
                return 0;
            }
        }
    }
    
    cout << "Yes\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    int p,q,r; cin >>p>>q>>r;

    cout << min(p+q, min(q+r, r+p)) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

using namespace std;

int nums[3];

int main() {
    scanf("%d%d%d", &nums[0], &nums[1], &nums[2]);
    for (int i = 0; i < 3; i++)
        for (int j = 0; j < 2 - i; j++)
            if (nums[j+1] < nums[j])
                swap(nums[j], nums[j + 1]);
    if(nums[0]==5&&nums[1]==5&&nums[2]==7)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}

Measured memory_bytes: 1548
using System;

namespace ABC127A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            string[] ss = Console.ReadLine().Split(' ');
            a = int.Parse(ss[0]);
            b = int.Parse(ss[1]);
            if (a >= 13)
                Console.WriteLine(b);
            else if (a >= 6 && a <= 12)
                Console.WriteLine(b / 2);
            else if (a <= 5)
                Console.WriteLine(0);
            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define all(v) (v).begin(),(v).end()
#define clr(t,v) memset(t,(v),sizeof(t))
template<class T1, class T2>ostream& operator<<(ostream& os, const pair<T1, T2>&a)
{
   return os << "(" << a.first << "," << a.second << ")";
}
template<class T>void pv(T a, T b)
{
   for(T i = a; i != b; ++i)
      cout << (*i) << " ";
   cout << endl;
}
template<class T>void chmin(T&a, const T&b)
{
   if(a > b)
      a = b;
}
template<class T>void chmax(T&a, const T&b)
{
   if(a < b)
      a = b;
}

int nextInt()
{
   int x;
   scanf("%d", &x);
   return x;
}

struct p {
   int a, b, c;
   p(int x, int y, int z): a(x), b(y), c(z) {}

};
typedef pair<p, int> pin;
set<long long> st;
long long f(int a, int b, int c)
{

   return a * 10000000000LL + b * 1000000 + c;
}
int main()
{
   int a[3];
   while(cin >> a[0] >> a[1] >> a[2]) {
      sort(a, a + 3);

      int ans ;
      if((a[1] - a[0]) & 1 )
         ans  = (a[1] - a[0] + 1) / 2 + a[2] - a[1] + 1;
      else
         ans  = (a[1] - a[0]) / 2 + a[2] - a[1];
      cout << ans << endl;


   }

   return 0;
}


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

int main()
{
    int a, b, c, d, s1, s2;
    cin >> a >> b >> c >> d;
    s1 = a * b;
    s2 = c * d;
    if (s1 > s2)
        cout << s1 << endl;
    else
        cout << s2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
    ll a, b, k;
    cin >> a >> b >> k;

    rep (i, k) {
        if (i % 2 == 0) {
            if (a % 2 == 1) {
                a--;
            }
            a /= 2;
            b += a;
        }
        else {
            if ( b % 2) {
                b--;
            }
            b /= 2;
            a += b;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()
{

    string integer;
    cin>>integer;
    char charray[4];
    integer.copy(charray, 4);
    if (((charray[0]==charray[1]) && (charray[1]==charray[2]) )|| ((charray[1]==charray[2]) && (charray[2]==charray[3])))
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main() {
    int a, b;
    char op;
    while(1){
        cin >> a >> op >> b;
        if(op == '?') break;
        else if( op == '+') cout << a + b << endl;
        else if( op == '-') cout << a - b << endl;
        else if( op == '*') cout << a * b << endl;
        else if( op == '/') cout << a / b << endl;
        else continue;
    }
    return 0;
}


Measured memory_bytes: 3060
class Restaurant:
    def __init__(self, id, city, score):
        self.id = id
        self.city = city
        self.score = score

    def __lt__(self, other):
        if (self.city != other.city):
            return self.city < other.city
        else:
            return self.score > other.score


n = int(input())
restaurants = list()
for i in range(n):
    tmp = input().split()
    c = tmp[0]
    s = int(tmp[1])
    restaurants.append(Restaurant(i + 1, c, s))

restaurants.sort()

for r in restaurants:
    print(r.id)


Measured memory_bytes: 3060
#https://atcoder.jp/contests/abc086/tasks/arc089_a

n = int(input())
data = [list(map(int, input().split())) for _ in range(n)]
data.insert(0, [0, 0, 0])
ans = 'Yes'

for i in range(n):
    time = data[i+1][0] - data[i][0]
    distance = abs(data[i+1][1] - data[i][1]) + abs(data[i+1][2] - data[i][2])
    if time < distance or time%2 != distance%2:
        ans = 'No'
        break

print(ans)


Measured memory_bytes: 27300
#include <iostream>
using namespace std;
int main()
{
    int a;cin>>a;
    int b;cin>>b;
    int c;cin>>c;
    int d;cin>>d;
    int e=a*b;
    int f=c*d;
    if(e>=f)
        cout<<e;
    else
        cout<<f;
   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    ll n, a, b;
    cin>>n>>a>>b;
    ll ans = (n/(a+b))*a;
    ll rem = MIN2(a, n%(a+b));
    ans += rem;
    cout<<ans<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair 
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
const ll INF=1000000000000000;

struct edge{ll from,to,cost;};//?から?まで?コスト
edge es[2500];//辺

vector<ll> d(1001,0);//最短距離

ll N,M;//頂点数、辺数

void shortest_path(ll s){ //s番目の頂点からの各点の最短距離を出す
    rep(i,N+1) d[i]=INF;
    d[s]=0;
    rep(j,N*2){
        bool update=false;
        rep(i,M){
            edge e=es[i];
            if(d[e.from]!=INF && d[e.to]>d[e.from]+e.cost){
				d[e.to]=d[e.from]+e.cost;
				if(j>=N) d[e.to]=-INF;

                update=true;
            }
        }
        if(!update) break;
    }
}

int main(){
	cin>>N>>M;//辺数
    //Eコの辺の情報入力
    rep(i,M){
        ll from,to,cost; cin>>from>>to>>cost;
        es[i].from=from;
        es[i].to=to;
        es[i].cost=-cost;
    }

	shortest_path(1);
	if(-d[N]==INF) cout<<"inf";
	else cout<<-d[N];
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n, m, a, b;
	cin >> n >> m >> a >> b;
	vector<string> field(n, string(m, '.'));
	if(n % 2 == 1){
		for(int i = 0; a > 0 && i + 1 < m; i += 2){
			field[n - 1][i]     = '<';
			field[n - 1][i + 1] = '>';
			--a;
		}
	}
	if(m % 2 == 1){
		for(int i = 0; b > 0 && i + 1 < n; i += 2){
			field[i][m - 1]     = '^';
			field[i + 1][m - 1] = 'v';
			--b;
		}
	}
	for(int i = 0; i + 1 < n; i += 2){
		for(int j = 0; j + 1 < m; j += 2){
			if(a >= 2){
				field[i + 0][j + 0] = '<';
				field[i + 0][j + 1] = '>';
				field[i + 1][j + 0] = '<';
				field[i + 1][j + 1] = '>';
				a -= 2;
			}else if(b >= 2){
				field[i + 0][j + 0] = '^';
				field[i + 0][j + 1] = '^';
				field[i + 1][j + 0] = 'v';
				field[i + 1][j + 1] = 'v';
				b -= 2;
			}else if(a > 0){
				field[i + 0][j + 0] = '<';
				field[i + 0][j + 1] = '>';
				a -= 1;
			}else if(b > 0){
				field[i + 0][j + 0] = '^';
				field[i + 1][j + 0] = 'v';
				b -= 1;
			}
		}
	}
	if(n >= 3 && m >= 3 &&
	   n % 2 == 1 && m % 2 == 1 &&
	   b == 1 &&
	   field[n - 3][m - 3] == '<' &&
	   field[n - 3][m - 1] == '^' &&
	   field[n - 2][m - 3] == '.' &&
	   field[n - 1][m - 3] == '<')
	{
		field[n - 3][m - 3] = '<';
		field[n - 3][m - 2] = '>';
		field[n - 3][m - 1] = '^';
		field[n - 2][m - 1] = 'v';
		field[n - 2][m - 3] = '^';
		field[n - 1][m - 3] = 'v';
		field[n - 1][m - 2] = '<';
		field[n - 1][m - 1] = '>';
		--b;
	}
	if(a > 0 || b > 0){
		cout << "NO" << endl;
	}else{
		cout << "YES" << endl;
		for(const auto& line : field){ cout << line << endl; }
	}
	return 0;
}


Measured memory_bytes: 2304
a,b=map(int,input().split())
s=str(input())
c=0-b
if len(s) == a+b+1:
  if s[:a].isdecimal()==True and s[c:].isdecimal()==True and s[a]=="-":
    print("Yes")
  else:
    print("No")
else:
  print("No")

Measured memory_bytes: 3060
S = input()

mod = 10**9+7
N = len(S)
ans = 0

memo = {}
for i in range(1000):
    s = str(i).zfill(3)
    memo[s] = [0 for _ in [0]*13]
    memo[s][i%13] = 1

def rep_Q_count(s):
    memo[s] = [0 for _ in [0]*13]
    for q in range(10):
        s2 = s.replace("?",str(q),1)
        for i,n in enumerate(memo[s2]):
            memo[s][i] += n

for i in range(100):
    s = str(i).zfill(2)
    rep_Q_count(s+"?")
    rep_Q_count(s[0]+"?"+s[1])
    rep_Q_count("?"+s)
for i in range(10):
    s = str(i)
    rep_Q_count(s+"??")
    rep_Q_count("?"+s+"?")
    rep_Q_count("??"+s)
rep_Q_count("???")

s0 = S[max(0,N-3):N].zfill(3)
dp = memo[s0][:]
for i in range(1,(N-1)//3+1):
    s = S[max(0,N-(i+1)*3):N-i*3].zfill(3)
    j = i%2
    tmp = memo[s]
    dp2 = [0]*13
    for k,n in enumerate(tmp):
        for l,m in enumerate(dp):
            dp2[(l+k*((-1)**j))%13] += n*m
    dp = dp2
    for i in range(13):
        dp[i] %= mod
print(dp[5])

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ld, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = 105;

int dp[N][N];
char conf[N][N];

int main(){
  fastIO;
  int n, m;
  cin >> n >> m;
  for(int i = 0 ; i <= n; i ++ ){
    for(int j = 0 ; j <= m ; j ++ ){
      conf[i][j] = '.';
      dp[i][j] = (int)1e9;
    }
  }
  for(int i = 1; i <= n; i ++ ){
    for(int j = 1; j <= m ; j ++ ){
      cin >> conf[i][j];
      if(i==1 && j == 1){
        dp[i][j] = (conf[i][j] == '#');
      }
      else{
        dp[i][j] = min(dp[i][j], dp[i-1][j] + (conf[i][j] == '#' && conf[i-1][j] == '.'));
        dp[i][j] = min(dp[i][j], dp[i][j-1] + (conf[i][j] == '#' && conf[i][j-1] == '.'));
      }
    }
  }
  cout << dp[n][m];
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long 
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define REP(i,n) for (int i=0; i<(n); i++)
#define RREP(i,n) for (int i=(n-1); i>=0; i--)
#define ALL(x) x.begin(),x.end()
#define SZ(x) x.size()
#define SQ(x) (x)*(x)
#define MNTO(a,b) a = min(a,(__typeof__(a))(b))
#define MXTO(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define debug(x) cerr<<#x<<" is "<<x<<endl
using namespace std;

// #define int ll

const int iinf = 1<<29;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;


void GG(){cout<<"NO\n"; exit(0);}

ll mpow(ll a, ll n){ // a^n % mod
    ll re=1;
    while (n>0){
        if (n&1) re = re*a %mod;
        a = a*a %mod;
        n>>=1;
    }
    return re;
}

ll inv (ll b){
    if (b==1) return b;
    return (mod-mod/b) * inv(mod%b) % mod;
}

const int maxn = 104;



main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    ll re = 0;
    ll i, j, l, foo;
    cin>>i>>re>>foo>>j>>l>>foo>>foo;
    ll r2 = re;
    re += (i/2 + j/2 + l/2)*2;
    if (i && j && l){
        i--; j--; l--;
        r2 += 3 + (i/2 + j/2 + l/2)*2;
    }
    cout<<max(r2, re)<<endl;
} 

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

int main(void)
{
  char s[128],t[128];
  scanf("%s %s",s,t);
  int len=(int)strlen(s);

  if(strcmp(s,t)==0){
    puts("Yes");
    return 0;
  }

  int count=len-1;
  while(count>0){
    char c=s[len-1];
    for(int i=len-1;i>0;i--){
      s[i]=s[i-1];
    }
    s[0]=c;
    if(strcmp(s,t)==0){
      puts("Yes");
      return 0;
    }
    count--;
  }

  puts("No");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Here your code !
    int n; // ???????????°
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    int min, ans;
    min = a[0];
    ans = a[1] - a[0];
    for(int i=1;i<n;i++) {
        if(a[i] < min) {
            min = a[i];
        } else if(ans < a[i] - min) {
            ans = a[i] - min;
        }
    }
    cout << ans << endl;
    
}

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

bool comp(const pair<string,int> a, const pair<string,int> b) {
  if (a.first != b.first)
    return a.first < b.first; // 高い順に並べたいので演算子を逆に
  else{
      return a.second > b.second;
  }
}

priority_queue<long long int,vector<long long int>, greater<long long int>> PQ;
priority_queue<long long int> PQ1;

int main(){
  int P,Q,R;
  vector<int> list;

  for(int i = 0;i<3;i++){
    int x;
    cin >>x;
    list.push_back(x);
  }

  sort(list.begin(),list.end());
  cout <<list[0]+list[1]<<endl;


  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <map>
#define ull unsigned long long
#define P 13331ll
#define N 5050
using namespace std;
int n,l,r,ans;
char ch[N];
map<ull,int> h;
ull  Hash[N],pow[N]={1};
inline ull f(int l,int r){ return Hash[r]-Hash[l-1]*pow[r-l+1]; }
inline bool check(int x){
	h.clear();
	for(int i=x;i<=n;i++){
		ull k=f(i-x+1,i);
		int p=h[k];
		if(p==0) h[k]=i;
		else if(p<=i-x) return 1;
	}
	return 0;
}
int main()
{
	scanf("%d",&n);
	scanf("%s",ch+1);
	for(int i=1;i<=n;i++)
		Hash[i]=Hash[i-1]*P+ch[i],pow[i]=pow[i-1]*P;
	l=1; r=n;
	while(l<=r){
		int mid=(l+r)>>1;
		if(check(mid)) ans=mid,l=mid+1;
		else r=mid-1;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<vector>
#include<algorithm>
//線分={始点,終点}（始点<=終点）
using lseg=std::pair<double,double>;
lseg init(){
    return {0,-1};
}
bool is_valid(lseg a){
    return a.first<=a.second;
}
void add_point(lseg &a,double x){
    if(!is_valid(a)) a={x,x};
    else a={std::min(a.first,x),std::max(a.second,x)};
}
lseg merge(lseg a,lseg b){
    if(!is_valid(a))return b;
    if(!is_valid(b))return a;
    return {std::min(a.first,b.first),std::max(a.second,b.second)};
}
lseg merge(lseg a,lseg b,lseg c){
    return merge(merge(a,b),c);
}
lseg move(lseg a,double t){
    return {a.first+t,a.second+t};
}
double len(lseg a){
    if(!is_valid(a)) return 0;
    return a.second-a.first;
}
double len(double t,lseg a_plus,lseg a_const,lseg a_minus){
    return len(merge(move(a_plus,t),a_const,move(a_minus,-t)));
}
//a+v_a*t==b+v_b*tなるt>=0が存在すればevに追加
void add_event(std::vector<double> &ev, double a, double v_a, double b, double v_b){
    if(v_a!=v_b&&(a-b)/(v_b-v_a)>=0)ev.push_back((a-b)/(v_b-v_a));
}
void add_event(std::vector<double> &ev, lseg a, double v_a, lseg b, double v_b){
    if(is_valid(a)&&is_valid(b)){
        add_event(ev,a.first,v_a,b.first,v_b);
        add_event(ev,a.first,v_a,b.second,v_b);
        add_event(ev,a.second,v_a,b.first,v_b);
        add_event(ev,a.second,v_a,b.second,v_b);
    }
}
int main(){
    int n;
    scanf("%d",&n);
    lseg x_plus=init(),x_const=init(),x_minus=init(),y_plus=init(),y_const=init(),y_minus=init();
    for(int i=0;i<n;i++){
        int x,y;
        char d;
        scanf("%d%d %c",&x,&y,&d);
        if(d=='R'){
            add_point(x_plus,x);
            add_point(y_const,y);
        }else if(d=='L'){
            add_point(x_minus,x);
            add_point(y_const,y);
        }else if(d=='U'){
            add_point(x_const,x);
            add_point(y_plus,y);
        }else{
            add_point(x_const,x);
            add_point(y_minus,y);
        }
    }
    std::vector<double> ev;
    ev.push_back(0);
    add_event(ev,x_plus,1,x_const,0);
    add_event(ev,x_plus,1,x_minus,-1);
    add_event(ev,x_minus,-1,x_const,0);
    add_event(ev,y_plus,1,y_const,0);
    add_event(ev,y_plus,1,y_minus,-1);
    add_event(ev,y_minus,-1,y_const,0);
    double area_min=1e30;
    for(auto &t:ev){
        auto area_tmp=len(t,x_plus,x_const,x_minus)*len(t,y_plus,y_const,y_minus);
        if(area_tmp<area_min)area_min=area_tmp;
    }
    printf("%.10lf\n",area_min);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	char a,b,c,d;
	cin>>a>>b>>c>>d;
	if((a==b&&b==c)||(b==c&&c==d)){
		cout<<"Yes";
	} 
	else{
		cout<<"No";
	}
	re 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
int Q;
long long a,b,c;

int Solve() {
	if(a>b)
		c=a,a=b,b=c;
	if(a==b||a==b-1) return 2*a-2;
	c=sqrt(a*b);
	if(c*c==a*b) c--;
	if(c*(c+1)<a*b)
		return 2*c-1;
	else return 2*c-2;
}

int main() {
	scanf("%d",&Q);
	for(int i=1;i<=Q;i++) {
		scanf("%lld %lld",&a,&b);
		printf("%d\n",Solve());
	}
	return 0;
}

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

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define Itr(i, c) for(typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(){
	int a, b, c; cin >> a >> b >> c;
	cout << max(a * 10 + b + c, max(a + b * 10 + c, a + b + c * 10)) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 300005

int n,k;

int main(){
	scanf("%d %d",&n,&k);
	if(k>(n-1)*(n-2)/2){
		puts("-1");
		return 0;
	}
	if(!k){
		printf("%d\n",n*(n-1)/2);
		for(int i=1;i<=n;i++)
			for(int j=i+1;j<=n;j++)
				printf("%d %d\n",i,j);
		return 0;
	}
	printf("%d\n",(n-1)*(n-2)/2-k+n-1);
	for(int i=1;i<n;i++)
		printf("%d %d\n",i,n);
	int cnt=(n-1)*(n-2)/2-k;
	for(int i=1;i<n&&cnt;i++)
		for(int j=i+1;j<n&&cnt;j++){
			cnt--;
			printf("%d %d\n",i,j);
		}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int n, S[100000];

int binarySearch(int key){
  int left = 0, middle,  right = n;
  while(left < right){
    middle = (left + right) / 2;
    if(S[middle] == key)  return 1;
    if(key < S[middle])   right = middle;
    else                           left = middle+1;
  }

  return 0;
}

int main(){
  int q, T[100000], i, cnt = 0;

  scanf("%d", &n);
  for(i = 0; i < n; i++)
    scanf("%d", &S[i]);

  scanf("%d", &q);
  for(i = 0; i < q; i++)
    scanf("%d", &T[i]);

  for(i = 0; i < q; i++){
    if(binarySearch(T[i])){
      cnt++;
    }
  }

  printf("%d\n", cnt);

  return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<60;
 
int main() {
    int N, M;
    cin >> N >> M;

    tuple<int, int, int> data[M];

    for (int i = 0; i < M; ++i) {
        int p, y;
        cin >> p >> y;
        data[i] = make_tuple(y, p, i);
    }

    sort(data, data + M);

    int cnt[N + 1];
    fill(cnt, cnt + N + 1, 0);

    pair<int, int> id[M];

    for (int i = 0; i < M; ++i) {
        int y, p, idx;
        tie(y, p, idx) = data[i];
        ++cnt[p];
        id[idx] = make_pair(p, cnt[p]);
    }

    for (int i = 0; i < M; ++i) {
        cout << setw(6) << setfill('0') << id[i].first;
        cout << setw(6) << setfill('0') << id[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 3840