akhauriyash/Code-Regression huggingface dataset:
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [n]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    const pointList: [number, number][] = [];
    const nList = [];
    let prod = 1;
    for (let i = 0; i < n; i++) {
      const [x, y] = tmp.shift().split(" ").map(int => parseInt(int));
      pointList.push([x, y]);
      nList.push(i);
      prod *= i + 1;
    }
    return `${Main.culc(n, nList, [], pointList) / prod}`;
  }

  static culc(n: number, remainList: number[], numberList: number[], pointList: [number, number][]) {
    if (remainList.length == 0) {
      let dist = 0;
      for (let i = 0, len = n - 1; i < len; i++) {
        dist += Main.dist(pointList[numberList[i]], pointList[numberList[i + 1]]);
      }
      return dist;
    }
    let dist = 0;
    for (let i = 0, len = remainList.length; i < len; i++) {
      dist += Main.culc(n, remainList.slice(0, i).concat(remainList.slice(i + 1, len)), numberList.concat([remainList[i]]), pointList);
    }
    return dist;
  }

  static tmp = {};

  static dist(point1: [number, number], point2: [number, number]): number {
    const [[x1, y1], [x2, y2]] = point1[0] < point2[0] || (point1[0] == point2[0] && point1[1] < point2[1]) ? [point1, point2] : [point2, point1];
    const key = `${x1}-${y1}-${x2}-${y2}`;
    if (Main.tmp[key] == null) {
      Main.tmp[key] = Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
    }
    return Main.tmp[key];
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 11716
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

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

	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];

	ll ans = 0;

	// 上位ビットからXとKが初めて一致しなかった桁をdとする
	for (int d = 40; d >= -1; d--) {
		if (d != -1 && !(k & (1LL << d))) continue;

		ll tmp = 0;
		// 40bitすべて計算する
		for (int e = 40; e >= 0; e--) {
			ll mask = 1LL << e;
			ll num = 0;
			// a[i]のiビット目が1である個数を求めている
			for(int i = 0; i < n; i++)
				if(a[i] & mask) num++;

			if (e > d) { // kの値に合わせる
				if (k & mask) tmp += mask * (n - num);
				else tmp += mask * num;
			}
			else if (e == d) { // 0とする
				tmp += mask * num;
			}
			else {// 0か1の選択に余裕があるなら増える方を選択
				tmp += mask * max(num, n - num);
			}
		}
		ans = max(ans, tmp);
	}
	cout << ans << endl;
}

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

