akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
const int N = 100001;
int n,m;
char g[1002][1002];
ll dp[1002][1002];
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            scanf(" %c",&g[i][j]);
    dp[1][1]=1;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            if(g[i][j]=='.')
                dp[i][j]+=(dp[i-1][j]+dp[i][j-1])%1000000007;
    cout<<dp[n][m];
}


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

int main(){
    int n;
    cin>>n;
    long long a[n],b[n];
    long long suma=0,sumb=0;
    long long cnt=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        suma+=a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
        sumb+=b[i];
    }
    for(int i=0;i<n;i++){
        if(a[i]>b[i]) cnt+=a[i]-b[i];
    }
    if(cnt>sumb-suma){
        cout<<"No"<<endl;
        return 0;
    }
    cnt=0;

    for(int i=0;i<n;i++){
        if(a[i]<b[i]) cnt+=(b[i]-a[i]+1)/2;
    }

    if(cnt>sumb-suma){
        cout<<"No"<<endl;
        return 0;
    }

    cout<<"Yes"<<endl;

    

}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
vector<ll> a[5];
ll sum1[109];
ll sum2[109];
ll sum3[109];
ll sum4[109];
const bool com(const ll a,const ll b)
{
    return a>b;
}
int main()
{
    int n;
    ll w;
    cin>>n;
    cin>>w;
    ll u1,v1;
    ll u,v;
    cin>>u1>>v1;
    a[1].push_back(v1);
    for(int i=2; i<=n; i++)
    {
        cin>>u>>v;
        if(u-u1==0)
        {
            a[1].push_back(v);
        }
        else if(u-u1==1)
        {
            a[2].push_back(v);
        }
        else if(u-u1==2)
        {
            a[3].push_back(v);
        }
        else
        {
            a[4].push_back(v);
        }
    }
    sort(a[1].begin(),a[1].end(),com);
    sort(a[2].begin(),a[2].end(),com);
    sort(a[3].begin(),a[3].end(),com);
    sort(a[4].begin(),a[4].end(),com);
    for(int i=0; i<a[1].size(); i++)
    {
        if(i==0)
        {
            sum1[i+1]=a[1][i];
        }
        else
        {
            sum1[i+1]=sum1[i]+a[1][i];
        }
    }
    for(int i=0; i<a[2].size(); i++)
    {
        if(i==0)
        {
            sum2[i+1]=a[2][i];
        }
        else
        {
            sum2[i+1]=sum2[i]+a[2][i];
        }
    }
    for(int i=0; i<a[3].size(); i++)
    {
        if(i==0)
        {
            sum3[i+1]=a[3][i];
        }
        else
        {
            sum3[i+1]=sum3[i]+a[3][i];
        }
    }
    for(int i=0; i<a[4].size(); i++)
    {
        if(i==0)
        {
            sum4[i+1]=a[4][i];
        }
        else
        {
            sum4[i+1]=sum4[i]+a[4][i];
        }
    }
    /*for(int i=1;i<=4;i++)
    {
        cout<<a[i].size()<<endl;
    }*/
    ll maxx=-1;
  for(int i=0;i<=a[1].size();i++)
  {
      for(int j=0;j<=a[2].size();j++)
      {
          for(int k=0;k<=a[3].size();k++)
          {
              for(int g=0;g<=a[4].size();g++)
              {
                  if(u1*i+(u1+1)*j+(u1+2)*k+(u1+3)*g<=w)
                  {
                      maxx=max(maxx,sum1[i]+sum2[j]+sum3[k]+sum4[g]);
                  }
              }
          }
      }
  }
  cout<<maxx<<endl;
}


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

#define int long long

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)

#define INF (3e9)

using namespace std;

int N;
int X[200003];
int SX[200003];

signed main()
{
    cin >> N;
    REP(i, N)
    {
        int x;
        cin >> x;
        X[i] = x;
        SX[i] = x;
    }


    sort(SX, SX+N);
    int mid = SX[N/2 - 1];
    int mid2 = SX[N/2];

    REP(i, N)
    {
        if (X[i] <= mid)
        {
            printf("%lld\n", mid2);
        }
        else
        {
            printf("%lld\n", mid);
        }
    }

    return 0;
}

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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

ll N;
vector<ll> A;

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

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

  cin >> N;
  set<string> s;
  rep(i, N) {
    string str;
    cin >> str;
    s.insert(str);
  }
  cout << s.size() << endl;
  return 0;
}


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

