akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int a, b;
	cin >> a >> b;
	if(a + b == 15) cout << "+" << endl;
	else if(a * b == 15) cout << "*" << endl;
	else cout << "x" << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1001001001
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
int main() {
    int n;cin >> n;
    n %= 1000;
    n = 1000 - n;
    if(n == 1000) cout << 0 << endl;
    else cout << n << endl;
}

Measured memory_bytes: 3628
import std.stdio, std.string, std.algorithm, std.array, std.range, std.conv,
    std.typecons, std.math, std.container, std.format, std.numeric;

auto maxE(T)(const scope T xs)
{
    ElementType!(T) x = xs[0];
    foreach (y; xs)
    {
        if (y > x)
        {
            x = y;
        }
    }
    return x;
}

auto minE(T)(const scope T xs)
{
    ElementType!(T) x = xs[0];
    foreach (y; xs)
    {
        if (y < x)
        {
            x = y;
        }
    }
    return x;
}

alias T = Tuple!(long, long);
void main(string[] args)
{
    long h, n;
    readf("%d %d\n", &h, &n);

    auto as = new long[](n);
    auto bs = new long[](n);

    foreach (i; 0 .. n)
    {
        long a, b;
        readf("%d %d\n", &a, &b);
        as[i] = a;
        bs[i] = b;
    }
    long maxa = maxE(as);

    long[] hs = new long[](h + maxa + 1);
    foreach (i; 0 .. hs.length)
    {
        hs[i] = long.max / 10;
    }
    hs[0] = 0;
    foreach (i; 0 .. h + 1)
    {
        foreach (j; 0 .. n)
        {
            hs[i + as[j]] = min(hs[i + as[j]], hs[i] + bs[j]);
        }
    }
    writeln(hs[h .. $].minE);
}


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

int main(){
  ll D;
  cin>>D;
  VL C(26);
  rep(i,26) cin>>C[i];
  VVL S(D,VL(26));
  rep(i,D) rep(j,26) cin>>S[i][j];
  VL T(D);
  rep(i,D){
    ll X=0;
    rep(j,26) if(S[i][X]<S[i][j]) X=j;
    T[i]=X+1;
  }
  
  ll ans=0;
  VL L(26);
  rep(i,D){
    ll tmp=0;
    L[T[i]-1]=i+1;
    rep(j,26) tmp+=C[j]*(i+1-L[j]);
    ans+=S[i][T[i]-1]-tmp;
  }
  
  vector< set<ll> > X(26);
  rep(i,D) X[T[i]-1].insert(i+1);
  rep(i,26) X[i].insert(0);
  rep(i,26) X[i].insert(D+1);
  ll M=1000000;
  VL d(M),q(M);
  rep(i,M) d[i]=rand()%D+1;
  rep(i,M) q[i]=rand()%26+1;
  ll cnt=0;
  VL A(0),B(0),E(0);
  ll ans2=ans;
  ll num=10;
  rep(i,M){
    ll prv=T[d[i]-1];
    ll nxt=q[i];
    if(prv==nxt) continue;
    auto itr=ub(all(X[prv-1]),d[i]);
    ll tmp=*itr;
    itr--;
    itr--;
    T[d[i]-1]=q[i];
    auto itr2=ub(all(X[nxt-1]),d[i]);
    ll tmp2=*itr2;
    itr2--;
    ans=ans-S[d[i]-1][prv-1]-C[prv-1]*(d[i]-*itr)*(tmp-d[i]);
    X[prv-1].erase(d[i]);
    ans=ans+S[d[i]-1][nxt-1]+C[nxt-1]*(d[i]-*itr2)*(tmp2-d[i]);
    X[nxt-1].insert(d[i]);
    if(ans>ans2){
      ans2=ans;
      cnt=0;
      A.clear();
      B.clear();
      E.clear();
    }else if(cnt<num){
      cnt++;
      A.pb(prv);
      B.pb(nxt);
      E.pb(d[i]);
    }else{
      ans=ans2;
      rep(j,num){
        T[E[num-1-j]-1]=A[num-1-j];
        X[B[num-1-j]-1].erase(E[num-1-j]);
        X[A[num-1-j]-1].insert(E[num-1-j]);
      }
      cnt=0;
      A.clear();
      B.clear();
      E.clear();
    }
  }
  rep(i,D) cout<<T[i]<<endl;
}


Measured memory_bytes: 19100
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const int inf = 1e+9;


int main() {
	string s;
	cin >> s;

	for (char c : s) {
		if (c == 'P' || c == 'D') {
			cout << c;
		} else {
			cout << 'D';
		}
	}
	cout << endl;
	

	return 0;
}


Measured memory_bytes: 3524
#include <iostream>
#include <cmath>
using namespace std;
using ll = long long;

int main()
{
    double n;
    while (cin >> n)
    {
        if (n == 0)
            return 0;
        double p = 0, s[1110], m = 0;
        for (int i = 0; i < n; i++)
        {
            cin >> s[i];
            m += s[i] / n;
        }
        for (int i = 0; i < n; i++)
        {
            p += (s[i] - m) * (s[i] - m) / n;
        }
        printf("%lf\n", sqrt(p));
    }
}