int main(){
	int n,k,x;
  	cin >> n >>k;
  	for(int i=0;i<n;i++){
    int d;
    cin >> d;
    if (d<=k/2) x +=2*d;
     else x +=2*k-2*d; 
    }
cout << x <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

int ceil(int x, int y) { return (x % y == 0) ? x / y : x / y + 1; }

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

int lcm(int x, int y) { return x / gcd(x, y) * y; }

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

  ll h;
  cin >> h;

  ll count = 0;
  ll base = 1;
  while(h > 0) {
    count += base;
    h = h / 2;
    base <<= 1;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 3652
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;

signed main() {
	int n; cin >> n; 
	if(n&1)cout << n/2 << endl;
	else cout << n / 2 - 1 << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int 
#define ar array
#define pb push_back
#define fi(a,b) for(int i=a;i<(b);i++)
#define fj(a,b) for(int j=a;j<(b);j++)
#define fk(a,b) for(int k=a;k<(b);k++)
#define lb lower_bound
#define ub upper_bound
//hash base 177013


int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	//ll testcase;
	//cin>>testcase;
	//while(testcase--)
	{
		int n;
		cin>>n;
		int a[n];
		fi(0,n)
			cin>>a[i];
		sort(a,a+n);
		int ans=0;
		fi(0,n)
		{
			fj(i+1,n)
			{
				fk(j+1,n)
				{
					if(a[i]+a[j]>a[k]&&a[i]!=a[j]&&a[j]!=a[k]&&a[i]!=a[k]) ans++;
				}
			}
		}
		cout<<ans;
		
	}
}


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


  
int main(){

  int n;
  cin>>n;
  
  vector<int> data(n);
  
  for (int i=0;i<n;i++){
    cin>>data.at(i);
  }
  
  sort(data.begin(),data.end());
  
  int sum=0;
  
  for (int i=0;i<n;i++){
    sum+=data.at(i);
  }
  
  if (sum%10!=0){
    cout<<sum<<endl;
  }
  
  else {
    
    int m=sum;
    
    for (int i=0;i<n;i++){
      if (data.at(i)%10!=0){
        m=data.at(i);
        break;
      }
    }
    
    cout<<sum-m<<endl;
  }
  
   

}
  















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

using namespace std;

int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   bool pos = 0;
   for(ll i=1;i<10;i++)
   {
       for(ll j=i;j<10;j++)
       {
           if(i*j == n)
                pos = 1;
       }
   }
   
   if(pos)
        cout<<"Yes";
   else cout<<"No";        
   
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <queue>
#include <functional> 

using namespace std;
typedef long long ll;

ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}

int main(){
    //制約に注意 
    //AとBを必ず１つ使うこと
    ll N;
    cin >> N;

    vector<ll > P(3 * N, 0);

    for(ll i = 0; i < 3 * N; i++){
        cin >> P[i];
    }


    sort(P.rbegin(), P.rend());

    /*for(ll i = 0; i < 3 * N; i++){
        cout << P[i] << " ";
    }
    cout << endl;
     */
    ll ans = 0;
    for(ll i = 1; i < 2 * N; i += 2){
        //cout << P[i] << endl;
        ans += P[i];
    }

    cout << ans << endl;


} 

Measured memory_bytes: 2560
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  string ans = "Yes";
  if (a + b < c) ans = "No";
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		
 		Scanner sc= new Scanner(System.in);
 		int n = sc.nextInt();
 		int arr[][]=new int[n][3];
 		int dp[][]=new int[n][3];
 		for(int i=0;i<n;i++){
 		    arr[i][0]=sc.nextInt();
 		    arr[i][1]=sc.nextInt();
 		    arr[i][2]=sc.nextInt();
 		    if(i==0){
 		        dp[0][0]=arr[i][0];
 		        dp[0][1]=arr[i][1];
 		        dp[0][2]=arr[i][2];
 		    }
 		}
 		for(int i=1;i<n;i++){
 		    dp[i][0] = Math.max(dp[i-1][1]+arr[i][0], dp[i-1][2]+arr[i][0]);
 		    dp[i][1] = Math.max(dp[i-1][0]+arr[i][1], dp[i-1][2]+arr[i][1]);
 		    dp[i][2] = Math.max(dp[i-1][1]+arr[i][2], dp[i-1][0]+arr[i][2]);
 		}

	System.out.println(Math.max(Math.max(dp[n-1][0], dp[n-1][1]),dp[n-1][2]));

	    
		
	}
}


Measured memory_bytes: 98924
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}


void solve(long long N){
    cout << (N - 2) * 180 << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

################
class UnionFind():
    """
    parents : 親要素(findしない場合は根ではないことの注意)，根の場合は"-(要素数）"
    find(x):要素xの属するグループの根を返す
    size(x):要素xの属するグループの要素数を返す
    same(x,y):x,yが同じグループに属しているか返す
    members(x):要素xが属するグループに属する要素をリストで返す
    roots:全ての根の要素を返す
    group_count():グループの数を返す
    all_group_members():{根要素：[そのグループに含まれる要素のリスト]}の辞書を返す
    """
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    
################

def main():
    mod=10**9+7
    N,M,K=MI()
    uf = UnionFind(N)
    cnt=[0]*N#友達の数
    for i in range(M):
        a,b=MI()
        a-=1
        b-=1
        cnt[a]+=1
        cnt[b]+=1
        uf.union(a,b)
        
    blo=[0]*N#同じユニオン内でブロックしているかず
    for i in range(K):
        c,d=MI()
        c-=1
        d-=1
        if uf.same(c,d):
            blo[c]+=1
            blo[d]+=1
    ans=[0]*N    
    for i in range(N):
        ans[i]=uf.size(i) - cnt[i]-blo[i]-1
        
    print(' '.join(map(str, ans)))
        
    

main()


Measured memory_bytes: 103512
import sys

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

cost = [sys.maxsize] * n
cost[0] = 0

for i in range(n-1):
    dif1 = int(abs(h_list[i] - h_list[i+1]))
    cost[i+1] = min(cost[i+1], cost[i]+dif1)
    if i+2 < n:
        dif2 = int(abs(h_list[i] - h_list[i+2]))
        cost[i+2] = min(cost[i+2], cost[i]+dif2)

print(cost[n-1])

Measured memory_bytes: 13928
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val p = (0 until n).map { sc.next().toInt() }
    println(problem072d(n, p))
}