// ** Change to Main. 
class Main {
    public static void main(String[] args) throws IOException {
		
		// ** Get this back for submission. 
		Scanner sc = new Scanner(System.in);
		
		// Write your code here. 
		
		String o = sc.next();
		String e = sc.next();
		
		StringBuilder ans = new StringBuilder();
		int lenO = o.length();
		int lenE = e.length();
		int po = 0, pe = 0;
		for (int i = 0; i < lenO + lenE; i++) {
			if (i % 2 == 0) {
				ans.append(o.charAt(po));
				po++;
			} else {
				ans.append(e.charAt(pe));
				pe++;
			}
		}
		
		System.out.println(ans.toString());
        
        
        
        
    }
}







































Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  string s;
  cin>>s;
  bool north=false,south=false,east=false,west=false;
  for(int i=0;i<s.length();i++){
  	if(s[i]=='N'){
  		north=true;
  	}else if(s[i]=='S'){
  		south=true;
  	}else if(s[i]=='E'){
  		east=true;
  	}else{
  		west=true;
  	}
  }
  if((north&&!south)||(south&&!north)||(east&&!west)||(west&&!east)){
  	cout<<"No"<<endl;
  }else{
  	cout<<"Yes"<<endl;
  }
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
/*bool subseq(string s,string t){
    ll y=0;
    for(ll i=0;y<s.size()&& i<t.size();i++){
        if(s[y]==t[i]){
            y++;
        }
    }
        if(y==s.size())
            return true;
        else  return false;
}*/
/*ll x=1000000001;
vector<bool>p(x,false);
void prime(){
    p[2]=true;
    for(ll i=3;i<x;i=i+2)
        p[i]=true;
    for(ll i=0;i<x;i=i+2){
        if(p[i]){
            for(ll j=i*i;j<x;j=j+i)
                p[j]=false;
        }
    }
}*/
/*vector<ll> divisor(ll n){
    vector<ll> d;
    for(ll i=1;i<=sqrt(n);i++){
        if(n%i==0){
        d.push_back(i);
        d.push_back(n/i);
        }
    }
    sort(d.begin(),d.end(),greater<ll>());
    return d;
}*/
/*bool bs(ll n,string s){
    ll a[4]={0};
    for(ll i=0;i<n-1;i++){
        a[s[i]-'0']++;
    }
    for(ll i=n-1;i<s.size();i++){
        a[s[i]-'0']++;
        if(a[1]>0 && a[2]>0 && a[3]>0)
        return true;
        a[s[i-n+1]-'0']--;
    }
    return false;
}*/


/*ll binarySearch(ll n,ll a[],ll x){
    ll low=0,high=n-1,mid,ans=-1;
    while(low<=high){
        mid=low+(high-low)/2;
        if(a[mid]>=x){

            high=mid-1;
        }
        else{
                ans=mid;
            low=mid+1;
        }
    }
    return a[ans];
}*/
/*ll lcs(string a,string b,ll n,ll m){
    ll dp[n+1][m+1];
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<=m;j++){
            if(i==0|| j==0)
                dp[i][j]=0;
            else if(a[i]==b[j])
                dp[i][j]=1+dp[i-1][j-1];
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    return dp[n][m];

}*/
/*ll editDist(string a,string b,ll n,ll m){
    vector<vector<ll> >dp(n+1,vector<ll>(m+1,-1));
    for(ll i=0;i<=n;i++){
        for(ll j=0;j<=m;j++){
            if(i==0)
                dp[i][j]=j;
            else if(j==0)
                dp[i][j]=i;
            else if(a[i]==b[j])
                dp[i][j]=dp[i-1][j-1];
            else{
                dp[i][j]=1+min(dp[i-1][j-1],min(dp[i-1][j],dp[i][j-1]));
            }
        }
    }
    return dp[n][m];
}*/

/*ll d1(vector<string>a,ll n,ll m,vector<vector<ll> >dp){
    if(n<0 || m<0 ) return 0;
    if(n==0 && m==0) return 0;
    if(a[n][m]=='#') dp[n][m]=0;
    if((n==0 &&m==1) || (m==0&&n==1)) return 1 ;
    if(dp[n][m]!=-1)
        return dp[n][m];

    dp[n][m]=d(a,n-1,m,dp)+d(a,n,m-1,dp);
    return dp[n][m];
}*/
ll solve(ll a[],ll n){
    ll l=0,r=n-1;
        while(a[l+1]>a[l] && l<n-1){
            l++;
        }
        while(a[r-1]<a[r] && r-1>=0){
            r--;
        }
        if(r==n-1 && l==0){
            cout<<"yes"<<endl;
            cout<<1<<" "<<n;
        }


}
int main() {
    string a,b;
    cin>>a>>b;
    ll x=0;
    for(ll i=0;i<a.size();i++){
        if(a[i]!=b[i]) x++;
    }
    cout<<x;

}


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

int popcount(int x)
{
  int n = 0;
  for (int i = 0; i < 32; i++) {
    if (x == 0) break;
    if ((x & 1) != 0) n++;
    x >>= 1;
  }
  return n;
}

int f(int x)
{
  return x == 0 ? 0 : f(x % popcount(x)) + 1;
}

int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  valarray<int> v(n);

  for (int i = 0; i < n; i++) {
    v[i] = s[i] == '0' ? 0 : 1;
  }

  int popcnt = v.sum();
  int r1 = 0;
  int r2 = 0;

  if (popcnt != 0) {
    for (int i = 0; i < n; i++) {
      r1 *= 2;
      r1 += v[i];
      r1 %= (popcnt + 1);
    }
  }
  if (popcnt > 1) {
    for (int i = 0; i < n; i++) {
      r2 *= 2;
      r2 += v[i];
      r2 %= (popcnt - 1);
    }
  }

  vector<int> ans(n);

  for (int i = n - 1, x = 1, y = 1; i >= 0; i--) {
    if (v[i] == 0) {
      ans[i] = f((r1 + x) % (popcnt + 1)) + 1;
    } else {
      ans[i] = popcnt > 1 ? f((r2 - y + popcnt - 1) % (popcnt - 1)) + 1 : 0;
    }
    x = x * 2 % (popcnt + 1);
    if (popcnt - 1 != 0) {
      y = y * 2 % (popcnt - 1);
    }
  }

  for (auto&& e : ans) {
    cout << e << endl;
  }
}


