akhauriyash/Code-Regression huggingface dataset:
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n,m;
    cin>>n>>m;
    vpi c(n), p(m);
    forn(i,n){
        int x,y;
        cin>>x>>y;
        c[i] = mp(x,y);
    }
    forn(i,m){
        int x,y;
        cin>>x>>y;
        p[i] = mp(x,y);
    }

    forn(i,n){
        int mindis = INT_MAX, id=0;
        forn(j,m){
            int dis = abs(c[i].fi-p[j].fi) + abs(c[i].se-p[j].se);
            if(dis<mindis){
                mindis = dis;
                id=j;
            }
        }
        cout<<id+1<<endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define inf1 INT_MAX
#define inf2 LLONG_MAX
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define sbit __builtin_popcount
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define rit(it,x) for(auto it=x.begin();it!=x.end();it++)
#define cases(t) int t; cin>>t; rep(casn,1,t+1)
#define fill(a,b) memset(a,b,sizeof(a))
#define dbg(x) cerr<<#x<<" "<<x<<endl;
#define dbga(arr,n) cerr<<#arr<<": "; rep(tt,0,n)cerr<<arr[tt]<<" "; cerr<<endl;
#define infile ifstream fin; fin.open("input.txt")
#define outfile ofstream fout; fout.open("output.txt")
#define vec vector<int>
#define pii pair<int,int>
#define plii pair<ll,int>
#define pll pair<ll,ll>
#define p_queue priority_queue< plii,vector< plii >,greater< plii > > 
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define si(x) scanf("%d",&x)
#define sc(x) scanf("%c",&x)
#define sl(x) scanf("%lld",&x)
#define sst(x) scanf("%s",x)
#define pl(x) printf("%lld\n",x)
#define pi(x) printf("%d\n",x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

inline ll binex(ll a,ll b)
{
    ll ans=1,temp=a%mod;
    while(b!=0){
        if(b&1) ans=(ans*temp)%mod;
        temp=(temp*temp)%mod;
        b=b>>1;
    }
    return ans;
}

inline ll solve(int n,int w,int val[],int wt[])
{
    ll dp[w+1][n+1];
    memset(dp,0,sizeof(dp));
    for(int j=1;j<=n;j++){
        for(int i=1;i<=w;i++){
            dp[i][j]=dp[i][j-1];
            if(i>=wt[j-1]) dp[i][j]=max(dp[i][j],dp[i-wt[j-1]][j-1]+val[j-1]);
        }
    }
    return dp[w][n];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,w; cin>>n>>w;
    int val[n],wt[n];
    rep(i,0,n) cin>>wt[i]>>val[i];
    cout<<solve(n,w,val,wt)<<endl;
}

Measured memory_bytes: 79232
#include <iostream>
using namespace std;
unsigned long long a, b, x;
int main() {
  cin >> a >> b >> x;
  if (b == 0) {
    cout << 1 << endl;
    return 0;
  }
  if (a == 0) {
    cout << (b / x) + 1 << endl;
    return 0;
  }
  cout << (b / x) - ((a - 1) / x) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <map>
using namespace std;
/*

*/
int main()
{
    //集計する変数はなるべくでかくしておけ
    long int N, count = 0;
    string temp;
    //連想行列定義
    map<string, long long> mp;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> temp;
        mp[temp]++;
    }
    for (auto x : mp)
    {
        count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 18772
import java.util.Scanner;

public class Main {

	/** 10 */
	private static final int TEN = 10;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			System.out.println((0 == n % s(n)) ? "Yes" : "No");
		}
	}

	/**
	 * 整数nに対して、nを十進法で表したときの各桁の和
	 * 
	 * @param n 整数n
	 * @return nを十進法で表したときの各桁の和
	 */
	private static int s(int n) {
		int answer = 0;
		while (n > 0) {
			answer += n % TEN;
			n /= TEN;
		}
		return answer;
	}
}


Measured memory_bytes: 35812
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    cout << mod_pow(k, n, MOD) << endl;
}


Measured memory_bytes: 3220
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { ij -> ij.toInt() }
    val a = readLine()!!.split(" ").map { ij -> ij.toLong() }
    val ar = arrayListOf<Long>()
    
    val map = mutableMapOf<Long, Long>()
    val seq = mutableListOf<Long>()
    
    for (i in 0 until m) {
        val (b, c) = readLine()!!.split(" ").map { it.toLong() }
        if (map.containsKey(c)) {
            map[c] = map[c]!! + b
        } else {
            map[c] = b
            seq.add(c)
        }
    }
    
    for (i in a.indices) {
        if (map.containsKey(a[i])) {
            map[a[i]] = map[a[i]]!! + 1
        } else {
            map[a[i]] = 1
            seq.add(a[i])
        }
    }
    
    val s = seq.sorted().reversed()
    var collected = 0L
    
    var ans = 0L
    
    for (i in s.indices) {
        if (collected < n) {
            val mn = Math.min(n - collected, map[s[i]]!!)
            ans += mn * s[i]
//            print("$mn*${s[i]} ")
            collected += mn
        }
    }
    
    
    