Measured memory_bytes: 3200
#include <cstdio>   /* cin, cout */
#include <list>     /* list */
#include <string>   /* string */
#include <algorithm>

using namespace std;

int main()
{
    int q, x;
    string com;
    list<int> l;
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%s", com.c_str());
        if (*com.begin() == 'i') {  // insert
            scanf("%d", &x);
            l.push_front(x);
        }
        else if (*(com.begin() + 6) == 'L') { // deleteLast
            l.pop_back();
        }
        else if (*(com.begin() + 6) == 'F') { // deleteFirst
            l.pop_front();
        }
        else {  // delete
            scanf("%d", &x);
            for (list<int>::iterator it = l.begin(); it != l.end(); it++) {
                if (*it == x) {
                    l.erase(it);
                    break;
                }
            }
        }
    }
    int i = 0;
    for (list<int>::iterator it = l.begin(); it != l.end(); it++) {
        if (i++)    printf(" ");
        printf("%d", *it);
    }
    printf("\n");

    return 0;
}



Measured memory_bytes: 34036
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        int k = in.ni();
        dfs(2000000);
        out.println((k/2)*((k+1)/2));
    }
    public static void dfs(long i){
        if(i!=0)dfs(i-1);
        return;
    }
    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 104404
# -*- coding: utf-8 -*-
a, b, k = list(map(int, input().split()))

def gcd(a, b):
    ans=[]
    for i in range(1, max(a,b)+1):
        if a%i==0 and b%i==0:
            ans.append(i)
    return ans
print(gcd(a, b)[-k])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;
    
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,q;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll dat[ohara];
    
//------ Believe yourself as a genius!!!!!! ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>k;
    rep(i,k){
        cin>>n>>m;
        ll hasi=m/2;
        ll ki,gu;
        if(m%2==0){
            gu=0;
            ki=1;
        }
        else{
            ki=0;
            gu=1;
        }
        while(1){
            if(hasi<n)break;
            int vi1[10]={};
            int vi2[10]={};
            if(hasi%2==1){
                vi1[gu]++;
                rep(j,3){
                    if(vi1[j]==0){
                        ki=j;
                        break;
                    }
                }
                vi2[ki]++;
                vi2[gu]++;
                rep(j,3){
                    if(vi2[j]==0){
                        gu=j;
                        break;
                    }
                }
            }
            else{
                vi1[gu]++;
                vi2[gu]++;
                vi1[ki]++;
                rep(j,3){
                    if(vi1[j]==0){
                        gu=j;
                        break;
                    }
                }
                vi2[gu]++;
                rep(j,3){
                    if(vi2[j]==0){
                        ki=j;
                        break;
                    }
                }
            }
            //cout<<hasi<<" "<<gu<<" "<<ki<<"\n";
            hasi/=2;
        }
        if(n%2==1)dat[i]=ki;
        else dat[i]=gu;
    }
    ans=dat[0];
    rrep(i,1,k){
        ans=(ans xor dat[i]);
    }
    if(ans==0)Cout("tubuann");
    else Cout("mo3tthi");
    return 0;
}


Measured memory_bytes: 4012
#include <iostream>
#include <vector>
#include <cstdint>

using i64 = int64_t;
using i32 = int32_t;

void run() {
    i32 n;
    std::cin >> n;
    const i64 m = 60;
    std::vector<i64> cnt(60, 0);
    for (i32 i = 0; i < n; ++i) {
        i64 a;
        std::cin >> a;
        for (i64 j = 0; j < m; ++j) {
            cnt.at(j) += (a >> j) & 1;
        }
    }
    const i64 mod = 1000000000 + 7;
    i64 ans = 0;
    for (i64 j = 0; j < m; ++j) {
        i64 c = cnt.at(j);
        ans = (ans + ((i64)1 << j) % mod * c % mod * (n - c)) % mod;
    }
    std::cout << ans << '\n';
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    run();
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  priority_queue<int> que;
  while(cin>>s&&s!="end"){
    if(s=="insert") {
      int x;
      cin >> x;
      que.push(x);
    } else {
      cout << que.top() << endl;
      que.pop();
    }
  }
}


Measured memory_bytes: 7020
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split(" "))))

tmp = A
t_min = min(A)
while True:
    tmp = A % t_min
    if sum(tmp) == 0:
        break
    t_min = min(tmp[tmp > 0])

print(t_min)


Measured memory_bytes: 23116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)

int hyou[200005];

