akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll ans = 0;
int first_len;
vector<string>v;
void sum(string S){
	ll pro = 0;
	
	for(int i = 0; i < S.length(); i++){
		
		if(S[i] != '+'){
			pro *= 10;
			pro+=S[i] - '0';
		//	cout<<pro<<endl;
		//	cout<<S.length()<<S<<endl;
		}
		if(S[i] == '+' || i == S.length() - 1){
			ans += pro;
			//cout<<"a"<<endl;
			//cout<<pro<<endl;
			pro = 0;
		}
	}
	
	
}

void add_plus(string S){
	if(S.length() == first_len * 2 - 1)return;
	for(int i = 0; i < S.length(); i++){
		if(S[i] != '+' && S[i + 1] != '+'){
			if(i != S.length() - 1){
			S.insert(S.begin() + i + 1, '+');
			//cout<<i<<","<<S[i]<<","<<S<<endl;
			//cout<<S<<endl;
		
			if(find(v.begin(), v.end(), S) == v.end()){
				add_plus(S);
				//cout<<S<<endl;
				sum(S);
			//	cout<<S<<endl;
				v.push_back(S);
			}
			S.erase(S.begin() + i + 1);
		}
		}	
	}
}
int main(){
	string S;
	cin>>S;
	first_len = S.length();
	sum(S);
	add_plus(S);
	cout<<ans<<endl;
	return 0;
}


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

#define ll long long
#define pb push_back
#define vb vector<bool>
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll, ll>
#define MOD 1000000007
#define MAX_TIME 1e9
#define nl "\n"
#define sp " "
#define gcd __gcd
#define pf printf
#define sf scanf
#define se(a) a.begin(),a.end()
#define fill(a,n) for(int i = 0; i < n; i++)cin>>a[i]


int main()
{
    string n;
    cin>>n;
    int ans = 0;
    for(int i = 0; i < n.size(); i++){
        ans += (n[i]-'0')%9;
    }
    if(ans%9 == 0)cout<<"Yes"<<nl;
    else cout<<"No"<<nl;
}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
#define ll 				long long
#define ld 				long double
#define fastio 			ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) 		cerr<<#x<<" "<<x<<endl
#define cina(a,n) 		for(ll i = 0;i<n;i++)	cin>>a[i];
#define couta(a,n) 		for(ll i = 0;i<n;i++) cout<<a[i]<<" ";
#define fauto(ar)		for(auto x : ar)	cout<<x<<" ";
#define mod 			1000000007
#define siz 			105
#define f 				first
#define s 				second
#define pb 				push_back
#define endl 			"\n"
#define ci 				cin.ignore()
using namespace std;
ll getans(ll h)
{
	if(h == 1)
	return 1;
	return 1 + 2*getans(h/2);
}
int main()
{
	ll h;
	cin>>h;
	cout<<getans(h);
	
	
	
	
	
	
	
}

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

int main()
{
	int n;
	int v[100][100];

	cin >> n;

	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			v[i][j] = 0;

	for (int i = 0; i < n; i++) {
		int u, k, t;

		cin >> u >> k;

		for (int j = 0; j < k; j++) {
			cin >> t;
			v[u - 1][t - 1] = 1;
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n - 1; j++)
			cout << v[i][j] << " ";
		cout << v[i][n - 1] << endl;
	}

	return 0;
}


Measured memory_bytes: 3124
#include<iostream>
#define INPUTNUM 100
using namespace std;
int main(void){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    int a = ty - sy;
    int b = tx - sx;
    for(int i(0);i<a;i++){
        cout<<"U";
    }
    for(int i(0);i<b;i++){
        cout<<"R";
    }
    for(int i(0);i<a;i++){
        cout<<"D";
    }
    for(int i(0);i<b;i++){
        cout<<"L";
    }
    cout<<"L";
    for(int i(0);i<a+1;i++){
        cout<<"U";
    }
    for(int i(0);i<b+1;i++){
        cout<<"R";
    }
    cout<<"D";
    cout<<"R";
    for(int i(0);i<a+1;i++){
        cout<<"D";
    }
    for(int i(0);i<b+1;i++){
        cout<<"L";
    }
    cout<<"U";
    cout<<endl;
    return 0;
}

Measured memory_bytes: 888
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n = INT()
c = Counter(prime_factorize(n))
ans = 0
for x in c.values():
    ans += int(-1+sqrt(1+8*x))//2
print(ans)

Measured memory_bytes: 10204
N=int(input())
A=[int(input()) for i in range(N)]
m1,m2,mi=0,0,-1
for i,a in enumerate(A):
    if a>m1:
        m1=a
        mi=i
    elif a>m2:
        m2=a
for i in range(N):
    print(m2 if i==mi else m1)

