akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define VPII vector<pair<int,int> >
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = 1e9+7;
const LL INF = 1LL<<60;
const int MAXN = 2e5;
const double eps = 1e-13;

LL rs1[100009];//c
LL rs2[100009];//m
int a[100009];

int main(){
	DRII(n,m);
	LL ans0=0;
	REP(i,n){
		RI(a[i]);a[i]--;
		if(i){
			if(a[i]>a[i-1]){
				ans0+=a[i]-a[i-1];
				rs2[a[i-1]+1]+=1;
				rs2[a[i]+1]--;
				rs1[a[i-1]+1]-=a[i-1]+1;
				rs1[a[i]+1]+=a[i-1]+1;
			}
			else{
				ans0+=m-a[i-1]+a[i];
				rs2[a[i-1]+1]+=1;
				rs1[a[i-1]+1]-=a[i-1]+1;
				rs2[0]++;
				rs1[0]+=m-1-a[i-1];
				rs2[a[i]+1]-=1;
				rs1[a[i]+1]-=m-1-a[i-1];
			}
		}
		//REP(i,m)printf("%lld ",rs1[i]);puts("");
		//REP(i,m)printf("%lld ",rs2[i]);puts("");puts("");
	}
	LL ans=0;
	REP(i,m){
		if(i)rs1[i]+=rs1[i-1],rs2[i]+=rs2[i-1];
		//printf("%lld %lld\n",rs1[i],rs2[i]);
		ans=max(ans,rs2[i]*i+rs1[i]);
	}
	printf("%lld",ans0-ans);
}

Measured memory_bytes: 2176
#include <iostream>
using namespace std;
int main(){
  int n,tmp=0;
  cin >> n;
  if(n/100==9) tmp+=100;
  else tmp+=900;
  if(n/10%10==9)tmp+=10;
  else tmp+=90;
  if(n%10==9)tmp+=1;
  else tmp+=9;

  cout << tmp;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var line = Console.ReadLine();
        var formerNum = int.Parse(line.Split(' ')[0]);
        var latterNum = int.Parse(line.Split(' ')[1]);
        var str = Console.ReadLine();

        if (str[formerNum] != '-' || str.Length != formerNum + latterNum + 1)
        {
            Console.WriteLine("No");
            return;
        }

        var formerStr = str.Substring(0, formerNum);
        var latterStr = str.Substring(formerNum + 1, latterNum);
        
        foreach (char c in formerStr + latterStr)
        {
            if (c < '0' || '9' < c)
            {
                Console.WriteLine("No");
                return;
            }
        }

        Console.WriteLine("Yes");
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i,n) for(int i = 0; i < int(n);++i)
#define pb push_back
#define vi vector<int>
#define vb vector<bool>
#define vll vector<ll>
#define sz(x) (int)x.size()

int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    bool x = true, y = true;
   for(int i = 0 ; i < sz(s); i += 2){
        if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D'){
            x = false;
        }
    }
    for(int i = 1 ; i < sz(s); i += 2){
        if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D'){
            y = false;
        }
    }
    if(x&&y){
        cout << "Yes";
    }else{
        cout << "No";
    }
    /* ll t;
    cin >> t;
    while(t--){
    	solve();
    }*/
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int n, m, l;
	int i, j, k;
	scanf("%d%d%d", &n, &m, &l);

	int a[n][m], b[m][l];
	long long c[n][l];

	//?????????
	for (i=0;i<n;i++)
	{
		for (j=0;j<l;j++)
		{
			c[i][j]=0;
		}
	}

	//a
	for (i=0;i<n;i++)
	{
		for (j=0;j<m;j++)
		{
			scanf("%d", &a[i][j]);
		}
	}

	//b
	for (i=0;i<m;i++)
	{
		for (j=0;j<l;j++)
		{
			scanf("%d", &b[i][j]);
		}
	}

	//c;

	for (i=0;i<n;i++)
	{
		for (j=0;j<l;j++)
		{
			for (k=0;k<m;k++)
			{
				c[i][j]+=a[i][k]*b[k][j];
				
			}
		printf("%lld", c[i][j]);
		if (j!=l-1)
		{
			printf(" ");
		}
		}
	printf("\n");
	}

	return 0;
}

Measured memory_bytes: 760
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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



	string s;
	cin >> s;
	int ans = 0;
	REP(i, 4) {
		if (s[i] == '+')ans++;
		else ans--;
	}

	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
