akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String w = sc.next();
        w = w.toLowerCase();
        boolean flag = true;
        int count = 0;
        while(flag){
            String t = sc.next();
            if(t.contains("END_OF_TEXT")){
                flag = false;
            }else{
                t = t.toLowerCase();
                if(t.equals(w)){
                    count = count + 1;
                }
            }
        }
        sc.close();
        System.out.println(count);
    }
}


Measured memory_bytes: 26104
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    a, b, c, d = map(int, input().split())
    ans = min(b, d)-max(a, c)
    if b < c or d < a:
        print(0)
    else:
        print(ans)  


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<stdio.h>
#include<string.h>
#define N 50
#define LEN 51
int main()
{
  int maxlen;
  int i,j,k;
  int flag;
  int n;
  int ans;
  char code[N][LEN];
  char temp[LEN];
  while(1)
    {
      scanf("%d",&n);
      if(n==0) break;
      maxlen=0;
      for(i=0;i<n;i++)
	{
	  scanf("%s",temp);
	  flag=1;
	  k=0;
	  for(j=0;j<strlen(temp);j++)
	    {
	      if(flag)
		{
		  code[i][k]=temp[j];
		  flag=0;
		  k++;
		}
	      if(temp[j]=='a'||temp[j]=='i'||temp[j]=='u'||temp[j]=='e'||temp[j]=='o') flag=1;
	    }
	  code[i][k]='\0';
	  if(strlen(code[i])>maxlen) maxlen=strlen(code[i]);
	}
      flag=0;
      for(i=0;i<n;i++)
	{
	  for(j=i+1;j<n;j++)
	    {
	      if(strcmp(code[i],code[j])==0)
		{
		  flag=1;
		  break;
		}
	    }
	  if(flag) break;
	}
      if(flag) ans=-1;
      else
	{
	  for(ans=1;ans<=maxlen;ans++)
	    {
	      flag=0;
	      for(i=0;i<n;i++)
		{
		  for(j=i+1;j<n;j++)
		    {
		      if(strncmp(code[i],code[j],ans)==0)
			{
			  flag=1;
			  break;
			}
		    }
		  if(flag) break;
		}
	      if(flag==0) break;
	    }
	}
      if(ans>maxlen) ans=-1;
      printf("%d\n",ans);
    }
  return 0;
}



Measured memory_bytes: 2032
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
int n[50000];
int a[50000][1000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int j=0;
    while(true){
        cin >> n[j];
        if(n[j]==0){
            break;
        }
    for (int i = 0; i < n[j]; i++)
        cin >> a[j][i];
    j++;
    }
    for(int i=0;i<j;i++){
        sort(a[i],a[i]+n[i]);
    }
    int ans[j];
    for(int i=0;i<j;i++){
        ans[i]=INF;
    }
    for(int i=0;i<j;i++){
        int temp=INF;
        for(int k=0;k<n[i]-1;k++){
            int sub=a[i][k+1]-a[i][k];
            temp=min(temp,sub);
        }
        ans[i]=temp;
    }
    for(int i=0;i<j;i++)
    cout << ans[i] << "\n";
}


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

vector<int> sosu;
vector<int> cnt;
int num(int a){
    int ans = 0;
    for(vector<int>::iterator i = cnt.begin(); i != cnt.end();i++){
        if(*i >= (a-1))
            ans++;
    }   
    return ans;
}
int main()
{
    int n;
    sosu.push_back(2);
    
    cin >> n;

    // for(int i = 3; i < 300; i++){
    //     bool flag = true;
    //     for(int j =2; j <i;j++){
    //         if(i%j==0)
    //             flag = false;
    //     }
    //     if(flag)
    //         sosu.push_back(i);
    // }

    // for(int i = 0; sosu[i] <= n/2+1; i++){
    //     cnt.push_back(0);
    //     for(int j = sosu[i]; j <= n; j*=j){
    //         cnt[i] +=n/j;
    //     }
    // }
    for(int i = 0; i < n;i++)
        cnt.push_back(0);
    for(int i = 2; i <= n;i++){
        int cur = i;
        for(int j = 2; j <= i; j++){
            while(cur%j==0){
                cnt[j] +=1;
                cur/=j;
            }
        }
    }
    // for(vector<int>::iterator i = sosu.begin(); i != sosu.end(); i++){
    //     cout << *i << endl;
    // }
    // cout << endl<<endl;
    // for(vector<int>::iterator i = cnt.begin(); i != cnt.end(); i++){
    //     cout << *i << endl;
    // }

    cout << (num(75)+num(25) *(num(3)-1)+num(15)*(num(5) -1)
    +num(5) *(num(5) -1)*(num(3)-2)/2)  << endl;
    
    return 0;
}

Measured memory_bytes: 256
x,y=map(int,input().split())
import math

#yをxこの2,4の組み合わせで記述できるか
#yを4で割った余りが0か2で
#あまり無し商<=x あまりあり商＋１<=x
#y=100の時には少なくとも25匹いればよい
#y=102の時は？　少なくとも100//4+1匹＝ceil((102/2)/2)匹
#逆にy=100の時xの上限は　50

if y%2==0 and math.ceil((y/2)/2)<=x and x<=(y/2):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9164
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayList<Integer> b = new ArrayList<Integer>();
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            b.add(x);
        }
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            for (int j = n - i -1; j >= 0; j--) {
                if(b.get(j) == j+1){
                    a[i] = j + 1;
                    b.remove(j);
                    break;
                }
                if(j == 0) a = null;
            }
        }
        if(a != null){
            for (int i = n-1; i >= 0; i--) {
                System.out.println(a[i]);
            }
        }else System.out.println(-1);
        sc.close();
    }

}


Measured memory_bytes: 23252
s = input()

