akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) printf("%s\n", "Possible");
	else printf("%s\n", "Impossible");
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    F = [[[0 for _ in range(2)] for _ in range(5)] for _ in range(N)]
    for i in range(N):
        tmp = inputList()
        for j,val in enumerate(tmp):
            ind = j // 2
            if j % 2 == 0:
                F[i][ind][0] = val
            else:
                F[i][ind][1] = val
                
    P = []
    for i in range(N):
        tmp = inputList()
        P.append(tmp)
        
    ans = -100000000000000000000000000
    for i in range(1, 2**10):
        ans_tmp = [0 for _ in range(N)]
        for j in [1,2,2**2,2**3,2**4,2**5,2**6,2**7,2**8,2**9]:
            tmp = j & i
            ind = 0
            hi = 0
            
            if tmp == 0:
                ind = -1
                hi = -1
            elif tmp == 1:
                ind = 0
                hi = 0
            elif tmp == 2:
                ind = 0
                hi = 1
            elif tmp == 4:
                ind = 1
                hi = 0
            elif tmp == 8:
                ind = 1
                hi = 1
            elif tmp == 16:
                ind = 2
                hi = 0
            elif tmp == 32:
                ind = 2
                hi = 1
            elif tmp == 64:
                ind = 3
                hi = 0
            elif tmp == 128:
                ind = 3
                hi = 1
            elif tmp == 256:
                ind = 4
                hi = 0
            elif tmp == 512:
                ind = 4
                hi = 1
                
            if ind != -1:
                for k in range(N):
                    tmp2 = F[k][ind][hi]
                    #if k == 0:
                        #print("{} {} {}".format(k,ind,hi))
                    #if i == 683:
                        #print("{} {} {}".format(k,ind,hi))
                    if tmp2 == 1:
                        ans_tmp[k] += 1
                        
        a_tmp = 0
        for j in range(N):
            a_tmp += P[j][ans_tmp[j]]
        if ans < a_tmp:
            ans = a_tmp
        
    print(ans)
            	
if __name__ == "__main__":
	main()


Measured memory_bytes: 45808
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    long double R; cin >> R;
    cout.precision(20);
    cout << 2.0 * M_PI * R << endl;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef pair< double,double> dd;
#define pb push_back
#define eb emplace_back
#define sz(a) (int)a.size()
#define all(c) c.begin(),c.end()
#define FOR(i,a,b) for(i=a; i<b; i++)
#define FORR(i,a,b) for(i=a;i>=b;i--)
#define REP(i,n) FOR(i,0,n)
#define x first
#define y second
#define mp make_pair

const int INF = 1000000007;
const long long INFLL = (ll)INF * (ll)INF;

int32_t main()
{
	IOS;
	int a;
	cin>>a;
	cout<<(a+(a*a)+(a*a*a));
	return 0;
}


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


public class Main {
    
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        
        int total = 0;
        for(int i = 1;i<=N;i++){
            total += i;
        }
        
        System.out.println(total);
        
        
    }      
 }

Measured memory_bytes: 9684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    ll n;
    cin>>n;
    string ans;

    while(n>0){
        n-=1;
        ans+=(char)('a'+n%26);
        n/=26;
    }

    reverse(all(ans));
    cout<<ans<<endl;
}



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

#define FLASH ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"

int32_t main()
{
    FLASH;
    int n; 
    cin>>n;
    int arr[n];
    int sal=0,sbob=0,x;
    for(int i=0;i<n;i++)
    {
       cin>>arr[i];
    }
    sort(arr, arr+n, greater<int>());
    for(int i=0;i<n;i++)
    {
        if(i%2==0) sal+=arr[i];
        else sbob+=arr[i];
    }
    cout<<abs(sal-sbob)<<endl;
}

Measured memory_bytes: 3668
#define _CRT_SECURE_NO_WARNINGS
#include <array>
#include <cstdio>
#include <set>
#include <vector>

using namespace std;

template<class T> void gc(T &x)
{
    char c;
    int s = 0;
    x = 0;

    c = getchar_unlocked();

    if (c == '-') s = 1;
    else if ('0' <= c && c <= '9')  x = c - '0';

    while (true)
    {
        c = getchar_unlocked();

        if (c < '0' || c > '9') break;
        x = x * 10 + (c - '0');
    }

    if (s) x = -x;
}

int main()
{
    int N;

    gc(N);

    array<bool, 100000> ary;

    ary.fill(false);

    set<int> st;

    for (int i = 0; i < N; i++)
    {
        int A;

        gc(A);

        if (st.find(A) != st.end()) st.erase(A);
        else st.insert(A);
    }

    printf("%d\n", st.size());
    return 0;
}


Measured memory_bytes: 4992
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		
	 		StringTokenizer st = new StringTokenizer(bf.readLine());
	 		int a = Integer.parseInt(st.nextToken());
	 		int b = Integer.parseInt(st.nextToken());
	 		int d = b-2*a;
	 		if (d%2 == 1 || d <0)
	 		{
	 			
	 			out.println("No");
	 		}else{
	 			int t = d/2;
	 			if (a >= t){
	 				out.println("Yes");
	 			}
	 			else{
	 				out.println("No");
	 			}
	 		}
	 		
	 		
 		
 		
 		
 		out.println();
	 		
 		out.close();
 		
 		
 		
 	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