int main(){
    int n, k; cin >> n >> k;
    rep(i, n){
        int a; cin >> a;
        hyou[a - 1]++;
    }
    int ans = 0;
    sort(hyou, hyou + n);
    for(int i = 0; i < n - k; i++){
        ans += hyou[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
n=int(input())
w=[""]*n
for i in range(n):
  w[i]=input()
flag=0
for i in range(n-1):
  if (w[i][-1]!=w[i+1][0] or w.count(w[i+1])>1):
    flag=1
print("Yes" if flag==0 else "No")



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,first,second,third,fourth;
  cin >> n;
  first = n / 1000;
  second = n / 100 % 10;
  third = n / 10 % 10;
  fourth = n % 10;
  string res = "No";
  if(first == second && second == third){
    res = "Yes";
  }else if(second == third && third == fourth){
    res = "Yes";
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX;
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;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	string s;
	ll i,k;
	cin>>s>>k;
	for(i=0;i<min((ll)s.size(),k);i++){
		if(s[i]>='2'){cout<<s[i]<<endl;return 0;}
	}
	cout<<1<<endl;
	
	
	
//////////////////////////////////////////////////////
	return 0;
}


Measured memory_bytes: 256
import itertools
n=int(input())
s=input()
d=[0]
for i in s:
  if i=="W":
    d.append(1)
  else:
    d.append(0)

accum=list(itertools.accumulate(d))
ans=10**9
count=0
for i in range(1,n+1):
  count+=accum[i-1]-accum[0]
  #左のWの数
  count+=(n-i)-(accum[-1]-accum[i])
  #右のEの数
  if ans>count:
    ans=count
  count=0
print(ans)
    

Measured memory_bytes: 17932
# -*- coding: utf-8 -*-
# B: Coins
# モジュールのインポート
import itertools

# 定数の定義
A_YEN = 500
B_YEN = 100
C_YEN = 50

# 標準入力の取得
A = int(input())
B = int(input())
C = int(input())
X = int(input())

# 全探索を行い、パターン数を求める
A_pattern_list = range(A+1)
B_pattern_list = range(B+1)
C_pattern_list = range(C+1)

answer = 0
for A_pattern,B_pattern,C_pattern in itertools.product(A_pattern_list, B_pattern_list, C_pattern_list):
    amount = A_YEN*A_pattern + B_YEN*B_pattern + C_YEN*C_pattern
    if amount == X:
        answer +=1

print(answer)

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

int main(void){
  string S, T;
  cin >> S >> T;
  int flag = 0;
  for(int j = 0; j < T.length(); j++){
    if(T[j] == S[0]){
      for(int i = 1; i < S.length(); i++){
        if(T[(j + i) % T.length()] != S[i]) {
          flag = 0;
          break;
        }
        else flag = 1;
      }
      if(flag){ 
        cout << "Yes";
        break;
      }
    }
  }
  
  if(!flag) cout << "No";
 return 0; 
}

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define Cin(x) cin >> x
#define Cin2(x,y) cin >> x >> y
#define Cin3(x,y,z) cin >> x >> y >> z
#define Cin4(w,x,y,z) cin >> w >> x >> y >> z
#define Cout(x) cout << x << "\n"
#define Cout2(x,y) cout << x << y << "\n"
#define Cout3(x,y,z) cout << x << y << z << "\n"
#define Cout4(w,x,y,z) cout << w << x << y << z << "\n"
#define Kaigyou cout << "\n"
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define Size(n) (n).size()
#define All(v) (v).begin(), (v).end()

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

    ll n,m,ans=0;
    string s[101],t[101];
    Cin(n);
    rep(i,n) Cin(s[i]);
    Cin(m);
    rep(i,m) Cin(t[i]);
    map<string,ll> mp;
    rep(i,n) mp[s[i]]++;
    rep(i,m) mp[t[i]]--;
    rep(i,n){
        ans = max(ans,mp[s[i]]);
    }
    Cout(ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int n, x, sum;

    while (1) {
        scanf("%d %d", &n, &x);
        
        if (n == 0 && x == 0) break;
        sum = 0;

        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++)
                for(int k = 1; k <= n; k++) {
                    if(i != j && j != k && i != k) {
                        if ((i + j + k) == x) sum++;
                    }
                }
        printf("%d\n", sum/6);
    }

    return 0;
}


Measured memory_bytes: 2088
#import pysnooper
#import os,re,sys,operator,math,heapq,string
from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

h,w=0,0
l=0
n=int(input().rstrip())
a=sorted(Counter([int(i) for i in input().split()]).most_common(),reverse=1)
#print(a)
for i in range(len(a)):
    if a[i][1]>=4:
        print(a[i][0]**2)
        exit()
    elif a[i][1]>=2:
        h=a[i][0]
        l=i+1
        break

for i in range(l,len(a)):
    if a[i][1]>=2:
        w=a[i][0]
        break
print(h*w)

Measured memory_bytes: 21532
s  = input()
l = int(s[0]) * 10 + int(s[1])
r = int(s[2]) * 10 + int(s[3])

res = "NA"
if l == 0:
    if 1 <= r <= 12:
        res = "YYMM"
    else:
        res = "NA"
elif 1 <= l <= 12:
    if 1 <= r <= 12:
        res ="AMBIGUOUS"
    else:
        res = "MMYY"
else:
    if 1 <= r <= 12:
        res = "YYMM"
    else:
        res = "NA"

print(res)


Measured memory_bytes: 8956
#include <iostream>
#include <list>
#include <vector>
#include <string>
#include <cmath>

typedef long long ll;

using namespace std;
int main(){
    int N, M;
    cin >> N;
    int T[N] = {};
    int sum = 0;
    for (int i = 0; i < N; i++) {
    	cin >> T[i];
    	sum += T[i];
    }
    cin >> M;
    int P[M], X[M];
    for (int i = 0; i < M; i++) {
    	int p;
    	cin >> p >> X[i];
    	p--;
    	P[i] = p;
    }
    
   	int ans;
    for (int i = 0; i < M; i++) {
    	ans = sum + X[i] - T[P[i]];
    	cout << ans << endl;
    }
}


Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		int a = int.Parse(Console.ReadLine());

		int renzoku = 0;
		bool kekka = false;
		// スペース区切りの整数の入力
		for (int i = 0; i < a; i++ )
		{
			string[] input = Console.ReadLine().Split(' ');
			int b = int.Parse(input[0]);
			int c = int.Parse(input[1]);

			if (b == c) renzoku++;
			else renzoku = 0;

			if (renzoku >= 3)
			{
				kekka = true;
			}
		}
		//出力
		if (kekka)
			Console.WriteLine("Yes");
		else
			Console.WriteLine("No");
	}
}