fun problem072d(n: Int, p: List<Int>): Int {
    var count = 0
    var isSwap = false
    var swapNum = 0
//    val temp = p.toIntArray()
    for (i in 0 until n - 1) {
//        debugLog(temp.toList())
        val pi = if (isSwap) swapNum else p[i]
        val pi2 = p[i + 1]
        val pi3 = if (i != n - 2) p[i + 2] else i + 2
        val i = i + 1
        if (pi == i && pi2 == i + 1) {
            swapNum = pi
            isSwap = true
            count++
//            temp[i - 1] = pi2
//            temp[i] = pi
            continue
        }
        if (pi == i && pi2 != i + 1) {
            swapNum = pi
            isSwap = true
            count++
//            temp[i - 1] = pi2
//            temp[i] = pi
            continue
        }
        if (pi != i && pi2 == i + 1 && pi3 != i + 2) {
            swapNum = pi
            isSwap = true
            count++
//            temp[i - 1] = pi2
//            temp[i] = pi
            continue
        }
        isSwap = false
    }

    return count
}

Measured memory_bytes: 51112
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 205;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = (_begin + _end) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


ll N,M,K,A[NMAX],B,C,D,E;
int dp[NMAX] = {};

string S;
vec v;

ll ans = INFLL;

void solve(){
  // main algorithm
  for (int i = 0; i < N; ++i)
  {
    ll a = A[i];
    int cnt = 0;
    while(!(a & 1)){
      cnt++;
      a >>= 1;
    }
    ans = min(ans, (ll)cnt);
  }
}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  cout << ans << endl;
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  cin >> N;
  for (int i = 0; i < N; ++i)
  {
    scanf("%lld", &A[i]);
  }
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std ;  
int main ()
{
 int n ; 
 cin>>n;
 while ( n > 0 )   
 {
   if ( n % 10 == 7 )     
   {
     cout << "Yes" << endl ;  
     return 0 ; 
       
   }
   else
   {
     n/= 10 ;  
   }
  }
   cout << "No" << endl ;  
  return 0 ;   
}

Measured memory_bytes: 3652
import sys
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
for i in range(X+1,Y+1):
  if max(x)<i and min(y)>=i:
    print("No War")
    sys.exit()
print("War")

Measured memory_bytes: 63216
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = Integer.parseInt(sc.next());
			if (n == 0)
				break;
			int[] a = new int[25 * 3600];
			for (int i = 0; i < n; i++) {
				String[] t = sc.next().split(":");
				int departure = Integer.parseInt(t[0]) * 3600 + Integer.parseInt(t[1]) * 60 + Integer.parseInt(t[2]) + 1;
				t = sc.next().split(":");
				int arrive = Integer.parseInt(t[0]) * 3600 + Integer.parseInt(t[1]) * 60 + Integer.parseInt(t[2]) + 1;
				a[departure]++;
				a[arrive]--;
			}
			int ans = 0;
			for (int i = 1; i < 25 * 3600; i++) {
				a[i] += a[i - 1];
				ans = Math.max(ans, a[i]);
			}
			System.out.println(ans);
		}
	}
}


Measured memory_bytes: 104704
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int LCM(int a, int b) { int g = gcd(a, b); return a / g * b; }
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int x,y,z; cin >> x >> y >> z;
    cout << (x - z) / ( y + z) <<endl;

    return 0;
}

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



int main(void){
	int N;
	int c;

	scanf("%d",&N);
	int *L=(int*)calloc(N*sizeof(int),N);
	int count=0;
	for(int i=0;i<N;i++){
		scanf("%d",&c);
		if(c>0){
			for(int j=0;j<count;j++){
				if(c==L[j]){
					printf("%d\n",i+1);
					return 0;
				}
			}
			L[count]=c;
			count++;
		}else{
			if(L[count-1]==(c*-1)){
				count--;
			}else{
				printf("%d\n",i+1);
				return 0;
			}
		}
	}

	printf("OK\n");


	return 0;
}


Measured memory_bytes: 5672
#include<iostream>
using namespace std;
int n,hantei;
char a[36][2],c[36][2];
void print(char a[36][2]){
    for(int i=0;i<n;i++){
        cout<<a[i][0]<<a[i][1];
        if(n-i-1)cout<<" ";
    }
    cout<<endl;
    if(hantei==1)cout<<"Stable";
    else cout<<"Not stable";
}

void bubble(){
    for(int i=0;i<n;i++){
        for(int j=n-1;j>i;j--){
            if(a[j][1]<a[j-1][1]){
                char t;
                t=a[j][1];
                a[j][1]=a[j-1][1];
                a[j-1][1]=t;

                t=a[j][0];
                a[j][0]=a[j-1][0];
                a[j-1][0]=t;
            }
        }
    }
}