n=int(input())
t,a=map(int,input().split())
ans=1
b=10**5
h=list(map(int,input().split()))
for i in range(n):
  if abs(b-a)>abs(t-h[i]*0.006-a):
    b=t-h[i]*0.006
    ans=i+1
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
long long int fact[1000006];
long long int modpow(long long int a, long long int n, long long int p)
{
	long long int res = 1;
	while (n > 0)
	{
		if (n % 2 > 0)
			res = res * a % p;
		a = a * a % p;
		n /= 2;
	}
	return res;
}
long long int comb(long long int n, long long int r, long long int p)
{
	long long int res = fact[n];
	res = res * modpow(fact[r], p - 2, p) % p;
	res = res * modpow(fact[n - r], p - 2, p) % p;
	return res;
}
int main()
{
	long long int n, k;
	scanf("%lld %lld", &n, &k);
	long long int p = 1000000007;
	long long int i;
	fact[0] = 1;
	for (i = 1; i < 1000006; i++)
		fact[i] = fact[i - 1] * i % p;
	if (k >= n - 1)
	{
		printf("%lld\n", comb(2 * n - 1, n, p));
		return 0;
	}
	long long int ans = 0;
	for (i = 0; i <= k; i++)
		ans = (ans + comb(n, i, p) * comb(n - 1, n - i - 1, p) % p) % p;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 7936
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define si(x)     scanf("%d", &x)
#define sll(x)    scanf("%lld", &x)
#define ssll(x,y)    scanf("%lld %lld", &x ,&y)
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int lim = 1e8+5;

int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		int k;
			cin>>k;
	if(k%2==0||k%5==0){
		cout<<-1;
		return 0;
	}
	int cur=7%k;
	int ans=1;
	while(cur!=0){
		cur=cur*10+7;
		cur%=k;
		ans++;
	}
	cout<<ans<<endl;
		return 0;
}  

/*
             
      * string s = 7;
      * ull x = stoi(s)
      * if divided print length
      * else s+='7'

*/


Measured memory_bytes: 3560
h,w,m = map(int, input().split())
row = [0]*(h+1)
rn = [[] for _ in range(h+1)]
col = [0]*(w+1)
cn = [[] for _ in range(w+1)]
data = []
for _ in range(m):
  hd,wd = map(int, input().split())
  row[hd] += 1
  rn[hd].append(wd)
  col[wd] += 1
  cn[wd].append(hd)

cm = max(col)
rm = max(row)
ri = [x for x,y in enumerate(row) if y == rm]
ci = [x for x,y in enumerate(col) if y == cm]
for r in ri:
  rs = set(rn[r])
  for c in ci:
    if c not in rs:
      ans = cm+rm
      print(ans)
      exit()
ans = cm+rm-1
print(ans)

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

int N, t, links, rechts, cur, num;
vector<int> L;

int main(void)
{
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> t;
		L.push_back(t);
	}

	sort(L.begin(), L.end());
	rechts = L.size() - 1;

	for (int i = L.size() - 1; i >= 0; --i) {
		rechts = i - 1;
		links = 0;
		cur = L[i];
		while (links < rechts) {
			if (L[links] + L[rechts] <= cur)
				links++;
			else {
				num += rechts - links;
				rechts--;
			}
		}
	}
	cout << num << "\n";
	return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
alist=list(map(int,input().split()))

cnt=0
while cnt<K:
  blist=[0]*(N+1)
  for i in range(N):
    l=max(0,i-alist[i])
    r=min(N-1,i+alist[i])
    blist[l]+=1
    blist[r+1]-=1
  
  alist[0]=blist[0]
  for i in range(1,N):
    alist[i]=alist[i-1]+blist[i]
  cnt+=1
  
  #print(alist,blist)
  if min(alist)==N:
    break
  
#print(cnt)
print(*alist)

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

N, M = map(int, input().split())
l_list = []
for _ in range(M):
    data = list(map(int, input().split()))[1:]
    l_list.append(sum(2**(x-1) for x in data))

p_list = list(map(int, input().split()))

# ビット全探索
count = 0
for sw in range(2**N):
    for l, p in zip(l_list, p_list):
        A = l & sw
        A = (0x55555555 & A) + ((0xAAAAAAAA & A)>>1)
        A = (0x33333333 & A) + ((0xCCCCCCCC & A)>>2)
        A = (0x0f0f0f0f & A) + ((0xf0f0f0f0 & A)>>4)
        A = (0x00ff00ff & A) + ((0xff00ff00 & A)>>8)
        A = (0x0000ffff & A) + ((0xffff0000 & A)>>16)
        if A % 2 != p:
            break
    else:
        count += 1