Measured memory_bytes: 27492
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;

int main()
{
    string s;
    int n;
    cin >> s >> n;
    for(int i = 0; i < s.size(); i++){
        int tmp = 'a' + 26 - s[i];
        if(i != s.size()-1){
            if(tmp <= n && s[i] != 'a'){
                n -= tmp;
                cout << 'a';
            }else{
                cout << s[i];
            }
        }else{
            n %= 26;
            if('z' - s[i] < n){
                char c = s[i] - (26-n);
                cout << c;
            }else{
              
                char c = s[i] + n;
                cout << c;
              
            }
        }
    }
}


Measured memory_bytes: 512
#include <cstdio>
#include <queue>
using namespace std;

typedef struct{
    int node;
    int weight;
}nw;

bool check[100001];
queue<nw> q[100001];
bool isblack[100001];

void coloring(int n, bool color){
    if(check[n])return;
    //printf("node:%d\n",n);

    check[n] = true;
    isblack[n] = color;

    nw tmp;
    while(!q[n].empty()){
        tmp = q[n].front();
        q[n].pop();
        if(tmp.weight%2==1){
            //printf("u:%d,v:%d,w:%d,->reverse\n",n,tmp.node,tmp.weight);
            coloring(tmp.node,!color);
        }else{
            //printf("u:%d,v:%d,w:%d,->same\n",n,tmp.node,tmp.weight);
            coloring(tmp.node,color);
        }
    }
    return;
}

int main(void){
    int n,u,v,w;
    for(int i=1;i<=n;i++){
        check[i] = false;
    }
    scanf("%d",&n);
    for(int i=1;i<n;i++){
        scanf("%d %d %d",&u,&v,&w);
        nw tmp;
        tmp.node = v;
        tmp.weight = w;
        q[u].push(tmp);
        tmp.node = u;
        tmp.weight = w;
        q[v].push(tmp);
    }
    coloring(1,true);
    for(int i=1;i<=n;i++){
        if(isblack[i])printf("1\n");
        else printf("0\n");
    }
    return 0;
}


Measured memory_bytes: 70144
#include <iostream>
#include <stdio.h>
#include <math.h>
typedef unsigned long long int ll;

using namespace std;

ll Euclid(ll m, ll n){
    if(n == 0)  return m;
    else        return Euclid(n, m % n);
}

int main(){
    ll gcd;    //the greatest common divisor
    ll lcm;    //least common multiple
    ll m, n, tmp;
    while (cin >> m >> n){
        if(m < n){
            tmp = m;
            m = n;
            n = tmp;
        }
        gcd = Euclid(m, n);
        lcm = m * n / gcd;
        cout << gcd << " " << lcm << endl;
    }
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	string S;
	cin >> S;
	bool top, bottom;
	if (S[0] == '0')
	{
		if (S[1] == '0')top = false;
		else top = true;
	}
	else if (S[0] == '1')
	{
		if (S[1] == '0' || S[1] == '1' || S[1] == '2')top = true;
		else top = false;
	}
	else top = false;

	if (S[2] == '0')
	{
		if (S[3] == '0')bottom = false;
		else bottom = true;
	}
	else if (S[2] == '1')
	{
		if (S[3] == '0' || S[3] == '1' || S[3] == '2')bottom = true;
		else bottom = false;
	}
	else bottom = false;

	if (top && bottom)cout << "AMBIGUOUS";
	else if (top)cout << "MMYY";
	else if (bottom)cout << "YYMM";
	else cout << "NA";
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<vector>
#include<cmath>
#include<queue>
#include<map>
#include<set>

using namespace std;

int read()
{
	int ans=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}

const int maxn=2e5;
int n,ans,now=1;

queue<int> qu;

bool check(int x);

int main()
{
	n=read();
	for(int i=1;i<=n;++i)
	{
		int x=read();
		qu.push(x);
	}
	while(!qu.empty())
	{
		while(!qu.empty()&&qu.front()!=now)
			qu.pop(),ans++;
		if(!qu.empty())
			qu.pop();
		now++;
	}
	if(ans==n)
		printf("-1\n");
	else
		printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <string.h>
#include <map>
#define Z class
#define ln cout<<'\n'
#define ll long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
// sort(vec.begin(), vec.end()); std::greater<>()
// reverse(vec.begin(), vec.end());
// scanf("%s",s);
// printf("%d\n",end-start+1);
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<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;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    int a,b,c; cin >> a >> b >> c;
    if(a+b==c || b+c==a || c+a==b) pr("Yes");
    else pr("No");
    
}


Measured memory_bytes: 256
def SOD(n):
    ans=0
    while n>0:
        ans+=n%10
        n=n//10
    return ans
n,a,b=map(int,input().split())
ans=0
for i in range(n):
    if a<=SOD(i+1)<=b:
        ans+=(i+1)
print(ans)

Measured memory_bytes: 39280
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000001;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};