//    println()
    
//    println(s)
//    println(map)

//    ar.sort()
//    ar.reverse()
    
    println(ans)
}


Measured memory_bytes: 102824
import java.io.*;
import java.util.*;
import java.math.BigInteger;

public class Main {

    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
	String[] a=sc.nextLine().split(" ");
	int N=Integer.parseInt(a[0]);
	int K=Integer.parseInt(a[1]);
	String[] line=sc.nextLine().split(" ");
	int[] H=new int[N];
	for(int i=0;i<N;i++){
	H[i]=Integer.parseInt(line[i]);
	}
	Arrays.sort(H);
	long res= 0;
	if(K>=N)
	System.out.println("0");
	else{
	for(int i=0;i<N-K;i++){
	long r=H[i];
	res=res+r;
	}
	System.out.println(res);
 	}	
	
    }

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

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

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

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



        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        } 
    }
}


Measured memory_bytes: 53076
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n, h, w;
int main(){
    cin>>n>>h>>w;

    ll ans=0;
    REP(i, 0, n-h+1){
        REP(j, 0, n-w+1){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
#include <cstdlib>
//using
using namespace std;
using vl = vector <long long>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
//vector<vector<char> > hyou(N, vector<char>(N));
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//素数判定　O(√A) 
bool is_prime(int x){
 if(x<=1) return false;
 for(int i=2;i*i<=x;i++)
 if(x%i==0) return false;
 return true;
 }
/*順列生成
do {
  // 順列に対する処理
} while (next_permutation(配列変数.begin(), 配列変数.end()));*/

//絶対値　abs()
//文字→数字　'0' アルファベット→数字　'a'　'A'が65番,'a'が97番だわ
//型キャスト　char('a'+1)
//reverse 回文

//グローバル変数宣言
ll p=0,q=0,r=0;

int main()
{
  ll n;
  cin>>n;
  vl h(n);
  rep(i,n)
  {
    cin>>h[i];
    if (i!=0){
    if (h[i-1]>=h[i])
    {
      p++;
    }else{
      q=max(p,q);
      p=0;
    }
    }
  }
  q=max(p,q);
  print(q)
}

Measured memory_bytes: 4044
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#define MOD 1000000007
using namespace std;
typedef long long ll;
ll modinv(ll a, ll m){
  ll b=m,u=1,v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  u%=m;
  if(u<0) u+=m;
  return u;
}
ll val(ll n){
  ll res=1;
  for(ll i=1;i<=n;i++){
    res *= i;
    res %= MOD;
  }
  return res;
}
ll valinv(ll n){
  ll res=1;
  for(ll i=1;i<=n;i++){
    res *= modinv(i,MOD);
    res %= MOD;
  }
  return res;
}
signed main(){
  ll x,y,cnt=0,ev,all,a,b,c;
  cin >> x >> y;
  if(x>y){
    swap(x,y);
  }
  while(y>x&&x!=0&&y!=0){
    y-=2;
    x--;
    cnt++;
  }
  if(x%3!=0||y%3!=0||x!=y){
    cout <<"0\n";
    return 0;
  }
  ev = x/3;
  all = ev*2+cnt;
  a = val(all);
  b = valinv(ev);
  c = valinv(all-ev);
  a*=b;
  a%=MOD;
  a*=c;
  a%=MOD;
  cout << a<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
	int n;
	char s[10001];
	scanf("%d%s",&n,s);
	for(int i=0;i<strlen(s);i++){
		printf("%c",(s[i]+n-'A')%('Z'-'A'+1)+'A');
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define MAX 45
int f[MAX];

int fib(int n){
  if(n==0||n==1)return f[n]=1;
  if(f[n]!=-1)return f[n];
  return f[n]=fib(n-2)+fib(n-1);
}

int main(){
  int n,i;
  for(i=0;i<MAX;i++)f[i]=-1;
  scanf("%d",&n);
  printf("%d\n",fib(n));

  return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define inf 1001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    cin.tie(0); cin.sync_with_stdio(false);
    string s;
    cin >> s;
    sort(all(s));
    cout << (s[0] == s[1] && s[1] != s[2] && s[2] == s[3] ? "Yes" : "No") << endl;
}

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

using namespace std;

int main() {
  int W, a, b;
  cin >> W >> a >> b;
  int move = (a < b ? b - (a + W) : a - (b + W));
  if (move < 0) {
    cout << 0 << endl;
  } else {
    cout << move << endl;
  }
  return 0;
}



Measured memory_bytes: 768
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	x := sc.ReadInt()
	t := sc.ReadInt()

	fmt.Println(Ceil(n, x) * t)
}

// from [my library](https://github.com/ikngtty/go-contestlib)
// -   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *Scanner) ReadFloat() float64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseFloat(text, 64)
	if err != nil {
		panic(err)
	}
	return num
}


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

int a[100010];

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

Measured memory_bytes: 640
n, m = map(int, input().split())
p = []
s = []
for i in range(m):
    pp, ss = input().split()
    p.append(int(pp) - 1)
    s.append(ss)

acs = [0] * n
was = [0] * n
for i in range(m):
    if s[i] == 'AC':
        acs[p[i]] = 1
    else:
        if acs[p[i]] == 0:
            was[p[i]] += 1
for i in range(n):
    if acs[i] == 0:
        was[i] = 0
print("{} {}".format(sum(acs), sum(was)))

Measured memory_bytes: 14920
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long int lld;
typedef vector<lld> vi;
typedef pair<lld, lld> pi;
#define F first
#define S second
#define N 1000007
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define rep(i, a, b) for (lld i = a; i < b; i++)
lld r, j, l, m, n, s, q, i, k, t, p,z,timer,x,y;string s1, s2;
lld a[N],dp[N];
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  cin>>n>>k;
  rep(i,1,n+1)cin>>a[i];
  rep(i,0,a[1])dp[i]=2;
  for(i=a[1];i<=k;i++)
  {
  	p=0;
  	rep(j,1,n+1)
  	{
  		if(i-a[j]>=0&&dp[i-a[j]]==2)
  		{
  			p++;
//  			if(i==k)cout<<j<<endl;
  		}
  	}
  	if(p)dp[i]=1;
  	else dp[i]=2;
  }
  if(dp[k]==1)cout<<"First";
  else cout<<"Second";
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 
bool ch[200];
int main() {
	ll n,k;
	cin>>n>>k;
	for(ll i=0;i<k;i++){
		ll now;
		cin>>now;
		for(ll j=0;j<now;j++){
			ll x;
			cin>>x;
			x--;
			ch[x]=true;
		}
	}
	ll cnt=0;
	for(ll i=0;i<n;i++){
		if(ch[i]==0){
			cnt++;
		}
	}
	cout <<cnt;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3592
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A_list = [list(map(int, input().split())) for _ in range(N)]

count = 0
for A in A_list:
    x = 0
    for a, b in zip(A, B):
        x += a * b
    x += C
    if x > 0:
        count += 1

print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef long long ll;
typedef unsigned long long ull;

P f(int x)
{
  int a = x % 10;
  int b = 0;
  while (x)
  {
    b = x;
    x /= 10;
  }
  return P(a, b);
}

int main()
{
  int n;
  cin >> n;
  map<P, int> freq;
  for (int i = 1; i <= n; i++)
  {
    P p = f(i);
    freq[p]++;
  }
  ll ans = 0;
  for (int i = 1; i <= n; i++)
  {
    P p = f(i);
    P q(p.second, p.first);
    ans += freq[q];
  }
  cout << ans << endl;
}

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

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

int min(int a, int b){
    if(a <= b) return a;
    else return b;
}

int main(void){
    int i,max_v,min_v;
    int n;
    int *array;
    scanf("%d", &n);

    array = (int *)malloc(n*sizeof(int));

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

    max_v = array[1] - array[0];
    min_v = array[0];

    for(i=1; i<n; i++){
        min_v = min(min_v, array[i-1]);
        max_v = max(max_v, array[i] - min_v);
    }

    printf("%d\n", max_v);
    return 0;
}


Measured memory_bytes: 2628
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define triplerep(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))

typedef long long ll;

int main() {
    int a, b;
    
    scnd2(a,b);
    if ( a <= b ) {
        prtd1(a);
    } else {
        prtd1(a-1);
    }
}


Measured memory_bytes: 256
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    s = input()
    if s.isupper():
        print("A")
    else:
        print("a")

if __name__ == '__main__':
    main()

Measured memory_bytes: 65196
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main() {
    ll a, b;
    cin >> a >> b;
    cout << a * b << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
ll A;
  ll B;
   ll C;
     cin >>A>>B>>C;
  ll z=max(max(A,B),C);
  ll w=3*z;
  ll sum=A+B+C;
  ll a=w%2;
  ll b=sum%2;
  if(a==b) {
    cout<<(w-sum)/2<<endl;
  }
  else {
    cout<<(w+3-sum)/2<<endl;
  }
  
  
}
  
 

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    string s;
    cin >> s;
    cout << (s == "ARC"? "ABC" : "ARC") << endl;
    return 0;
}


Measured memory_bytes: 3468
import sys

def main():
  input = sys.stdin.readline
  n, k = map(int, input().split())
  a = [int(x) for x in input().split()]
  f = [int(x) for x in input().split()]
  a.sort(reverse=True)
  f.sort()
  
  l, r = -1, pow(10, 12)+1
  while r-l > 1:
    judge = (r+l)//2
    sub = 0
    for i in range(n):
      if a[i]*f[i] <= judge:
        continue
      sub += a[i]-judge//f[i]
    if sub <= k:
      r = judge
    else:
      l = judge
  
  print(r)
  
if __name__ == "__main__":
  main()

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

int main() {
  long int N,s,f;
  s=0;
  cin>>N;
  f=N;
  for(int i=0;i<1;i--){
    if(N>=10){
      s+=N%10;
      N=(N-N%10)/10;
    }
    else{
      if(f%(s+N)==0)
        cout<<"Yes"<<endl;
      else
        cout<<"No"<<endl;
      return 0;
    }
      
  }
}


Measured memory_bytes: 256
import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
#from bisect import bisect_left as bl, bisect_right as br, insort
#from heapq import heapify, heappush, heappop
#from collections import defaultdict as dd, deque, Counter
#from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var) : sys.stdout.write(' '.join(map(str, var))+'\n')
def out(var) : sys.stdout.write(str(var)+'\n')
from decimal import Decimal
#from fractions import Fraction
#sys.setrecursionlimit(100000)
INF = float('inf')
mod = int(1e9)+7

n,x,t=mdata()
out(int(math.ceil(n/x)*t))


Measured memory_bytes: 71128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {

	public static void main(String[] args)throws IOException  {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		 List<Integer> list = new ArrayList<Integer>();
		 for (String s : Arrays.asList(br.readLine().trim().split("\\s+"))) list.add(Integer.parseInt(s));
		 
		 int a = list.get(0), b = list.get(1);
		 
		 System.out.println(""+(a*b)+" "+(2*a+2*b));
		 
	}

}

Measured memory_bytes: 24620
using System;
using System.Collections.Generic;

namespace _1154
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 1) break;
                Console.Write(n + ":");
                List<int> list = new List<int>();
                for (int i = 2; i <= n; i++)
                {
                    if (n % i == 0 && (i % 7 == 1 || i % 7 == 6))
                    {
                        bool flag = true;
                        foreach (var item in list) if (i % item == 0) flag = false;
                        if (flag) { list.Add(i); Console.Write(" " + i); }
                    }
                }
                Console.WriteLine();
            }
        }
    }
}