Measured memory_bytes: 25396
//
//  main.cpp
//  koch_curve
//
//  Created by ???????????? on 2017/10/07.
//  Copyright ?? 2017 ????????????. All rights reserved.
//

#include <iostream>
#include <stdio.h>
//#include <cmath>
#include <iomanip>
#include <math.h>

//#define PI 3.14159265

using namespace std;

double param = 60.0*M_PI/180.0;

struct P {
    double x;
    double y;
};


void print(P p){
//    cout << setprecision(10) << p.x << " " <<setprecision(10)<< p.y << endl;
    printf("%.8f %.8f\n", p.x, p.y);
}

void koch(int n, P p1, P p2){
    if(n == 0) return;
    
    P s, u, t;
    s.x = (2*p1.x + p2.x)/3;
    s.y = (2*p1.y + p2.y)/3;
    
    t.x = (p1.x + 2*p2.x)/3;
    t.y = (p1.y + 2*p2.y)/3;
    
    u.x = (t.x-s.x)*cos(param) - (t.y-s.y)*sin(param) + s.x;
    u.y = (t.x-s.x)*sin(param) + (t.y-s.y)*cos(param) + s.y;
    
    koch(n-1, p1, s);
    print(s);
//    cout << s.x << " "<< s.y<< endl;
    koch(n-1, s, u);
    print(u);
//    cout << u.x << " "<< u.y<< endl;
    koch(n-1, u, t);
    print(t);
//    cout << t.x << " "<< t.y<< endl;
    koch(n-1, t, p2);
    
    
}




int main(int argc, const char * argv[]) {
    
    int n;
    scanf("%d", &n);
    P p1, p2;
    
    p1.x = 0.0;
    p1.y = 0.0;
    
    p2.x = 100.0;
    p2.y = 0.0;
    
    printf("%.8f %.8f\n", p1.x, p1.y);
    koch(n, p1, p2);
    printf("%.8f %.8f\n", p2.x, p2.y);

    return 0;
}

Measured memory_bytes: 3396
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;


int main(){
    int n,T;
    cin>>n>>T;
    vector<int> c(n),t(n);
    vector<pair<int,int>> r(n);
    for(int i=0;i<n;i++){
        cin>>c[i]>>t[i];
        r[i]=make_pair(c[i],t[i]);
    }
    sort(r.begin(),r.end());
    for(int i=0;i<n;i++){
        if(r[i].second<=T){
            cout<<r[i].first<<endl;
            return 0;
        }
    }
    cout<<"TLE"<<endl;


    
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll pr[200200];
ll v[200200];
int main() {
	int l,n;
	scanf("%d %d ",&l,&n);
	pr[0] = 0;
	for(int i=0;i<n;i++) {
		scanf("%lld ",&v[i]);
		pr[i+1] = pr[i]+v[i];
	}
	ll ma = 0;
	for(int i=0;i<n;i++) {
		ll fs = (i+n)/2;
		bool bs = (i+n)%2;
		ll val;
		if(bs) {
			val = (pr[fs]-pr[i])*2;
			val += (l*(n-fs-1)-(pr[n]-pr[fs+1]))*2;
			val += v[fs];
		} else {
			val = (pr[fs]-pr[i])*2;
			val += (l*(n-fs-1)-(pr[n]-pr[fs+1]))*2;
			val += l-v[fs];
		}
		//printf("val forloop %lld\n",val);
		ma = max(ma,val);
	}
	for(int i=0;i<n;i++) {
		ll fs = (n-i-1)/2;
		bool bs = (n-i-1)%2;
		ll val;
		if(bs) {
			val = (l*(n-i-fs-1)-(pr[n-i]-pr[fs+1]))*2;
			val += pr[fs]*2;
			val += v[fs];
		} else {
			val = (l*(n-i-fs-1)-(pr[n-i]-pr[fs+1]))*2;
			val += pr[fs]*2;
			val += l-v[fs];
		}
		//printf("val backloop %lld\n",val);
		ma = max(ma,val);
	}
	printf("%lld\n",ma);

}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    for(int h = 1; h <= H; h++) {
        for(char a = 'A'; a < 'A' + W; a++) {
            string s;
            cin >> s;
            if(s == "snuke") {
                cout << a << h << endl;
                return 0;
            }
        }
    }
    return 0;
}


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

using namespace std;