int d[51][51]={};

int main() {

	int h,w;
	char c[51][51];
	cin>>h>>w;

	int t=0;
	rep(i,h){
		rep(j,w){
			cin>>c[j][i];
			if(c[j][i]=='#')t++;
		}
	}
	d[0][0]++;

	queue<pos> que;
	pos pos1={0,0,1};
	que.push(pos1);
	while(!que.empty()){
		pos pos2=que.front();que.pop();
		if(pos2.x==w-1&&pos2.y==h-1){
			cout<<h*w-pos2.cost-t<<endl;
			return 0;
		}
		if(c[pos2.x+1][pos2.y]=='.'&&d[pos2.x+1][pos2.y]==0){
			pos pos3={pos2.x+1,pos2.y,pos2.cost+1};
			que.push(pos3);
			d[pos2.x+1][pos2.y]++;
		}
		if(c[pos2.x][pos2.y+1]=='.'&&d[pos2.x][pos2.y+1]==0){
			pos pos4={pos2.x,pos2.y+1,pos2.cost+1};
			que.push(pos4);
			d[pos2.x][pos2.y+1]++;
		}
		if(c[pos2.x-1][pos2.y]=='.'&&d[pos2.x-1][pos2.y]==0){
			pos pos5={pos2.x-1,pos2.y,pos2.cost+1};
			que.push(pos5);
			d[pos2.x-1][pos2.y]++;
		}
		if(c[pos2.x][pos2.y-1]=='.'&&d[pos2.x][pos2.y-1]==0){
			pos pos6={pos2.x,pos2.y-1,pos2.cost+1};
			que.push(pos6);
			d[pos2.x][pos2.y-1]++;
		}
	}
	cout<<"-1"<<endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vl;
#define endl "\n"
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define b begin
#define e end
#define pi pair<int, int>
#define pii pair<int, pair<int, int> >
#define pl pair<ll, ll>
#define pll pair<ll, pair<ll, ll> >
#define plc pair<ll,char>
#define vpl vector<pl>
#define vplc vector<plc>
#define mod 1e9+7

int main() {
	fio;
ll n,k;
  cin>>n>>k;

  if(k==1)
    	cout<<0<<endl;
  else
    	cout<<n-k<<endl;



	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    bool have[d5];
    fill(have,have+d5,true);
    for(int i=0;i<k;i++){
        int d;
        cin>>d;
        for(int j=0;j<d;j++){
            int x;
            cin>>x;
            x--;
            have[x]=false;
        }
    }
    int res=0;
    for(int i=0;i<n;i++)res+=have[i];
    cout<<res<<endl;
}


Measured memory_bytes: 3736
<?php

fscanf(STDIN,"%d %d %d",$n,$m,$l);

for($i=0; $i<$n; $i++){
    $A[$i] = explode(" ", trim(fgets(STDIN)));
}

for($i=0; $i<$m; $i++){
    $B[$i] = explode(" ", trim(fgets(STDIN)));
}

for($i=0; $i<$n; $i++){
    $C[$i] = array_fill(0, $l, 0);
}
// var_dump($C);
foreach($A as $i=>$a){
    // var_dump($a);
    foreach($B as $j=>$b){
        // var_dump($b);
        foreach($b as $k=>$n){
            // echo $i,$k,$j,PHP_EOL;
            $C[$i][$k] += $n * $a[$j];
        }
    }
    echo implode(" ", $C[$i]),PHP_EOL;
}


Measured memory_bytes: 14400
#include <stdio.h>
int main(void)
{
    int n,i,max=0,ans=0;
    scanf("%d", &n);
    int h[n];
    for(i=0; i<n; i++) scanf("%d", &h[i]);
    for(i=0; i<n; i++)
    {
        if(max<=h[i])
        {
            max=h[i];
            ans++;
        }
    }
    printf("%d", ans);
    return 0;
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define forn(i,o,n) for(int i=o;i<n;i++)
#define int long long
#define endl "\n"
#define mod 1000000007
#define double long double
#define pb push_back
#define mk make_pair
#define swap(x,y) (x^=y^=x^=y)
#define TT int ttt;cin>>ttt;while(ttt--)

using namespace std;

int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b); 
}
bool isPrime(int n){
    if(n < 2)
        return 0;
    if(n < 4)
        return 1;
    if(n % 2 == 0 or n % 3 == 0)
        return 0;
    for(int i = 5; i*i <= n; i += 6)
        if(n % i == 0 or n % (i+2) == 0)
            return 0;
    return 1;
}
int modexpo(int x,int p){
    int res = 1;
    x = x%mod;
    while(p){
        if(p%2)
            res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}

int max(int a,int b){
    if(a>b){
        return a;
    }
    return b;
}

int min(int a,int b){
    if(a<b){
        return a;
    }
    return b;
}
const int N = 2005;
int n,k;
int32_t main(){
    IOS
    int x = 0;
    int sum = 0;
    cin>>n;
    for(int i=1;i<1000000;i++){
        int temp = i*(i+1);
        temp/=2;
        if(temp>n){
            x = i-1;
            break;
        }
    }
    //cout<<x<<" "<<sum<<endl;
    sum = x*(x+1);
    sum/=2;
    int temp = n-sum;
    if(temp == 0){
        cout<<x<<endl;
    }
    else{
        cout<<x+1<<endl;
    }
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int n;
vvi G;
vi in;
bool h=true;
int dfs(int a){
	bitset<5011>bs;
	bs[0]=1;
	int sum=0,out=inf;
	rep(i,G[a].size()){
		int to=G[a][i];
		int p=dfs(to);
		sum+=in[to]+p;
		bs=bs<<p|bs<<in[to];
	}
	rep(i,in[a]+1)if(bs[i])out=min(out,sum-i);
	if(out==inf)h=false,out=1;
	return out;
}
int main(){
	cin>>n;
	G=vvi(n);
	rep(i,n-1){
		int a;cin>>a;
		G[a-1].pb(i+1);
	}
	in=vi(n);
	rep(i,n)cin>>in[i];
	dfs(0);
	if(h)cout<<"POSSIBLE"<<endl;
	else cout<<"IMPOSSIBLE"<<endl;
}









Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,x,cn;
    vector<int>v;
    vector<int>v1;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        v.push_back(x);
    }
    cin>>m;
    for(int i=0;i<m;i++)
    {
        cin>>x;
        v1.push_back(x);
    }
    sort(v.begin(),v.end());
    sort(v1.begin(),v1.end());
    if(includes(v.begin(),v.end(),v1.begin(),v1.end()))
    {
        cout<<"1"<<endl;
    }
    else
        cout<<"0"<<endl;
    return 0;
}