Measured memory_bytes: 12640
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String s = saori.nextHayami();
		String t = saori.nextHayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		String u = saori.nextHayami();
		if(s.equals(u)){
			a--;
		} else {
			b--;
		}
		System.out.println(a + " " + b);
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>


using namespace std;
typedef long long ll;
ll N;

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

int main(){

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

    if(A * B % 2 == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define l first
#define r second

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
    for(int n, res; cin >> n, n; cout << res << endl){
        res = 0;

        bool u = false;
        pair<bool, bool> uu = mp(false, false);

        rep(i, n){
            string in; cin >> in;
            if(in.at(0) == 'l'){
                uu.l = in.at(1) == 'u';
            }
            else{
                uu.r = in.at(1) == 'u';
            }

            if(u && uu == mp(false, false)){
                res++;
                u = false;
            }
            if(!u&& uu == mp(true, true)){
                res++;
                u = true;
            }
        }
    }

	return 0;
}

Measured memory_bytes: 1200
N = int(input())
H = list(map(int,input().split()))

sabun = [H[i+1]-H[i] for i in range(N-1)]
sei = [i+1 for i in range(N-1) if sabun[i] <= 0]

# print(sabun)
# print(sei)

if N == 1:
    print("0")
    exit()
if min(sabun) > 0:
    print("0")
    exit()

sa = [sei[i+1]-sei[i] for i in range(len(sei)-1)]
sa.append(0)
sa.insert(0,0)
index = [i for i in range(len(sa)) if sa[i] != 1]
ans = [index[i+1]-index[i] for i in range(len(index)-1)]

# print(sa)
# print(index)
if ans == []:
    print(N-1)
    exit()
print(max(ans))

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

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


Measured memory_bytes: 256
import sys

h, w = map(int, sys.stdin.readline().split())
canvas = ['.' * (w + 2)]
canvas += ['.' + sys.stdin.readline().rstrip() + '.' for _ in range(h)]
canvas += ['.' * (w + 2)]

def main():
    d = [(1, 0), (0, 1), (-1, 0), (0, -1)]
    for i in range(1, h+1):
        for j in range(1, w+1):
            if canvas[i][j] == '#':
                for di, dj in d:
                    y = i + di
                    x = j + dj
                    if canvas[y][x] == '#':
                        break
                else:
                    return 'No'
    return 'Yes'

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using lint=int64_t;
using namespace std;

template<typename T> 
void pfact(map<T,T> &m,T n)
{
	T x=n;
	for(T i=2;i*i<=n;i++)
	{
		while(x%i==0)
		{
			m[i]++;
			x/=i;
		}
	}
	if(x!=1)m[x]++;
	return;
}

int main()
{
	lint A,B;

	cin >> A >> B;

	map<lint,lint> ma;
	map<lint,lint> mb;
	pfact(ma,A);
	pfact(mb,B);

	map<lint,int> m;
	for(auto&& i:ma)
		m[i.first]++;
	for(auto&& i:mb)
		m[i.first]++;
	
	lint ans=0;
	for(auto&& i:m)
	{
		if(i.second>1)
			ans++;
	}
	cout << ans+1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<string,int> w;
int p;

int num(string &s){
    int res=0;
    while(isdigit(s[p])){
        res*=10;
        res+=s[p]-'0';
        p++;
    }
    if(res==0) res=1;
    return res;
}

int atom(string &s){
    string name="";
    name+=s[p];
    p++;
    if(islower(s[p])){
        name+=s[p];
        p++;
    }
    if(!w.count(name)){
        throw("UNKNOWN");
    }
    return w[name];
}
int weight(string& s){
    int res=0;
    while(p!=s.size() && s[p]!=')'){
        int wei;
        if(s[p]=='('){
            p++;
            wei=weight(s);
            p++;
            
        }else{
            wei=atom(s);    
        }
        int n=num(s);
        res+=wei*n;
    }
    return res;
}

int main(){
    
    while(true){
        string name;
        cin>>name;
        if(name=="END_OF_FIRST_PART") break;
        int wv;
        cin>>wv;
        w[name]=wv;
    }
    string s;
    while(cin>>s,s!="0"){
        p=0;
        try{
            cout<<weight(s)<<endl;
        }catch(const char* msg){
            cout<<"UNKNOWN"<<endl;
        }
    }
    return 0;
}


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

int main() {
    vector<int> avg;
    while(true) {
        int n;
        cin >> n;
        if(n==0)
            break;

        vector<int> v(n);
        int sum = 0;
        int ma = -1;
        int mi = 10000;
        for(int i=0;i<n;i++) {
            int vi;
            cin >> vi;
            ma = max(ma, vi);
            mi = min(mi, vi);
            sum += vi;
        }

        sum = sum - ma - mi;
        avg.push_back(sum/(n-2));
    }
    for(int i=0;i<avg.size();i++)
        cout << avg[i] << endl;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}

ll dp[2020][2020];
ll sum[2020][2020];
int main(void) {
  ll N, M;
  cin >> N >> M;
  ll s[2020], t[2020];
  ll i, j;
  
  for(i=0; i<N; i++) cin >> s[i];
  for(i=0; i<M; i++) cin >> t[i];
  
  for(i=0; i<=N; i++) dp[i][0]=1;
  for(j=0; j<=M; j++) dp[0][j]=1;
  
  for(i=0; i<N; i++) {
    for(j=0; j<M; j++) {
      if(s[i]==t[j])
        dp[i+1][j+1]=(dp[i+1][j]+dp[i][j+1])%MOD;
      else
        dp[i+1][j+1]=(dp[i+1][j]+dp[i][j+1]-dp[i][j]+MOD)%MOD;
    }
  }
  
  pt(dp[N][M]);
  
}







Measured memory_bytes: 33024
/*
?????????????????¨?????????????????¨????????????
????±???¨?????????????????????????????¨????????????????????¨???????????´??????????????°???????????¶???????????°??¢
*/
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(ll i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

const double EPS = 1e-14;
int main(void){
	ll n;
	cin >> n;
	vector<pair<double, double> > point(n);//fi???;x??§?¨???? se ;y??§?¨?
	rep(i, n) scanf("%lf %lf", &point[i].fi, &point[i].se);

	//n????\???°?????¨??????????§°??????????????????
	if(n % 2 == 1){
		printf("NA\n");
		return 0;
	}

	//???????????§??????
	vector<double> len(n);
	rep(i, n - 1){
		double tmp = pow(point[i + 1].fi - point[i].fi, 2) + pow(point[i + 1].se - point[i].se, 2);
		len.push_back(tmp);
	}
	double tmp = pow(point[0].fi - point[n - 1].fi, 2) + pow(point[0].se - point[n - 1].se, 2);
	len.push_back(tmp);
	sort(all(len));
	if(len[n - 1] - len[0] > EPS){
		printf("NA\n");
		return 0;
	}

	//????±???¨????????????????????????????±???????
	vector<double> Px;
	vector<double> Py;
	rep(i, n / 2){
		double x = (point[i].fi + point[i + n / 2].fi) / 2.0;
		Px.push_back(x);
		double y = (point[i].se + point[i + n / 2].se) / 2.0;
		Py.push_back(y);
	}

	//?????§?±???????????±???¨??????????????????????????????????????§??????????????¨?°?????????????????????´??????????????°??????????±???§??????
	sort(all(Px));
	if(Px[n / 2 - 1] - Px[0] > EPS){
		printf("NA\n");
		return 0;
	}
	sort(all(Py));
	if(Py[n / 2 - 1] - Py[0] > EPS){
		printf("NA\n");
		return 0;
	}

	printf("%.9f %.9f\n", Px[0], Py[0]);
	return 0;
}

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

int main(){
  long long a, b, c;
  cin >> a >> b;
  if(a == 1){
    cout << 1 << endl;
    return 0;
  }
  if(b == 1){
    cout << 1 << endl;
    return 0;
  }
  c = a * b / 2;
  if(a * b % 2 == 1)
    c++;
  cout << c << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d\n", &n)

	slice := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d\n", &slice[i])
	}

	min := 100
	sum := 0
	for i := 0; i < n; i++ {
		sum += slice[i]
		if slice[i]%10 != 0 {
			if slice[i] < min {
				min = slice[i]
			}
		}
	}

	if sum%10 == 0 {
		if min != 100 {
			sum -= min
		} else {
			sum = 0
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 1840
import math
import itertools
import numpy as np
def l2_dist(a,b):
    return math.sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2)
def rate(n):
    if n == 1:
        return 2
    else:
        return n * rate(n - 1) 
def fact(n):
    if n == 1 or n == 0:
        return 1
    else:
        return n * fact(n - 1)
n = int(input())
point_list = []
for i in range(n):
    point_list.append(tuple(map(float,input().split(' '))))
dist_list = []
for i in itertools.combinations([i for i in range(n)], 2):
    dist_list.append(l2_dist(point_list[i[0]],point_list[i[1]]))
r = rate(n - 1) if n > 2 else 1
f = fact(n) if n > 2 else 1
dist_list = np.asarray(dist_list) * r
print(dist_list.sum() / f)

Measured memory_bytes: 12500
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<ctime>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<utility>
#include<string>
using namespace std;
char m[10][10];
int main(void){
  while(cin >> m[1][1]){
    for(int i=1;i<=8;i++){
      for(int j=1;j<=8;j++){
	if(i!=1 || j!=1)scanf(" %c",&m[i][j]);
      }
    }
    bool f=true;
    for(int i=1;i<=8 && f;i++){
      for(int j=1;j<=8 && f;j++){
	if(m[i][j]=='1'){
	  if(m[i+1][j]=='1' && m[i][j+1]=='1' && m[i+1][j+1]=='1'){
	    puts("A");
	    f=false;
	  }
	  else if(m[i+1][j]=='1' && m[i+2][j]=='1' && m[i+3][j]=='1'){
	    puts("B");
	    f=false;
	  }
	  else if(m[i][j+1]=='1' && m[i][j+2]=='1' && m[i][j+3]=='1'){
	    puts("C");
	    f=false;
	  }
	  else if(m[i+1][j]=='1' && m[i+1][j-1]=='1' && m[i+2][j-1]=='1'){
	    puts("D");
	    f=false;
	  }
	  else if(m[i][j+1]=='1' && m[i+1][j+1]=='1' && m[i+1][j+2]=='1'){
	    puts("E");
	    f=false;
	  }
	  else if(m[i+1][j]=='1' && m[i+1][j+1]=='1' && m[i+2][j+1]=='1'){
	    puts("F");
	    f=false;
	  }
	  else if(m[i][j+1]=='1' && m[i+1][j]=='1' && m[i+1][j-1]=='1'){
	    puts("G");
	    f=false;
	  }
	}
      }
    }
  }
}

Measured memory_bytes: 0
# 公式解答
N = int(input())

def solve(s):
  if int(s) > N:
    return 0
  res = 1 if all(s.count(c)>0 for c in '753') else 0 # s自体が七五三数なら+1
  for c in '753':
    res += solve(s + c)
  return res

print(solve('0'))

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
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;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int a;
  cin >> a;
  string s;
  cin >> s;
  if (a >= 3200) {
    cout << s << endl;
  } else {
    cout << "red" << endl;
  }
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

  int a, p;
  cin >> a >> p;

  int apple_piece = a * 3;
  int pie = (apple_piece + p) / 2;

  cout << pie << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(int)(n); ++i)
 
template<class T> inline bool chmin(T &a, T b) { if(a>b){ a=b; return true; }  return false;}
template<class T> inline bool chmax(T &a, T b) { if(a<b){ a=b; return true; }  return false;}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  ll x, y; cin >> x >> y;
  if((2*x-y)%3!=0 || (2*y-x)%3!=0) {
    cout << 0 << endl;
    return 0;
  }
  // a+b C aする
  ll a = (2*x-y)/3;
  ll b = (2*y-x)/3;
  combination con(a+b);
  mint ans = con(a+b, a);

  cout << ans.x << endl;
}


Measured memory_bytes: 10624
A,B,H,M = map(int,input().split())
import math
# 角度を求める
#長針
m = 6*M
#短針
h = (H * 30) + ((30/60)*M)
#最終角度
kakudo = min(360 - abs(m - h), abs(h - m))
kakudo_a = math.radians(kakudo)
cos_x = math.cos(kakudo_a)
 
c = A**2 + B**2 - 2*A*B*cos_x
print(math.sqrt(c))

Measured memory_bytes: 9460
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
 #define mod 1000000007
 const int N=100005;
 const int inf=1e18;
 const double eps=1e-9;
int pow(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int a;
    string s;
    cin>>a>>s;
    if(a>=3200){
        cout<<s;
    }else{
        cout<<"red";
    }








	
return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, m, c int
	fmt.Scan(&n, &m, &c)

	listB := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&listB[i])
	}
	list := make([][]int, n)
	for i := 0; i < n; i++ {
		list[i] = make([]int, m)
		for j := 0; j < m; j++ {
			fmt.Scan(&list[i][j])
		}
	}

	count := 0
	for i := 0; i < n; i++ {
		result := 0
		for j := 0; j < m; j++ {
			result += list[i][j] * listB[j]
		}
		if result+c > 0 {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
#include <cstdio>

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

    long res = 0;
    while (n --) {
        int l, r;
        scanf("%d %d", &l, &r);
        res += r - l + 1;
    }
    printf("%ld\n", res);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
string A = "AKIHABARA";
int I[]{8,6,4,0};
int main() {
  string S;
  cin >> S;
  bool flag{0};
  for (int i = 0, n = 1 << 4; i != n; ++i) {
    string B{A};
    int j = i, k{};
    while(j) {
      if (j&1) B.erase(I[k],1);
      ++k, j >>= 1;
    }
    if (S == B) {
      flag = 1;
      break;
    }
  }
  cout << (flag ? "YES" : "NO") << endl;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

template<typename T>
class CumulativeSum {
	vector<T> a;
	public:
	CumulativeSum(vector<T>& x) : a(x.size() + 1,0) {
		rep(i,x.size()){
			a[i + 1] = a[i] + x[i];
		}
	}
	T get(int l, int r){ // [l, r]の区間の合計を求める
		if(l < 0 or r < 0) return 0;
		if(l >= r) return 0;
		return a[r + 1] - a[l];
	}
	T operator [] (const int i) const {
		return a[i];
	}
};

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

	vector<char> a(n);
	cin >> a;

	vector<int> e(n, 0), w(n, 0);
	rep(i,a.size()){
		if(a[i] == 'W'){
			w[i]++;
		}else{
			e[i]++;
		}
	}

	CumulativeSum<int> E(e), W(w);

	int ans = 1e9;
	rep(i,n){
		ans = min(ans, W.get(0, i - 1) + E.get(i + 1, n - 1));
		//cout << i << ' ' << ans << endl;
	}
	cout << ans << endl;
}


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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    vector<int> pasta(3);
    rep(i, 3) cin >> pasta[i];
    vector<int> juice(2);
    rep(i, 2) cin >> juice[i];
    int ans = INF;
    rep(i, 3) rep(j, 2) {
        ans = min(ans, pasta[i] + juice[j] - 50);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3180
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner (System .in);
        Integer a = scan.nextInt();
        Integer b = scan.nextInt();

        if(a <= 9 && b <= 9){
            System.out.println(a*b);
        }
        else {
            System.out.println(-1);
        }
        scan.close();
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
//#define s second
#define f first
long long const mod = 1000000007; 
#define inf 1000000000000000000
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod)+mod)%mod;}
inline ll mul(ll a, ll b){ return (((a%mod)*(b%mod))%mod+mod)%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

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

ll power(ll x,ll y,ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
}

ll modInv(ll x)
{
    return power(x,mod-2,mod)%mod;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
   
    ll s,w;
    cin>>s>>w;
    if(w>=s)
    {
        cout<<"unsafe\n";
    }
    else
    {
        cout<<"safe\n";
    }
    

    return 0;
}



Measured memory_bytes: 3648
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=0
for j in range(N):
    tmp=min(A[j],B[j])
    ans+=tmp
    B[j]-=tmp
    tmp=min(A[j+1],B[j])
    ans+=tmp
    A[j+1]-=tmp
print(ans)

Measured memory_bytes: 19116
import java.util.Arrays;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Collectors;

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

        int n = sc.nextInt();
        String[] s = new String[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
        }

        var es = Arrays.stream(s).collect(Collectors.groupingBy(key -> key, Collectors.counting())).entrySet();
        long max = es.stream().max(Map.Entry.comparingByValue()).get().getValue();
        es.stream()
                .filter(e -> e.getValue() == max)
                .sorted(Map.Entry.comparingByKey())
                .forEach(e -> System.out.println(e.getKey()));
    }
}