int main()
{
    int N, M;
    while (cin >> N >> M, N) {
        vector<int> p(N);
        int sum = 0;
        for (int i = 0; i < N; i++) {
            cin >> p[i];
            sum += p[i];
        }
        sort(p.begin(), p.end());
        for (int i = N - M; i >= 0; i -= M) {
            sum -= p[i];
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3164
#include <iostream>
using namespace std;
int main(void){
    
    int x;
    
    //繰り返し処理をするときは「　for文　」を使う
    for(int i=1; i<=10000; i++){
        //各Caseの値を入力
        cin >> x;
        
        //if文を使用してxの値が「 0 」なら終了の条件を考える
        if(x != 0){
            cout << "Case " << i << ": " << x << endl;
        }
        else{
            break;  //break: for文の {  } のエリアから出るときの使用する
        }
    }
    
    return 0;
    
}


/****************************************　breakとは　***************************************************


☆繰り返し処理を終了・出処理から出たいときに使用

    
*********************************************************************************************************/


















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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);  rep(i, 0, n) cin >> a[i];
  
  vector<ll> once(n, 0);
  ll now = 0;
  ll roop = -1;
  ll shuuki = 0;
  ll dist = 0;
  
  rep(i, 0, n) {
    if(once[now] != 0) {
      roop = now;
      shuuki = i+1-once[now];
      break;
    }
    once[now] = i+1;
    now = a[now]-1;
  }
  now = 0;
  
  if(roop == -1) dist = 0;
  else if(roop == 0) dist = 0;
  else {
    rep(i, 0, n) {
      now = a[now]-1;
      if(now == roop) {
        dist = i+1;
        break;
      }
    }
  }
  
  if(roop == -1) {
    cout << once[min(k, n-1)] << "\n";
    return 0;
  }
  else {
    if(k < dist) {
      rep(i, 0, n) {
        if(once[i]-1 == k) {
          cout << i+1 << "\n";
          return 0;
        }
      }
    }
    else {
      ll l = k;
      l -= dist;
      l %= shuuki;
      ll x = roop;
      rep(i, 0, l) {
        x = a[x]-1;
      }
      x++;        
      cout << x << "\n";
      return 0;
    }
  }
}

Measured memory_bytes: 6368
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	N = int(input())
	xy = []
	for i in range(N):
		x, y = map(int, input().split(" "))
		xy.append((x, y))
		
	if N == 1:
		print(1)
		sys.exit()
		
	re = {}
	for i, val in enumerate(xy):
		x, y = val
		for j, vol in enumerate(xy):
			if i == j:
				continue
			nx, ny = vol
			p = nx - x
			q = ny -y
			if (p, q) in re:
				re[(p, q)] += 1
			else:
				re[(p, q)] = 1
				
	ans = N - max(re.values())
	
	print(ans)
	
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 13464
#include<bits/stdc++.h>
using namespace std;
long long const MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    map<int, int> num_map;
    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        num_map[a]++;
    }
    int ans = 1;
    for (auto elem: num_map)
    {
        if (elem.first ==  0 and 1 == elem.second)
        {}
        else if (elem.second == 2 and elem.first < N)
            ans = (ans * elem.second) % MOD;
        else
        {
            // cout << elem.first <<' ' << elem.second << endl;
            cout << 0 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3200
def solve():
    h, w = list(map(int, input().split()))
    
    if w == 1 or h == 1:
        print(1)
        return
    
    _odd = ((w + 1) // 2) * ((h + 1) // 2)
    _even = (w // 2) * (h // 2)

    print(_odd + _even)

if __name__ == "__main__":
    solve()

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

int main() {
  int x[4][13];
  char a;
  int b,n;
  cin >> n;
  
  
  for(int i=0;i<4;i++){
    for(int j=0;j<13;j++){
      x[i][j]=0;
    }
  }
  
  
  
  for(int i=0; i<n; i++){
    cin >> a >> b;
    b=b-1;
    if(a=='S')
      x[0][b]=1;
    else if(a=='H')
      x[1][b]=1;
    else if(a=='C')
      x[2][b]=1;
    else if(a=='D')
      x[3][b]=1;
  }
  for(int j=0; j<4; j++){
    for(int k=0; k<13; k++){
      if(x[j][k]!=1){
      if(j==0)
        cout << "S " << k+1 << endl;
      else if(j==1)
        cout << "H " << k+1 << endl;
      else if(j==2)
        cout << "C " << k+1 << endl;
      else if(j==3)
        cout << "D " << k+1 << endl;
      }
    }
  }
}



Measured memory_bytes: 3068
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
long int cnt;
int l;
vector<int> G;
void InsertionSort(int a[], int n, int g) {
	
	for (int i = g; i < n; i++)
	{
		int v = a[i];
		int j = i - g;
		while (j >= 0 && a[j] > v)
		{
			a[j + g] = a[j];
			j = j - g;
			cnt++;
		}
		a[j + g] = v;
	}
}
void shellSort(int a[], int n) {
	for (int h = 1;;) {
		if (h > n) 
			break;
		G.push_back(h);
		h = 3 * h + 1;
	}
	for (int i = G.size() - 1; i >= 0; i--) {
		InsertionSort(a, n, G[i]);
	}
	

}
int main()
{
	int n;
	int a[1000000];
	while (cin >> n) {
		for (int i = 0; i < n; i++) cin>>a[i];
		cnt = 0;
		shellSort(a, n);
		
		cout << G.size()<<endl;
		for (int i = G.size() - 1; i >0; i--)
			cout << G[i] << " ";
		cout << G[0] << endl;
		cout << cnt << endl;
		for (int i = 0; i < n; i++)
			cout << a[i] << endl;

	}
    return 0;
}


Measured memory_bytes: 6988
import std;

// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}
T[] lreads(T=long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}
void arywrite(T=long)(T[] ary){ary.map!(text).join(' ').writeln;}
void scan(TList...)(ref TList Args){auto line = readln.split;
foreach (i,T;TList){T val=line[i].to!(T);Args[i]=val;}}
void dprint(TList...)(TList Args){debug{auto s=new string[](TList.length);
static foreach(i,a;Args) s[i]=text(a);s.map!(text).join(' ').writeln;}}
alias sread=()=>readln.chomp();enum MOD =10^^9+7;
alias PQueue(T,alias less="a<b") = BinaryHeap!(Array!T,less);
// dfmt on

void main()
{
    auto S = sread();
    auto T = sread();
    writeln(S == T[0 .. $ - 1] ? "Yes" : "No");
}


Measured memory_bytes: 3624
n,k=map(int,input().split())
mod=998244353
lr=[]
for i in range(k):
    lr.append(list(map(int,input().split())))
d=[0]*(n+1)
d[0]=1
for i in range(n): 
    for l,r in lr:
        r+=1
        d[min(n,i+l)]+=d[i]
        d[min(n,i+r)]-=d[i]
    if i!=0:
        d[i+1]+=d[i]
    d[i+1]%=mod
#print(d)
print(d[n-1]%mod)

Measured memory_bytes: 16840
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl

//ここから編集する
bool func(vector<int> F,int target){
    int sum_F = 0;
    rep(i,0,F.size()){
        sum_F += F[i];
    }
    if((sum_F + target) % 2 == 1) return false;
    vector<vector<bool> > dp(F.size()+1,vector<bool>(2*sum_F+1,false));
    dp[0][0] = true;
    rep(i,0,F.size()){
        for(int j = 0; j <= 2*sum_F; j++){
            if(j + 2*F[i] <= 2*sum_F && dp[i][j]){
                dp[i+1][j+2*F[i]] = true;
                dp[i+1][j] = true;
            }
        }
    }
    if(sum_F + target < 0 || sum_F + target > 2 * sum_F) return false;

    return dp[F.size()][(sum_F + target)];

}


int main() {
    string s;
    cin >> s;
    int x,y;
    cin >> x >> y;
    vector<int> v,w;
    int ff;

    int cnt = 0;
    int num = 0;
    rep(i,0,s.size()){
        if(s[i] == 'T'){
            if(cnt == 0){
                ff = num;
                num = 0;
            }else if(cnt % 2 == 0){
                w.push_back(num);
                num = 0;
            }else if(cnt % 2 == 1){
                v.push_back(num);
                num = 0;
            }
            cnt++;
        }else{
            num++;
            if(i == s.size() - 1){
                if(cnt == 0){
                    ff = num;
                    num = 0;
                }else if(cnt % 2 == 0){
                    w.push_back(num);
                    num = 0;
                }else if(cnt % 2 == 1){
                    v.push_back(num);
                    num = 0;
                }
            }
        }
    }

    if(func(v,y) && func(w,x-ff)){
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }


    return 0;
}


Measured memory_bytes: 2304
S = input()

E1 = int(S[:2])
E2 = int(S[2:])

if E1 >= 1 and E1 <= 12 and E2 >= 1 and E2 <= 12:
  print('AMBIGUOUS')
elif E1 >= 1 and E1 <= 12:
  print('MMYY')
elif E2 >= 1 and E2 <= 12:
  print('YYMM')
else:
  print('NA')










Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <map>
using namespace std;

#define rep(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define SZ(x) ((int) (x).size())
typedef long long ll;

const int N = 100000 + 5;
const int MOD = (int)1e9 + 7;
int a[N], b[N];
long long C[N], INV[N];
int pow(long long x, int n) {
	long long y = 1;
	while(n) {
		if(n & 1) y = y * x % MOD;
		x = x * x % MOD;
		n /= 2;
	}
	return y % MOD;
}

int main(){
	int n, x;
	cin >> n;
	rep(i,0,n+1) {
		cin >> b[i];
		a[b[i]-1]++;
		if(a[b[i]-1]>1) x = b[i];
	}
	//cout << x << endl;
	n++;
	C[0] = 1;
	INV[0] = 1;
	rep(i,1,n+1) C[i] = C[i-1] * i % MOD; 
	//rep(i,1,n+1) INV[i] = mod_reverse(C[i], MOD);
	rep(i,1,n+1) INV[i] = pow(C[i], MOD-2);
	int y = 0, z = 0;
	rep(i,0,n) {
		if(b[i] != x) y++;
		else break;
	}
	for(int i=n-1; i>=0; --i) {
		if(b[i] != x) z++;
		else break;
	}
	//cout << y << " " << z << endl;
	rep(i,1,n) {
		if(i==1) cout << n - 1 << endl;
		else {
			long long t = (C[n] * INV[i] % MOD) * INV[n-i] % MOD;
			long long tt = 0;
			if(y + z >= i - 1) {
				tt = (C[y+z] * INV[i-1] % MOD) * INV[y+z-i+1] % MOD;
			}
			cout << (t - tt + MOD) % MOD << endl;
		}
	}
	cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#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 mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	int n;
	while(cin>>n,n){
		vvi cost(n,vi(n,inf));
		int out=0;
		rep(i,n-1){
			int a,b,c;
			cin>>a>>b>>c;
			a--;b--;
			cost[a][b]=cost[b][a]=c;
			out+=2*c;
		}
		vi ha(n);
		loop(i,1,n){
			int c=0;
			rep(j,n)if(cost[i][j]!=inf)c++;
			if(c==1){
				rep(j,n)if(cost[i][j]!=inf)out-=2*cost[i][j];
				ha[i]=true;
			}
		}
		vi used(n);
		vi d(n,inf);
		d[0]=0;
		while(1){
			int v=-1;
			rep(i,n)if(!used[i]&&(v==-1||d[v]>d[i]))v=i;
			if(v==-1)break;
			used[v]=true;
			rep(i,n)d[i]=min(d[i],d[v]+cost[v][i]);
		}
		int ma=0;
		rep(i,n)if(!ha[i])ma=max(ma,d[i]);
		cout<<out-ma<<endl;
	}
}

Measured memory_bytes: 1224
import sys
input = sys.stdin.readline
from heapq import heappop, heappush
def prim(G):
    used = [False] * len(G) 
    hq = [(0, 0)]
    res = 0
    while hq:
        w, v = heappop(hq)
        if used[v]:
            continue
        used[v] = True
        res += w
        for cv, cw in G[v]:
            if used[cv]:
                continue
            heappush(hq, (cw, cv))
    return res

def main():
    N = int(input())
    X = []
    Y = []
    for i, _ in enumerate(range(N)):
        x, y = map(int, input().split())
        X.append((x, i))
        Y.append((y, i))
    X.sort()
    Y.sort()
    graph = [[] for _ in range(N)]
    prev_x, prev_x_ind = X[0]
    prev_y, prev_y_ind = Y[0]
    for i in range(1, N):
        x, x_ind = X[i]
        y, y_ind = Y[i]
        graph[prev_x_ind].append((x_ind, x - prev_x))
        graph[x_ind].append((prev_x_ind, x - prev_x))
        graph[prev_y_ind].append((y_ind, y - prev_y))
        graph[y_ind].append((prev_y_ind, y - prev_y))
        prev_x, prev_x_ind = x, x_ind
        prev_y, prev_y_ind = y, y_ind
    print(prim(graph))

if __name__ == '__main__':
    main()

Measured memory_bytes: 84732
#include<bits/stdc++.h>
using namespace std;
#define LL long long

int main(){
	// sengen
	int n;
	// nyuryoku
	cin >> n;
	string s;
	int p;
	vector<pair<string,pair<int,int>>> v;
	for(int i=0;i<n;i++){
		cin >> s >> p;
		v.push_back({s,{-p,i+1}});
	}
	sort(v.begin(),v.end());
	// keisan
	for(auto x:v){
		cout << x.second.second << endl;
	}
	// syutsuryoku
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 220000
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define sp ' '
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
ll power(ll x,ll y){
    ll ret=1;
    while(y>0){
        if(y&1)
            ret=(ret*x);
        y/=2;
        x=(x*x);
    }
    return ret;
}
vector<ll> divs(ll n){
	vector<ll>ret;
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			if(i*i==n){
				ret.push_back(i);
			}
			else{
				ret.push_back(i);
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}
void solve(){
	ll n,i;
	cin>>n;
	if(n>=1800)cout<<1<<endl,exit(0);
	if(n>=1600)cout<<2<<endl,exit(0);
	if(n>=1400)cout<<3<<endl,exit(0);
	if(n>=1200)cout<<4<<endl,exit(0);
	if(n>=1000)cout<<5<<endl,exit(0);
	if(n>=800)cout<<6<<endl,exit(0);
	if(n>=600)cout<<7<<endl,exit(0);
	if(n>=400)cout<<8<<endl,exit(0);
}	
int main(){
	gear_change;
	ll test=1;
	// in(test);
	while(test--){
		solve();
	}
}	

Measured memory_bytes: 3652
let s = read_line () in
let n = String.length s in
let m = 1_000_000_007 in
let ( *@) a b = (a * b) mod m in
let ( +@) a b = (a + b) mod m in

let rec loop i k a b acc =
    if i = n then acc else
        match s.[i] with
        | 'A' -> loop (i + 1) k (a +@ k) b acc
        | 'B' -> loop (i + 1) k a (b +@ a) acc
        | 'C' -> loop (i + 1) k a b (acc +@ b)
        | _   -> loop (i + 1) (k *@ 3) (a *@ 3 +@ k) (b *@ 3 +@ a) (acc *@ 3 +@ b)
in
loop 0 1 0 0 0 |> Printf.printf "%d\n"

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <algorithm>

using ll = long long;
const ll MOD = 1000000000 + 7;

int main()
{
	ll N;
	scanf("%lld", &N);

	ll all = (N + 1) * (N * (N + 1) / 2) - N * (N + 1) * (2 * N + 1) / 6;
	//printf("%lld\n", all);

	for (ll i = 0; i < N - 1; i++) {
		ll u, v;
		scanf("%lld%lld", &u, &v);
		if (u > v) {
			ll tmp = u;
			u = v;
			v = tmp;
		}
		all -= (u * (N - v + 1));
	}
	printf("%lld\n", all);

	return 0;
}


Measured memory_bytes: 1724
#include <iostream>
using namespace std;
int main()
{
	int r, g, b;
	cin >> r >> g >> b;

	int n = 100 * r + 10 * g + b;
	if (n % 4 == 0) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}

	return 0;
}

Measured memory_bytes: 256
#include <set>
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
	set<pair<int, int>> t;
	for (int i = 0; i<2; i++){
		int N;
		cin >> N;
		while (N--){
			int h, m;
			cin >> h >> m;
			t.insert(pair<int, int>(h, m));
		}
	}
	for (auto i = t.begin(); i != t.end();){
		printf("%d:%02d", i->first, i->second);
		++i;
		if (i != t.end())
			cout << " ";
	}
        cout << endl;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int 
#define pb push_back
#define vv vector<ll>
#define fr(i,x) for(int i=0;i<x;i++)
int dx[4] = {-1,0,0,1};
int dy[4] = {0,-1,1,0};

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    
    if(a.first == b.first) return a.second<b.second;
    return (a.first < b.first); 
}
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    
    

    ll n,x,r,cnt = 0;
    cin >> n;
    cout << n + (pow(n,2))+pow(n,3) << endl;
   
    
    
    
    
    
    
    
}

Measured memory_bytes: 4196
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("0"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



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







Measured memory_bytes: 256
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll gcd(ll a, ll b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }

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

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

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N;
    cin >> N;

    vll A(N);
    rep(i, N) cin >> A[i];

    ll ans = A[0];
    rep(i, N) ans = gcd(ans, A[i]);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3992
#include <iostream>
#include <string>
#define ll long long
#define mod 1000000007

using namespace std;

int main () {
  ll n;
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;
  ll ans = 1;
  ll rest = 3;
  for (ll i = 0; i < n; i++) {
    if (s1[i] == s2[i]) {
      ans = ((ans % mod) * (rest % mod)) % mod;
      rest = 2;    
    }  
    else {
      i++;
      if (rest == 2) {
        ans = ((ans % mod) * (rest % mod)) % mod;  
      }  
      else {
        if (rest != 3) {
          ans = ((ans % mod) * (3 % mod)) % mod;  
        }
        else {
          ans = 6;  
        }
      }
      rest = 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int n,seq[300050];
bool flg[300050];
 
bool chk(int l,int r)
{
	if(l > r) return 0;
	if(l == r) return seq[l] != l;
	int minn = 300001,maxn = 0;
	for(int i = l;i <= r; ++ i) minn = min(minn,seq[i]),maxn = max(maxn,seq[i]);
	if(minn != l || maxn != r) return 1;
	for(int i = l + 1;i <= r;i += 2)
		if(!flg[i])
			return 1;
	for(int i = l;i <= r;i += 2)
		if(flg[i])
			return 1;
	int lst1 = 0,lst2 = 0;
	for(int i = l;i <= r;i += 2)
		if(seq[i] > i)
		{
			if(lst1 > seq[i])
				return 1;
			lst1 = seq[i];
		}
		else
		{
			if(lst2 > seq[i])
				return 1;
			lst2 = seq[i];
		}
	return 0;
}
 
int main()
{
	scanf("%d",&n);
	for(int i = 1;i <= n; ++ i)
	{
		scanf("%d",&seq[i]);
		flg[i] = seq[i] == i;
	}
	flg[0] = 1;
	int las = 1;
	for(int i = 1;i <= n; ++ i)
	{
		if(flg[i] && flg[i - 1])
		{
			if(chk(las,i - 2))
			{
				printf("No\n");
				return 0;
			}
			las = i + 1;
		}
		else if(flg[i] && flg[i - 2]);
		else if(flg[i] && flg[i - 3])
		{
			if(chk(las,i - 2))
			{
				printf("No\n");
				return 0;
			}
			las = i - 1;
		}
		else if(flg[i])
		{
			printf("No\n");
			return 0;
		}
	}
	if(chk(las,n)) printf("No\n");
	else printf("Yes\n");
} 

Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <bitset>
#include <math.h>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
const ll MOD = 1e9+7;
#define INF 10000000000000


inline ll Upstair(ll n){
	ll rt;
	if(n==1) return 1;
	return n*Upstair(n-1);
}

template<class T>
bool inline ChangeMinimum( T &a, T b )
{
	if( a > b ){
		a = b;
		return true;
	}
	return false;
}

class Tree
{
	public:
//		Tree(int _root);
		int root;
		vector<int> next;
		int value = 0;
};

template<class T>
class Vec3
{
	public:
		T act[3];
};

int Stair( int now, vector<ll> &H )
{
	if( H[now] >= H[now+1] ){}
	
}

int main(void) {
	
	string W;
	inp(W);
	string ans;
	if(W=="Sunny") ans = "Cloudy";
	if(W=="Rainy") ans = "Sunny";
	if(W=="Cloudy") ans = "Rainy";
	out(ans);
	
		
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll A; cin >> A;
    string B; cin >> B;
    string C = B.substr(0, 1) + B.substr(2,2);
    ll D = stoll(C);
    ll c = A * D / 100;
    
    cout << c << endl;
}


Measured memory_bytes: 3624
using System;
using System.Linq;

class C
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var ps = new int[n].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();
		Console.WriteLine(ps.SelectMany(p => ps.Select(q => Norm(p, q))).Sum() / n);
	}

	static double Norm(int[] p, int[] q)
	{
		var dx = p[0] - q[0];
		var dy = p[1] - q[1];
		return Math.Sqrt(dx * dx + dy * dy);
	}
}


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

void Main()
{
    int a, b;
    cin >> a >> b;
    if ( a > b ) swap(a, b);
    int ans;
    if ( a == 1 & b == 2) ans = 3;
    if ( a == 2 & b == 3) ans = 1;
    if ( a == 1 & b == 3) ans = 2;
    cout << ans << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;
int main() {
    int query;
    cin >> query;
    for(int q=0;q<query;q++){
        string x,y;
        cin >> x >> y;
        vector<vector<int> > dp(x.length()+1,vector<int>(y.length()+1,0));
        for(int i=0;i<x.length();i++){
            for(int j=0;j<y.length();j++){
                if(x[i] == y[j]){
                    dp[i+1][j+1] = dp[i][j] +1;
                }else{
                    dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
                }
            }
        }
        cout << dp[x.length()][y.length()] << endl;
    }
}


Measured memory_bytes: 6752
#include <stdio.h>
#include <stdlib.h>

#define N 100000
int a[N+2];

int main(void){
    int n;
    scanf("%d", &n);
    int d=0;
    for(int i=1; i<=n; i++){
        int t;
        scanf("%d", &t);
        d += abs(a[i-1]-t);
        a[i]=t;
    }
    d += abs(a[n]-a[n+1]);
    for(int i=1; i<=n; i++){
        int t = abs(a[i-1]-a[i]) + abs(a[i]-a[i+1]) - abs(a[i-1]-a[i+1]);
        printf("%d\n", d-t);
    }
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll A, B, C, D, E, F; cin >> A >> B >> C >> D >> E >> F;
    ll T = -1;
    ll S = 0;
    for (int a = 0; a * 100 <= F; a += A) {
        for (int b = 0; (a+b)*100 <= F; b += B) {
            for (int c = 0; (a+b)*100 + c <= F; c += C) {
                for (int d = 0; (a+b) * 100 + c + d <= F; d += D) {
                    int s = c + d;
                    int t = (a+b) * 100 + s;
                    if (s <= (a+b) * E && t > 0 && (T < 0 || S*t < s*T)) {
                        S = s;
                        T = t;
                    }
                }
            }
        }
    }
    cout << T << " " << S << endl;
    return 0;
}

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

int main(){
	
	std::string A, B, C;
	std::cin >> A >> B >> C;

	bool b =
		*(A.end() - 1) == *(B.begin()) &&
		*(B.end() - 1) == *(C.begin());

	if (b) {
		std::cout << "YES" << std::endl;
	}
	else {
		std::cout << "NO" << std::endl;
	}

	return 0;
}


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

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

    int n,k;
    cin>>n>>k;
    int a[n+1];
    for(int i=0; i<=n; i++)a[i]=0;
    while(k--){
        int m;
        cin>>m;
        for(int i=0; i<m; i++){
            int x;
            cin>>x;
            a[x]++;
        }
    }
    int cnt=0;
    for(int i=1; i<=n; i++){
        if(a[i]==0)cnt++;
    }
    cout<<cnt<<"\n";

    return 0;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define REP(i, b, e) for (auto i = b; i < e; ++i)

int n, m, s, t;

typedef pair<int, int> P;

struct Edge {
    Edge(int to, int cost) : to(to), cost(cost) {}

    int to, cost;
};

vector<vector<Edge>> graph;

const int inf = 1 << 28;

int dijkstra(int s, int t) {
    priority_queue<P, vector<P>, greater<P>> que;
    vector<int> d(n, inf);
    d[s] = 0;
    que.emplace(0, s);

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (auto& e : graph[v]) {
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.emplace(d[e.to], e.to);
            }
        }
    }

    return d[t];
}

int main() {
    cin >> n >> m >> s >> t;

    s--;
    t--;

    graph.assign(n, {});

    vector<int> d(n);
    for (auto& x : d) {
        cin >> x;
    }

    REP(i, 0, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        graph[a].emplace_back(b, d[b]);
    }

    REP(i, 1, n) { graph[i].emplace_back(i - 1, 0); }

    cout << dijkstra(s, t) << endl;
}

Measured memory_bytes: 11276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
const ll INF = 1LL<<60;

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

int main(){
  ll N,X;
  cin>>N>>X;
  ll x[N];
  ll m[N];//Xとの差
  rep(i,N){
  cin>>x[i];
    m[i]=abs(X-x[i]);
  }
  ll ans=m[N-1];
  rep(i,N-1){
    ans=gcd(ans,m[i]);
  }
  
  cout<<ans<<endl;


}


Measured memory_bytes: 5176
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
	long long x,a,b;
	while(scanf("%lld%lld%lld",&x,&a,&b)!=EOF)
	{
		if(b<=a)
		printf("delicious\n");
		else if(x+a>=b)
		printf("safe\n");
		else
		printf("dangerous\n");
	}	
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main()
{
	char c[30];
	int i,ch;
	scanf("%s",c);
	ch=strlen(c);
	for(i=ch-1;i>=0;i--)
		printf("%c",c[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 524
#create date: 2020-07-25 09:13

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    w = na()
    l, r = 0, sum(w)
    ans = 10**10
    for i in range(0, n-1):
        l += w[i]
        r -= w[i]
        ans = min(ans, abs(l - r))
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9056
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1) 
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
#define MOD 1e9+7
#define inf 1e9+9
#define int long long
#define ld long double
#define fast  ios_base::sync_with_stdio(false);  cin.tie(NULL);
typedef vector<int> vi;
typedef pair<int,int> pii; 
int max(int a, int b){return a>b? a:b;}
int min(int a, int b){return a<b? a:b;}

void solve(){
	int n; cin>>n;
	int arr[n][3];
	int dp[n+1][3];
	for(int i=0;i<n;i++)
		cin>>arr[i][0]>>arr[i][1]>>arr[i][2];

	memset(dp,0,sizeof(dp));
	for(int i=1;i<=n;i++){
		dp[i][0]=arr[i-1][0]+max(dp[i-1][1], dp[i-1][2]);
		dp[i][1]=arr[i-1][1]+max(dp[i-1][0], dp[i-1][2]);
		dp[i][2]=arr[i-1][2]+max(dp[i-1][0], dp[i-1][1]);
	}
	cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;

}
int32_t main(){
	fast
	int t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 8272
#include<bits/stdc++.h>
using namespace std;
#define int long long

int N;
int a[300];
double dp[301][301][301];

double rec(int c1, int c2, int c3) {
  if(c1<0 || c2<0 || c3<0) return 0;
  if(dp[c1][c2][c3] > -0.1) return dp[c1][c2][c3];
  dp[c1][c2][c3] = (1
         + rec(c1-1, c2  , c3  ) * ((double)c1 / N)
         + rec(c1+1, c2-1, c3  ) * ((double)c2 / N)
         + rec(c1  , c2+1, c3-1) * ((double)c3 / N)) / (1.0 - (double)(N-c1-c2-c3) / N);
  return dp[c1][c2][c3];
}

signed main() {
  cin >> N;
  int count[4] = {0,0,0,0};
  for(int i=0; i<N; i++) {
    int a;
    cin >> a;
    count[a]++;
  }

  fill((double*)dp, (double*)dp+301*301*301, -1.0);

  dp[0][0][0] = 0;
  printf("%.10lf\n", rec(count[1], count[2], count[3]));
}


Measured memory_bytes: 213376
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 998244353;

int main()
{
    string A;
    cin >> A;
    // Ai != Aj (i<j) であるような (i,j) のペア数を数える
    // →全ペア数から Ai == Aj であるペア数を引く
    LLONG N = A.size();
    LLONG ans = N * (N - 1) / 2;
    map<char, LLONG> char2NumMap;
    // 各文字の数を数える：O(N)
    for (const char &ch : A)
    {
        ++char2NumMap[ch];
    }
    // 文字ごとに Ai == Aj となりうるペア数を引く：O(1)
    for (const auto &kvp : char2NumMap)
    {
        const LLONG num = kvp.second;
        ans -= num * (num - 1) / 2;
    }
    // 「操作を行わない」１通りを加えたものが答え
    cout << ans + 1 << endl;
}


Measured memory_bytes: 640
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();

    List<Integer> list = new ArrayList<>();
    for(int i = 0; i < N; i++){
      list.add(sc.nextInt());
    }
    Collections.sort(list);

    double ans = list.get(0);

    for(int i = 1; i < N; i++){
      ans = (ans + list.get(i)) / 2d;
    }

    System.out.println(ans);
  }
}


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

#define max(a,b) (((a) < (b)) ? (b) : (a))
int main(void) {
    int64_t A,B,C,X,Y;
    int64_t sum,minsum = LONG_MAX;
    cin >> A >> B >> C >> X >> Y;
    
    for(int i=0;i<=100000;i++) {
        sum = (2 * C * i) + (max(X-i,0) * A) + (max(Y-i,0) * B);
        if(minsum > sum) {
            minsum = sum;
        }
    }

    cout << minsum << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(void){
    int x[100];
    int n;
    int i;
    int k=0;
    
    do{
    scanf("%d",&n);
    }while(n<1 || n>100);
    for(i=0;i<n;i++){
        do{
        scanf("%d",&x[i]);
        }while(x[i]<1 || x[i]>1000);
    }
 
    for(i=0;i<n;i++){
        if(x[i]%2==0){
          if(x[i]%3!=0)
            if(x[i]%5!=0)
              k=1;
        }
    }
    if(k==0)
        printf("APPROVED");
    if(k==1)
        printf("DENIED");
}

Measured memory_bytes: 128