Measured memory_bytes: 5164
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#include<deque>
#include<tuple>
#include<stdio.h>
#include<iomanip>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int n, a[4];
	cin>>n;
	string s;
	rep(i, 4){
		a[i]=0;
	}
	rep(i, n){
		cin>>s;
		if(s=="AC"){
			a[0]++;
		}
		if(s=="WA"){
			a[1]++;
		}
		if(s=="TLE"){
			a[2]++;
		}
		if(s=="RE"){
			a[3]++;
		}
	}
	cout<<"AC x "<<a[0]<<endl;
	cout<<"WA x "<<a[1]<<endl;
	cout<<"TLE x "<<a[2]<<endl;
	cout<<"RE x "<<a[3]<<endl;
	return 0;
}

Measured memory_bytes: 3620
def dfs(A, max_a):
    if len(A) == n:
        score = 0
        for a, b, c, d in conditions:
            if A[b - 1] - A[a - 1] == c:
                score += d
        return score
    ans = 0
    for i in range(max_a, m + 1):
        ans = max(ans, dfs(A + [i], i))
    return ans


n, m, q = map(int, input().split())
conditions = [list(map(int, input().split())) for _ in range(q)]
print(dfs([1], 1))


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

using namespace std;

typedef long long LL;

const int N = 100003;

int n, m, a[5][5];
bool st[5][5];
char s[N];

int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i+=1) s[i] = '+';
    for (int i = 1; i <= m; i+=1)
    {
        int u, v;
        cin >> u >> v;
        if (s[u] == '+') s[u] = v + '0';
        else if (s[u] != v + '0') {puts("-1"); return 0;}
    }
    if (n == 1 && s[1] == '+') {puts("0"); return 0;}
    if (n == 1 && s[1] == '0') {puts("0"); return 0;}
    if (s[1] == '0') {puts("-1"); return 0;}
    if (s[1] == '+') s[1] = '1';
    for (int i = 1; i <= n; i+=1)
        if (s[i] == '+') printf("0");
        else printf("%c", s[i]);
    puts("");
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int i,jud=0,judo=0,num=0,point=0;
  char str[11];
  for(i=0;i<10;i++)
  {
    scanf("%c",&str[i]);
    if(str[i]>='A') num++;
  }
  if(str[0]!='A') jud=1;

  
  for(i=2;i<=num-2;i++)
  {
    if(str[i]=='C')
    {
      judo++;
      point=i;
    }
  }
  if(judo!=1) jud=1;

  
  for(i=1;i<num;i++)
  {
    if(i==point) continue;
    if(str[i]<'a' || str[i]>'z') jud=1;
  }
  
  
  if(jud==0) printf("AC");
  else printf("WA");
  
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

#define EMPTY 0