Measured memory_bytes: 84964
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
#define chmin(x,y) x = min(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;



int main() {
    int n;
    cin >> n;
    vector<deque<int>> a(n);
    rep(i,n) {
        rep(j,n-1) {
            int A;
            cin >> A;
            A--;
            a[i].push_back(A);
        }
    }
    vector<P> q;
    auto check = [&](int i) {
        if (a[i].size() == 0) return;
        int j = a[i].front();
        if (a[j].size() == 0) return;
        if (a[j].front() == i) {
            P p(i,j);
            if (p.second < p.first) swap(p.first, p.second);
            q.push_back(p);
        }
    };
    rep(i,n) check(i);
    int day = 0;
    while (q.size() > 0) {
        day++;
        sort(q.begin(), q.end());
        q.erase(unique(q.begin(), q.end()), q.end());
        vector<P> prevQ;
        swap(prevQ, q);
        for (P p : prevQ) {
            int i = p.first, j = p.second;
            a[i].pop_front();
            a[j].pop_front();
        }
        for (P p : prevQ) {
            int i = p.first, j = p.second;
            check(i);
            check(j);
        }
    }
    rep(i,n) {
        if (a[i].size() != 0) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << day << endl;
    return 0;
}

Measured memory_bytes: 8056
require 'pp'

n, d = gets.split.map(&:to_i)
a_n = Array.new(n)
n.times do |i|
    x, y = gets.split.map(&:to_i)
    a_n[i] = [x, y]
end

count = 0
a_n.each do |a|
    t = Math.sqrt(a[0] ** 2 + a[1] ** 2)
    if t <= d
        count += 1
    end
end

puts count


Measured memory_bytes: 28784
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}
int main() {
long long a,b,c,d;
cin >> a >> b >> c >> d;
long long ans_b=b-(b/c)-(b/d)+(b/lcm(c,d));
long long ans_a=(a-1)-((a-1)/c)-((a-1)/d)+((a-1)/lcm(c,d));
cout << ans_b-ans_a << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
struct Node {
  int parent;
  int left;
  int right;
};
int n;
struct Node tree[100000];
int dipth[100000];
void getdip(int,int);
void printtree(int);
int main(){
  int i,id,j,num,p,l,root;
  scanf("%d",&n);
  for(i=0;i<n;i++)tree[i].parent=tree[i].left=tree[i].right=-1;
  for(i=0;i<n;i++){
    scanf("%d %d",&id,&num);
    for(j=0;j<num;j++){
      scanf("%d",&p);
      if(j==0)tree[id].left=p;
      else tree[l].right=p;
      tree[p].parent=id;
      l=p;
    }
  }
  for(i=0;i<n;i++){
    if(tree[i].parent==-1)root=i;
  }
  getdip(root,0);
  for(i=0;i<n;i++)printtree(i);
  return 0;
}
void getdip(int r,int d){
  dipth[r]=d;
  if(tree[r].right!=-1)getdip(tree[r].right,d);
  if(tree[r].left!=-1)getdip(tree[r].left,d+1);
}
void printtree(int i){
  int m,j=0;
  printf("node %d: parent = %d, depth = %d, ",i,tree[i].parent,dipth[i]);
  if(tree[i].parent==-1)printf("root, [");
  else if(tree[i].left==-1)printf("leaf, [");
  else printf("internal node, [");
  m=tree[i].left;
  while(m!=-1){
    if(j!=0)printf(", ");
    printf("%d",m);
    m=tree[m].right;
    j++;
  }
  printf("]\n");
}




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

using namespace std;

int n, m;
struct edge{
	int u, v, flip;
};
vector<edge> e;
vector<vector<int> > g;
vector<int> vis, f;
int dfs(int cur, int eid){
	vis[cur] = 1;
	for(int u: g[cur]){
		int next = e[u].u + e[u].v - cur;
		if(vis[next] == 1) continue;
		f[cur] ^= dfs(next, u);
	}
	if(f[cur]){
		if(eid != -1){
			assert(eid >= 0 && eid < e.size());
			e[eid].flip ^= 1;
		}
	}
	return f[cur];
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>n>>m;
	if(m%2 != 0){
		cout<<-1<<endl;
		return 0;
	}

	e.resize(m);
	g.resize(n);
	for(int i = 0; i < m; i++){
		cin>>e[i].u>>e[i].v; //egde is right now going from u to v
		e[i].u--; e[i].v--;
		e[i].flip = 0;
		g[e[i].u].push_back(i);
		g[e[i].v].push_back(i);
	}
	vis.resize(n);
	f.resize(n);
	for(int i = 0; i < n; i++){
		f[i] = 0;
		for(int k: g[i]){
			if(e[k].u == i){
				f[i] ^= 1;
			}
		}
	}
	dfs(0, -1);
	for(auto ed: e){
		if(ed.flip){
			swap(ed.u, ed.v);
		}
		cout<<ed.u+1<<" "<<ed.v+1<<endl;
	}
}

Measured memory_bytes: 13568
import sys
s=input()
if s.startswith("A") and s[2:len(s)-1].count("C")==1:
    for i in range(len(s)):
        if s[i]=="C" or s[i]=="A":
            pass
        else:
            if s[i]!=s[i].lower():
                print("WA")
                sys.exit()
    print("AC")
else:
    print("WA")
        

Measured memory_bytes: 2940
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i_a in range(a+1):
    for j_b in range(b+1):
        for k_c in range(c+1):
            if(i_a * 500 + j_b * 100 + k_c * 50 == x):
                count = count + 1
if a == b == c == 0:
    count = count + 1
print(count)


Measured memory_bytes: 3060
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int cnt = 0;
        
        for(int i = 0;i<10;i++){
            for(int j = 0;j<10;j++){
                if(n==i*j){
                    cnt++;
                }
            }
        }
        if(cnt!=0){
            System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }
}