Measured memory_bytes: 5240
#include<stdio.h>
int main (void)
{
	int S,h,m,s;
	scanf("%d",&S);
	h=S/3600;
	m=(S-h*3600)/60;
	s=S-m*60-h*3600;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int main(){
    ll a, b, n;
    while(cin>>n>>a>>b){
        if(abs(a-b)%2==0){
            cout<<(abs(a-b)/2)<<endl;
        }
        else{
            ll tmp=min(max(a-1, b-1), max(n-a, n-b));
            tmp=min(tmp, (n-a+n-b+1)/2);
            tmp=min(tmp, (a-1+b-1+1)/2);
            cout<<tmp<<endl;
        }
    }
  return 0;
}




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

int main() {
    int ans = 0;
	string S, T;
	cin >> S >> T;
    for (int i = 0; i < S.length(); ++i){
        if (S[i] != T[i]) ans++;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3844
#include <stdio.h>
int main(void){
    int n,x;
    int i,j,k;
    int cnt;
    
    do{
        scanf("%d %d",&n, &x);
        cnt=0;
        
        if(n==0 && x==0) break;
        for(i=1; i<=n-2; i++){
            for(j=i+1; j<=n-1; j++){
                for(k=j+1; k<=n; k++){
                    if(i+j+k==x) cnt+=1;
                }
            }
        }
        printf("%d\n",cnt);
    }while(1);
    
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//小数点以下　cout << fixed << setprecision(10) << num << endl;

int list[300][300];
char s[300][300];
int h,w,k;

void marky(int a,int x,int y){
    list[x][y]=a;
    for(int i=y+1;i<w;i++){
        if(s[x][i]=='#' || list[x][i]>0) break;
        else list[x][i]=a;
    }
    for(int i=0;i<w;i++){
        if(s[x][i]=='#' || list[x][i]>0) break;
        else list[x][i]=a;
    }
}
int main(){
    cin >> h >> w >> k;
    int a = 1;
    rep(i,h){
        rep(j,w){
            cin >> s[i][j];
            if(s[i][j]=='#'){
                list[i][j]=a;
                a++;
            }
            else list[i][j]=0;
        }
    }
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#') marky(list[i][j],i,j);
        }
    }
  rep(k,h){
    rep(i,w){
        rep(j,h){
            if(0<j && list[j-1][i]==0) list[j-1][i]=list[j][i];
            if(j+1<h && list[j+1][i]==0) list[j+1][i]=list[j][i];
        }
    }
  }
    rep(i,h){
        rep(j,w){
            cout << list[i][j] << " ";
        }
        cout << endl;
    }
}





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


#define loop(s) for(int i = 0; s > i; i++)
#define repp(i,o,q) for(int i = o; q >= i; i++)
#define depp(i,q) for(int i = q; 0 < i; i--)
#define rep(i,q) for(int i = 0; (q) > i; i++)



int main(){
  int N,M;
  cin >> N >> M;
  int saidai = M/N; 
  int ok = 1;
  //4,9 3,3,3,0
  //i*N = M
  //i > M/N
  depp(i,saidai){
    if(M%i == 0){
      ok = i; break;
    } 
    //
  }
  cout << ok << endl;
}
//100000 1000000000
//

Measured memory_bytes: 256
import itertools
 
 
def main():
    n = input()
    print(sev(n))
 
 
def sev(n: str) -> int:
    ret = 0
    d = len(n)
    while d > 2:
        for comb in itertools.product(['3', '5', '7'], repeat=d):
            s = ''.join(comb)
            if '3' in comb and '5' in comb and '7' in comb and int(s) <= int(n):
                ret += 1
        d -= 1
    return ret
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 9116
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    a=sort(parseMap(split(readline())))
    println(a[end]-a[1])
end
main()

Measured memory_bytes: 168592
object Main extends App {
    var get = readLine
    var i = 0
    var j = 0
    var max = 0
    var sum = 0
    var loop = 0
  
  for(i <- 0 to get.size - 1) {
    	j=i
      while(loop==0){
        if(get.charAt(j)=='A')
          sum+=1
    	else if(get.charAt(j)=='C')
          sum+=1
    	else if(get.charAt(j)=='G')
          sum+=1
    	else if(get.charAt(j)=='T')
          sum+=1
        else
    		loop=1
        j +=1
        if(j>get.size-1 || max > get.size -1-i)
        loop=1
      }
        max = math.max(sum,max)
        sum = 0
        loop = 0
  }
  println(max)
}

Measured memory_bytes: 27472
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($format:expr) => (write!(out,$format).unwrap());
        ($format:expr, $($args:expr),+) => (write!(out,$format,$($args),*).unwrap())
    }
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut first = false;
    for a in a {
        if a % 2 == 1 { first = true; }
    }
    puts!("{}\n", if first { "first" } else { "second" });
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
//
//  sublime text 3,
//  emre yazicioglu
//

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;
typedef vector <ll> vll;
typedef vector <pll> vpll;
#define pb push_back
#define fi first
#define se second
#define INF (ll) (1e18 + 7)
#define MOD (ll) (1e9 + 7)

const int N = 2e6 + 7;
ll mn = INF, mx = -INF;
ll n, m, k, s, q, t;
ll a, b, c, d, e;
ll ans, cur, sum, cnt;
ll ar[N], p[N], dp[N];
string str; bool h[N];
pll pp[N]; vll v;

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

  // freopen("../in.txt","r",stdin);
  // freopen("../out.txt","w",stdout);

  cin >> k >> str;
  n = str.size();
  for(int i = 0; i < n; i++)
    str[i] = (str[i] - 'A' + k) % 26 + 'A';
  cout << str;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL<<60;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,j,n) for(int i=j;i<n;i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    string S,T;
    cin >> S>>T;
    int slen = S.length();
    int tlen = T.length();
    int dp[slen+1][tlen+1]={};
    REP(i,slen){
        REP(j,tlen){
            //i番目の文字とj番目の文字が同じなら増やす．
            if(S[i]==T[j]){
                chmax(dp[i+1][j+1],dp[i][j]+1);
            }
            //それ以外は一つ増やした物と比較．
            chmax(dp[i+1][j+1], dp[i+1][j]);
            chmax(dp[i+1][j+1], dp[i][j+1]);
        }
    }
    // REP(i,slen+1){
    //     REP(j,tlen+1){
    //         cout<<dp[i][j]<<' ';
    //     }
    //     cout << endl;
    // }
    string ans= "";
    int x=slen,y=tlen;

    while(x > 0 && y>0){
        // cout<<x<<' '<<y<<endl;
        if(dp[x][y]==dp[x-1][y]){
            --x;
        }else if(dp[x][y]==dp[x][y-1]){
            --y;
        }else{
            --x;
            --y;
            ans=S[x]+ans;
        }

    }
    cout<<ans << endl;

}