int main(void) {
    int i, car_stack[100];
    for(i = 0; i < 100; i++) car_stack[i] = EMPTY;

    int id_coming_car;
    int pos_head = 0;
    while(scanf("%d", &id_coming_car) != EOF) {                                                                    
        if(id_coming_car != 0) car_stack[pos_head++] = id_coming_car;
        else {
            printf("%d\n", car_stack[--pos_head]);
            car_stack[pos_head] = EMPTY;
        }   
    }   

    return 0;
}

Measured memory_bytes: 600
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nt = readln.split.to!(long[]);
    auto N = nt[0];
    auto T = nt[1];
    auto ts = readln.split.to!(long[]);
    ts ~= long.max;
    long st;
    foreach (i; 0..N) st += min(T, ts[i+1] - ts[i]);
    writeln(st);
}

Measured memory_bytes: 14552
while True:
    n,w,h = map(int,input().split())
    if w == 0:
        break
    ls = [[w,h]]
    for i in range(n):
        p,s = map(int,input().split())
        p -= 1
        pw,ph = ls[p]
        if s%(pw+ph) < pw:
            s %= pw+ph
            ls.extend([[min(s,pw-s),ph],[max(s,pw-s),ph]])
        else:
            s = (s-pw)%(ph+pw)
            ls.extend([[pw,min(s,ph-s)],[pw,max(s,ph-s)]])
        ls.pop(p)
    ans = [hi*wi for wi,hi in ls]
    ans.sort()
    print(' '.join(map(str,ans)))


Measured memory_bytes: 5624
#include <stdio.h>

int main(){
    int i, j, n, tarop=0, hanap=0;
    char taro[101], hana[101];
    
    scanf("%d", &n);
    
    for(i=0;i<n;i++) {
        scanf("%s %s", taro, hana);
        
        for(j=0;;j++){
            if (taro[j] > hana[j]) {
                tarop += 3;
                break;
            }else if (taro[j] < hana[j]) {
                hanap += 3;
                break;
            }else if (taro[j] + hana[j] == 0) {
                hanap++;
                tarop++;
                break;
            }
        }
    }
    
    printf("%d %d\n", tarop , hanap);
    return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#include <stdarg.h>
#include <assert.h>
#include <ctype.h>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>

using namespace std;
using boost::algorithm::split;
using boost::algorithm::join;
using boost::algorithm::replace_all;

typedef long long int lli;
typedef vector<int> iv;
typedef vector<bool> bv;
typedef vector<string> sv;
typedef vector<long long int> llv;
typedef vector<double> dv;

#define sor_(vec) sort(vec.begin(),vec.end())
#define rev_(vec) reverse(vec.begin(),vec.end())
#define rep(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define reps(i,n,s) for(int i=static_cast<int>(s);i<static_cast<int>(n);i++)
#define isposi(num) if(num>0)
const long long mod = 1000000007;
#define PI 3.141592653589793

template<typename TypeInt>
std::string Itoa(const TypeInt v, int base)
{
    static const char table[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string ret;
    static numeric_limits<TypeInt> t;
    TypeInt n = v;
    if (t.is_signed) {
        if (v < 0) n *= -1;
    }

    while (n >= base) {
        ret += table[n%base];
        n /= base;
    }
    ret += table[n];
    if (t.is_signed) {
        if (v < 0 && base == 10) ret += '-';
    }
    std::reverse(ret.begin(), ret.end());

    return ret;
}

void printm(char const *format,...){
    va_list arguments;
    va_start(arguments,format);
    unsigned index=0;
    while (format[index]!='\0') {
        if(format[index]=='%'){
            index++;
            if(format[index]=='d')printf("%d",va_arg(arguments, int));
            else if(format[index]=='c')printf("%c",va_arg(arguments, int));
            else if(format[index]=='x')printf("%x",va_arg(arguments,int));
            else if(format[index]=='o')printf("%o",va_arg(arguments,int));
            else if(format[index]=='f')printf("%f",va_arg(arguments, double));
            else if(format[index]=='s')printf("%s",va_arg(arguments, char const *));
            else if(format[index]=='p')printf("%p",va_arg(arguments,void*));
            else if(format[index]=='y')printf("Yes");
            else if(format[index]=='n')printf("No");
            else if(format[index]=='%')printf("%%");
            else assert(!"Unknown format with %.");
        }
        else printf("%c",format[index]);
        index++;
    }
    va_end(arguments);
    return;
}

struct Chara{
    int hp;
    int sp;
};
bool pairCompare(const pair<int,int>& firstElof, const pair<int,int>& secondElof)
{
    return firstElof.second > secondElof.second;
}

int main(void){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << std::setprecision(15);
    //
    long int a,b;
    cin>>a>>b;
    cout<<a*b;
    //
    return 0;
}


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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()

typedef long long lint;
typedef double Double;
typedef pair< int, int > pii;

typedef vector< int > Array;
typedef vector< Array > Matrix;
typedef vector< Double > DArray;
typedef vector< DArray > DMatirx;
typedef vector< string > SArray;
typedef vector< pii > PArray;

inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }

const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
const Double EPS = 1e-9;

inline void maxUpdate(int& _a, int _b) { _a = max(_a, _b); }
inline void maxUpdate(lint& _a, lint _b) { _a = max(_a, _b); }

int t, n, h[110];


void solve() {
	int mx1 = 0, mx2 = 0;
	
	for_(i,0,n) {
		if (i > 0) maxUpdate(mx1, h[i - 1] - h[i]);
		if (i < n - 1) maxUpdate(mx2, h[i + 1] - h[i]);
	}
	
	cout << mx2 << " " << mx1 << endl;
}

int main() {
	cin >> t;
	for_(i,0,t) {
		cin >> n;
		for_(i,0,n) cin >> h[i];
		solve();
	}
	return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int N;
string S;

bool expr(int&, LL&);
bool term(int&, LL&);

bool expr(int &i, LL& res){
  int bk = i;
  if(!term(i, res)){
	i = bk;
	return false;
  }
  while(i < N){
	if(!(i+1 < N && S[i] == '>' && S[i+1] == '>')) break;
	bk = i;
	i += 2;
	LL t;
	if(!term(i,t)){
	  i = bk;
	  break;
	}
	while(res>0 && t > 0){
	  res /= 2;
	  --t;
	}
  }
  return true;
}

bool term(int& i, LL& res){
  res = 0;
  if(isdigit(S[i])){
	while(i < N && isdigit(S[i])){
	  res = res * 10 + (S[i] - '0');
	  ++i;
	}
	return true;
  }
  int bk = i;
  if(i < N && S[i] == 'S'){
	++i;
	if(i < N && S[i] == '<'){
	  ++i;
	  if(expr(i, res)){
		if(i < N && S[i] == '>'){
		  ++i;
		  res %= MOD;
		  res = res * res % MOD;
		  return true;
		}
	  }
	}
  }

  i = bk;
  return false;
}

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

  while(getline(cin,S), S != "#"){
	N = SZ(S);
	string tmp;
	REP(i,N) if(S[i] != ' ') tmp += S[i];

	S = tmp;
	N = SZ(S);

	int i = 0;
	LL ans = 0;
	assert(expr(i, ans));
	cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 7128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int size = sc.nextInt();
			int[] nums = new int[size];
			for (int i = 0; i < size; i++) {
				nums[i] = sc.nextInt();
			}
			int count = 0;
			int tempCount = 0;
			for (int i = 1; i < size; i++) {
				if (nums[i - 1] >= nums[i]) {
					tempCount++;
				} else {
					if (count < tempCount) {
						count = tempCount;
					}
					tempCount = 0;
				}
				if (i == size - 1) {
					if (count < tempCount) {
						count = tempCount;
					}
				}
			}
			System.out.println(count);
		}
	}
}


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

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> g(n);
  for(int i = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    --u; --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  long long ans = 0;
  for(int len = 1; len <= n; ++len) {
    ans += 1LL * (n - len + 1) * len;
  }
  for(int u = 0; u < n; ++u) {
    for(int v : g[u]) if(u < v) {
      ans -= 1LL * (u + 1) * (n - v);
    }
  }
  cout << ans << '\n';
}