void Select(){
    for(int i=0;i<n;i++){
        int minj=i;
        for(int j=i;j<n;j++){
            if(c[j][1]<c[minj][1])minj=j;
        }
        char t;
        t=c[i][1];
        c[i][1]=c[minj][1];
        c[minj][1]=t;

        t=c[i][0];
        c[i][0]=c[minj][0];
        c[minj][0]=t;
    }
}

void Hantei(){
    hantei=1;
    for(int i=0;i<n;i++){
        if(a[i][0]!=c[i][0]){
            hantei=0;
            break;
        }
    }
}
int main(){
    int i,j;
    cin>>n;
    for(i=0;i<n;i++)for(int j=0;j<2;j++){
        cin>>c[i][j];
        a[i][j]=c[i][j];
    }

    bubble();
    hantei=1;
    print(a);
    cout<<endl;
    Select();
    Hantei();
    print(c);
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3100
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int A,B;
	public void solve() {
		A = nextInt();
		B = nextInt();
		if(A == B){
			out.println("Draw");
		}
		else if(A == 1){
			out.println("Alice");
		}else if(B == 1){
			out.println("Bob");
		}else{
			if(A > B){
				out.println("Alice");
			}else{
				out.println("Bob");
			}
		}
	}

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

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 8148
s=str(input())
n=len(s)

evensum = 0
oddsum = 0
evenall = 0
oddall = 0

for i in range(0,n,2):
    evensum += int(s[i])
    evenall += 1
for i in range(1,n,2):
    oddsum += int(s[i])
    oddall += 1

#evenを1にするとき
evendiff = evenall-evensum
odddiff = oddsum
even1count = evendiff+odddiff 

#oddを1にするとき
evendiff = evensum
odddiff = oddall-oddsum
odd1count = evendiff+odddiff 

print(min(even1count,odd1count))

Measured memory_bytes: 3188
/**
 * C - Low Elements
 * https://atcoder.jp/contests/abc152/tasks/abc152_c
 **/
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<numeric>
#include<functional>
#include<sstream>
#include<iomanip>

using namespace std;

#define ll long long

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i=0; i<n; i++) cin >> p[i];
    int min_p = p[0];
    int ans = 0;
    for(int i=0; i<n; i++) {
        if(min_p>=p[i]) {
            ans++;
            min_p = p[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

using ll=long long;

using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;

int main() {
  string s; cin >>s;
  cout <<s.substr(0,4) <<' ' <<s.substr(4) <<endl;
  return 0;
}


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

bool S[13] = {}, H[13] = {}, D[13] = {}, C[13] = {};

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		char c;
		int a;
		cin >> c >> a;
		if(c == 'S')
			S[a-1]++;
		if(c == 'H')
			H[a-1]++;
		if(c == 'D')
			D[a-1]++;
		if(c == 'C')
			C[a-1]++;
	}
	for(int i = 0; i < 13; i++)
		if(!S[i])
			cout << "S " << i+1 << endl;
	for(int i = 0; i < 13; i++)
		if(!H[i])
			cout << "H " << i+1 << endl;
	for(int i = 0; i < 13; i++)
		if(!C[i])
			cout << "C " << i+1 << endl;
	for(int i = 0; i < 13; i++)
		if(!D[i])
			cout << "D " << i+1 << endl;
	
}


Measured memory_bytes: 3072
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

#define D 10 
#define MAXN (1 << 18)
#define MAXW (100010)

ll dp[(1 << D)][MAXW];
ll v[MAXN];
ll w[MAXN];

int n, q;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> v[i] >> w[i];
	}
	for (int i = 1; i < (1 << D); i++) {
		ll prevdp[MAXW];
		memcpy(prevdp, dp[i / 2], sizeof(dp[0]));
		for (int j = 0; j + w[i] < MAXW; j++) {
			dp[i][j + w[i]] = prevdp[j] + v[i];
		}
		for (int j = 0; j < MAXW; j++) {
			dp[i][j] = max(prevdp[j], dp[i][j]);
		}
		for (int j = 1; j < MAXW; j++) {
			dp[i][j] = max(dp[i][j], dp[i][j - 1]);
		}
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		int cur, cap;
		cin >> cur >> cap;
		if (cur < (1 << D)) {
			cout << dp[cur][cap] << endl;
		} else {
			vector<int> items;
			while (cur >= (1 << D)) {
				items.push_back(cur);
				cur >>= 1;
			}
			int m = items.size();
			ll bestval = 0;
			for (int mask = 0; mask < (1 << m); mask++) {
				ll curv = 0;
				ll curw = 0;
				for (int j = 0; j < m; j++) {
					if (mask & (1 << j)) {
						curv += v[items[j]];
						curw += w[items[j]];
					}
				}
				if (curw > cap) {
					continue;
				}
				curv += dp[cur][cap - curw]; 
				bestval = max(curv, bestval);
			}
			cout << bestval << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 807652
a,b,c,d = map(int,input().split())
x = c-a
y = d-b
print('U'*y + 'R'*x + 'D'*y + 'L'*x + 'L' + 'U'*(1+y) + 'R'*(1+x) + 'D' + 'R' + 'D'*(1+y) + 'L'*(1+x) + 'U')


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int K, N;
    vector<int> lens;
    cin >> K >> N;
    
    lens.resize(N);
    for(int i=0;i<N;i++){
        cin >> lens[i];
    }
    sort(lens.begin(), lens.end());

    int max = K-lens[N-1]+lens[0];
    for(int i=0;i<N-1;i++){
        if(lens[i+1]-lens[i]>max){
            max = lens[i+1]-lens[i];
        }
    }

    cout << K - max << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main()
{
	int N;
	cin >> N;
	vector<pair<string, int>> R(N);
	map<pair<string, int>, int> M;

	rep(i, N) {
		string s;
		int x;
		cin >> s >> x;

		pair<string, int> P = make_pair(s, -x);
		R.at(i) = P;
		M[P] = i+1;
	}

	sort(R.begin(), R.end());
	for (auto p : R) cout << M[p] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <map>

typedef long long ll;
#define fi first
#define se second

using namespace std;

///////////////////////////////////////
//
//
///////////////////////////////////////
//


int N;
int A[112345];
int J[112345];
//増加１減少２同じ0
//

int main(){
  
  cin>>N;
  
  int i;
  int num;
  
  for( i = 0; i < N; i++ ){
    scanf("%d", A+i);
    if( i ){
      if( A[i] > A[i-1] ){
        J[i] = 1;
      }
      else if( A[i] < A[i-1] ){
        J[i] = 2;
      }
      else if( A[i] == A[i-1] ){
        J[i] = 0;
      }
    }
    else{
      J[i] = 0;
    }
  }
  
  int ans = 1;
  int jdg = 1;
  int b = 0;
  
  for( i = 0; i < N; i++ ){
    if( J[i] ){
      if( J[i] != b ){
        if( b ){
          ans++;
          b = 0;
        }
        else{
          b = J[i];
        }
      }
      else{
        b = J[i];
      }
    }
  }
  
  
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 1024
N, K = map(int, input().split())
A = [int(a) for a in input().split()]

def chk(x):
    s = 0
    for a in A:
        s += (a - 1) // x
    return 1 if s <= K else 0

l, r = 0, 1 << 30
while r - l > 1:
    m = (l + r) // 2
    if chk(m):
        r = m
    else:
        l = m
print(r)

Measured memory_bytes: 94024
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int cc = b / c - (a - 1) / c;
    int dd = b / d - (a - 1) / d;
    int g = gcd(c, d);
    int l = c * d / g;
    int ll = b / l - (a - 1) / l;

    cout << b - a + 1 - cc - dd + ll << endl;

    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#define ll long long int
#define ss second
#define ff first
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;
typedef pair<int, int> pii;
const ll mod = 998244353;
const int sz = 200000 + 3, inf = 1e9 + 10;

bool ok(string s)
{
	for (int i = 0; i < s.size() / 2 + 1; i++) {
		if (s[i] != s[s.size() - i - 1]) {
			return false;
			break;
		}
	}
	return true;
}
string get1(string s)
{
	string x;
	int len = s.size();
	if (len % 2)len--;
	len /= 2;
	for (int i = 0; i < len; i++)x += s[i];
	return x;
}
string get2(string s)
{
	string x;
	int len = s.size();
	int l = len;
	if (len % 2)l--;
	int id = (l + 3) / 2;
	for (int i = id; i < len; i++)x += s[i];
	return x;
}
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	string s; cin >> s;
	if (!ok(s))cout << "No\n", exit(0);

	string s1 = get1(s);
	string s2 = get2(s);
	//cout << s1 << " " << s2 << "\n";
	if (ok(s1) and ok(s2))cout << "Yes\n";
	else cout << "No\n";


	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var item = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var N = item[0];
            var R = item[1];

            int answer;
            if (N >= 10)
            {
                answer = R;
            }
            else
            {
                answer = R + 100 * (10 - N);
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d);
}


Measured memory_bytes: 256
N=int(input())
S=input() #all# or all. or あるところから#
m=S.count('.')
b=[0]*(N+1)
a=[0]*(N+1)
m=N
for i in range(N):
  if S[i]=='#':
    b[i+1]=b[i]+1
    a[i+1]=a[i]
  else:
    b[i+1]=b[i]
    a[i+1]=a[i]+1
for j in range(N+1):
  m=min(m,b[j]+(a[N]-a[j]))
print(m)



Measured memory_bytes: 43488
#include<bits/stdc++.h>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <cstdio>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=1e5+10;
#define ll long long
#define inf 0x3f3f3f3f
#define mem(x) memset(x,0,sizeof(x))
#define sca(x) scanf("%d",&x)
#define scall(x) scanf("%lld",&x)
#define eps 1e-6
int main()
{
	int n;sca(n);
	ll d;scall(d);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		ll x,y;scall(x);scall(y);
		ll sum=0;
		sum=x*x+y*y;
		if(sum<=d*d)
		ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

int main() {
  i64 N;
  while(cin >> N, N) {
    i64 W, H;
    cin >> W >> H;
    vector<vector<i64>> fie(H +1, vector<i64>(W + 1));
    rep(i,0,N) {
      i64 x, y;
      cin >> x >> y;
      fie[y][x]++;
    }
    i64 s, t;
    cin >> t >> s;
    rep(i,1,H + 1) rep(j, 1, W + 1) fie[i][j] += fie[i][j - 1];
    rep(i,1,H + 1) rep(j, 1, W + 1) fie[i][j] += fie[i - 1][j];
    i64 ans = 0;
    for(int i = s; i <= H; i++) {
      for(int j = t; j <= W;j++) {
        ans = max(ans, fie[i][j] + fie[i - s][j - t] - fie[i][j - t] - fie[i - s][j]);
      }
    }

    cout << ans << endl;
  }
}



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

int main()
{
	//合計時間

	int sum=0, n;
	for (int i = 0; i < 4; i++) {
		cin >> n;
		sum += n;
	}
	cout << sum / 60 << endl;
	cout << sum % 60 << endl;
	//平均点
	/*
	int P[5];
	int sum=0;
	for (int i = 0; i < 5; i++) {
		cin >> P[i];
		if (P[i] < 40) P[i] = 40;
		sum += P[i];
	}
	cout << sum / 5 << endl;
	*/
	//投票
	/*
	int N, M;
	cin >> N >> M;
	int A[1000], vote[1000];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		vote[i] = 0;
	}
	int b;
	for (int i = 0; i < M; i++) {
		cin >> b;
		for (int j = 0; j < N; j++) {
			if (A[j] <= b) {
				vote[j]++;
				break;
			}
		}
	}
	int temps = 0, ans;
	for (int i = 0; i < N; i++) {
		if (vote[i] > temps) {
			temps = vote[i];
			ans = i;
		}
	}
	cout << ans + 1 << endl;
	*/

	//2.すごろく	
	/*
	int n;
	cin >> n;
	int A, _A = 1;
	int k = 0;
	int A_count[100];
	A_count[0] = 1;
	for (int i = 0; i < n; i++)
	{
	cin >> A;
	if (A == 1)
	{
	if (A == _A)
	{
	A_count[k]++;
	}
	else
	{
	k++;
	A_count[k] = 2;
	}
	}
	_A = A;
	}
	sort(A_count, A_count + k + 1);
	cout << A_count[k] << endl;
	*/

	//タイムカード
	/*
	int t[2][3];
	int x[3][3];
	for (int n=0; n < 3; n++)
	{
	for (int i=0; i < 2; i++)
	for (int k=0; k < 3; k++)
	cin >> t[i][k];

	for (int m = 2; m >= 0; m--)
	{
	x[n][m] = t[1][m] - t[0][m];
	if (t[0][m] > t[1][m])
	{
	x[n][m] += 60;
	t[1][m - 1]--;
	}
	}
	}
	for (int n= 0; n < 3; n++)
	{
	cout << x[n][0] << ' ' << x[n][1] <<' '<< x[n][2] << endl;
	}
	*/



	return 0;
}


Measured memory_bytes: 3076
h, w = map(int, input().split())
f = []
for i in range(h):
    f.append([i for i in input()])

for i in range(h):
    for j in range(w):
        if f[i][j] == '#':
            continue
        bomb = 0
        for k in range(i-1, i+2):
            if k < 0 or k > h-1:
                continue
            for l in range(j-1, j+2):
                if l < 0 or l > w-1:
                    continue
                if f[k][l] == '#':
                    bomb += 1

        f[i][j] = str(bomb)

for i in range(h):
    print("".join(f[i]))


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

int main(){
  int a;
  string s;
  cin >> a >> s;
  if(a >= 3200) cout << s;
  else cout << "red";
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
#define ll long long
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
ll D[18],d,now=1;
ll get_now(ll p){ll r=0;for(;p;r+=p%10,p/=10);return r;}
int main()
{
	D[0]=1;
	for(int i=1;i<=17;++i) D[i]=D[i-1]*10ll;
	int n=read();
	while(n--)
	{
		printf("%lld\n",now);
		if((now+D[d])*get_now(now+2*D[d])>(now+D[d]*2)*get_now(now+D[d])) d++;
		now+=D[d];
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

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


Measured memory_bytes: 256
let readIntArray _ =
    stdin.ReadLine().Split(" ") |> Array.map int

let readCharArray _ = stdin.ReadLine().ToCharArray()
let third (_, _, c) = c

let isNotAllBlank arr =
    arr
    |> Array.groupBy third
    |> fun x -> not (x.Length = 1 && (x.[0] |> fst |> (=) '.'))

()
|> readIntArray
|> fun [| h; w |] ->
    [| 1 .. h |]
    |> Array.map (fun a -> a |> readCharArray |> Array.indexed)
    |> Array.indexed
    |> Array.collect (fun (r, arr) -> arr |> Array.map (fun (c, v) -> (r, c, v)))
    |> Array.groupBy (fun (_, c, _) -> c)
    |> Array.filter (fun (_, arr) -> arr |> isNotAllBlank)
    |> Array.collect snd
    |> Array.groupBy (fun (r, _, _) -> r)
    |> Array.filter (fun (_, arr) -> arr |> isNotAllBlank)
    |> Array.map (fun (_, arr) ->
        arr
        |> Array.map (fun (_, _, c) -> c)
        |> System.String)
    |> String.concat "\n"
    |> printfn "%s"


Measured memory_bytes: 32220
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s;
    cin>>s;
    string s1="s";
    string s2="es";
    ll n=s.length();

    if(s[n-1]=='s')
        s+=s2;
    else
        s+=s1;
    cout<<s;

}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
int inf = 1000000000; //10e9

int main(){

    int a, b, m;
    cin >> a >> b >> m;
    
    vector<int> mat_a(a);
    vector<int> mat_b(b);
    rep(i,a) cin >> mat_a[i];
    rep(i,b) cin >> mat_b[i];

    int ans = 0, x, y, c, tmp_ans=inf;
    rep(i,m){
        cin >> x >> y >> c;
        int coupon = mat_a[x-1] + mat_b[y-1] - c;
        tmp_ans = min(coupon,tmp_ans);
    }
    int min_cost = 
        *min_element(mat_a.begin(),mat_a.end()) +
        *min_element(mat_b.begin(),mat_b.end());
    ans = min(min_cost,tmp_ans);

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 4028
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

template <typename T>
bool chmax(T &a, const T& b) {
    if (a < b) {
      a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
    if (a > b) {
      a = b;
      return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H,W;
    cin >> H >> W;
    int DX[]={1,0,-1,0},DY[]={0,1,0,-1};
    bool seen[H][W][25];
    ll d[H][W];
    rep(i,H){
        rep(j,W){
            rep(k,25)
            seen[i][j][k]=false;
            d[i][j]=INF;
        }
    }
    int ch,cw,dh,dw;
    cin >> ch >> cw >> dh >> dw;
    ch--;cw--;dh--;dw--;
    deque<P> que;
    que.push_front({ch,cw});
    vvc s(H,vc(W));
    rep(i,H){
        rep(j,W){
            cin >> s[i][j];
        }
    }
    d[ch][cw]=0;
    while(!que.empty()){
        P p=que.front();
        que.pop_front();
        ll x=p.first,y=p.second;
        FOR(dx,-2,3){
            FOR(dy,-2,3){
                int nx=x+dx,ny=y+dy;
                if(!(0<=nx&&nx<H&&0<=ny&&ny<W&&s[nx][ny]=='.')){
                    continue;
                }
                if(dx==0&&dy==0){
                    continue;
                }
                if(seen[nx][ny][(dx+2)+5*(dy+2)])continue;
                if(abs(dx)+abs(dy)==1){
                    if(chmin(d[nx][ny],d[x][y]))que.push_front({nx,ny});
                }
                else{
                    if(chmin(d[nx][ny],d[x][y]+1))que.push_back({nx,ny});
                }
                seen[nx][ny][(dx+2)+5*(dy+2)]=true;
            }
        }
    }
    cout << (d[dh][dw]==INF?-1:d[dh][dw]) << endl;
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/


Measured memory_bytes: 36892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int a[200005];
int sum;
int main(){
    scanf("%d",&n);
    for (int i = 0; i < n;i ++){
        scanf("%d",&a[i]);
        sum ^= a[i];
    }
    for (int i = 0; i < n; i++){
		printf("%d ",a[i]^sum);
	}	
    
}


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

#define debug(x) cout << (#x) << " is " << x << endl;
#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<int, int> pi;

#define N 300005
lli H[N], W[N];

int main()
{
    lli h, w, m, hmx=0, wmx=0;
    cin >> h >> w >> m;
    vector<pair<lli, lli> > p;
    for(lli i=0; i<m; i++){
		lli x, y;
		cin >> x >> y;
		H[x]++;
		W[y]++;
		p.push_back({x, y});
		hmx = max(hmx, H[x]);
		wmx = max(wmx, W[y]);
	}
	lli hc=0, wc=0;
	for(lli i=1; i<=h; i++) hc += (H[i] == hmx);
	for(lli i=1; i<=w; i++) wc += (W[i] == wmx);
	
	lli cc = 0;
	for(auto el: p){
		if(H[el.first]==hmx && W[el.second]==wmx) cc++;
	}
	if(cc == hc*wc){
		cout << hmx+wmx-1 << endl;
	}
	else{
		cout << hmx+wmx << endl;
	}
 
    return 0;
}


Measured memory_bytes: 16344
s = input()

a = int(s[0:2])
b = int(s[2:4])

if a <= 12 and b <= 12 and a > 0 and b > 0:
    print('AMBIGUOUS')

elif a <= 12 and b > 12 and a > 0 and b > 0:
    print('MMYY')

elif a > 12 and b <= 12 and a > 0 and b > 0:
    print('YYMM')

elif a == 0 and b <= 12 and b > 0:
    print('YYMM')

elif a <= 12 and b == 0 and a > 0:
    print('MMYY')

else:
    print('NA')


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

int main() {
	int n;
	cin >> n;
	vector<int>V(n);
	rep(i, n) {
		cin >> V[i];
	}
	vector<int>C(n);
	rep(i, n) {
		cin >> C[i];
	}
	int ans = 0;
	rep(i, n) {
		if (V[i] > C[i]) {
			ans += V[i] - C[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define f(i,a,b,c) for(ll i=a;i<b;i+=c)
#define r(i,a,b,c) for(ll i=a;i>=b;i-=c)
#define mod 1000000007
int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    ll n; cin >> n;
    ll ar[n];
    ll sum = 0;
    f(i,0,n,1){
    	cin >> ar[i];
    }
    ll in = ar[n-1];
    r(i,n-1,1,1){
    	//cout << in << "\n";
    	sum += (ar[i-1]*in);
    	in += ar[i-1];
    	sum%=mod;
      	in%=mod;
    	//cout << ar[i-1] << " " << sum  << " " << in << "\n"; 
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 5188
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
int n, x, cnt = 0;
int minv = 100005, maxv = -1;
int main(){
    scanf("%d",&n);
    for (int i = 1; i <= n; i++) {
        scanf ("%d", &x);
        if (x == minv) cnt++;
        if (x < minv) minv = x, cnt=1;
        if (x > maxv) maxv = x;
    }
    if (maxv - minv > 1) {
    	puts("No");
    	return 0;
	}
    if (maxv == minv) {
        if (minv == n-1) {
        	puts("Yes");
        	return 0;
		}
        if (n / minv >= 2) puts("Yes");
		else puts("No");
		return 0;
    }
    int a = n - cnt, b = maxv - cnt;
    if (b < 1) puts("No");
    else if (a / b >= 2) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
#define end getchar();getchar();return 0
int inf = 1000000000;
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt=1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
int prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
void prime_factor(int n){
	int cnt = 1;
	map<int, int>res;
	int m = n;
	for (int i = 2; i<= n; i++) {
		if(prime(i)){
			while (m%i == 0) {
				++res[i];
				m /= i;
			}
		}
	}
	cout << n <<":"<< endl;
	for (int i = 2; i<= n; i++) {
		if (res[i]) {
			cout << i << " " << res[i] << endl;
		}
	}
	cout << endl;
}
/*Library End!*/
int n, a[100005], ans = 1, b = 1;
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	if (a[0] > a[1])b = 0;
	if (a[0] < a[1])b = 2;
	for (int i = 1; i < n - 1; i++) {
		if (b == 2 && a[i] > a[i + 1]) {
			ans++;
			b = 1;
			i++;
		}
		if (b == 0 && a[i] < a[i + 1]) {
			ans++;
			b = 1;
			i++;
		}
		if (a[i] < a[i + 1])b = 2;
		if (a[i] > a[i + 1])b = 0;
	}
	cout << ans << endl;
	end;
}

Measured memory_bytes: 1024