if s[0]=="A":
    s_t = s[0:2].replace("A","")
    s_m = s[2:-1]
    s_e = s[-1]
    if s_m.count("C")==1:
        s_m = s_m.replace("C","")
        s = s_t + s_m + s_e
        if s.islower():
            print("AC")
        else:
            print("WA")
    else:
        print("WA")
else:
    print("WA")

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

int main()
{
  int N;
  cin >> N;
  
  int H[N],G[N-1];
  
  for(int i=1;i<=N;i++)
    cin >> H[i];
  
  H[0]=H[1];
  int ans=0;
  
  for(int i=N-1;i>0;i--){
    if(H[i]<=H[i+1])
      continue;
    else if(H[i]==H[i+1]+1)
      H[i]--;
    else
      ans++;
  }
  
  if(ans==0)
    cout << "Yes";
  
  else
    cout << "No";
    
  return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
long long const modp=998244353;
long long ncr[4011][4011],pow2[4011];
inline long long nHr(int n,int r){
    return ncr[n+r-1][r];
}
int main(){
    int k,n;
    scanf("%d%d",&k,&n);
    int max=k+n+10;
    for(int i=0;i<=max;i++){
        for(int j=0;j<=max && j<=i;j++){
            if(i==0||i==j)ncr[i][j]=1;
            else ncr[i][j]=(ncr[i-1][j-1]+ncr[i-1][j])%modp;
        }
    }
    pow2[0]=1;
    for(int i=1;i<=max;i++)pow2[i]=(pow2[i-1]*2)%modp;
    for(int i=2;i<=2*k;i++){
        int p=(std::min(k,i-1)-std::max(1,i-k)+1)/2;
        long long ans=0;
        if(i%2!=0){
            for(int q=0;q<=p;q++)ans=(ans+ncr[p][q]*pow2[p-q]%modp*nHr(k-p-q,n-p+q)%modp)%modp;
        }else{
            for(int q=0;q<=p;q++)ans=(ans+ncr[p][q]*pow2[p-q]%modp*(nHr(k-1-p-q,n-p+q)+nHr(k-1-p-q,n-1-p+q))%modp)%modp;
        }
        printf("%lld\n",ans%modp);
    }
    return 0;
}

Measured memory_bytes: 124160
n = int(input())
t0, x0, y0 = 0, 0, 0
t, x, y = t0, x0, y0 # current
ans = "Yes"
for i in range(1, n+1):
  ti, xi, yi = map(int, input().split())
  displacement = (xi - x) + (yi - y)
  distance = abs(displacement)
  dt = ti - t
  # 時間差が移動距離より大きく、時間差-距離がeven_numberだったら
  # 寄り道しても往復してたどり着ける
  if dt >= distance and (dt - distance) % 2 == 0:
    t, x, y = ti, xi, yi
  else:
    ans = "No"
    break
 
print(ans)

Measured memory_bytes: 3064
use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let (n, m, s, t) = i.read4::<usize, usize, usize, usize>();
    let mut la = vec![Vec::new(); n];
    let mut lb = vec![Vec::new(); n];
    for _ in 0..m {
        let (u, v, a, b) = i.read4::<usize, usize, usize, usize>();
        let (u, v) = (u - 1, v - 1);

        la[u].push((v, a));
        la[v].push((u, a));

        lb[u].push((v, b));
        lb[v].push((u, b));
    }
    let rs = solve(n, s - 1, t - 1, la, lb);
    for r in rs {
        writeln!(o, "{}", 1000000000000000 - r).unwrap();
    }
}
fn solve(
    n: usize,
    s: usize,
    t: usize,
    la: Vec<Vec<(usize, usize)>>,
    lb: Vec<Vec<(usize, usize)>>,
) -> Vec<usize> {
    let ca = get_costs(n, s, la);
    let cb = get_costs(n, t, lb);

    let mut rs = Vec::new();
    let mut r = usize::max_value();
    for i in (0..n).rev() {
        r = min(r, ca[i] + cb[i]);
        rs.push(r);
    }
    rs.reverse();
    rs
}
fn get_costs(n: usize, s: usize, l: Vec<Vec<(usize, usize)>>) -> Vec<usize> {
    let mut q: BinaryHeap<(usize, usize)> = BinaryHeap::new();
    let mut cs = vec![usize::max_value(); n];
    cs[s] = 0;
    q.push((s, 0));
    while let Some((i0, c0)) = q.pop() {
        for &(i1, c) in &l[i0] {
            let c1_new = c0 + c;
            let c1_old = cs[i1];
            if c1_new < c1_old {
                cs[i1] = c1_new;
                q.push((i1, c1_new));
            }
        }
    }
    cs
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        {$f:ident($($v:ident: $t:ident),*)} => {
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                $(
                    let $v = i.next().unwrap().parse().ok().unwrap();
                )*
                ($($v),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read4(v1: T1, v2: T2, v3: T3, v4: T4) }
    }
}


Measured memory_bytes: 31496
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

int ans[999999];

bool isprime(int n) {
    if (n == 2) return true;
    if (n % 2 == 0) return false;
    for(int i = 3; i <= sqrt(n); i+=2) {
        if (n % i == 0) return false;
    }
    return true;
}