Measured memory_bytes: 15060
#include<stdio.h>
#define N 100001
void QS(int p,int r);
int P(int p, int r);
struct Card{
  int num;
  char ch;
  int m;
}; 
struct Card A[N];
int main(){
  int i,j,n,f=0;
  char m1,m2,m3;
  scanf("%d%c",&n,&m1);
  for(i=1;i<=n;i++){
    scanf("%c%c%d%c",&A[i].ch,&m2,&A[i].num,&m3);
    A[i].m = i;
  }
  j = P(1,n);
  QS(1,n);
  for(i=1;i<n;i++){
    if((A[i].m > A[i+1].m) && (A[i].num == A[i+1].num)){
      f = 1;
      break;
    }
  }
  if(f == 1)
    printf("Not stable\n");
  else printf("Stable\n");
  for(i=1;i<=n;i++)
    printf("%c %d\n",A[i].ch,A[i].num);
  return 0;
} 
int P(int p, int r){
  int i,j;
  struct Card x,tmp1,tmp2;
  x.num = A[r].num;
  i = p -1;
  for(j = p; j <= r-1; j++){
    if(A[j].num <= x.num){
      i = i + 1;
      tmp1 = A[i];
      A[i] = A[j];
      A[j] = tmp1;
    }
  }
  tmp2 = A[i + 1];
  A[i+1] = A[r];
  A[r] = tmp2;
    
  return i + 1;
}
void QS(int p,int r){
  int q;
  if(p < r){
    q =  P(p,r);
    QS(p,q-1);
    QS(q+1,r);
  }
}
 



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

int main() {
  int a, b;
  cin >> a >> b;
  if (a > b) swap(a, b);

  int ans = 1;
  for (int i = 2; i <= sqrt(a); i++) {
    while (a % i == 0 && b % i == 0) {
      ans *= i;
      a /= i;
      b /= i;
    }
    while (a % i == 0) a /= i;
    while (b % i == 0) b /= i;
    if (a == 1 || b == 1) break;
  }
  if (b % a == 0) ans *= a;
  
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3084