Measured memory_bytes: 35456
N=int(input())
data=[input().split() for i in range(N)]
data_name=[]
for i in range(N):
    if data[i][0] in data_name:
        continue
    else:
        data_name.append(data[i][0])
data_name_sort=sorted(data_name)
#print(data_name_sort)
data_point=[]
for i in range(N):
    num=0
    for j in range(len(data_name_sort)):
        if data[i][0]==data_name_sort[j]:
            num+=(len(data_name)-j)*200+int(data[i][1])
        else:
            continue
    data_point.append(num)
#print(data_point)
data_sort=[i for i, _ in sorted(enumerate(data_point), key=lambda x:x[1])][::-1]
#print(data_sort)
for i in range(N):
    ans=int(data_sort[i])+1
    print(ans)

Measured memory_bytes: 9236
package main

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

const maxBuf = 200100

var buf []byte = make([]byte, maxBuf)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

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

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readFloat64() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

/* #### main #### */
func main() {
	N := readInt()
	x := make([]int, N)
	for i := 0; i < N; i++ {
		x[i] = readInt()
	}

	pows := make([]int, 100)
	for i := 0; i < 100; i++ {
		pows[i] = power(x, i)
	}
	sort.Ints(pows)

	fmt.Println(pows[0])
}

func power(x []int, fes int) int {
	pow := 0
	for i := range x {
		pow += (x[i] - fes) * (x[i] - fes)
	}
	return pow
}