Measured memory_bytes: 23124
n = int(input())
p = list(map(int, input().split()))

ans = 0
for i in range(1, len(p)-1):
    if p[i - 1] < p[i] < p[i + 1] or p[i + 1] < p[i] < p[i - 1] :
        ans += 1
print(ans)

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

#define sswap(x, y) { x+=y; y=x-y; x-=y; }
#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
	int n, l, s, m;
	s = 0;
	m = 555;
	cin >> n >> l;
	n++;
	while (--n) {
		s += n+l-1;
		m = abs(m) > abs(n+l-1) ? n+l-1 : m;
	}
	cout << s-m << ende;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL << 60;
 
int main(){
 
  ll n;cin>>n;
  ll l[n+10];rep(i,0,n)cin>>l[i];

  sort(l,l+n);

  ll ans=0;

  rep(i,0,n-2){
     rep(j,i+1,n-1){
        rep(k,j+1,n){
           if(l[i]+l[j]>l[k])ans++;
         }
     }	
  }

  out(ans);
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,x,y,i;
	x=0;
	y=0;
	
//	for(i=0;i<3;i++) {
		scanf("%d",&a);
		if(a==5)	x++;
		if(a==7)	y++;
//	}
//	for(i=0;i<3;i++) {
		scanf("%d",&b);
		if(b==5)	x++;
		if(b==7)	y++;
//		}
//	for(i=0;i<3;i++) {
		scanf("%d",&c);
		if(c==5)	x++;
		if(c==7)	y++;
//		}
//		printf("%d %d\n",x,y);
		if(x==2&&y==1) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
A, B, C, D, E, F = gets.split.map(&:to_i)
rate, sugar, water = 0, 0, 0
N=F/100
ws = []
ss = []
(N+1).times do |x|
  (N+1).times do |y|
    break if x+y > N
    w = A*x*100+B*y*100
    ws << w if w <= F  
  end
end
(F+1).times do |x|
  (F+1).times do |y|
    break if x+y > F
    s = C*x+D*y
    ss << s if s <= F
  end
end
ws.each do |w|
  ss.each do |s|
    next if s > w
    next if w+s > F
    next if E < s.to_f/(w/100)
    r = s.to_f / (s + w)
    if rate < r
      rate = r
      sugar = s
      water = w
    end
  end
end
if water == 0
  puts [ws[1] + sugar, sugar] * " "
else
  puts [water + sugar, sugar] * " "
end

Measured memory_bytes: 3836
import fractions

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def main():
    n = int(input())
    num_list = list(map(int, input().split()))

    left = [0] * (n + 1)
    right = [0] * (n + 1)
    for i in range(n):
        left[i + 1] = (fractions.gcd(left[i],num_list[i]))
        right[n - i - 1] = (fractions.gcd(right[n - i],num_list[n - 1 - i]))
    
    ans = 0
    for i in range(n):
        ans = max(ans,fractions.gcd(left[i],right[i + 1]))

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 89580
# 2019 = 3*673
MOD = 2019
S = input()
N = len(S)
X = [0]*2100
X[0] += 1
tmp = 0
hoge = pow(10,N,2019)

for i in range(N):
    tmp = (tmp*10+int(S[i]))%MOD
    hoge = (hoge*202)%MOD 
    X[(tmp*hoge)%MOD] += 1

ans = 0

for i in X:
    ans += ((i*(i-1))//2)

print(ans)

Measured memory_bytes: 9324
import sys
N=int(input())
L=[int(i)-1 for i in input().split()]
M=[]
while True:
    flag=0
    if len(L)==0:
        for m in M[::-1]:
            print(m+1)
        sys.exit()
    for i in range(len(L)-1,-1,-1):
        if L[i]==i:
            s = L.pop(i)
            M.append(s)
            flag=1
            break
    if flag==0 and len(L)!=0:
        print(-1)
        sys.exit()



Measured memory_bytes: 38384
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

# 参考にしました(参考というよりほぼ写経)
# https://drken1215.hatenablog.com/entry/2019/10/05/173700

n = I()
dp = [[0] * (n+2) for _ in range(n+1)]
# 今回の順位と前回の順位を結んだグラフを考える
# dp[i][j] := i番目まで見たときに, j個繋がっているときの場合の数
dp[0][0] = 1
for i in range(n):
    s = input()
    if s == 'U':
        # Uのとき，今回順位から前回順位に向かう辺は必ず下向きなので
        # i+1番目まで見たときに今回順位からの辺によってjが増加することはない
        # jが増加するのは前回順位からの辺が上に伸びている場合
        # このとき，対応するペアを今回順位の中からi-j個の中から選ぶ
        for j in range(n):
            dp[i+1][j] += dp[i][j]# 今回順位からも前回順位からも下へ伸びている場合
            dp[i+1][j+1] += dp[i][j] * (i - j)# 今回順位からは下へ，前回順位からは上へ伸びている場合
            dp[i+1][j+1] %= mod 
    elif s == '-':
        # -のとき，今回順位から前回順位に向かう辺は必ず同じ位置であり，
        # 前回順位から今回順位へ向かう辺も必ず同じ位置である
        # つまり，jが1だけ増加する
        for j in range(n):
            dp[i+1][j+1] += dp[i][j]
    else:
        # Dのとき，今回順位から前回順位に向かう辺は必ず上向きなので
        # i+1番目まで見たときに今回順位からの辺によって必ずjが増加する
        # 前回順位から今回順位へ向かう辺が上向きの場合は，両方ともjが増加するのでj+2
        # 前回順位から今回順位へ向かう辺が下向きの場合は，jが増加しないのでj+1
        for j in range(n):
            dp[i+1][j+2] += dp[i][j] * (i - j) * (i - j)# 今回順位からも前回順位からも上へ伸びている場合
            dp[i+1][j+2] %= mod
            dp[i+1][j+1] += dp[i][j] * (i - j)# 今回順位からは上へ，前回順位からは下へ伸びている場合
            dp[i+1][j+1] %= mod
print(dp[n][n])




Measured memory_bytes: 6648
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i,j,k,l;
    cin>>n;
    long long arr[n+10];
    for(i=1;i<=n;i++)
    {
        cin>>k;
        arr[k]=i;
    }
    for(i=1;i<=n;i++)
    {
        cout<<arr[i]<<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 1536
import collections
import math
import operator as op
from functools import reduce
from collections import Counter
import numpy as np
import math
import bisect
import heapq


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def main():
    S = get_input()
    if S == "ABC":
        print("ARC")
    else:
        print("ABC")


if __name__ == '__main__':
    main()


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

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

    int N;
    cin >> N;
    vector<int> A(N);
    for (auto &x : A) cin >> x;

    int ans = 1;
    int comp = 0;
    for (int i = 1; i < N; ++i) {
        if (comp == 1) {
            if (A.at(i - 1) > A.at(i)) {
                ans++;
                comp = 0;
            }
        } else if (comp == -1) {
            if (A.at(i - 1) < A.at(i)) {
                ans++;
                comp = 0;
            }
        } else {
            if (A.at(i - 1) < A.at(i)) {
                comp = 1;
            } else if (A.at(i - 1) > A.at(i)) {
                comp = -1;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main(){
    string s;
    cin >> s;
    bool a=1;
    for(int i=0;i<s.length()-1;i++){
        if(s.at(i) == s.at(i+1)){
            a=0;
        }
    }
    cout << (a ? "Good" : "Bad") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>

using namespace std;
#define i64  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807

void solve(void)
{

  char str[1200];
  cin.getline(str,sizeof(str));
  
  for (int i = 0; i < 1200; i++)
  {
    if((str[i] >= 'A') && str[i] <= 'Z')
    {
      str[i] += 32;
    }
    else if((str[i] >= 'a') && str[i] <= 'z')
    {
      str[i] -= 32;
    }
  }
  
  cout<<str<<endl;
    

  return;
}

int main(int argc, const char *argv[])
{

  solve();

  return 0;
}



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

int n,ans;

int main()
{
	scanf("%d",&n);
	int t;
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&t);
		if(t%2)ans++;
	}
	if(ans%2)printf("NO");
	else printf("YES");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void init_ios() {ios_base::sync_with_stdio(false); cin.tie(nullptr);}

int N;

int main() {
	cin >> N;

	vector<int> a(N), b(N);
	long long asum = 0, bsum = 0;

	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		asum += a[i];
	}
	for (int i = 0; i < N; ++i) {
		cin >> b[i];
		bsum += b[i];
	}

	if (bsum < asum) {
		cout << "No" << endl;
		return 0;
	}

	long long diffsum = asum - bsum;

	long long cnt1 = 0, cnt2 = 0, aadd = 0, badd = 0;
	for (int i = 0; i < N; ++i) {
		if (a[i] < b[i]) {
			long long c = b[i] - a[i];
			if (c % 2) {
				cnt1 += c / 2;
			} else {
				cnt1 += c / 2 + 1;
				cnt2 += 1;
			}
		} else {
			cnt2 += a[i] - b[i];
		}
	}

	if (cnt1 < cnt2) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
char m[100][100];
int main()
{
	int x,y;
	scanf("%d%d", &x, &y);
	for (int i = 1; i <= x; i++)for (int j = 1; j <= y; j++)scanf(" %c", &m[i][j]);
	for (int i = 1; i <= x; i++)
	{
		for (int j = 1; j <= y; j++)
		{
			if (m[i][j] == '#')printf("#");
			else
			{
				int c = 0;
				for (int k = -1; k <= 1; k++)for (int l = -1; l <= 1; l++)c += (m[i + k][j + l] == '#');
				printf("%d", c);
			}
		}
		printf("\n");
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main(){
    int a[6];
    F(i,0,6) cin >> a[i];
    int ans=0;
    string s;
    cin >> s;
    int t;
    F(i,0,s.size()){
        switch(s[i]){
            case 'N':   t=a[0];
                        a[0]=a[1];
                        a[1]=a[5];
                        a[5]=a[4];
                        a[4]=t;
                        break;
            case 'S':   t=a[0];
                        a[0]=a[4];
                        a[4]=a[5];
                        a[5]=a[1];
                        a[1]=t;
                        break;
            case 'W':   t=a[0];
                        a[0]=a[2];
                        a[2]=a[5];
                        a[5]=a[3];
                        a[3]=t;
                        break;
            case 'E':   t=a[0];
                        a[0]=a[3];
                        a[3]=a[5];
                        a[5]=a[2];
                        a[2]=t;
                        break;
        }
    }
    cout << a[0] << endl;
    return 0;
}


Measured memory_bytes: 3176