int main() {
    FOR(i, 1, 999999) {
        ans[i] = ans[i-1] + isprime(i+1);
    }
    int i;
    while(cin >> i) {
        cout << ans[i-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 5060
use std::io::*;
use std::str::FromStr;

fn main() {
    let s: usize = read();

    let mut a: Vec<bool> = vec![false; 10000000];
    
    let mut m = 2;
    let mut am = s;
    a[s] = true;
    loop {
        if am % 2 == 0 {
            am /= 2;
        } else {
            am = 3 * am + 1;
        }
        if a[am] {
            println!("{}", m);
            return;
        }
        a[am] = true;
        m += 1;
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 14588
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery

#define eps 1e-9
#define M_PI 3.141592653589793
#define bsize 1024

#define ldouble long double
using namespace std;

#define bs 998244353

const int N = 200031;

int n,k;
int solver(int x){
	int ret=0;
	int goal=x;
	while (true){
		if (x%2==1)
			x/=2;
		else
			x=x/2+(1<<(n-1));
		++ret;
		if (x==goal)
			return ret;
	}
}

void show_binary(int x){
	for (int i=n-1;i>=0;--i){
		if (x&(1<<i))
			cout<<1;
		else
			cout<<0;
	}
	cout<<endl;
}

int eval(string st){
	int res=0;
	for (int i=0;i<st.size();i++){
		res=res*2+st[i]-48;
		res%=bs;
	}
	return res;
}

long long ans;

vector<int> interesting;

long long count_with[N];

string temp;

long long eval_prefix(int len){
	int res=0;
	for (int i=0;i<len;i++){
		res=res*2+temp[i]-48;
		res%=bs;
	}
	return res;
}

string combine(int len){
	string ret=temp;
	for (int i=0;i<temp.size();i++){
		if (i<len)
			ret[i]=temp[i];
		else
			ret[i]='0'+'1'-ret[i-len];
	}
	return ret;
}

int main(){
//    freopen("apache.in","r",stdin);
//    freopen("apache.out","w",stdout);
 //   freopen("input.txt", "r", stdin);
 //   freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
 //   cin.tie(0);

    cin>>n;
    cin>>temp;
 /*   k=eval(temp);
    for (int i=0;i<=k;i++){
    	int F=solver(i);
    	ans+=F;
    	if (F!=n*2){
    		cout<<i<<" "<<F<<endl;
    		show_binary(i);
    	}
    }

    cout<<"@"<<ans<<endl;
*/
    ans=eval(temp)+1;
    ans%=bs;
    ans*=(n*2);
    ans%=bs;

    for (int i=1;i<temp.size();i++){
    	if (temp.size()%i)
    		continue;
    	int L=temp.size()/i;
    	if (L%2==0)
    		continue;
    	interesting.push_back(i);
    }

    for (int i=0;i<interesting.size();i++){
    	count_with[i]=eval_prefix(interesting[i])+1;
    	count_with[i]%=bs;
    	string T2=combine(interesting[i]);
    	if (T2>temp)
    		count_with[i]=(count_with[i]-1+bs)%bs;
//    	cout<<i<<" "<<interesting[i]<<" "<<count_with[i]<<endl;
    }

    for (int i=0;i<interesting.size();i++){
    	for (int j=i+1;j<interesting.size();j++){
    		if (interesting[j]%interesting[i]==0){
    			count_with[j]-=count_with[i];
    			if (count_with[j]<0)
    				count_with[j]+=bs;
    		}
    	}
    }

    for (int i=0;i<interesting.size();i++){
    	ans=(ans-(n*2)*count_with[i]+2*interesting[i]*count_with[i]);
    	ans%=bs;
    	if (ans<0)
    		ans+=bs;
    }

    cout<<ans<<endl;

//    cin.get(); cin.get();
    return 0;
}


Measured memory_bytes: 788
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int t = sc.nextInt();
        sc.close();

        System.out.println( t * (int) Math.ceil((double) n / (double) x));
    }
}

Measured memory_bytes: 35680
import java.util.*;
public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();

      if (b <= a && c <= a) {
         System.out.println(10 * a + b + c);
      }
      else if (c <= b) {
         System.out.println(10 * b + a + c);
      }
      else {
         System.out.println(10 * c + a + b);
      }

   }
}

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

int main() {
  
 int A, B;
  cin >> A >> B;
   
  if ( A < B ) {
    cout << 0 << endl;
  }
  else if ( A <= B * 2 ) {
    cout << 0 << endl;
  }
  else {
    cout << A - B * 2 << endl;
  }

   
} 

Measured memory_bytes: 256
import copy
N = int(input())
dp = [0]*3
for _ in range(N):
  tmp = [int(n) for n in input().split()]
  tmp_dp = copy.deepcopy(dp)
  tmp_dp[0] = max(dp[1],dp[2]) + tmp[0]
  tmp_dp[1] = max(dp[0],dp[2]) + tmp[1]
  tmp_dp[2] = max(dp[0],dp[1]) + tmp[2]
  dp = tmp_dp
print(max(dp))

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define int long long
#define P(x) {if (debug) cout << x << endl;}
#define H(x) P(#x << ": " << (x))
#define FR(i,a,b) for (int i=(a); i<(b); i++)
#define F(i,n) FR(i,0,n)
#define DR(i,a,b) for (int i=(b); i-->(a);)
#define D(i,n) DR(i,0,n)
#define S(s) (int)(s).size()
#define ALL(v) v.begin(), v.end()
#define MI(a,v) a = min(a,v)
#define MA(a,v) a = max(a,v)
#define V vector
#define pb push_back
#define mt make_tuple
using namespace std;
template<class T> ostream &operator<<(ostream &os, V<T> v) {
    F(i,S(v)) os<<(i?" ":"")<<v[i];
    return os;
}
const bool debug = 0;
int bestPos(int l, V<int> ps) {
    auto optPath = [&](int d) {
        return max(d, l-d);
    };
    if (S(ps) == 1) return optPath(ps[0]);
    int n = S(ps);
    V<int> pref(n+1);
    pref[0] = 0;
    F(i,n) pref[i+1] = pref[i] + ps[i];
    int best = 0;
    F(i,n-1) {
        H(i)
        int numL = i+1, numR = n-2-i;
        int doublesL = min(numL-1, numR),
            doublesR = min(numR, numL);
        int partL = 2*(pref[i] - pref[i-doublesL]) + ps[i],
            partR = 2*(l*doublesR - (pref[i+2+doublesR] - pref[i+2]));
        H(numL)
        H(numR)
        MA(best, partL+partR+optPath(ps[i+1]-ps[i]));
    }
    return best;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int l,n; cin>>l>>n;
    V<int> ps(n);
    for (int &p : ps) cin>>p;
    int best = bestPos(l, ps);
    for (int &p : ps) p = l-p;
    reverse(ALL(ps));
    MA(best, bestPos(l, ps));
    cout<<best<<"\n";
}

Measured memory_bytes: 4992
package main

import "fmt"

func main() {
	var n int
	var w, old string
	fmt.Scan(&n)
	m := make(map[string]int)
	fmt.Scan(&w)
	m[w]++
	old = w
	follow := true
	for i := 1; i < n; i++ {
		fmt.Scan(&w)
		if _, exist := m[w]; exist {
			follow = false
		}
		m[w]++
		if old[len(old)-1] != w[0] {
			follow = false
		}
		old = w
	}
	if follow {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>

using namespace std;  //このネームスペースを使う

int main(){
  long a,b;
  cin >> a >> b;

  long tmp;
  tmp = b-a;

  int i;
  for(i=0;i<(a*2-1);i++){
    tmp++;
    if(tmp > (-1)*(1000001) && tmp < 1000001){
    cout << tmp << endl;
    }
  }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

int n;
int A[100001];
llong S[100001];

llong solve() {
    llong ret = 0;
    for (int i = 1, sn = 1; i <= n; ++i, sn = -sn) {
        S[i] += S[i - 1];
        if (sn < 0 && 0 <= S[i]) {
            ret += S[i] + 1;
            S[i] = -1;
        }
        else if (sn > 0 && S[i] <= 0) {
            ret -= S[i] - 1;
            S[i] = 1;
        }
    }
    return ret;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> A[i];
        S[i] = A[i];
    }
    llong ans = solve();
    for (int i = 1; i <= n; ++i) {
        S[i] = -A[i];
    }
    ans = min(ans, solve());
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1408
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,b,n) for(int i=b;i<n;i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int n,k;
int dp[11][2010];//ジャンルiまででj冊売った時の最大の値段
vector<int> book[11];
int solve(int j,int i){//売った本がj冊で今ジャンルiを売る
	if(j==k)
		return 0;
	if(i >10)
		return 0;

	if(dp[i][j]!=-1)
		return dp[i][j];
	int res = 0;
	int sum =0 ;
	res =solve(j,i+1);
	int len =min((int)book[i].size(),k-j);
	for(int m =0;m <len;m++){
		sum +=book[i][m];
		res =max(res,solve(j+m+1,i+1)+sum+m*(m+1));
	}
	return dp[i][j]=res;
}
int main(){
	for(int i=1;i <=10;i++){
		fill(dp[i],dp[i]+2009,-1);
	}
	cin>>n>>k;
	map<int,int> ma;
	for(int i= 1;i <= n;i++){
		int a,b;
		cin>>a>>b;
		book[b].push_back(a);
		ma[b]=1;
	}
	int l= ma.size();
	for(int i= 0;i <=10;i++){
		sort(book[i].begin(),book[i].end(),greater<int>());
	}
	cout<<solve(0,1)<<endl;
	return 0;
}

Measured memory_bytes: 1316
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    string s;
    cin >> s;
    int a = -1, z;
    rep(i, s.size()){
        if(s[i] == 'A'){a = i;break;}
    }
    rep(i, s.size())if(s[i] == 'Z')z = i;
    cout << z-a+1 << endl;
}


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

vector<int>E[100000];
int d[100000], pr[100000];

void rec(int v, int p) {
	d[v] = p;
	for (int u : E[v])rec(u, p + 1);
}
int main() {
	int n; scanf("%d", &n);
	memset(pr, -1, sizeof(pr));
	rep(i, n) {
		int id, k; scanf("%d%d", &id, &k);
		rep(j, k) {
			int c; scanf("%d", &c);
			E[id].push_back(c);
			pr[c] = id;
		}
	}
	rep(i, n) {
		if (!~pr[i]) {
			rec(i, 0); break;
		}
	}
	rep(i, n) {
		printf("node %d: parent = %d, depth = %d, ", i, pr[i], d[i]);
		if (!~pr[i])printf("root, [");
		else if (E[i].empty())printf("leaf, [");
		else printf("internal node, [");
		rep(j, E[i].size()) {
			if (j)printf(", ");
			printf("%d", E[i][j]);
		}
		printf("]\n");
	}
}

Measured memory_bytes: 7064
import math

while True:
    try:
        a,l,x=map(int, input().split())
        temp=(l+x)/2
    except EOFError:
        break

    def heron(i,j,k):
        d = (i+j+k)/2
        return math.sqrt(d*(d-i)*(d-j)*(d-k))

    print((str(heron(a,l,l)+heron(l,temp,temp)*2)))


Measured memory_bytes: 5680
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		//String str = "a->e<-a<-d->a->e<-a<-d<-c->d->a<-d<-c<-b->c->d<-c";
		String str;
        Scanner sc = new Scanner(System.in);
        
        boolean bool = false;
        int DataCount = 0;
        
        while(sc.hasNext()){
        	if (bool == false){
		        DataCount = sc.nextInt();
		        bool = true;
        	}
        	str = "";
	        str = sc.next();
			
			str = str.replaceAll("-","");
			//System.out.println(str);
			
			char chr;
			String result = "";
			boolean before = false;
			boolean next = false;
			
			int i = 0;
			for(i=0; i<str.length();i++){
				chr = str.charAt(i);
				if (i==0){
					result = String.valueOf(chr);
				}else{
					if (chr == '<'){
						before = true;
					}else if(chr == '>'){
						next = true;
					}else {
						//System.out.println("result:" + result);
						//System.out.println("chr:" + chr);
						if(result.indexOf(chr) == -1){
							if (before){
								result = String.valueOf(chr) + result;
							}else{
								result = result + String.valueOf(chr);
							}
						}
						before = false;
						next = false;
					}
				}
			}
			System.out.println(result);
        }
	}
}

Measured memory_bytes: 24752
#include <bits/stdc++.h>
#define int long long

using namespace std;

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

    int n,m;
    cin>>n>>m;
    int x;
    priority_queue<int>q;
    for (int i = 0; i < n; ++i) {
        cin>>x;
        q.push(x);
    }

    int ans=0;
    while (m--)
    {
        int z=q.top();
        q.pop();
        q.push(z/2);
    }

    while (!q.empty())
    {
        ans+=q.top();
        q.pop();
    }

    cout<<ans;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}