print(count)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
	int n,p,max=100,sum=0;
	for(scanf("%d",&n);n;n--){
		scanf("%d",&p);
		sum+=p;
		if(max<p){max=p;}
	}
	printf("%d",sum-max/2);
	return 0;
}

Measured memory_bytes: 128
n = int(input())
#n, t = map(int,input().split())
#ls = list(map(int,input().split()))
#ls = [list(map(int,input().split())) for i in range(n)]
#ls = [int(input()) for i in range(n)]

if n% 111 == 0:
  print(n)
  quit()
print(n + 111 - n % 111 )

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int INF =1001001;

int main() {
    ll N,Ma,Mb;
    cin >> N >> Ma >> Mb;
    vector<int> A(N),B(N),C(N);
    for(int i=0;i<N;i++){
        cin >> A[i] >> B[i] >>C[i];
    } 
    int dp[N+1][401][401];
    memset(dp,INF,sizeof(dp));
    dp[0][0][0] = 0;
    for(int i=0;i<N;i++)for(int j=0;j<=400;j++)for(int k=0;k<=400;k++){
        dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j][k]);
        if(A[i]<=j && B[i]<=k){
            dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j-A[i]][k-B[i]]+C[i]);
        }
        // cerr << dp[i+1][3][3]<<endl;
    }
    cerr <<"A"<<endl;
    int ans = INF;
    for(int i=1;i<=400;i++){
        if(Ma*i>400|| Mb*i >400){
            break;
        }
        ans = min(ans,dp[N][Ma*i][Mb*i]);
    }
    if(ans == INF){
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 25984
#include <iostream>
using namespace std;
int main()
{
    int a,b,c,x,y;
    while(cin>>a>>b>>c>>x>>y)
    {
        int m,z,ans=0,bns=0;
        m=min(x,y);
        z=x+y-m*2;
        if(a+b>2*c)
        {
            ans=ans+m*2*c;
            if(x>y) ans+=z*a;
            else ans+=z*b;
        }
        else ans=a*x+b*y;
        bns=2*c*max(x,y);
        if(bns<ans)ans=bns;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll N,A,B,tp; 
vector<ll> h;

bool func(ll T){
    vector<ll> tp = h;
    rep(i,N) tp[i] -= B*T;
    ll ans = 0;
    rep(i,N) if(tp[i] > 0) ans += (tp[i]-1) / (A-B) + 1;
    return ans <= T;
}

int main(){
    cin >> N >> A >> B;
    h.resize(N);
    rep(i,N) cin >> h[i];
    
    ll l = 0, r = 1e10;
    while((r-l) > 1){
        if(func((l+r)/2)) r = (l+r)/2;
        else l = (l+r)/2;
    }
    pr(r);
}


Measured memory_bytes: 1792
import collections as ct
n = int(input())
s_c = ct.Counter([input() for i in range(n)])
m = int(input())
t_c = ct.defaultdict(int, ct.Counter([input() for i in range(m)]))
ans = max([s_c[k] - t_c[k] for k in s_c])
print(max(ans, 0))

Measured memory_bytes: 3316
import sys


class UnionFind:
    def __init__(self, max_size):
        self.max_size = max_size
        self.dat = [i for i in range(self.max_size)]

    def find(self, vertex):
        if self.dat[vertex] is vertex: return vertex
        self.dat[vertex] = self.find(self.dat[vertex])
        # print("searching : " + str(vertex))
        return self.dat[vertex]

    def merge(self, child, parent):
        """
        parentとchildをマージして、parentの所属にする
        :param parent:
        :param child:
        :return:
        """
        self.dat[self.find(child)] = self.dat[self.find(parent)]

    def is_same(self, v, w):
        """
        頂点vと頂点wが同じ集合に所属しているか
        :param v:
        :param w:
        :return:
        """
        return self.find(v) == self.find(w)


n, q = map(int, input().split())
uni = UnionFind(n)
sys.setrecursionlimit(114514)
while q > 0:
    q -= 1
    com, x, y = map(int, input().split())
    if com is 0:
        uni.merge(x, y)
    else:
        print(1 if uni.is_same(x, y) else 0)



Measured memory_bytes: 13108
import math

s = input()

goal = math.floor(len(s) / 2) 

ans = 0
for num in range(0, goal):
    # print(s[num])
    # print(s[(num + 1) * -1])
    if s[num] != s[(num + 1) * -1]:
        ans += 1

print(ans)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n, k;
    int[] xs;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        k = sc.nextInt();
        xs = new int[n];
        for (int i = 0; i < n; i++) {
            xs[i] = sc.nextInt();
        }
        solve();
    }

    void solve() {
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (xs[i] < k - xs[i]) {
                ans += xs[i];
            } else {
                ans += k - xs[i];
            }
        }
        System.out.println(2 * ans);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

namespace program
{
    class Program
    {
        static void Main()
        {
          int[] n = Input.ScanIntArray();
          
          // W a b
          if((n[1]<=n[2] && n[2]<= n[0]+n[1])||(n[2]<=n[1] && n[1]<=n[0]+n[2])){
            Out(0);
          }else{
            Out(Math.Min(Math.Abs(n[1]-(n[0]+n[2])), Math.Abs(n[2]-(n[0]+n[1]))));
          }
        }
        static public void Out(object s) { Console.WriteLine(s); }
    }
    
    static class Input {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(); }
    }

    static class MyMath {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


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

int main() {
	int a, b, c, d;
  	cin >> a >> b >> c >> d;
  	while(true)
    {
      c = c - b;
      if(c <= 0)
      {
        cout << "Yes";
        break;
      }
      a = a - d;
      if(a <= 0)
      {
        cout << "No";
        break;
      }
    }
  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char a, b;
  cin >> a >>b;
  if ((a=='H'&&b=='H')||(a=='D'&&b=='D')) {
    cout << 'H' << endl;
  } else {
    cout << 'D' << endl;
  }
  return 0;
}

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

int main(){
	long long a, b, k;
	while(cin >> a >> b >> k){
		if(k > a){
			k = k - a;
			a = 0;
			b = b - k;
			if(b < 0) b = 0;
		}
		else a = a - k;
		printf("%lld %lld\n",a, b);
	}
	return 0;
}

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

typedef long long ll;

const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//  freopen("abc.inp", "r", stdin); freopen("abc.out", "w", stdout);
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(n * a, b);
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int>a;
  int r;
  for(int i = 0;i < n;i++){
  cin >> r;
  if(r == 0){
  int x;
  cin >> x;
  a.push_back(x);
}
  if(r == 1){
  int y;
  cin >> y;
  cout << a.at(y) << endl;
  }
  if(r == 2){
  a.pop_back();
  
  }
}
}
  


Measured memory_bytes: 3940
//
// Created by kuroneko on 2019-07-06.
//

using namespace std;

#include <iostream>
#include <vector>

typedef long long ll;

int main() {
    int N; cin >> N;
    int X; cin >> X;
    int L[N], G[N];

    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }

    G[0] = 0;
    int cnt = 1;
    for (int i = 0; i < N; i++) {
        G[i+1] = G[i] + L[i];
        if (G[i+1] > X) break;
        cnt++;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
const int MOD = 1000000007;

int main()
{
  int R,G;
  cin >> R >> G;
  cout << (2*G-R) << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


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

using namespace std;

void call(int n)
{
    for (int i=1; i<=n; i++) {
        // Check num
        int x = i;
        if (x % 3 == 0) {
            cout << " " << i;
            if (i > n)
                break;
            else
                continue;
        }

        while (x) {
            if (x % 10 == 3) {
                cout << " " << i;
                break;
            }
            x /= 10;
        }
    }
    printf("\n");
}

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

Measured memory_bytes: 3212
import java.util.*;

public class Main {

    static int n;
    static int m;
    static int q;
    static int[][] a;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        q = sc.nextInt();
        a = new int[q][4];
        for (int i = 0; i < q; i++) {
            a[i][0] = sc.nextInt()-1;
            a[i][1] = sc.nextInt()-1;
            a[i][2] = sc.nextInt();
            a[i][3] = sc.nextInt();
        }
        int[] b = new int[n];
        long ans = dfs(0, 1, b);
        System.out.println(ans);
        sc.close();

    }

    private static long dfs(int idx, int curmax, int[] b) {
        long ret = 0L;
        if(idx == n){
            for (int i = 0; i < q; i++) {
                int x = a[i][0], y = a[i][1], c = a[i][2], d = a[i][3];
                if(b[y] - b[x] == c) ret += d;
            }
            return ret;
        }else{
            for (int k = curmax; k <= m; k++) {
                b[idx] = k;
                long t = dfs(idx+1, Math.max(k, curmax), b);
                ret = Math.max(ret, t);
            }
        }
        return ret;
    }

}


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

int main(){
	/*input*/
	int a, b, c, d;	cin >> a >> b >> c >> d;
	/*calculation*/
	bool ok = false;	//true:Yes false:No
	if(abs(a - c) <= d)ok = true;
	if(abs(a - b) <= d && abs(b - c) <= d)ok = true;
	/*output*/
	if(ok){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<string.h>
#include<assert.h>
#include<queue>
using namespace std;
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
typedef long long ll;
typedef unsigned long long ull;
inline ll lowbit(ll x){return x&(-x);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
const int INF=0x3f3f3f3f,max_n=200005,mod=19260817;
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
inline ll pow(ll a,ll b,ll mod){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int max1=-1;
int n;
int a[max_n];
int f(int x)
{
	int count1=2;
	int ans=1;
	for(int i=x+1;i<=n;i++)
	{
		if(a[i]==count1)
		{
			ans++;
			count1++;
		}
	}
	return ans;
}
int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(max1>=n-i+1)
		{
			break;
		}
		if(a[i]==1)
		{
			max1=max(max1,f(i));
			break;
		}
	}
	if(max1==-1)
	cout<<"-1";
	else
	cout<<n-max1;
}

Measured memory_bytes: 4332
import numpy as np
from numba import njit

N, K = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
a = np.array(A, dtype=int)


fin = [N] * N

@njit(cache=True)
def calc_b(a):
    b = np.zeros(N, dtype=np.int64)
    for i, _a in enumerate(a):
        l = max(0, i - _a)
        r = min(N - 1, i + _a)

        # imos hou
        b[l] += 1
        if r + 1 < N:
            b[r + 1] -= 1

    b = np.cumsum(b)
    # print('b_sum', b)
    return b


for k in range(min(K,100)):
    # print('a', a)
    a = calc_b(a)
    # if all(a == fin):
    #     break

a = [str(_) for _ in a]
print(' '.join(a))
# print('step=', k)

Measured memory_bytes: 139420
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=998244353;
const LL LINF=1LL<<62;

struct edge {int a;int b;int c;};

int main(){
    int N;
    cin >> N;
    vector<edge> v;
    int t=0,s=N;
    while(s){
        s/=2;
        t++;
    }
    cout << t << " ";
    s=1;
    int sum=0;
    for(int i=1;i<t;i++){
        v.pb({i,i+1,0});
        v.pb({i,i+1,s});
        sum+=s;
        s*=2;
    }
    int p=1;
    int k=1;
    while(N!=1){
        if(N%2==1){
            v.pb({p,t,sum+1});
            sum+=k;
        }
        N/=2;
        p++;
        k*=2;
    }
    cout << v.size() << endl;
    for(int i=0;i<v.size();i++){
        edge e;
        e=v[i];
        cout << e.a << " " << e.b << " " << e.c << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from collections import Counter


class UnionFind:
    def __init__(self, n):
        self.n = n
        self.p = [e for e in range(n)]
        self.rank = [0] * n
        self.size = [1] * n

    def same(self, u, v):
        return self.find_set(u) == self.find_set(v)

    def unite(self, u, v):
        u = self.find_set(u)
        v = self.find_set(v)

        if u == v:
            return

        if self.rank[u] > self.rank[v]:
            self.p[v] = u
            self.size[u] += self.size[v]
        else:
            self.p[u] = v
            self.size[v] += self.size[u]
            if self.rank[u] == self.rank[v]:
                self.rank[v] += 1

    def find_set(self, u):
        if u != self.p[u]:
            self.p[u] = self.find_set(self.p[u])

        return self.p[u]

    def update_p(self):
        for u in range(self.n):
            self.find_set(u)

    def get_size(self, u):
        return self.size[self.find_set(u)]


n, m = map(int, input().split())
uf = UnionFind(n)
for _ in range(m):
    x, y, z = map(int, input().split())
    x -= 1
    y -= 1
    uf.unite(x, y)

c = Counter(uf.find_set(i) for i in range(n))
ans = len(c)
print(ans)


Measured memory_bytes: 18176
#include<bits/stdc++.h>
#define deb(x) cout<<#x<<" "<<x<<endl;
#define print(arr,n) for(int i=0;i<n;++i) { cout<<arr[i]<<" "; } cout<<endl;
#define ub(x,el) upper_bound(x.begin(),x.end(),el) - x.begin()
#define lb(x,el) lower_bound(x.begin(),x.end(),el) - x.begin();
#define bs(x,el) binary_search(x.begin(),x.end(),el)
#define MOD 1000000007
#define finish return 0
using namespace std;
typedef long long int ll;
ll mod(ll x) { return x%MOD; }
ll power(ll x,ll y, ll p) { ll res = 1; x = x % p; while (y > 0) { if (y & 1) res = (res*x) % p; y = y>>1; x = (x*x) % p;   } return res; } 
ll mod(ll num, ll den){ return mod(mod(num) * power(den,MOD-2,MOD)); }
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n;
	cin>>n;
	bool ok = false;
	while(n)
	{
		auto r = n%10;
		if(r==7) ok = true;
		n/=10;
	}
	if(ok) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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

#define PI acos(-1)
#define pb push_back
#define int long long int
#define pi pair<int, int>
#define fir first
#define sec second
#define MAXN 3001
#define MAXL 20
#define mod 1000000007

int n, m, k;
int grid[MAXN][MAXN];
int dp[MAXN][MAXN][4];

int solve(int i, int j, int k)
{
  if (i == n - 1 && j == m - 1)
  {
    if (k < 3)
      return grid[i][j];
    else
      return 0;
  }
  if (dp[i][j][k] != -1)
    return dp[i][j][k];
  int best = 0;
  if (i + 1 < n)
  {
    if (k < 3)
      best = max(best, grid[i][j] + solve(i + 1, j, 0));
    best = max(best, solve(i + 1, j, 0));
  }
  if (j + 1 < m)
  {
    if (k < 3)
      best = max(best, grid[i][j] + solve(i, j + 1, k + 1));
    best = max(best, solve(i, j + 1, k));
  }
  return dp[i][j][k] = best;
}
signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m >> k;
  for (int i = 0; i < k; i++)
  {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    grid[a][b] = c;
  }
  for (int i = 0; i < MAXN; i++)
    for (int j = 0; j < MAXN; j++)
      for (int k = 0; k < 4; k++)
        dp[i][j][k] = -1;
  cout << solve(0, 0, 0) << endl;
}

Measured memory_bytes: 355772
def c():
    X, N = map(int, input().split())
    P = list(map(int, input().split()))

    for d in range(101):
        if X-d not in P:
            print(X-d)
            return
        elif X+d not in P:
            print(X+d)
            return


##########
if __name__ == "__main__":
    c()


Measured memory_bytes: 9176
/*

#      #      #####   ##   ##  #####      ##     #  #      #   #  #####
#      #      #   #  #  ###  # #          # ##   #  #      #   #  #   #
#      #      #   #  #   #   # #          #  ##  #  #      #   #  #   #
#      #      #   #   #     #  #####      #   #  #  #       ###   #####
#      #      #   #    #   #   #          #  ##  #  #        #    #   #
#      #      #   #     ###    #          # ##   #  #        #    #   #
#      #####  #####      #     #####      ##     #  #####    #    #   #

*/

#include <bits/stdc++.h>

using namespace std;

#define f first
#define s second
#define pb push_back
#define np next_permutation
#define bs binary_search
#define mp make_pair
#define all(x) x.begin(), x.end()
#define bp __builtin_popcountll
#define sqr(x) ((llong)sqrt (x))
#define b_ctz __builtin_ctzll
#define b_clz __builtin_clzll

#define y1 road_to_respa_top_6
#define prev road_to_respa_top_6
#define Abdrakhman abcdefghijklmnopqrstuvwxyzRakhman
#define left kotoriy_levee_chem_right
#define right kotoriy_pravee_chem_left

#define android ios_base::sync_with_stdio(0), cin.tie (0), cout.tie (0)
#define fn ""

typedef long long llong;
typedef long double ldouble;
typedef unsigned long long ullong;

typedef vector <int> vi;
typedef vector <string> vs;
typedef vector <vector <llong> > matrix;

typedef pair <llong, llong> pll;

typedef map <int, int> mii;

typedef set <llong> sl;

const llong MXN = 1e6 + 1;
const llong MNN = 1e3 + 1;
const llong MOD = 1e9 + 7;
const int INF = 1e9;
const llong LINF = 1e18;
const llong MAGIC = 1000;
const ldouble EPS = 1e-9;
const ldouble PI = 3.1415926536;
const string TIME = "rovno_ushten_push_ketti";

inline llong log2 (llong x) {return 64 - b_clz (x) - 1;};
inline llong __lcm (llong a, llong b) {return a / __gcd (a, b) * b;};

string s;

int main () {
    android;
    //freopen ("input.txt", "r", stdin);
    cin >> s;
    int mn = 1000;
    for (int i = 0; i < s.size () - 2; i ++) {
        int x = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0');
        mn = min (mn, abs (x - 753));
    }
    cout << mn;
    return 0;
}


Measured memory_bytes: 256
<?php
/*
    Problem URL : http://arc069.contest.atcoder.jp/tasks/arc069_a

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

fscanf(STDIN, "%d %d", $s, $c);

$cc = floor($c / 2);
// if ($s < $cc) {
    // ccが多く作れる
    $ext = floor(($cc - $s) / 2);
// }

// printf("%d %d %d\n", $s, $cc, $ext);

echo min($s, $cc) + max($ext, 0);
echo PHP_EOL;

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

int main(){
  int n;
  cin>>n;
  vector<int> num(n+1);
  num[0]=0;
  for(int i=1;i<n+1;i++){
    cin>>num[i];
  }int x=n;
  if(x%2==0){
    while(x>1){
      cout<<num[x]<<' ';
      x-=2;
    }x=1;
    while(x<n){
      cout<<num[x]<<' ';
      x+=2;
    }cout<<endl;
  }else{
    while(0<x){
      cout<<num[x]<<' ';
      x-=2;
    }x=2;
    while(x<n){
      cout<<num[x]<<' ';
      x+=2;
    }cout<<endl;
  }
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>

using namespace std;

struct Query {
  int T;
  int F;
  char C;
};

int main()
{
  string S;
  int Q;
  vector<Query> query_array;

  cin >> S >> Q;
  query_array.resize(Q);
  for (int i = 0; i < Q; i++) {
    cin >> query_array[i].T;
    if (query_array[i].T == 2) {
      cin >> query_array[i].F >> query_array[i].C;
    }
  }

  deque<char> list_S;
  for (int i = 0; i < S.size(); i++) {
    list_S.push_back(S[i]);
  }

  int flip_num = 0;

  for (int i = 0; i < Q; i++) {
    if (query_array[i].T == 1) {
      flip_num++;
    }
    else if ((1 - (query_array[i].F - 1) * 2) * (1 - (flip_num % 2) * 2) == 1) {
      list_S.push_front(query_array[i].C);
    }
    else {
      list_S.push_back(query_array[i].C);
    }
  }

  if (flip_num % 2 == 1) {
    reverse(list_S.begin(), list_S.end());
  }

  for (auto &&i : list_S) {
    cout << i;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s;
	int sum;
	while (getline(cin, s))
	{
		if((s[0] - '0') == 0) break;
		sum = 0;
		for (int i = 0; i < s.length(); i++)
			sum+= s[i] - '0';
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,m,p;
   cin>>n>>m>>p;
   if((m-n)==(p-m))
   {
       cout<<"YES"<<endl;
   }
   if((m-n)!=(p-m))
   {
       cout<<"NO"<<endl;
   }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;

  if (A > D || C > B) {
    cout << 0;
  } else {
    cout << min(B, D) - max(A, C);
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll INF = 1LL << 62;
const int inf = 1 << 30;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string a, b, c; cin >> a >> b >> c;
    cout << "A" << b[0] << "C" << endl;

    return 0;
}


Measured memory_bytes: 256
// May this submission get accepted
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// 標準入出力
struct inp {
    size_t sz;
    inp(size_t _sz = 1) : sz(_sz) {}
    template <typename T> operator T () const { T a; cin >> a; return a; }
    template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
    template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
inp inp1; // input one
template <typename T> void say(T &x, char end = '\n') { cout << x << end; }
template <typename T> void say(vector<T> &x, char sep = ' ', char end = '\n') { for (size_t i = 0, sz = x.size(); i < sz; i++) { cout << x[i] << (i == sz-1 ? end : sep); } }

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
    cin.tie(nullptr);            // インタラクティブ問題ではコメントアウトすること
    
    ll n = inp1;
    ll m = inp1;
    vector<ll> p(m);
    vector<string> s(m);
    REP(i, m) {
        cin >> p[i] >> s[i];
        p[i]--;
    }

    vector<ll> ac(n, 0), wa(n, 0);
    REP(i, m) {
        if (s[i] == "AC") {
            ac[p[i]] = 1;
        } else if (!ac[p[i]]) {
            wa[p[i]]++;
        }
    }

    ll acc = 0, pen = 0;
    REP(i, n) {
        if (ac[i]) {
            acc++;
            pen += wa[i];
        }
    }
    cout << acc << " " << pen << endl;
    
}

Measured memory_bytes: 8064
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int d = Integer.parseInt(scanner.nextLine());

        switch (d){
            case 25:
                System.out.println("Christmas");
                break;
            case 24:
                System.out.println("Christmas Eve");
                break;
            case 23:
                System.out.println("Christmas Eve Eve");
                break;
            case 22:
                System.out.println("Christmas Eve Eve Eve");
                break;
        }
    }
}


Measured memory_bytes: 22996
#include <iostream>

using namespace std;

int main() {

   long long w, h, x, y;
   cin >> w >> h >> x >> y;

   double z = 1e-6;

   double s = w * h * 0.5;
   double dx = w * 0.5 - x * 1.0;
   double dy = h * 0.5 - y * 1.0;

   if (-z < dx && dx < z && -z < dy && dy < z)
      cout << s << " " << 1 << endl;
   else
      cout << s << " " << 0 << endl;

   return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    long A = sc.nextLong();
    long B = sc.nextLong();
    long g = gcd(A,B);

    int ans = 1;
    long f = (long)Math.sqrt(g)+1;
    for(int i = 2; i <= f; i++){
      boolean c = false;
      while(g%i == 0){
        c = true;
        g /= i;
      }
      if(c){
        ans++;
      }
    }
    if(g != 1){
      ans++;
    }
    System.out.println(ans);
  }
  public static long gcd(long a, long b){
    if(a < b){
      return gcd(b, a);
    }
    if(b == 0){
      return a;
    }
    
    return gcd(b, a%b);
  }
}


Measured memory_bytes: 23124
#include <stdio.h>

#define M 10000
#define parent(i) (i/2)
#define right(i) (2*i+1)
#define left(i) (2*i)

int A[M];

int main(){
  int num;
  int i;
  
  scanf("%d",&num);
  for(i=1;i<=num;i++) scanf("%d",&A[i]);

  for(i=1;i<=num;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(A[parent(i)]!=0) printf("parent key = %d, ",A[parent(i)]);
    if(A[left(i)]!=0) printf("left key = %d, ",A[left(i)]);
    if(A[right(i)]!=0) printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2056
#include <iostream>
using namespace std;
int main(){
 int i,in,s=0,t=0;
 for(i=0;i<4;i++){cin>>in;s+=in;}
 for(i=0;i<4;i++){cin>>in;t+=in;}
 if (t>s)s = t;
 cout<<s<<endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  string S; cin >> S;
  int n = S.size();
  map<char, int> cnt;
  REP(i, n) {
    cnt[S[i]]++;
  }

  if (abs(cnt['a'] - cnt['b']) <= 1 &&
      abs(cnt['a'] - cnt['c']) <= 1 &&
      abs(cnt['b'] - cnt['c']) <= 1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 512
#include <stdio.h>
#include <algorithm>
int n;
int a[200000];
int b[200000];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", a + i, b + i);
	}
	std::sort(a, a + n);
	std::sort(b, b + n);
	if (n % 2) {
		printf("%d\n", b[n / 2] - a[n / 2] + 1);
	}
	else {
		printf("%d\n", b[n / 2] + b[n / 2 - 1] - a[n / 2] - a[n / 2 - 1] + 1);
	}
}

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

#define all(x) (x).begin(),(x).end()

#define MOD 1000000007

using namespace std;

int main(){
	long long int n,ans;
	cin >> n;
	ans = 0;

	for( int i=1; i<=n; i++ ){
		if( i % 3 != 0 && i % 5 != 0 ){
			ans += i;
		}
	}

	cout << ans << endl;

	return 0;
}


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

const long long MAX = 10000000;
const long long MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int x, y;
    cin >> x >> y;

    if ((2 * x - y) % 3 != 0 or (2 * y - x) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    unsigned int n = (2 * x - y) / 3;
    unsigned int m = (2 * y - x) / 3;
    unsigned int sum = n + m;

    long long result;
    COMinit();
    result = COM(sum, n);
 
    cout << result % 1000000007 << endl;
    return 0;
}


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

int main(){
	char a[4][4];
	for(int i=1;i<4;i++){
		for(int j=1;j<4;j++){
			scanf(" %c",&a[i][j]);
		}
	}
	printf("%c%c%c\n",a[1][1],a[2][2],a[3][3]);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define const INF 10000000000

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

    string s;
    ll ans = 0, cnt = 0;
    cin >> s;
    rep(i, s.length()){
        if(s[i] == 'W'){
            ans += i - cnt;
            cnt++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 720
#!/usr/bin/env python3
l, r = map(int, input().split())
if r - l >= 2019:
    print(0)
    exit()
m = 1e9
for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
        m = min(m, i * j % 2019)
print(m)


Measured memory_bytes: 2940
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
string s;
cin >> s;
int cnt = 0;
int ans = 0;
for(int i = 0; i < 3; i++) {
    if (s[i] == 'R')cnt++;
    else{
        ans = max(cnt,ans);
        cnt = 0;
    }
}
cout << max(ans,cnt) << endl;
}

Measured memory_bytes: 3636