Measured memory_bytes: 9284
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 1e9 + 7;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	vector<int> a(3);
	for (auto& i : a) cin >> i;
	sort(a.begin(), a.end());
	for (auto i : a) {
		if (i % 2 == 0) {
			cout << 0;
			return 0;
		}
	}
	cout << a[0] * a[1];
	return 0;
}

Measured memory_bytes: 3668
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

int M,T,P,R;
int m[2000],t[2000],p[2000],j[2000];
struct team{
	int n,s,t,w[2000];
};

bool comp(const team &t1,const team &t2){
	if(t1.t==t2.t && t1.s==t2.s)return t1.n>t2.n;
	if(t1.s==t2.s)return t1.t<t2.t;
	return t1.s>t2.s;
};

team dat[2001];

int main(void){
	while(1){
		scanf("%d%d%d%d",&M,&T,&P,&R);
		if(M+T+R+P==0)break;
		memset(dat,0,sizeof(dat));
		for(int i=0;i<T;i++)dat[i].n=i+1;
		for(int i=0;i<R;i++){
			scanf("%d%d%d%d",&m[i],&t[i],&p[i],&j[i]);
			if(j[i]!=0){
				dat[t[i]-1].w[p[i]]++;
			}else{
				dat[t[i]-1].s++;
				dat[t[i]-1].t+=m[i]+dat[t[i]-1].w[p[i]]*20;
			}
		}
		sort(dat,dat+T,comp);
		printf("%d",dat[0].n);
		for(int i=1;i<T;i++){
			if(dat[i-1].s==dat[i].s && dat[i-1].t==dat[i].t)printf("=");
			else printf(",");
			printf("%d",dat[i].n);
		}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 18884
def insertion_sort(n, l, g=1):
    count = 0
    for i in range(1, n):
        v = l[i]
        j = i-g
        while j >= 0 and l[j] > v:
            l[j+g] = l[j]
            j -= g
            count += 1
        l[j+g] = v
    return l, count

def shell_sort(n, l):
    h = 1
    G = []
    while h <= n:
        G.insert(0, h)
        h = 3*h + 1
    print(len(G))
    print(' '.join(map(str, G)))
    cnt = 0
    for i in range(len(G)):
        l, count = insertion_sort(n, l, g=G[i])
        cnt += count
    print(cnt)
    for i in range(len(l)):
        print(l[i])

if __name__=='__main__':
    n = int(input())
    l = []
    for _ in range(n):
        l.append(int(input()))
    shell_sort(n, l)



Measured memory_bytes: 45520
#include <string>
#include <iostream>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);

using namespace std;
int main() {
    fastIO;
    string s,t;
    cin >> s >> t;
    int n1=s.length();
    int n2=t.length();
    int ans=n2+1;
    for(int i=0 ; i<=(n1-n2) ; i++){
        int tem=0;
        for(int j=i ; j<(i+n2) ; j++){
            if(s[j]!=t[j-i]){
                tem++;
            }
        }
        ans=min(ans,tem);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3644
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

X,Y,Z=get_i
puts (X-Z)/(Y+Z)

Measured memory_bytes: 1788
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var (
	N  int
	M  int
	dp []int
)

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func readKey() [2]int {
	a := readInt()
	b := readInt()
	m := 0
	for i := 0; i < b; i++ {
		m |= 1 << uint(readInt()-1)
	}
	return [2]int{a, m}
}

func readKeys() (result [][2]int) {
	for i := 0; i < M; i++ {
		result = append(result, readKey())
	}
	return
}

func solve(keys [][2]int, amount int, cm int) int {
	if cm == (1<<uint(N))-1 {
		return amount
	}
	if len(keys) == 0 {
		return math.MaxInt64
	}
	a := keys[0][0]
	m := keys[0][1]
	if dp[cm|m] < amount+a {
		return solve(keys[1:], amount, cm)
	} else {
		dp[cm|m] = amount + a
		return min(solve(keys[1:], amount+a, cm|m), solve(keys[1:], amount, cm))
	}
}

func main() {
	N = readInt()
	M = readInt()
	keys := readKeys()

	dp = make([]int, 1<<uint(N))
	for i := 0; i < 1<<uint(N); i++ {
		dp[i] = math.MaxInt64
	}

	t := solve(keys, 0, 0)
	if t == math.MaxInt64 {
		fmt.Println(-1)
	} else {
		fmt.Println(t)
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 1024
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<cstdio>
#include<climits>
#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<utility>
#include<queue>

using namespace std;

void solve(int n){
  int s = 0;
  for(int i = 1;i*i <= n;i++){
    if(n % i == 0){
      s += i + (n/i);
    }
    if(i*i == n)s -= i;
  }
  s -= n;
  if(n == 1) cout << "deficient number";
  else if(s == n)cout << "perfect number";
  else if(s < n)cout << "deficient number";
  else if(s > n)cout << "abundant number";
  cout << endl;
} 

int main(){
  ios::sync_with_stdio(false);
  int n = 0;
  while(cin >> n && n != 0){
    solve(n);
  }
  return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,ans[105],s;
int main()
{
	cin>>a>>b>>c;
	ans[a]++;
	ans[b]++;
	ans[c]++;
	for(int i=1;i<=100;i++)
	{
		if(ans[i]>0)  s++;
	}
	cout<<s;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
     long long int n,k;
     cin>>n>>k;
     long long int a[n];
     for(int i=0;i<n;i++)
          cin>>a[i];
     for(int i=k;i<n;i++)
     {
          if(a[i]>a[i-k])
          {
              // cout<<a[i]<<" "<<a[i-k]<<endl;
               cout<<"Yes"<<endl;
          }
          else
          {
               //cout<<a[i]<<" "<<a[i-k]<<endl;
               cout<<"No"<<endl;
          }
     }
      return 0;
}


Measured memory_bytes: 5188
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() { return readln.chomp.to!int; }
int[] readints() { return readln.split.to!(int[]); }

void main() {
    int n = readint;
    int[] a;

    int[string] db; // name -> int
    for (int i = 0; i < n; i++) {
        auto ax = readln.split;
        string material = ax[0];
        int price = ax[1].to!int;

        db[material] = i;
        a ~= price;
    }

    auto uf = new UnionFind(n);
    int m = readint;
    for (int i = 0; i < m; i++) {
        auto ss = readln.split;
        // s と t は自由に交換可能
        int s = db[ss[0]];
        int t = db[ss[1]];

        // rs, rt の集合の最安値を更新
        int rs = uf.root(s);
        int rt = uf.root(t);
        uf.unite(s, t);
        a[uf.root(s)] = min(a[rs], a[rt]);
    }

    int ans = iota(n).map!(e => a[uf.root(e)]).sum;
    writeln(ans);
}

class UnionFind {
    private int[] _data;
    private int[] _nexts; // 次の要素。なければ -1
    private int[] _tails; // 末尾の要素

    this(int n) {
        _data  = new int[](n + 1);
        _nexts = new int[](n + 1);
        _tails = new int[](n + 1);

        _data[] = -1;
        _nexts[] = -1;
        for (int i = 0; i < _tails.length; i++)
            _tails[i] = i;
    }

    int root(int a) {
        if (_data[a] < 0) return a;
        return _data[a] = root(_data[a]);
    }

    bool unite(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        if (ra == rb) return false;
        // ra に rb を繋げる
        _data[ra] += _data[rb];
        _data[rb] = ra;

        // ra の末尾の後ろに rb を繋げる
        _nexts[_tails[ra]] = rb;
        // ra の末尾が rb の末尾になる
        _tails[ra] = _tails[rb];
        return true;
    }

    bool isSame(int a, int b) {
        return root(a) == root(b);
    }

    /// a が属する集合のサイズ
    int groupSize(int a) {
        return -_data[root(a)];
    }

    /// a が属する集合の要素全て
    void doEach(int a, void delegate(int) fn) {
        auto node = root(a);
        while (node != -1) {
            fn(node);
            node = _nexts[node];
        }
    }
}



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

int main()
{
	ll n,ans = 2e18;
	scanf("%lld",&n);
	for(ll i = 1;i <= sqrt(n);++i){
		if(n % i == 0) ans = min(ans,i+n/i-2);
	}
	printf("%lld",ans);
	return 0;
}

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

int main() {
    int w,a,b;
    cin >> w >> a >> b;
    if((b>=a&&b<=a+w)||(b+w>=a&&b+w<=a+w))cout << 0 << endl;
    else cout << min(abs(b-a-w),abs(a-b-w)) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
long long N;
cin>>N;
long long ans=N-1;
long long tmp=0;
for(long long i=2;i*i<=N;++i){
  if(N%i==0){
    tmp=(N/i)+i-2;
    if(ans>tmp){
      ans=tmp;
    }
  }
}
cout<<ans<<"\n";
return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		switch(S) {
		case "Sunny":
			System.out.println("Cloudy");
			break;
		case "Cloudy":
			System.out.println("Rainy");
			break;
		case "Rainy":
			System.out.println("Sunny");
			break;
		}
	}
}

Measured memory_bytes: 19540
#include <iostream>
#include <math.h>
using namespace std;

bool isPrime(int x){
    if(x == 2) return true;
    if(x < 2 || x % 2 == 0) return false;
    
    int i = 3;
    while(i <= sqrt(x)){
        if(x % i == 0){
            return false;
        }
        i = i + 2;
    }
    
    return true;
}


int main(void){
    int n, x;
    int count = 0;
    cin >> n;
    
    for(int i = 1; i <= n; i++){
        cin >> x;
        if(isPrime(x)) count++;
    }
    
    cout << count << endl;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;

int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> a(n,make_pair(0,0));
    for(int i=0;i<m;i++){
        int p; string s;
        cin >> p >> s;
        p--;
        if(a.at(p).first == 1) continue;
        if(s == "WA") a.at(p).second++;
        if(s == "AC") a.at(p).first = 1;
    }
    int nc = 0,npe = 0;
    for(int i=0;i<n;i++){
        if(a.at(i).first == 1){
          nc++;
          npe += a.at(i).second;
        }
    }
    cout << nc << " " << npe << endl;
}

Measured memory_bytes: 1024
def connected_components(n, graph):
    components, visited = [], [False] * n

    def dfs(start):
        component, stack = [], [start]

        while stack:
            start = stack[-1]

            if visited[start]:
                stack.pop()
                continue
            else:
                visited[start] = True
                component.append(start)

            for i in graph[start]:
                if not visited[i]:
                    stack.append(i)

        return component

    for i in range(n):
        if not visited[i]:
            components.append(dfs(i))

    return components

n,m=map(int,input().split())
adj=[]
for i in range(n+1):
	adj.append([])
for i in range(m):
	a,b=map(int,input().split())
	adj[a].append(b)
	adj[b].append(a)
mat=connected_components(n+1,adj)
ans=0
for i in mat:
	if(len(i)>ans):
		ans=len(i)
print(ans)

Measured memory_bytes: 51712
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define ins insert
#define rs (x<<1|1) 
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define sqr(x) ((x)*(x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x)&(-x))
#define SZ(x) (int((x).size()))
#define ms(x,y) memset(x,y,sizeof (x))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)]) 
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
#define debegin printf("debug\nbegin\n")
#define deend printf("debug\nend\n")
#define isfind printf("find\n")
template<class T>inline void rread(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
inline int getgcd(int x,int y){if(!x)return y;return getgcd(y%x,x);}
inline int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=(ll)x*x%p)if(k&1)res=(ll)res*x%p;return res;}
const double pi=acos(-1);
inline void judge(){
	freopen("input.txt","r",stdin);
} 
//********************************head*************************************	
int n,m;
ll ans=1e18,S[3];
inline void check(ll a,ll b,ll c){
	S[0]=a;S[1]=b;S[2]=c;
	sort(S,S+2+1);
	ans=min(ans,S[2]-S[0]);
}
int main(){
	rread(n);rread(m);
	rep(i,1,n-1){
		int nown=n-i,nowm=m;
		if((nown%2==0)||(nowm%2==0)){
			check(1ll*i*m,1ll*nown*nowm/2,1ll*nown*nowm/2);
		}else{
			if(nowm>1)check(1ll*i*m,1ll*nown*(nowm/2),1ll*nown*((nowm+1)/2));
			if(nown>1)check(1ll*i*m,1ll*(nown/m)*nowm,1ll*((nown+1)/2)*nowm);
		}
	}
	rep(i,1,m-1){
		int nown=n,nowm=m-i;
		if((nown%2==0)||(nowm%2==0)){
			check(1ll*i*n,1ll*nown*nowm/2,1ll*nown*nowm/2);
		}else{
			if(nowm>1)check(1ll*i*n,1ll*nown*(nowm/2),1ll*nown*((nowm+1)/2));
			if(nown>1)check(1ll*i*n,1ll*(nown/m)*nowm,1ll*((nown+1)/2)*nowm);
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	int n; cin >> n;
	vector<int> a(n + 1);
	for (int i = 2; i <= n; ++i) {
		int x; cin >> x;
		a[x]++;
	}
	for (int i = 1; i <= n; ++i) cout << a[i] << '\n';
}


Measured memory_bytes: 3996
#include <stdio.h>

int main(void)
{
	int num[5];
	int i;
	int j;
	
	for( i = 0; i < 5; i++ )
	{
		scanf( "%d", &num[i] );
	}
	
	for( i = 0; i < 5; i++ )
	{
		for( j = i + 1; j < 5; j++ )
		{
			if( num[i] < num[j] )
			{
				int buf = num[i];
				num[i] = num[j];
				num[j] = buf;
			}
		}
	}
	
	for( i = 0; i < 5; i++ )
	{
		printf( "%d%c", num[i], i == 4 ? '\n' : ' ' );
	}
	
	return (0);
}

Measured memory_bytes: 596
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        int Q = Integer.parseInt(sc.next());
        int[] a = new int[Q];
        int[] b = new int[Q];
        int[] c = new int[Q];
        int[] d = new int[Q];
        int[] A = new int[10];
        int ans = 0;
        
        for(int i = 0; i < Q; i++) {
            a[i] = Integer.parseInt(sc.next());
            b[i] = Integer.parseInt(sc.next());
            c[i] = Integer.parseInt(sc.next());
            d[i] = Integer.parseInt(sc.next());
        }
        
        for(A[0] = 1; A[0] <= M; A[0]++) {
            for(A[1] =A[0]; A[1] <= M; A[1]++) {
                for(A[2] =A[1]; A[2] <= M; A[2]++) {
                    for(A[3] =A[2]; A[3] <= M; A[3]++) {
                        for(A[4] =A[3]; A[4] <= M; A[4]++) {
                            for(A[5] =A[4]; A[5] <= M; A[5]++) {
                                for(A[6] =A[5]; A[6] <= M; A[6]++) {
                                    for(A[7] =A[6]; A[7] <= M; A[7]++) {
                                        for(A[8] =A[7]; A[8] <= M; A[8]++) {
                                            for(A[9] =A[8]; A[9] <= M; A[9]++) {
                                                int sum = 0;
                                                for(int i = 0; i < Q; i++) {
                                                    if(A[b[i]-1] - A[a[i]-1] == c[i]) {
                                                        sum += d[i];
                                                    }
                                                }
                                                if(ans < sum) {
                                                    ans = sum;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        
        System.out.println(ans);
        

    }
}

Measured memory_bytes: 36896
s=input()
a=[1,0,0,0]
for i in s:
    if i=="A": a[1]+=a[0]
    elif i=="B": a[2]+=a[1]
    elif i=="C": a[3]+=a[2]
    else: a=[ a[0]*3 ] + [ a[j+1]*3+a[j] for j in range(3) ]

    a=[a[i]%1000000007 for i in range(4)]
print(a[3])

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

class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try{
	    String st; int rec = 0, loz = 0;
	    while((st=sc.readLine())!=null){
		String[] ab = st.split(",");
		int[] a = {Integer.valueOf(ab[0]),Integer.valueOf(ab[1]),Integer.valueOf(ab[2])};
		if((a[0]*a[0]+a[1]*a[1]) == a[2]*a[2])
		    rec++;
		else if(a[0]==a[1])
		    loz++;

	    }
	    System.out.println(rec);
	    System.out.println(loz);
	}catch (Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 9360
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    long long sum=0;
    map<long long,long long>m;
    m[0]++;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
        m[sum]++;
    }
    long long ans=0;
    for(auto itr=m.begin();itr!=m.end();itr++){
        long long x=itr->second;
        ans+=x*(x-1)/2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 16884
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] s = new int[n];
    int sum = 0;
    for(int i = 0; i < n; i++){
      s[i] = sc.nextInt();
      sum += s[i];
    }
    if(sum % 10 != 0){
      System.out.println(sum);
    }else{
      Arrays.sort(s);
      for(int i = 0; i < n; i++){
        if(s[i] % 10 != 0){
          System.out.println(sum-s[i]);
          System.exit(0);
        }
      }
      System.out.println(0);
    }
  }
}


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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N,M;
vector<int> edge [100001];
bool vis [100001];

void dfs(int curr,vector<int>& res)
{
	for(const auto& it : edge [curr]) if(vis [it] == false){
		res.push_back(it);
		vis [it] = true;
		dfs(it,res);
		break;
	}
}

int main()
{
	scanf("%d%d",&N,&M);
	FOR(i,0,M){
		int u,v;
		scanf("%d%d",&u,&v);
		edge [u].push_back(v);
		edge [v].push_back(u);
	}

	vector<int> ans;
	vis [1] = true;
	vector<int> res;
	dfs(1,res);
	reverse(res.begin(),res.end());
	ans.insert(ans.end(),res.begin(),res.end());
	ans.push_back(1);
	res.clear();
	dfs(1,res);
	ans.insert(ans.end(),res.begin(),res.end());

	printf("%lu\n",ans.size());
	FOR(i,0,ans.size()){
		printf("%d%s",ans [i],i == ans.size() - 1 ? "\n" : " ");
	}

	return 0;
}


Measured memory_bytes: 7312
import collections

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
K = 2*(10**5)
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, K + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
n=int(input())
print(n)
nCk=n
R=list()
L=list(map(int,input().split()))
c = collections.Counter(L)
nikai=c.most_common()[0][0]#2回出てくる数
for i in range(n+1):
  if L[i]==nikai:
    R.append(i)
#Rに二個のindがある。それぞれR[0]こ、N-R[1]
k=n-R[1]+R[0]
for i in range(1,n):
  nCk=cmb(n+1,i+1,mod)
  a = cmb(k,i,mod)
  print((nCk-a)%mod)
print(1)

Measured memory_bytes: 50660
N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))

u_cnt = [0] * N
d_cnt = [0] * N

t = 0
for i in range(N):
    while t < N and A[t] < B[i]:
        t += 1
    u_cnt[i] = t

t = N-1
for i in range(N-1,-1,-1):
    while t >= 0 and C[t] > B[i]:
        t -= 1
    d_cnt[i] = N - 1 - t

ans = 0
for i in range(N):
    ans += u_cnt[i] * d_cnt[i]

print(ans)

Measured memory_bytes: 29268