akhauriyash/Code-Regression huggingface dataset:
macro_rules! scan_sub {
    ( $itr:ident, $t:ty ) => {
        let mut buf = String::new();
        let $itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
    };
}

macro_rules! scan {
    ( $x:ident; Vec<$t:ty> ) => {
        scan_sub!(itr, $t);
        let $x = itr.collect::<Vec<_>>();
    };
    ( $( $x:ident ),*; $t:ty ) => {
        scan_sub!(itr, $t);
        let mut itr = itr;
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

const INF: usize = 100000000;

fn main() {
    scan!(n, m, x; usize);
    let books = (0..n).map(|_| {
        scan!(line; Vec<usize>);
        let mut c = line;
        let arr = c.split_off(1);
        (c[0], arr)
    }).collect::<Vec<_>>();

    let mut flag = false;
    let mut res: usize = INF;
    for i in 0..2u64.pow(n as u32) {
        let mut b = i;
        let mut s = 0;
        let mut skills = vec![0; m];
        for j in 0..n {
            if b % 2 == 0 {
                s += books[j].0;
                for k in 0..m {
                    skills[k] += (books[j].1)[k];
                }
            }
            b /= 2;
        }

        if skills.into_iter().all(|a| a >= x) {
            flag = true;
            if s < res { res = s; }
        }
    }

    println!("{}", if flag { res as i64 } else { -1 });
}


Measured memory_bytes: 2148
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    bool ok = 0;
    for(int i = 1; i <= b; i++){
        if(a*i%b==c) ok = 1; 
    }
    if(ok) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main() {
    int A, B;
    cin >> A >> B;
    cout << (A + B) % 24;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long i,j,w,n,m,p,k,l,Max,ans,t,ans2,B,r,b,d,ind,x,y,dp[201][100001];
pair <long long,long long> a[2000001];
int main () {
    cin>>n>>w;
    for (i=1;i<=n;i++) {
        cin>>a[i].first>>a[i].second;
    }
    for (i=0;i<=n;i++) {
        for (j=0;j<=100000;j++) {
           dp[i][j]=10000000000;
        }
    }
    for (i=1;i<=n;i++) {
        for (j=1;j<=100000;j++) {
            dp[i][j]=min(dp[i][j],dp[i-1][j]);
            if (j-a[i].second>=0)
            {
                if (j-a[i].second==0) k=0;
                else
                k=dp[i-1][j-a[i].second];
                dp[i][j]=min(dp[i][j],k+a[i].first);
            }
        }
    }
   // cout<<dp[1][31]<<endl;
    for (i=1;i<=100000;i++) {
        if (dp[n][i]<=w && dp[n][i]!=10000000000) ans=max(ans,i);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 80128
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  int a,b;
  double tubo=3.305785;
  cin>>a>>b;

  printf("%f\n",a*b/tubo);

}

Measured memory_bytes: 1184
#include <set>
#include <map>
#include <list>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;

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

Measured memory_bytes: 256
#include <iostream>

int main(){
  int n, x;

  while(std::cin >> n >> x){
    if(n==0 && x ==0)break;
    int count=0;
    for(int i=1; i<=n; i++){
      for(int j=i+1; j<=n; j++){
        for(int k=j+1; k<=n; k++){
          if(i+j+k == x) count++;
        }
      }
    }
    std::cout << count << std::endl;
  }
  //  std::cout << count << std::endl;
  return 0;
}



Measured memory_bytes: 3096
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
using namespace std;

int main(){
	int n,q,t;
	string name;
	queue<pair <string,int> > Q;
	cin >> n >> q;
	for(int i=0;i<n;i++){
		cin >> name >> t;
		Q.push(make_pair(name,t));
	}
	pair<string,int> u;
	int elaps = 0,a;
	while(!Q.empty()){
		u = Q.front();Q.pop();
		a = min(u.second,q);
		u.second -= a;
		elaps += a;
		if(u.second > 0){
			Q.push(u);
		}
		else{
			cout << u.first << " " << elaps << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 6248
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	final int offset = 10000;
	HashSet<Integer> ps;
	
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			ps = new HashSet<Integer>();
			int n = sc.nextInt();
			if( n==0 ) break;
			for(int i=0;i<n;i++) {
				ps.add(p2Int(sc.nextInt(), sc.nextInt()));
			}
//			debug(ps);
			int max = 0;
			for(int ind1: ps) {
				for(int ind2: ps) {
					if( ind1 == ind2 ) continue;
					P p1 = int2P(ind1);
					P p2 = int2P(ind2);
					P dp = p1.sub(p2);
//					debug(p1.x, p1.y, p2.x, p2.y);
					if( ps.contains(p2Int(p1.x-dp.y, p1.y+dp.x)) && ps.contains(p2Int(p2.x-dp.y, p2.y+dp.x)) )
						max = max(max, dp.d());
					else if 
					  ( ps.contains(p2Int(p1.x+dp.y, p1.y-dp.x)) && ps.contains(p2Int(p2.x+dp.y, p2.y-dp.x)) )
						max = max(max, dp.d());
				}
			}
			System.out.println(max);
		}
	}
	
	int p2Int(int x, int y) {
		return x * offset + y;
	}
	
	P int2P(int val) {
		int x = val / offset;
		int y = val-x*offset;
		return new P(x, y);
	}
	
	class P {
		int x, y;
		P (int x, int y) {
			this.x = x;
			this.y = y;
		}
		
		P sub(P p) {
			int x = this.x-p.x;
			int y = this.y-p.y;
			return new P(x, y);
		}
		
		int d() {
			return x*x + y*y;
		}
	}

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

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

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

int main() {
  ll Q, H, S, D, N;
  cin >> Q >> H >> S >> D >> N;
  ll P = 0;
  ll m = min (D, S * 2);
  m = min(m, H * 4);
  m = min(m, Q * 8);
  
  if (m == D) {
    ll PD = N / 2 * D;
    ll m2 = min(S, H * 2);
    m2 = min(m2, Q * 4);
    ll PS = (N % 2) * m2;
    P = PD + PS;
  }
  else P = N * m / 2;
  
  cout << P << endl;
}

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

int main() {
    int N, K, x[100],sum_a=0, sum_b=0, sum=0;
    cin >> N >> K;
    for(int i=0; i<N; i++) cin >> x[i];
    
    for(int i=0; i<N; i++){
        sum_a=0; sum_b=0;
        /* A */
        for(int j=0; j<x[i]; j++){
            sum_a++;
        }
        /* B */
        if(K<x[i]){
            for(int j=K; j<x[i]; j++){
                sum_b++;
            }
        }
        else{
            for(int j=K; j>x[i]; j--){
                sum_b++;
            }
        }
        (sum_a > sum_b) ? sum += sum_b*2 : sum += sum_a*2;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i,n) for (int i = 1; i <= (int)(n); i++)

int main()
{
  ll x,y;
  cin >> x >> y;
  
  ll ans = 0;
  while(x <= y)
  {
    ans++;
    x *= 2;
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	string s;
	while(cin >> s){
		if(s == "Sunny") cout << "Cloudy" << endl;
		else if (s == "Cloudy") cout << "Rainy" << endl;
		else cout << "Sunny" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>

#define X first
#define Y second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())


//INT_MAX
//INT_MIN
//LLONG_MAX
//LLONG_MIN
//DBL_MIN
//DBL_MAX
//LDBL_MIN
//LDBL_MAX

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (i < k) {
            ans += x;
        }else{
            ans += y;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int length = sc.nextInt();
		int [] array = new int[length];
		
		for (int i = 0; i < length; i++) {
			array[i] = sc.nextInt();
		}
		
		for (int i = 0; i < length; i++) {

			for (int j = 0; j < i; j++) {
				if (array[j] > array[i]) {
					int temp = array[i];
					for (int k = i - 1; k >= j; k--) {
						array[k + 1] = array[k];
					}
					array[j] = temp;
				}
			}

			for (int j = 0; j < length; j++) {
				System.out.print(array[j]);
				if (j != length - 1) {
					System.out.print(" ");
				}
			}
			System.out.println("");
		}
	}
}

Measured memory_bytes: 33800
#include<stdio.h>

int main(void){
   int A1, A2, A3;
   scanf("%d%d%d", &A1, &A2, &A3);
   int total = A1+A2+A3;
   if(total >= 22){
      printf("bust");
   } else {
      printf("win");
   }
}


Measured memory_bytes: 1700
/*
 * スケートリンクで、一人の大人の司会と N 人の子供がゲームを行います。 ゲームは K ラウンドからなり、ラウンド i では司会が次のように言います。
 * 
 *     Ai 人組を作って！
 * 
 * すると、まだ脱落していない子供たちは Ai 人からなるグループをできるだけ多く組みます。 一人につき一つのグループにしか入れません。 グループに入れなかった子供たちは脱落し、その他は次のラウンドに進みます。 
 * ラウンドで誰も脱落しないこともありえます。
 * 
 * 最後まで、つまりラウンド K のあとまで残ったのは 2 人で、彼らが勝者となりました。
 * 
 * あなたは A1, A2, ..., AK の値を聞き、N の値は知りませんが、推定してみたくなりました。
 * 
 * ゲームの開始前にいた子供たちの人数として考えられる最小の値と、最大の値を求めてください。もしくは、考えられる N の値は存在しないと判定してください。
 */

import java.util.*;
	public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            //入力
            int k = Integer.parseInt(sc.next());
            int[] ak = new int[k];
            
            for(int i=0; i<k; i++){
            	ak[i] = Integer.parseInt(sc.next());
            }
            sc.close();
            
            long min = 2;
            long max = 3;
            for(int i=k-1; i>=0; i--){
            	if((max-1)/ak[i] <= (min-1)/ak[i]){
            		System.out.println(-1);
            		return;
            	}
            	min = ak[i] * ((min-1)/ak[i] + 1);
            	max = ak[i] * ((max-1)/ak[i] + 1);
            }
            
            //出力
            System.out.println(min + " " + (max-1));
        }
    }
	

Measured memory_bytes: 48952
#include <set>
#include <map>
#include <list>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
 
int main(){
  int n, h, a, c=0;
  cin >> n >> h;
  rep(i, n) {
    cin >> a;
    if(a >= h) c++;
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define ll long long
#define lld double
#define vi vector<int>
#define pii pair<int,int>
#define piii pair<pii, ll>
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define ppb pop_back
#define d0(x) cout<<x<<" "
#define d1(x) cout<<(x)<<"\n"
#define d2(x,y) cout<<x<<" "<<y<<"\n"
#define d3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define d5(x,y,z,w,s) cout<<x<<" "<<y<<" "<<z<<" "<<w<<" "<<s<<endl
using namespace std;
const ll mod = 998244353;


int a[11][1001];int H,W,K;char c[11][1001];int po[11];int s[11][1001];

int sum(int x1,int y1,int x2,int y2)
{
    //d5("##",x1,y1,x2,y2);
    //d4(s[x2][y2],s[x1][y2],s[x2][y1],s[x1][y1]);
    return s[x2][y2]-s[x1][y2] - s[x2][y1] + s[x1][y1];
}
void solve(int t)
{
    cin>>H>>W>>K;
    for(int i=1;i<=H;i++)
    {
        cin>>(c[i]+1);
        for(int j=1;j<=W;j++)
            a[i][j] = (c[i][j]-'0');
    }
    for(int i=0;i<=H;i++)s[i][0]=0;
    for(int i=0;i<=W;i++)s[0][i]=0;

    for(int i=1;i<=H;i++)
        for(int j=1;j<=W;j++)
        {
            s[i][j] = a[i][j]+s[i-1][j]+s[i][j-1]-s[i-1][j-1];
        }
    /*for(int i=0;i<=H;i++)
    {
        for(int j=0;j<=W;j++)
        {
            d0(s[i][j]);
        }
        d1("");
    }*/
    int ans = (H-1)+(W-1);

    po[0]=1;
    for(int i=1;i<=H;i++)
        po[i] = 2*po[i-1];

    for(int ii=0;ii<po[H-1];ii++)
    {
        int tmpans = 0;
        vi cuts;
        cuts.pb(0);
        for(int j=0;j<H-1;j++)
        {
            if((ii&po[j])!=0)
            {
                tmpans++;
                cuts.pb(j+1);
            }
        }
        cuts.pb(H);
        if(tmpans>=ans)
            continue;
        int m = cuts.size()-1;
        vi crrs(m);
        for(int i=0;i<m;i++)
            crrs[i]=0;

        //d2("#m",m);
        for(int i=1;i<=W;i++)
        {
            int maxs = 0;
            for(int j=0;j<m;j++)
            {
                int tmp = sum(cuts[j],i-1,cuts[j+1],i);
                //d5(cuts[j],i-1,cuts[j+1],i,tmp);

                crrs[j] += tmp;

                maxs = max(crrs[j],maxs);
            }
            //d2("maxs",maxs);
            if(maxs>K )
            {
                //d3(maxs,K,ii);
                tmpans++;
                for(int j=0;j<m;j++)
                    crrs[j]=sum(cuts[j],i-1,cuts[j+1],i);
            }
            for(int j=0;j<m;j++)
            {
                if(crrs[j]>K)
                    tmpans+=(H+W);
            }
        }
        /*if(tmpans<ans)
        {
            d1(ii);
            for(int i=0;i<=m;i++)
                d0(cuts[i]);
            d1("");
            d2("#",tmpans);
        }*/
        ans = min(tmpans,ans);

    }

    cout<<ans<<"\n";

}


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int T=1;
    //cin>>T;
    for(int t=1;t<=T;t++)
        solve(t);
}


Measured memory_bytes: 384
s = input()
l = len(s)
for i in range(l-2):
  temp = s[i]
  if s[i+1]==temp:
    print(str(i+1)+" "+str(i+2))
    quit()
  if s[i+2]==temp:
    print(str(i+1)+" "+str(i+3))
    quit()
    
if s[-1]==s[-2]:
  print(str(l-1)+ " "+str(l))
  quit()
print("-1 -1")

Measured memory_bytes: 8964
import sys
from itertools import accumulate

n, k, *aaa = map(int, sys.stdin.buffer.read().split())

for _ in range(k):
    bbb = [0] * (n + 1)
    for i in range(n):
        a = aaa[i]
        bbb[max(0, i - a)] += 1
        bbb[min(n, i + a + 1)] -= 1

    aaa = list(accumulate(bbb))
    aaa.pop()

    if all(a == n for a in aaa):
        break

print(*aaa)


Measured memory_bytes: 182176
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    
    char c;
    cin >> c;

    switch(c){
    case 'A':
	P("T");
	break;
    case 'T':
	P("A");
	break;
    case 'C':
	P("G");
	break;
    case 'G':
	P("C");
	break;
    }
    return  0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define int long long

using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


const int MOD = 1000000007;


ll A[500];
ll ans[500][500];
signed main() {
	REP(i, 500) {
		A[i] = i * (i + 1);
	}
	int N;
	cin >> N;
	bool found = false;
	REP(i, 500) {
		if (A[i] == N * 2) {
			found = true;
			break;
		}
	}
	if (!found) {
		cout << "No" << endl;
		return 0;
	}
	ll m=0, n=0;
	REP(i, 500) {
		if (i*(i + 1) == N * 2) {
			m = i;
			n = i + 1;
			break;
		}
	}
	ll cnt = 1;
	REP(i, m) {
		FOR(j, i, m) {
			ans[i][j] = cnt;
			cnt++;
		}
	}
	ll cnt2 = 1;
	REP(i, m) {
		FOR(j, i+1, m + 1) {
			ans[j][i] = cnt2;
			cnt2++;
		}
	}
	cout << "Yes" << endl;
	cout << n << endl;
	REP(i, n) {
		cout << m << " ";
		REP(j, m) {
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}
}




Measured memory_bytes: 3200
#サイコロの問題B
class Dice:
    def __init__(self, input_dice):
        self.flow = [input_dice[3], input_dice[1], input_dice[0], input_dice[5], input_dice[2], input_dice[4]]
        self.dice = [input_dice[3], input_dice[1], input_dice[0], input_dice[5], input_dice[2], input_dice[4]]
  
    def setNumber(self, n0, n1, n2, n3, n4, n5):
        self.dice[0] = n0
        self.dice[1] = n1
        self.dice[2] = n2
        self.dice[3] = n3
        self.dice[4] = n4
        self.dice[5] = n5
        return self.dice
    
    def roll(self, dir):
        if dir == 'S':
            self.setNumber(self.flow[0], self.flow[2], self.flow[5], self.flow[1], self.flow[4], self.flow[3])
            self.flow = self.dice
            return self.dice
        if dir == 'N':
            self.setNumber(self.flow[0], self.flow[3], self.flow[1], self.flow[5], self.flow[4], self.flow[2])
            self.flow = self.dice
            return self.dice
        if dir == 'W':
            self.setNumber(self.flow[2], self.flow[1], self.flow[4], self.flow[0], self.flow[3], self.flow[5])
            self.flow = self.dice
            return self.dice
        if dir == 'E':
            self.setNumber(self.flow[3], self.flow[1], self.flow[0], self.flow[4], self.flow[2], self.flow[5])
            self.flow = self.dice
            return self.dice

    def right_side(self, ue, mae):
        #以下メモ書き[1,2,3,4,5,6]の入力が与えられたとする
        #以下南北方向を軸に回転させる
        #最初2が前面
        i = 0
        for i in range(4):
            self.roll('W')
            if self.dice[2] == ue and self.dice[1] == mae:
                print(self.dice[4])
                break
        #1を前面に持ってきて回転させる
        self.roll('S')
        for i in range(4):
            self.roll('W')
            if self.dice[2] == ue and self.dice[1] == mae:
                print(self.dice[4])
                break
        #5を前面に持ってきて回転させる
        self.roll('S')
        for i in range(4):
            self.roll('W')
            if self.dice[2] == ue and self.dice[1] == mae:
                print(self.dice[4])
                break
        #6を前面に持ってきて回転させる
        self.roll('S')
        for i in range(4):
            self.roll('W')
            if self.dice[2] == ue and self.dice[1] == mae:
                print(self.dice[4])
                break
        #4を前面に持ってきて回転させる
        self.roll('E')
        self.roll('S')
        for i in range(4):
            self.roll('W')
            if self.dice[2] == ue and self.dice[1] == mae:
                print(self.dice[4])
                break
        #3を前面に持ってきて回転させる
        self.roll('N')
        self.roll('N')
        for i in range(4):
            self.roll('W')
            if self.dice[2] == ue and self.dice[1] == mae:
                print(self.dice[4])
                break

dice = list(map(int, input().split()))
n = int(input())
ue = [0]*n
mae = [0]*n
for i in range(n):
    ue[i], mae[i] = map(int, input().split())

d = Dice(dice)
for i in range(n):
    d.right_side(ue[i], mae[i])


Measured memory_bytes: 5628
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
  int H, W;
  cin >> H >> W;
  vector< vector<bool> > S(H);
  for(int i=0;i<H;i++) {
    S[i].resize(W);
    string tmp;
    cin >> tmp;
    for(int j=0;j<W;j++) {
      S[i][j] = tmp[j] == '#';
    }
  }

  bool ans = true;
  bool breakFlag = false;
  for(int i=0;i<H && !breakFlag;i++) {
    for(int j=0;j<W;j++) {
      if(!S[i][j]) continue;

      if(i > 0 && S[i-1][j]) {
        continue;
      }
      if(i < H-1 && S[i+1][j]) {
        continue;
      }
      if(j > 0 && S[i][j-1]) {
        continue;
      }
      if(j < W-1 && S[i][j+1]) {
        continue;
      }

      breakFlag = true;
      ans = false;
      break;
    }
  }

  string out = ans ? "Yes" : "No";
  cout << out << endl;
  return 0;
}


Measured memory_bytes: 256
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
for i in range(3):
  for j in range(3):
    if a[i][j] in b:
      a[i][j] = "o"
for i in range(3):
  if a[i][0] == a[i][1] == a[i][2]:
    print("Yes")
    exit()
  elif a[0][i] == a[1][i] == a[2][i]:
    print("Yes")
    exit()
  elif a[0][0] == a[1][1] == a[2][2]:
    print("Yes")
    exit()
  elif a[0][2] == a[1][1] == a[2][0]:
    print("Yes")
    exit()
  elif i == 2:
    print("No")

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

int main() {
  string s;
  cin >> s;
  int counter = 0;
  if (s[0] == 'o') ++counter;
  if (s[1] == 'o') ++counter;
  if (s[2] == 'o') ++counter;
  cout << 700 + 100 * counter;
}


Measured memory_bytes: 256
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define FP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define FS(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define IT(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
using namespace __gnu_pbds;

template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m)
{
	return (a % m + m) % m;
}

inline ll modInverse(ll a, ll m)
{
	assert(__gcd(a, m) == 1);
	ll m0 = m;
	ll y = 0, x = 1;

	if (m == 1)
		return 0;

	while (a > 1)
	{
		ll q = a / m;
		ll t = m;

		m = a % m, a = t;
		t = y;

		y = x - q * y;
		x = t;
	}

	if (x < 0)
		x += m0;

	return x;
}

inline ll modPow(ll x, ll y, ll m)
{ //x^y % m
	if (y == 0)
		return 1LL;
	else if (y == 1)
		return x;
	else
	{
		ll ans = modPow(x, y / 2, m) % m;
		if (y & 1)
		{
			return (((ans * ans) % m) * x) % m;
		}
		else
		{
			return (ans * ans) % m;
		}
	}
}

int main(int argc, char* argv[])
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	double n;
	cin>>n;
	cout<<ceil(n/2);
	return 0;
}

Measured memory_bytes: 256
a,b,c=(map(int, input().split(" ")))
if b-a+1 < c*2:
    for i in range(a,b+1):
        print(i)
else:
    for j in range(a,a+c):
        print(j)
    for k in range(b-c+1,b+1):
        print(k)


Measured memory_bytes: 3060
# C
N = int(input())
i = 0
lst = []
str_map = [chr(i) for i in range(97, 97+26)]
while N > 0:
    i = (N - 1) % 26
    N = (N - 1) // 26
    lst.append(str_map[i])
print(''.join(list(reversed(lst))))

Measured memory_bytes: 61748
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) begin(x),end(x)
typedef long long ll;
int OO = 0x3f3f3f3f;

int n;
int a[100005];
int b[100005];
int c[100005];
int mem[100005][3];

int solve(int x, int k)
{
    int op1, op2, op3;
    if(x == n)
        return 0;

    if(mem[x][k] != -1)
        return mem[x][k];

    op1 = op2 = op3 = 0;
    if(k != 1)
        op1 = solve(x+1, 1)+a[x];
    if(k != 2)
        op2 = solve(x+1, 2)+b[x];
    if(k != 3)
        op3 = solve(x+1, 3)+c[x];

    return mem[x][k] = max(op1, max(op2, op3));
}

int main()
{
    memset(mem, -1, sizeof mem);
    cin >> n;
    for(int i = 0; i< n; i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    cout << solve(0, 0) << endl;
    return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define int long long
int a[114514];
const int z = 0;
signed main() {
	int n, k; cin >> n >> k;
	int sum = 0, sum1 = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i < k)sum += a[i];
		else sum1 += max(z, a[i]);
	}
	int ans = max(sum, z) + sum1;
	for (int i = 0; i < n - k; i++) {
		sum1 += max(z, a[i]);
		sum -= a[i];
		sum += a[i + k];
		sum1 -= max(z, a[i + k]);
		ans = max(ans, max(sum, z) + sum1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  int D = (a+b)/2; //商
  int R= (a+b)%2; //余り、割る2だから余りをそのまま足す
  cout << D + R << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val k = sc.nextInt()
    val c = sc.nextInt()
    val s = sc.nextLine()
    val dp1 = Array(n) { 0 }
    dp1[0] = if (s[0] == 'o') 1 else 0
    for (i in 1 until n) {
        dp1[i] = dp1[i - 1]
        if (i - c - 1 < 0) {
            dp1[i] = Math.max(dp1[i], if (s[i] == 'o') 1 else 0)
        } else {
            dp1[i] = Math.max(dp1[i], dp1[i - c - 1] + if (s[i] == 'o') 1 else 0)
        }
    }
    val dp2 = Array(n) { 0 }
    dp2[n - 1] = if (s[n - 1] == 'o') 1 else 0
    for (i in n - 2 downTo 0) {
        dp2[i] = dp2[i + 1]
        if (i + c + 1 < n) {
            dp2[i] = Math.max(dp2[i], dp2[i + c + 1] + if (s[i] == 'o') 1 else 0)
        } else {
            dp2[i] = Math.max(dp2[i], if (s[i] == 'o') 1 else 0)
        }
    }
    for (i in 0 until n) {
        val v1 = if (i == 0) 0 else dp1[i - 1]
        val v2 = if (i == n - 1) 0 else dp2[i + 1]
        if (s[i] == 'o' && v1 + v2 == k - 1) {
            println(i + 1)
        }
    }
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 48772
r,g,b,n = gets.split.map(&:to_i)

ans = 0
(0..(n/r)).each do |ri|
  (0..(n/g)).each do |gi|
    ans += 1 if (n - (r*ri + g*gi)) >= 0 && (n - (r*ri + g*gi)) % b == 0
  end
end

puts ans

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())

lli data[100010];
lli odd[100010];
lli even[100010];

signed main(){

	lli n,k;
	cin>>n>>k;

	REP(i,0,n){
		lli tmp;
		cin>>tmp;
		data[tmp]++;
	}

	for(lli i=1;i<100010;i++){
		if(data[i]>0){
			if(data[i]%2){
				odd[i%k]++;
				data[i]--;
			}
			even[i%k]+=data[i];
		}
	}

	lli ans=0;

	//割った余りが0だけ特殊なので処理する
	ans += odd[0]/2;
	ans += even[0]/2;

	//また割った余りが半分の時一致すると厄介なので処理する
	if(k%2==0){
		ans += odd[k/2]/2;
		ans += even[k/2]/2;
	}

	for(lli i=1;i<=k/2;i++){
		if(i == k/2 && k%2==0)continue;
		lli next = k-i;
		if(DEBUG)cout<<"i="<<i<<" next="<<next<<endl;
		if(DEBUG)cout<<"ans="<<ans<<endl;
		lli cnt = min(odd[i],odd[next]);
		if(DEBUG)cout<<"odd[i]="<<odd[i]<<" odd[next]="<<odd[next]<<endl;
		if(DEBUG)cout<<"even[i]="<<even[i]<<" even[next]="<<even[next]<<endl;
		odd[i]-=cnt;
		odd[next]-=cnt;
		ans += cnt;

		if(odd[i]>0){
			cnt=0;
			if(DEBUG)cout<<"odd[i]="<<odd[i]<<" even[next]="<<even[next]<<endl;
			cnt = min(odd[i],even[next]);
			odd[i]-=cnt;
			even[next]-=cnt;
			ans+=cnt;
		}
		if(odd[next]>0){
			cnt=0;
			if(DEBUG)cout<<"odd[next]="<<odd[next]<<" even[i]="<<even[i]<<endl;
			cnt = min(odd[next],even[i]);
			odd[next]-=cnt;
			even[i] -=cnt;
			ans += cnt;
		}

		ans += even[i]/2;
		ans += even[next]/2;
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const long long MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
    return a / GCD(a, b) * b;
}

// ax + by = gcd(a, b) となるような (x, y) を求める
// 多くの場合 a と b は互いに素として ax + by = 1 となる (x, y) を求める
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    // 再帰的に解く (x, y を入れ替えておく)
    long long d = extGCD(b, a % b, y, x); 
    y -= a / b * x;
    return d;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

//約数列挙
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

ll t[110];

int main () {

    int n;cin>>n;

    rep(i,n) cin>>t[i];

    ll ans=t[0];

    rep(i,n-1) {
        ans=LCM(ans,t[i+1]);
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 256
x=int(input())
def divisors(n):
    lower_divisors=[]
    upper_divisors=[]
    i=1
    while i*i<=n:
        if n%i==0:
            lower_divisors.append(i)
            if i!=n//i:
                upper_divisors.append(n//i)
        i+=1
    return lower_divisors
max_lower_div=max(divisors(x))
print((max_lower_div-1)+(x//max_lower_div-1))

Measured memory_bytes: 9176
#include<iostream>
using namespace std;
int main(void)
{
	int i,h,w,e,k;
	int D=0,E=0,K=0;
	int a[101],b[101],c[101],d[101],z[203]={0},p[203]={0};
	cin>>h;
	for(i=0;i<101;i++){
			a[i]=999;
			b[i]=999;
			d[i]=999;
			c[i]=999;
	}
	for(i=0;i<h;i++){
			cin>>a[i]>>b[i];
	}
	cin>>w;
	for(i=0;i<w;i++){
			cin>>c[i]>>d[i];
	}
	while(1){
		if(D>=h&&E>=w) break;
		if(a[D]<c[E]||(a[D]==c[E]&&b[D]<d[E])){
			z[K]=a[D];
			p[K]=b[D];
			D++;
		}
		else if(a[D]>c[E]||(a[D]==c[E]&&b[D]>d[E])){
			z[K]=c[E];
			p[K]=d[E];
			E++;
		}
		else{
			z[K]=a[D];
			p[K]=b[D];
			D++;
			E++;
		}
		K++;
	}
	//cout<<K<<" "<<D<<" "<<E;
	for(i=0;i<K-1;i++){
		if(p[i]>=10){
		cout<<z[i]<<":"<<p[i]<<" ";
		}
		else{
		cout<<z[i]<<":0"<<p[i]<<" ";
		}
	}
	if(p[K-1]>=10){
		cout<<z[K-1]<<":"<<p[K-1]<<endl;
	}
	else{
		cout<<z[K-1]<<":0"<<p[K-1]<<endl;
	}
	//for(i=0;i<h+w;i++){
	//		cout<<a[i]<<b[i]<<endl;
	//}

	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
 
 
 
 
int main() {
    vector<int> a(3);
    rep(i,3){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    int b=a[0]+a[1];
    cout<<b<<endl;

}


Measured memory_bytes: 256
//ABC158C
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	for(int num=0;num<2000;num++){
		if(num*8/100 == a && num*10/100 == b){
			cout << num << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;
long long modpow(long long x,long long n,long long mod)
{
  if(n==0)return 1;
  long long res=modpow(x*x%mod,n/2,mod);
  if(n&1)res=res*x%mod;
  return res;
}
long long modinv(long long a,long long mod)//extgcdの方がいいらしい
{
  return modpow(a,mod-2,mod);
}
vector<int>inv;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,x;
  int mod=1e9+7;
  cin>>n>>x;
  vector<int>s(n);
  rep(i,n)cin>>s[i];
  sort(all(s),greater<int>());
  inv.resize(n+1);
  repi(i,1,n+1)inv[i]=modinv(i,mod);
  vector<vector<int>>dp(2,vector<int>(x+1,0));
  dp[0][x]=1;
  rep(i,n)
  {
    int no=i&1,ne=1-no;
    fill(all(dp[ne]),0);
    rep(j,x+1)
    {
      if(dp[no][j]==0)continue;
      dp[ne][j%s[i]]+=(ll)dp[no][j]*inv[n-i]%mod;
      dp[ne][j]+=(ll)dp[no][j]*inv[n-i]%mod*(n-i-1)%mod;
      dp[ne][j%s[i]]%=mod;
      dp[ne][j]%=mod;
    }
  }
  ll res=0;
  int kai=1;
  rep(i,n)kai=(ll)kai*(i+1)%mod;
  rep(i,x+1)
  {
    res+=(ll)kai*dp[n&1][i]%mod*i%mod;
  }
  cout<<res%mod<<endl;


  return 0;

}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int main(){
  int N,D;
  cin>>N>>D;
  if(N%(2*D+1) == 0){
    cout<< N/(2*D+1) <<endl;
  }
  else{
    cout<< N/(2*D+1) +1 <<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<ll> A(N);
  bool zero = false;
  rep(i, N) {
    cin >> A[i];
    if(A[i] == 0) zero = true;
  }
  if(zero) cout << 0 << endl;
  else {
    ll large = 1000000000000000000LL;
    ll ans = 1;
    rep(i, N) {
      if(ans > LONG_LONG_MAX / A[i] || ans * A[i] > large) {
        cout << -1 << endl;
        return 0;
      }
      ans *= A[i];
    }
    cout << ans << endl;
  }
  return 0;
}


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


int main(){
	vector<int> v;
	for (int i=0;i<10;i++){
		int n;
		cin >> n;
		v.push_back(n);
	}
	sort(v.begin(),v.end(),greater<int>());
	for(int i=0;i<3;i++){
		cout<<v[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
int n, l, k, a[100005];
int main() {
	int i;
	scanf("%d%d", &n, &l);
	for(i=1; i<=n; i++) {
		scanf("%d", a+i);
		if(a[i] + a[i-1] >= l) k = i-1;
	}
	if(k) {
		puts("Possible");
		for(i=1; i<k; i++) printf("%d\n", i);
		for(i=n-1; i>k; i--) printf("%d\n", i);
		printf("%d", k);
	} else {
		puts("Impossible");
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> s(n);
    rep(i,0,k-1){
        int d;
        cin >> d;
        rep(j,0,d-1){
            int a;
            cin >> a;
            a--;
            s[a]++;
        }
    }
    int ans = 0;
    rep(i,0,n-1)if(s[i] == 0)ans++;

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000
int C[VMAX+1];
int B[MAX];
void CountingSort(int A[],int n)
{
  int i,j;
    for(i=0; i<=VMAX+1; i++){
      C[i] = 0;
    }
    for(j=1; j<=n; j++){
      C[A[j]]++;
    }
    for(i=1; i<=VMAX+1; i++){
      C[i] = C[i]+C[i-1];
    }
    for(j=n; j>=1; j--){
      B[C[A[j]]] = A[j];
      C[A[j]]--;
    }
    for(i=1; i<n; i++){
      printf("%d ",B[i]);
    }
    printf("%d\n",B[n]);
}
int main(){
  int A[MAX],n;  
  int i, j, k=0;

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



Measured memory_bytes: 17516
def read_input():
    n = int(input())
    alist = list(map(int, input().split()))

    return n, alist


def submit():
    n, alist = read_input()

    dist_list  = []
    alist_se = [0] + alist + [0]

    for s,e in zip(alist_se, alist_se[1:]):
        dist_list.append(abs(e - s))

    origin = sum(dist_list)

    for i in range(1, n+1):
        # iがなかったとすると
        # a[i-1]-a[i]-a[i+1]がa[i-1]-a[i+1]になる
        diff = abs(alist_se[i-1] - alist_se[i]) + abs(alist_se[i] - alist_se[i+1]) - abs(alist_se[i-1] - alist_se[i+1])
        print(origin - diff)

if __name__ == '__main__':
    submit()


Measured memory_bytes: 14048
#include <stdio.h>

int main(){
    long N;
    scanf("%ld", &N);
    long sum=0;
    long i=1;
    while(i <= N){
        if (i % 3 !=0 && i % 5 != 0)
            sum += i;
        i++;
    }
    printf("%ld", sum);
    return 0;
}

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

int main() {
  long long a, b, x;
  cin >> a >> b >> x;
  if (a!=0 && b<x) cout << 0 << endl;
  else if (a==0 && b<x) cout << 1 << endl;
  else if (a==b && a%x!=0) cout << 0 << endl;
  else if (a%x==0) cout << b/x-(a/x-1) << endl;
  else if (a%x!=0) cout << b/x-a/x << endl;
}

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

ll sad(ll x) {
  ll n = 0;
  for (ll i = 0; i < N; i++) {
    n+= abs(x-a[i]);
  }
  return n;
}


int main() {
  cin >> N;
  for (ll i = 0; i < N; i++) {
    ll x; cin >> x; x -= (i+1); a.push_back(x);
  }
  sort(a.begin(), a.end());
  cout << sad(a[(N+1)/2-1]) << endl;
}

Measured memory_bytes: 2420
#include <cstdio>

int main()
{
	int H, N;
	int tmp;
	int sum = 0;

	scanf("%d %d", &H, &N);

	for (int i = 0; i < N; ++i)
	{
		scanf("%d", &tmp);
		sum += tmp;
	}

	if (sum >= H)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

Measured memory_bytes: 128
x, k, d = map(int, input().split())

x_ = abs(x)

if x_ >= d * k:
    print(x_ - d*k)
    exit(0)

a = x_ % d
b = - (a - d)
k_ = x_ // d
l = k - k_

if l % 2 == 0:
    print(a)
else:
    print(b)

Measured memory_bytes: 9116
import java.util.*;
public class Main {
	public static void main(String[] args){
      	
		Scanner sc = new Scanner(System.in);
		
		int Karr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
		
		System.out.println(Karr[sc.nextInt()-1]);

		
		
      	sc.close();
    }
		
		
}


Measured memory_bytes: 21716
package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"os"
)

type IOTp struct {
	iBuffer []byte
	iPos int
}
func (this *IOTp) GetChar() byte {
	res:=this.iBuffer[this.iPos]
	this.iPos++
	return res
}
func (this *IOTp) ReadInt() int {
	res:=0
	k:=1
	for ch:=this.iBuffer[this.iPos]; !(ch>='0' && ch<='9'); ch=this.iBuffer[this.iPos]{
		if ch=='-' {
			k=-1
		}
		this.iPos++
	}
	for ch:=this.iBuffer[this.iPos]; ch>='0' && ch<='9'; ch=this.iBuffer[this.iPos]{
		res=res*10+int(ch-'0')
		this.iPos++
	}
	res*=k
	return res
}
func NewIOTp() *IOTp {
	now:=new(IOTp)
	//inputFile,_:=os.Open("in.txt")
	inputFile:=os.Stdin
	now.iBuffer,_=ioutil.ReadAll(inputFile)
	now.iBuffer=append(now.iBuffer, '\n')
	now.iPos=0
	return now
}
var cin *bufio.Reader
var cout *bufio.Writer
func main() {
	IO:=NewIOTp()
	cout=bufio.NewWriter(os.Stdout)
	n,p:=IO.ReadInt(),IO.ReadInt()
	var cnt [2]int
	for i:=1; i<=n; i++ {
		t:=IO.ReadInt()
		cnt[t%2]++
	}
	if p==1 && cnt[1]==0 {
		fmt.Println(0)
		return
	}
	if cnt[1]>0 {
		n--
	}
	ans:=1
	for i:=1; i<=n; i++ {
		ans*=2
	}
	fmt.Println(ans)
	cout.Flush()
}


Measured memory_bytes: 640
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() + a;
		if( b >=24 ){
			System.out.println(b-24);
		}else{
			System.out.println(b);
		}
		return;
	}
}

Measured memory_bytes: 21716