int main()
{
    fastio();
    ll h,a,c;
    cin >> h  >> a;
    c=h%a;
    if(c==0)
        cout << h/a << endl;
    else
        cout << h/a+1 << endl;
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef pair<ll, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (ll i = 0; i < x; i++)
#define rep1(i, x) for (ll i = 1; i <= x; i++)
#define rrep(i, x) for (ll i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (ll i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

const int INF = 1000000000;
const ll M = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                         {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/*----------------------------------------------/
/- char         : %c  | char *       : %s  | short        : %hd
/- int          : %d  | long         : %ld | long long    : %lld
/- unsigned short:%hu | unsigned int : %u  | unsigned long: %lu
/- u_long long  : %llu| (octal)      : %o  | (hexadecimal): %x
/- float        : %f  | double       : %lf |
/----------------------------------------------*/

/*----------------------------------------------/
/- INT_MAX, LONG_MAX   : 1<<15 = 2.1*pow(10, 9)       (= 2147483647)
/- UINT_MAX, ULONG_MAX : 1<<16 = 4.2*pow(10, 9)       (= 4294967295)
/- LLONG_MAX           : 1<<63 = 9.2*pow(10, 18)      (= 9223372036854775807)
/- ULLONG_MAX          : 1<<64 = 1.8*pow(10, 19)      (= 18446744073709551615)
/----------------------------------------------*/

int main() {
    ll n, m, a[100100], b[100100];
    cin >> n >> m;
    rep(i, n) cin >> a[i] >> b[i];

    vector<pair<ll, ll>> ps(n);

    rep(i, n) ps[i] = make_pair(a[i], b[i]);
    sort(ps.begin(), ps.end());
    ll k = 0;
    ll ret = 0;
    while (m > 0) {
        P p = ps[k];
        if (m - p.sc <= 0) {
            ret += p.fr * m;
            m -= p.sc;
        } else {
            ret += p.fr * p.sc;
            m -= p.sc;
        }
        k++;
    }
    cout << ret;

    /* ====================================== */
    cout << endl;
    return 0;
}

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

int main() {
  int W, H;
  char c;
  cin >> H >> W;
  for(int i = 0; i < W + 2; i++) {
    cout << '#';
  }
  cout << endl;
  for(int i = 0; i < H; i++) {
    cout << '#';
    for(int j = 0; j < W; j++) {
      cin >> c;
      cout << c;
    }
    cout << '#' << endl;
  }
  for(int i = 0; i < W + 2; i++) {
    cout << '#';
  }
  cout << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
char grid[10100][10100];
long long int isvisited[10100][10100];
int H,W;
int main()
{


        cin>>H>>W;
        for(int i=0; i<H; i++)
                for(int j=0; j<W; j++)
                        cin>>grid[i][j];

        for(int i=0; i<H; i++) {
                if(i==0) {
                        for(int j=0; j<W; j++)
                        {
                                if(grid[i][j]=='#')
                                        break;
                                isvisited[i][j]=1;
                        }

                        for(int j=0; j<H; j++)
                        {
                                if(grid[j][i]=='#')
                                        break;
                                isvisited[j][i]=1;
                        }
                }

                else
                for(int j=1; j<W; j++) {
                        if(grid[i][j]=='.'){
                                isvisited[i][j]=(isvisited[i-1][j]+isvisited[i][j-1])%mod;

                                }

                }

        }
        cout<<isvisited[H-1][W-1]<<endl;

}


Measured memory_bytes: 88576
#include <stdio.h>
#include<math.h>
#define N 10000000

int isprime(int x){
		if(x==2){return 1;}
		
		 if(x<2 || x%2==0){return 0;}
		
		int j=3;
		while(j<=sqrt(x)){
			 if(x%j==0){return 0;}
			j=j+2;
		}
		return 1;
	}
int main(void){
	int n;
	int i,j;
	int a[N];
	int cnt=0;
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=0; i<n; i++){
		if(isprime(a[i])){cnt++;}
	}
	printf("%d\n",cnt);
	
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for (auto&& p_ : p)
    cin >> p_;
  
  int count = 0;
  for (int i = 1; i < n -1; ++i){
    if ((p[i] > p[i-1] && p[i] < p[i+1]) || (p[i] > p[i+1] && p[i] < p[i-1]))
      count++;
  }
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <queue>
#include <set>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> P;
typedef long long LL;
#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IFOR(v,it) for(VI::iterator it=(v).begin();it!=(v).end();++it)
#define IN(v) cin>>(v)
#define OUT(v) cout>>(v)>>endl

int H, W;
void fill(char S[50][50], int i, int j) {
  queue<P> q;
  q.push(MP(i, j));
  while (!q.empty()) {
    P p = q.front(); q.pop();
    int i = p.first, j = p.second;
    if (S[i][j] == '.')
      continue;
    S[i][j] = '.';
    REP(k, 4) {
      int di = k % 2 * (k - 2), dj = (1 - k % 2) * (k - 1);
      if (!(0 <= i + di && i + di < H && 0 <= j + dj && j + dj < W))
        continue;
      if (S[i+di][j+dj] == '#')
        q.push(MP(i + di, j + dj));
    }
  }
}

int main() {
  cin >> H >> W;

  char S[50][50];
  REP(i, H) {
    REP(j, W) {
      char s;
      cin >> s;
      S[i][j] = s;
    }
  }
  REP(i, H) {
    REP(j, W) {
      if (S[i][j] == '.')
        continue;
      int count = 0;
      REP(k, 4) {
        int di = k % 2 * (k - 2), dj = (1 - k % 2) * (k - 1);
        if (!(0 <= i + di && i + di < H && 0 <= j + dj && j + dj < W))
          continue;
        if (S[i+di][j+dj] == '#')
          ++count;
      }
      if (count == 0) {
        cout << "No" << endl;
        return 0;
      }
      fill(S, i, j);
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>

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

int main( void ){
	int  n;
	if (!scanf( "%d", &n ))
		return -1;
	double* array = new double[n];
	rep(i,0,n){
		int input;
		if (!scanf( "%d", &input))
			return -1;
		array[i] = (double)input;
	}
	std::sort(array, array+n);
	rep(i,1,n){
		array[i] = (array[i]+array[i-1])/2;
	}
	printf("%lf\n", array[n-1]);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1LL<<60;

// DAME:
// TIPS: 図を書いて考える
// 二部グラフの最大マッチングと考えることも可能

/*
    青点のx座標が小さいものからloop
        - 赤点のy座標が高いものを選択
*/

int main(){
    int n, x, y, ans = 0;
    cin >> n;
    vector < pair<ll, ll> > r, b;
    for (int i = 0; i < n; i++) {
        cin >> x >> y;
        r.push_back({x, y});
    }
    for (int i = 0; i < n; i++) {
        cin >> x >> y;
        b.push_back({x, y});
    }
    // 逆向きsort
    sort(r.rbegin(), r.rend());
    sort(b.begin(), b.end());
 
    for (int i = 0; i < n; i++) {
        ll ymax = -1, pos = -1;
        for (int j = 0; j < n; j++) {
            if ((r[j].first < b[i].first) && (r[j].second < b[i].second)) {
                if (ymax < r[j].second) {
                    ymax = r[j].second;
                    pos = j;
                }
            }
        }
        if (ymax == -1) continue;
        else {
            r[pos].first = inf;
            r[pos].second = inf;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <ctype.h>
const int bufSize = 1e6;
inline char nc()
{
    #ifdef DEBUG
    return getchar();
    #endif
    static char buf[bufSize], *p1 = buf, *p2 = buf;
    return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, bufSize, stdin), p1 == p2) ? EOF : *p1++;
}
inline void read(char *s)
{
    static char c;
    for (; !isalpha(c); c = nc());
    for (; isalpha(c); c = nc()) *s++ = c;
    *s = '\0';
}
template<typename T>
inline T read(T &r)
{
    static char c;
    static int flag;
    flag = 1, r = 0;
    for (c = nc(); !isdigit(c); c = nc()) if (c == '-') flag = -1;
    for (; isdigit(c); c = nc()) r = r * 10 + c - 48;
    return r *= flag;
}
const int maxn = 3100;
int n,m,num;
int a[maxn][maxn];
long long f[maxn][maxn][4],g[maxn][maxn];
int main()
{
    read(n),read(m),read(num);
    while(num--)
    {
        int x,y,z;
        read(x),read(y),read(z);
        a[x][y] = z;
    }
    for(int i = 1;i<=n;++i)
    {
        for(int j = 1;j<=m;++j)
        {
            for(int k = 0;k<=3;++k)
            {
                f[i][j][k] = std::max(f[i][j][k],f[i-1][j][k]);
                f[i][j][k] = std::max(f[i][j][k],f[i][j-1][k]);
                if(k) f[i][j][k] = std::max(f[i][j][k],g[i-1][j] + a[i][j]);
                if(k) f[i][j][k] = std::max(f[i][j][k],f[i][j-1][k-1] + a[i][j]);
            }
            for(int k = 0;k<=3;++k) g[i][j] = std::max(g[i][j],f[i][j][k]);
        }
    }
//    for(int i = 1;i<=n;puts(""),++i) for(int j = 1;j<=m;++j) printf("%d ",g[i][j]);
//    puts("");
    printf("%lld\n",g[n][m]);
    return 0;
}

Measured memory_bytes: 403640
/*
  Contest 069
  B - i18n
  Rakesh Kumar --> 01/09/2020
 */

#include <bits/stdc++.h>

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0); std::cout.tie(0);

    std::string s;
    std::getline(std::cin, s);
    std::cout << s[0] << s.size() - 2 << s[s.size() - 1] << std::endl;

    return 0;
}


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

struct BinaryIndexedTree {
  BinaryIndexedTree(int n) : n(n + 1), v(n + 2, 0), r(1 << (31 - __builtin_clz(n + 1))) {}

  vector<int> v;
  int n, r;

  int sum(int k) {
    int ret = 0;
    for (++k; k; k -= k & -k) ret += v[k];
    return ret;
  }

  void add(int k, int x) {
    for (++k; k <= n; k += k & -k) v[k] += x;
  }

  int lower_bound(int w) {
    int idx = 0;
    for (int k = r; k > 0; k /= 2) {
      if (idx + k <= n && v[idx + k] < w) {
        w -= v[idx + k];
        idx += k;
      }
    }

    return idx;
  }
};

struct segtree {
  segtree() {}
  segtree(int n, vector<char> v) : n(n) {
    init(v);
  }

  pair<char, int> id = make_pair('{', -1);
  int n;
  vector<pair<char, int>> node;

  void init(vector<char> v) {
    int n_ = n;
    n = 1;
    while (n < n_) n *= 2;

    node.assign(2 * n - 1, id);
    for (int i = 0; i < v.size(); ++i) {
      int idx = i + n - 1;
      node[idx] = make_pair(v[i], i);
    }
    for (int i = n - 2; i >= 0; --i) {
      node[i] = min(node[2 * i + 1], node[2 * i + 2]);
    }
  }

  pair<char, int> find(int a, int b, int k, int l, int r) {
    if (b <= l || r <= a) return id;
    if (a <= l && r <= b) return node[k];

    return min(find(a, b, 2 * k + 1, l, (l + r) / 2), find(a, b, 2 * k + 2, (l + r) / 2, r));
  }

  pair<char, int> find(int a, int b) {
    return find(a, b, 0, 0, n);
  }

  void update(int k) {
    k += n - 1;
    node[k] = id;
    while (k) {
      k = (k - 1) / 2;
      node[k] = min(node[2 * k + 1], node[2 * k + 2]);
    }
  }
};

int main() {
  string s;
  int k;

  cin >> s >> k;
  vector<char> v(s.size());
  for (int i = 0; i < s.size(); ++i) v[i] = s[i];

  BinaryIndexedTree bit(s.size());
  segtree seg(s.size(), v);

  for (int i = 0; i < s.size(); ++i) bit.add(i, 1);

  string ans;
  for (int i = 0; i < s.size(); ++i) {
    int r = bit.lower_bound(k + 1);
    pair<char, int> c = seg.find(0, r + 1);
    seg.update(c.second);
    bit.add(c.second, -1);
    k -= bit.sum(c.second);

    ans.push_back(c.first);
  }

  cout << ans << endl;
}

Measured memory_bytes: 8784
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
sum = 0
K = int(input())
for i in range(1,K+1):
  for j in range(1,K+1):
    gcd_0 = gcd(i,j)
    for k in range(1,K+1):
      sum += gcd(gcd_0,k)

print(sum)

Measured memory_bytes: 69748
n = int(input())
a = list(map(int, input().split()))

m = 10 ** 6 + 7

count = [0] * m

for x in a:
    if count[x] != 0:
        count[x] = 2
        continue

    for i in range(x, m, x):
        count[i] += 1

ans = 0
for x in a:
    if count[x] == 1:
        ans += 1

print(ans)

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

int main(){
  int n;
  cin >> n;
  string s[n];
  int ac=0,wa=0,tl=0,re=0;
  rep(i,n)cin >> s[i];
  rep(i,n){
    if(s[i]=="AC")ac++;
    else if(s[i]=="WA")wa++;
    else if(s[i]=="TLE")tl++;
    else re++;
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tl << endl;
  cout << "RE x " << re << endl;
  return 0;
}

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

int main()
{
    int d;
    cin >> d;
    if (d == 22)
        cout << "Christmas Eve Eve Eve" << endl;
    if (d == 23)
        cout << "Christmas Eve Eve" << endl;
    if (d == 24)
        cout << "Christmas Eve" << endl;
    if (d == 25)
        cout << "Christmas" << endl;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    for(int t=1; ; ++t)
    {
        immutable W = readln().chomp().to!int();
        if(!W) break;
        auto dp = new int[W+1];
        foreach(_;0..readln().chomp().to!int())
        {
            auto m = readln().chomp().split(",").map!(to!int);
            immutable v=m[0], w=m[1];
            foreach_reverse(i;w..W+1)
                dp[i]=max(dp[i],dp[i-w]+v);
        }
        int mv=0,mw=0;
        foreach(int w,v;dp)
            if(mv<v) mv=v,mw=w;
        writeln("Case ",t,":\n",mv,"\n",mw);
    }
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int table[1001] = {0};
void factor(int n) {
    //int nn = n;
    for (int i = 2; i <= n; ++i) {
        if (n % i == 0) {
            while (n % i == 0) {
                n /= i;
                table[i]++;
            }/*
            for (int i = 2; i <= nn; ++i) {
                cout << table[i] << " ";
            }
            cout << endl;*/
        }
        if (n == 0) break;
    }
    return;
}
int main() {
    int n; cin >> n;
    table[1] = 1;
    for (int i = 2; i <= n; ++i) {
        factor(i);
    }
    long long ans = 1;
    for (int i = 2; i <= n; ++i) {
        if (table[i]) {
            ans *= table[i] + 1;
            ans %= (long long)1e9 + 7;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import fractions
import sys

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


A,B,C,D = map(int,input().split())
if C == 1 or D == 1:
    print(0)
    sys.exit(0)

E = lcm(C,D)
c = (A-1)//C + 1 if C!=1 else A
d = (A-1)//D + 1 if D!=1 else A
e = (A-1)//E + 1 if E!=1 else A
cde = [[c,C], [d,D], [e,E]]
cnt_cde = []
for x,y in cde:
    if x*y < B:
        cnt_cde.append((B-x*y)//y+1)
    elif x*y == B:
        cnt_cde.append(1)
    else :
        cnt_cde.append(0)
answer = B-A+1-(cnt_cde[0]+cnt_cde[1]-cnt_cde[2])
print(answer)
            


Measured memory_bytes: 5044
N, M = map(int, input().split())
l = []
for _ in range(M):
  l.append(list(map(int, input().split())))
p = list(map(int, input().split()))

m = [0] * M # 電球のonoffチェック。on:1 off:0
cnt1 = 0 # 1の個数を数える
cnt2 = 0 # 答え

for i in range(2 ** N):
  for j in range(M):
    for k in range(l[j][0]):
      if (i >> (l[j][k+1] - 1) & 1):
        cnt1 += 1
    if cnt1 % 2 == p[j]:
      m[j] = 1
    cnt1 = 0
  if m == [1] * M:
    cnt2 += 1
  m = [0] * M
print(cnt2)

Measured memory_bytes: 3064
fun main() = Thread(null, ::msolutions2020a, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun msolutions2020a() {
    val x = readLine()!!.toInt()

    val answer = 10 - x / 200

    println(answer)
}


Measured memory_bytes: 34780
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define Inarr(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18;
const int iINF=1e9,MOD=1e9+7;
char mp[11][11];
int mh[4]={1,0,-1,0},mw[4]={0,1,0,-1};
typedef struct{
    int h,w,rank;
}maze;
int main(){
    int h,w,ans;
    bool goal_flag=false;
    cin>>h>>w;
    vector<string>mp(h);
    rep(i,h)cin>>mp[i];
    int cnt_bk=0;
    rep(i,h)rep(j,w)if(mp[i][j]=='#')cnt_bk++;

    queue<maze>que;
    que.push({0,0,0});
    while(!que.empty()){
        maze now=que.front();
        que.pop();
        if(mp[now.h][now.w]=='#')continue;
        else mp[now.h][now.w]='#';

        if(now.h==h-1&&now.w==w-1){
            goal_flag=true;
            ans=now.rank;
            break;
        }

        rep(i,4){
            int moveh=now.h+mh[i],movew=now.w+mw[i];
            if(moveh<0||moveh>=h||movew<0||movew>=w)continue;
            que.push({moveh,movew,now.rank+1});
        }

    }
    if(goal_flag){
        cout<<h*w-cnt_bk-(ans+1)<<endl;
    }
    else cout<<-1<<endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<string> a(n), b(n);
  rep(i, 0, n) cin >> a.at(i);
  b = a;
  
  //BubbleSort
  rep(i, 0, n) {
    for (int j = n-1; j > i; j--) {
      if (a.at(j).at(1) < a.at(j-1).at(1))
        swap(a.at(j), a.at(j-1));
    }
  }        
        
  //SelectionSort
  rep(i, 0, n) {
    int minj = i;
    rep(j, i, n) {
      if (b.at(j).at(1) < b.at(minj).at(1))
        minj = j;
    }
    swap(b.at(i), b.at(minj));
  }
  
  rep(k, 0, n) {
    if(k > 0) 
      cout << " ";
    cout << a.at(k);
  }
  cout << "\n";
  
  cout << (1 ?"Stable" :"Not stable") << "\n";
  
  rep(k, 0, n) {
    if(k > 0) 
      cout << " ";
    cout << b.at(k);
  }
  cout << "\n";
  
  cout << ((a == b) ?"Stable" :"Not stable") << "\n";

}



Measured memory_bytes: 3236
package main

import (
	"fmt"
	"math"
)

func main() {
	var k, n int
	fmt.Scan(&k, &n)
	ai := make([]int, n)
	for a := 0; a < n; a++ {
		var tmp int
		fmt.Scan(&tmp)
		ai[a] = tmp
	}
	//maxroute
	min := k
	for r := 0; r < n; r++ {
		var tm int
		if len(ai)-1 == r {
			tm = k - ((k - ai[r]) + ai[0])
		} else {
			tm = (k + ai[r]) - ai[r+1]
		}
		if min > tm {
			min = tm
		}
	}
	fmt.Println(min)
}

//-------------------------------------------
// util tools

// abs 絶対値を返す
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// sliceInt []intをスライスする
func sliceInt(k int) []int {
	s := make([]int, getDigit(k))
	count := 0
	for k > 0 {
		i := k % 10
		s[len(s)-1-count] = i
		count++
		k = k / 10
	}
	return s
}

// sliceIntSum []intの合計を出す
func sliceIntSum(v []int) int {
	sum := 0
	for _, x := range v {
		sum += x
	}
	return sum
}

// reverse []intを反転
func reverse(s []int) []int {
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		s[i], s[j] = s[j], s[i]
	}
	return s
}

// getDigit intの桁数を取得
func getDigit(num int) int {
	digit := 0
	for num != 0 {
		num /= 10
		digit++
	}
	return digit
}

// getSumDigit intの各位の和を返す
func getSumDigit(num int) int {
	sum := 0
	for num != 0 {
		t := num % 10
		num /= 10
		sum += t
	}
	return sum
}

// lastPrime 素数 エラトステネスの篩
func lastPrime(max int64) int64 {
	if max <= 1 {
		return 2
	}
	primes := make([]int64, 1, max)
	primesF := make([]float64, 1, max)
	primes[0] = 2
	primesF[0] = 2.0

	count := int64(1)
	for n := int64(3); ; n += 2 {
		flag := true
		f := float64(n)
		rf := math.Sqrt(f)
		for i := 1; i < len(primes); i++ {
			if primesF[i] > rf {
				break
			} else if (n % primes[i]) == 0 {
				flag = false
				break
			}
		}
		if flag {
			count++
			if count >= max {
				return n
			}
			primes = append(primes, n)
			primesF = append(primesF, f)
		}
	}
}


Measured memory_bytes: 6144
import math
[N,D] = list(map(int,input().split()))
X = []
for i in range(N):
    tmp = list(map(int,input().split()))
    X.append(tmp)
ans = 0
for i in range(N):
    for j in range(i,N):
        c = 0
        for k in range(D):
            c += (X[i][k] - X[j][k])**2
        if (int(c**(0.5)))**2 == c:
            ans+= 1
print(ans-N)

Measured memory_bytes: 3188