Measured memory_bytes: 1796
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n;
    cin >> n;
    
    ll ans = 0;
    rep(i, n){
        ans += (i + 1) * (n - i);
    }
    rep(i, n - 1){
        ll a, b;
        cin >> a >> b;
        if(a > b) swap(a, b);
        ans -= a * (n - b + 1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3616
from math import *
from statistics import median
N=int(input())
A,B=[],[]
for i in range(N):
    a,b=map(int,input().split())
    A.append(a);B.append(b)
A.sort();B.sort()
if N%2:
    ans=B[(N+1)//2-1]-A[(N+1)//2-1]+1
else:
    ans=1+((B[N//2-1]+B[N//2]))-((A[N//2-1]+A[N//2]))
print(ans)

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

int v[2005];
int n,sum;
bitset<2000005> dp;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    while(cin >> n)
    {
        for(int i = 0; i < n; i++)
            cin >> v[i];
        sum = accumulate(v, v + n, 0);
        dp.reset(); dp.set(0);
        for(int i = 0; i < n; i++)
            dp |= dp << v[i];
        for(int i = (sum+1)/2; i <= sum; i++)
            if(dp[i])
            {
                cout << i << '\n';
                break;
            }
    }
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(){
    int n,i;
    scanf("%d",&n);
    int a[n];
    long long int b[n+1], c=0, d=0;
    for(i=1;i<=n;i++){
        b[i]=0;
    }
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        b[a[i]]++;
    }
    for(i=1;i<=n;i++){
        if(b[i]>1){
            c += b[i]*(b[i]-1)/2;
        }
    }
    for(i=0;i<n;i++){
        if(b[a[i]]>1){ d = b[a[i]]-1; }
        printf("%lld\n",c-d);
        d = 0;
    }
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    if(s=="Sunny")
    cout<<"Cloudy"<<endl;
    if(s=="Cloudy")
    cout<<"Rainy"<<endl;
    if(s=="Rainy")
    cout<<"Sunny"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
#define max(a, b) ((a>b)?a:b)
#define fori(i, n) for(int i=0; i<n; ++i)
typedef long long ll;

ll H;

int main(){
	scanf("%lli", &H);
	ll n_a = 0;
	ll m = 1;
	while(H>1){
		n_a	+= m;
		H /= 2;
		m *= 2;
	}
	n_a += m;
	printf("%lli\n", n_a);
}

















Measured memory_bytes: 3220
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int H = scan.nextInt();
        int W = scan.nextInt();
        int N = scan.nextInt();
        int sr = scan.nextInt()-1;
        int sc = scan.nextInt()-1;
        String S = scan.next();
        String T = scan.next();

        int left = 0;
        int right = W;
    if (S.charAt(N-1) == 'L') ++left;
    if (S.charAt(N-1) == 'R') --right;
        for (int i=N-2;i>=0;i--) {
            if (T.charAt(i)=='L') {
                if (right<W) right++;
            } else if (T.charAt(i)=='R') {
                if (left>0) left--;
            }

            if (S.charAt(i)=='L') {
                left++;
            } else if (S.charAt(i)=='R') {
                right--;
            }

            if (right<=left) {
                System.out.println("NO");
                return;
            }
        }

        int down = 0;
        int up = H;
    if (S.charAt(N-1) == 'U') ++down;
    if (S.charAt(N-1) == 'D') --up;
        for (int i=N-2;i>=0;i--) {
            if (T.charAt(i)=='U') {
                if (up<H) up++;
            } else if (T.charAt(i)=='D') {
                if (down>0) down--;
            }

            if (S.charAt(i)=='U') {
                down++;
            } else if (S.charAt(i)=='D') {
                up--;
            }

            if (up<=down) {
                System.out.println("NO");
                return;
            }
        }

        if (left<=sc && sc<right && down<=sr && sr<up) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 28964
#include <bits/stdc++.h>
#define LL long long
#define INF 0x7FFFFFFF//or 0x3f3f3f3f ? -Wall
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

/*============ Header Template ============*/

LL a, b;

int main() {
	read(a), read(b);
	if (a > b) swap(a, b);
	if (a <= 0 && b >= 0) {puts("Zero"); return 0;}
	if (a > 0) {puts("Positive"); return 0;}
	LL len = b - a + 1;
	puts(len & 1 ? "Negative" : "Positive");
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
lst = [[0]*2 for i in range(m)]
for i in range(m):
    a, b = map(int, input().split())
    lst[i][0] = a
    lst[i][1] = b

ans = 1000
if n != 1:
    for i in range(10**(n-1), 10**n):
        str_num = str(i)
        flag = True
        for l in lst:
            if str_num[l[0]-1] != str(l[1]):
                flag = False
        if flag == True and i < ans:
            ans = i
else:
    for i in range(10):
        str_num = str(i)
        flag = True
        for l in lst:
            if str_num[l[0]-1] != str(l[1]):
                flag = False
        if flag == True and i < ans:
            ans = i

print(ans if ans!=1000 else '-1')

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int64 n,x,d;
  cin >> n >> x >> d;

  if(d == 0){
    if(x != 0){
      ANS(n+1);
    }else{
      ANS(1);
    }
    return 0;
  }

  map<int32,vector<pll>> mp;
  REP(k,n+1){
    int32 idx = ((k*x)%d+d)%d;
    mp[idx].emplace_back(((k*x-idx)/d+k*(k-1)/2), ((k*x-idx)/d+k*(2*n-k-1)/2));
  }
  int64 ans = 0;
  for(auto p : mp){
    // cout << p.first << endl;
    // for(auto q : p.second){
    //   cout << q.first << " " << q.second << endl;
    // }
    // cout << endl;
    vector<pll> evt;
    for(auto q : p.second){
      evt.emplace_back(q.first,1);
      evt.emplace_back(q.second+1,-1);
    }
    sort(ALL(evt));
    int32 cur = 0;
    int32 pre = -INF;
    for(auto q : evt){
      if(cur)ans += q.first - pre;
      pre = q.first;
      cur += q.second;
    }
  }
  ANS(ans);
  return 0;
}

Measured memory_bytes: 22144
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

ll h[100010];
vector<ll> v[100010];

int main(){
    int n, m;
    cin >> n >> m;
    rep(i, n) cin >> h[i];

    rep(i, m){
        ll a, b;
        cin >> a >> b;
        a--, b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    ll cnt = 0;
    rep(i, n){
        ll thr = h[i];
        bool flag = true;
        if(v[i].size() == 0) {
            flag = true;
        }
        for (auto next : v[i]){
            if (h[next] >= thr) flag = false;
        }
        if (flag) cnt ++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 10244
(eval-when  (:compile-toplevel :load-toplevel :execute)
  (defun script-p ()
    (eql sb-sys:*stdin* *standard-input*)))

;;; helper
(defmacro defvars (&rest vars)
  `(progn ,@(mapcar #'(lambda (x) `(defvar ,x)) vars)))

(macrolet ((optimize (pred)
	     (if pred
		 `(declaim (optimize (speed 3) (debug 0) (safety 0)))
		 `(declaim (optimize (speed 0) (debug 3) (safety 3))))))
  (optimize #. (script-p)))

(defun xclip ()
  (with-output-to-string (s)
    (sb-ext:run-program "/usr/bin/xclip" '("-sel" "clip" "-o") :output s)))

(defun test ()
  (with-input-from-string (*standard-input* (xclip))
    (main)))

(defmacro show (name)
  (if (script-p)
      nil
      `(format t ,(concatenate 'string (format nil "~a" name) " is ~a~%")
	       ,name)))

;;; code starts here
(defparameter dmax 10)

(defstruct v color ns mark)

(defvars n m vs l dp init colors)

;; table[v][d]
;;  v: vertex
;;  d: distace
;;  value: -1 invalid
;;       |  0 not colored
;;       |  n otherwise

(defun rundp (v d)
  (cond ((> d dmax) 0)
	((>= (aref dp v d) 0) (aref dp v d))
	(t (setf (aref dp v d)
		 (max (aref init v d)
		      (loop for x in (aref vs v)
			 maximize (rundp x (1+ d))))))))

(defun main ()
  (setf n (read))
  (setf m (read))
  (setf vs (make-array n :initial-element nil))

  (loop for i from 0 below n
       do (push i (aref vs i)))

  (loop repeat m
     for a = (1- (read))
     for b = (1- (read))
     do (push b (aref vs a))
     do (push a (aref vs b)))

  (show vs)

  (setf l (read))
  (setf dp (make-array (list n (1+ dmax)) :initial-element -1))
  (setf init (make-array (list n (1+ dmax)) :initial-element -1))
  (setf colors (make-array (1+ l)))

  (loop repeat l
     for i from 1 ;; 1!
     for v = (1- (read))
     for d = (read)
     for c = (read)
     do (setf (aref init v d) i
	      (aref colors i) c))

  (show init)
  (show colors)
  
  (loop for v from 0 below n
     do (format t "~a~%" (aref colors (rundp v 0)))))

(when (script-p) (main))


Measured memory_bytes: 82984
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n;
    cin>>n;
    int d[n];
    for(int i=0;i<n;i++){
        cin>>d[i];
    }
    sort(d,d+n);
    cout<<d[n/2]-d[n/2-1]<<endl;
}


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

int main()
{
	int n, k, x, y;
	scanf("%d%d%d%d", &n, &k, &x, &y);
	if (n < k)
		printf("%d\n", n * x);
	else
		printf("%d\n", k * x + (n - k) * y);

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long ll;

const int N=(1<<14)+5,M=805,Mo=998244353;

ll pwr(ll x,ll y) {
	ll z=1;
	for(;y;y>>=1,x=x*x%Mo)
		if (y&1) z=z*x%Mo;
	return z;
}

int n,m,len,lg,rev[N];
ll f[M][N],fac[N],inv[N],W[2][N],t1[N],t2[N],ilen;

void pre(int N) {
	fac[0]=1;fo(i,1,N) fac[i]=fac[i-1]*i%Mo;
	inv[N]=pwr(fac[N],Mo-2);fd(i,N-1,0) inv[i]=inv[i+1]*(i+1)%Mo;
	for(int i=1;i<N;i<<=1) {
		ll wn=pwr(3,(Mo-1)/(i<<1));
		for(int j=0;j<i;j++) W[1][i+j]=j?W[1][i+j-1]*wn%Mo:1;
		wn=pwr(3,Mo-1-(Mo-1)/(i<<1));
		for(int j=0;j<i;j++) W[0][i+j]=j?W[0][i+j-1]*wn%Mo:1;
	}
}

void DFT(ll *a,int len,int flag) {
	for(int i=0;i<len;i++) if (i<rev[i]) swap(a[i],a[rev[i]]);
	for(int i=1;i<len;i<<=1)
		for(int j=0;j<len;j+=i<<1)
			for(int k=0;k<i;k++) {
				ll u=a[j+k],v=a[j+k+i]*W[flag][i+k]%Mo;
				a[j+k]=(u+v)%Mo;a[j+k+i]=(u-v)%Mo;
			}
	if (!flag) for(int i=0;i<len;i++) a[i]=a[i]*ilen%Mo;
}

int main() {
	pre(1<<14);
	scanf("%d%d",&n,&m);
	for(len=1,lg=0;len<=n<<1;len<<=1) lg++;
	fo(i,0,len-1) rev[i]=rev[i>>1]>>1|((i&1)<<lg-1);
	ilen=pwr(len,Mo-2);
	f[0][0]=1;
	fo(i,0,m-1) {
		fo(j,0,len-1) t1[j]=t2[j]=0;
		fo(j,0,n) t1[j]=f[i][j]*inv[j]%Mo;
		fo(j,1,n) t2[j]=inv[j+2];
		DFT(t1,len,1);DFT(t2,len,1);
		fo(j,0,len-1) t1[j]=t1[j]*t2[j]%Mo;
		DFT(t1,len,0);
		fo(j,0,n) f[i+1][j]=t1[j]*fac[j+2]%Mo;
		fo(j,0,n) (f[i+1][j]+=f[i][j]*(j*(j+1)/2+1)%Mo)%=Mo;
	}
	ll ans=0;
	fo(j,0,n) (ans+=f[m][j]*fac[n]%Mo*inv[j]%Mo*inv[n-j]%Mo)%=Mo;
	printf("%lld\n",(ans+Mo)%Mo);
	return 0;
}

Measured memory_bytes: 26112
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int N; cin >> N;
  bool a[N+1]; rep(i,N) cin >> a[i+1];

  bool c[N+1];
  for (int i=N;i>=1;i--){
    bool tot = 0;
    for (int j=2;j*i<=N;j++) tot ^= c[j*i];
    c[i] = a[i]^tot;
  }

  int M = 0;
  vector<int> ans;
  for (int i=1;i<=N;i++){
    if (c[i]) {
      ans.push_back(i);
      M++;
    }
  }
  if (M==0){
    cout << 0 << endl;
    return 0;
  }

  cout << M << endl;
  for (int i=0;i<ans.size();i++){
    if (i>0) cout << " ";
    cout << ans[i];
  } 
  cout << endl;


  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 4228
import math

prims = list()

prims.append(2)

base = int(input())

def _is_prim(n):
  global prims
  for p in prims:
    if n == p:
      return True
    elif n % p == 0:
      return False
  
  return True

# 入力値の平方根までの素数を作る
rt = int(math.sqrt(base))
for n in range(rt):
  if n < 2:
    continue
  elif n % 2 == 0:
    continue
  elif _is_prim(n):
    prims.append(n)

# 作った素数値で。。。
while not _is_prim(base):
  base += 1

print(base)   

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=3005;
int n,mo,ans;
int S[N][N],C[N][N];
int power(int x,int y,int mo){
	int s=1;
	for (;y;y/=2,x=1ll*x*x%mo)
		if (y&1) s=1ll*s*x%mo;
	return s;
}
int main(){
	scanf("%d%d",&n,&mo);
	S[0][0]=1;
	For(i,0,n+1) C[i][0]=1;
	For(i,1,n+1) For(j,1,i){
		S[i][j]=(S[i-1][j-1]+1ll*S[i-1][j]*j)%mo;
		C[i][j]=(C[i-1][j-1]+C[i-1][j])%mo;
	}
	For(i,0,n){
		int val=(i&1?mo-C[n][i]:C[n][i]);
		int p=power(2,n-i,mo),vp=1;
		val=1ll*val*power(2,power(2,n-i,mo-1),mo)%mo;
		For(j,0,i){
			int vval=1ll*val*S[i+1][j+1]%mo;
			ans=(ans+1ll*vval*vp)%mo;
			vp=1ll*vp*p%mo;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 69504
a=input().split()
N=int(a[0])
M=int(a[1])
H=[int(x) for x in input().split()]
way=[]
for i in range(M):
    way.append([int(x) for x in input().split()])

dic={}
for i in range(N):
    dic[i]=set()

for h in way:
    dic[h[0]-1].add(h[1]-1)
    dic[h[1]-1].add(h[0]-1)
    

print(sum(all([H[i]>H[hs] for hs in dic[i]])for i in range(N)))

Measured memory_bytes: 70532
#include<iostream>
using namespace std;
int main(){
    int n,b,f,r,v;
    int  x[4][3][10]={{{}}} ;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>b>>f>>r>>v;
        x[b-1][f-1][r-1]+=v;
    }
    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                cout<<" ";
                cout<<x[i][j][k];
            }
            cout<<endl;
        }
        if(i<3){
            cout<<"####################"<<endl;
        }
    }
    return 0;
}


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

bool hashs[200] = {};

int main(){
    int a, b, c, cnt= 0;
    scanf("%d %d %d",&a,&b,&c);
    hashs[a] = hashs[b] = hashs[c] = true;
    for(int i=0;i<=200;i++)
        if(hashs[i])
            cnt++;
    printf("%d\n",cnt);
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>

#define MAX_C 12

struct node{
  int key;
  struct node *prev;
  struct node *next;
};

typedef struct node* NodePointer;
NodePointer head;

void init(void);
int getType(char*);
void insert(int);
void _delete(int);
void deleteFirst(void);
void deleteLast(void);
void deleteNode(NodePointer);
NodePointer search(int);
void print(void);

int main(){
  int N,i,key;
  char command[MAX_C];
  scanf("%d",&N); init();
  for(i = 0 ; i < N ; i++){
    scanf("%s",command);
    switch(getType(command)){
    case 0:
      scanf("%d",&key);
      insert(key);
      break;
    case 1:
      scanf("%d",&key);
      _delete(key);
      break;
    case 2:
      deleteFirst();
      break;
    case 3:
      deleteLast();
      break;
    default:
      assert(0);
    }
  }
  print();
  return 0;
}

void init(){
  head = malloc(sizeof(struct node));
  head->next = head->prev = head;
  head->key = -1;
}

int getType(char *command){
  if(!strcmp(command,"insert")){
    return 0;
  }else if(!strcmp(command,"delete")){
    return 1;
  }else if(!strcmp(command,"deleteFirst")){
    return 2;
  }else{
    return 3;
  }
  return -1;
}

void insert(int key){
  NodePointer x,y;
  x = malloc(sizeof(struct node));
  x->key = key;
  y = head->next;
  head->next = x; x->prev = head;
  y->prev = x; x->next = y;
}

void _delete(int key){
  NodePointer x = search(key);
  if(x == NULL){ return; }
  deleteNode(x);
}

void deleteFirst(){
  NodePointer x = head->next;
  if(x == head){ return; }
  deleteNode(x);
}

void deleteLast(){
  NodePointer x = head->prev;
  if(x == head){ return; }
  deleteNode(x);
}

void deleteNode(NodePointer x){
  NodePointer y = x->prev,z = x->next;
  y->next = z; z->prev = y;
  free(x);
}

NodePointer search(int key){
  NodePointer cur;
  for(cur = head->next ; cur != head ; cur=cur->next){
    if(cur->key == key){
      return cur;
    }
  }
  return NULL;
}

void print(){
  int i;
  NodePointer cur;
  for(i = 0,cur = head->next ; cur != head ; cur=cur->next,i++){
    if(i > 0){ printf(" "); }
    printf("%d",cur->key);
  }
  printf("\n");
}

Measured memory_bytes: 31788
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	a := nextInt()
	b := nextInt()
	_ = nextInt()
	k := nextInt()

	if k <= a {
		fmt.Println(k)
		return
	}
	if k <= a+b {
		fmt.Println(a)
		return
	}
	fmt.Println(a - (k - a - b))
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
import math

a, b, x = map(int, input().split())

if a * a * b / 2.0 <= x:
  ans = math.degrees(math.atan(2 * (a * a * b - x) / (a * a * a)))
else:
  ans = math.degrees(math.pi / 2.0 - math.atan(2 * x / (a * b * b)))
print('{:.010f}'.format(ans))

Measured memory_bytes: 3188
#include<iostream>
using namespace std;
int n,m,k;
main()
{
	cin>>n>>m>>k;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			int now=i*m+j*n-2*i*j;
			if(now==k)
			{
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<stdlib.h>

using namespace std;

vector<string> ans;
string bot[10] = {"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
int main(){
	int n;
	cin >> n;
	for(int i = 0;i < n;i++){
		string mess;
		string code;
		cin >> code;
		int count = 0;
		for(int j = 0;j < code.size();j++){
			if(code[j] == '0'){
				if(j == 0 || count == 0) continue;
				int num = 1;
				for(int k = 1;k <= 9;k++){
					if(('0' + k) == code[j-1]){num = k; break;}
				}
				int roop = bot[num].size();
				mess += bot[num][(count - 1)% roop];
				count = 0;
			}else{
				count++;
			}
		}
		ans.push_back(mess);
	}
	
	for(int i = 0;i < n;i++){
		cout << ans[i] << endl;
	}
	return 0;
}

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

int main() {
	int h;
	cin >> h;
	int w;
	cin >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}

	vector<bool> row(h, false);
	vector<bool> col(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}

	for (int i = 0; i < h; i++) {
		if (row[i]) {
			for (int j = 0; j < w; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}


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

namespace Backfront {
    class ConsoleInput {
        private string[] currentLine = null;
        private int currentCursor = 0;

        public string Get() {
            if (currentLine == null || currentCursor >= currentLine.Length) {
                currentLine = Console.ReadLine().Split(' ');
                currentCursor = 0;
            }
            var res = currentLine[currentCursor];
            currentCursor++;
            return res;
        }

        public int GetInt() {
            return int.Parse(Get());
        }
    }
    
    struct Pair : IComparable<Pair>{
        public int index;
        public int value;

        public int CompareTo(Pair other) {
            return this.value - other.value;
        }
    }

    class Program {
        static ConsoleInput input = new ConsoleInput();

        static void Main(string[] args) {
            int N = input.GetInt();
            var P = new List<Pair>();
            for(int i = 0; i < N; ++i) {
                P.Add(new Pair {
                    index = i,
                    value = input.GetInt()
                });
            }

            P.Sort();

            int counter = 1;
            int maxCount = 1;
            for(int i = 0; i < N - 1; ++i) {
                if(P[i].index < P[i + 1].index) {
                    counter++;
                    if (counter > maxCount) maxCount = counter;
                }
                else {
                    counter = 1;
                }
            }
            Console.WriteLine(N - maxCount);
        }
    }
}


Measured memory_bytes: 21312
N = int(input())
p = [int(x) for x in input().split()]
a = list(range(1,N+1))
counter = 0
for j in range(N):
    if p[j] != a[j]:
        counter += 1
    if counter > 2:
        print('NO')
        exit()
else:
    if counter in {0, 2}:
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 3060
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;



void main() {
    string s = readln.chomp;
    int w;
    scan(w);

    foreach (i ; 0 .. (s.length.to!int + w - 1) / w ) {
        write(s[i*w]);
    }
    writeln;
}












































void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<algorithm>
#include<iterator>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#define lli long long int
#define mp make_pair
#define ULTRA_INSTINCT ios_base::sync_with_stdio(false); cin.tie(0)
#define PI  3.141592653589793
#define fo(i,n) for(lli i=0;i<(n);i++)
#define FO(i,x,n) for(lli i=(x);i<(n);i++)
#define pb push_back
#define FI first
#define SE second
#define vi vector<lli>
#define pi pair<lli,lli>
#define vii vector<pi >
#define Endl endl
#define ITA 200005
#define ROH 100005
using namespace std;
lli mod = 1e9 +7,test; 
lli max(lli a,lli b){return a>b?a:b;}
lli min(lli a,lli b){return a>b?b:a;}

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

lli n;
int comp[22][22];

lli take_this(lli curr , lli i){
    return curr - (1<<i);
}
lli available(lli curr , lli i){
    return ( curr & (1<<i));
}
vector<vi >dp(21 , vi( (1<<21) + 10 , -1));

lli f(lli idx , lli curr){
    // rem contains.. the bitmask of available.. indices..
    if(idx == -1 && curr ==0){
        return 1;
    }
    if(dp[idx][curr] != -1){
        return dp[idx][curr];
    }
    lli here = 0;
    fo(i,n){
        if(available(curr , i) && comp[idx][i] == 1){
            here += f(idx-1 , take_this(curr , i));
            here %= mod;
        }
    }
    dp[idx][curr] = here;
    return here;
}

void solve(){

    cin>>n;
    fo(i,n){
        fo(j,n){
            cin>>comp[i][j];
        }
    }
    lli have = 0;
    fo(i,n){
        have += (1<<i);
    }
    cout<<f(n -1,have )<<endl;
}

int main(){
    ULTRA_INSTINCT;
    lli t =1;
    // cin>>t;
    fo(i,t){
        solve();
    }
    return 0;

}

Measured memory_bytes: 360832
n = int(input())
l = [list(map(int, input().split())) for i in range(n - 1)]

for i in range(n):
    t = 0
    for c, s, f in l[i:]:
        t = max(s, t)
        mod = abs(t - s)%f
        if mod != 0:
            t += f - mod
        t += c
    print(t)

Measured memory_bytes: 9148
A = list(map(int,input().split()))
A.sort()
a = A[2]-A[1]
A[0] += a

if (A[2]-A[0])%2 == 0:
    print(a+(A[2]-A[0])//2)
else:
    print(a+(A[2]-A[0])//2+2)

Measured memory_bytes: 3060