akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    vi a(3);
    rep(i,3) cin >> a[i];
    sort(a.rbegin(), a.rend());
    cout << a[0] - a[1] + a[1] - a[2] << endl;
}

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

int n;
bool f;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0; i<n; ++i){
		char c;
		cin >> c;
		if(c == 'Y') f = true;
	}
	cout << (f ? "Four" : "Three") << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<array>
#include<algorithm>
#include<deque>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<list>
#include<bitset>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x,y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x,LLI y) {
//	return x / gcd(x,y) * y;
//}

//long nCr(int n,int r) {
//	long ans = 1;
//	for (int i = n; i > n - r;i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1;i++) {
//		ans = ans / i;
//	}
//	return ans;
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	LLI A, B;
	cin >> A >> B;
	LLI res = max(A, B);
	if (A >= B) {
		A--;
	}
	else {
		B--;
	}
	res += max(A, B);
	cout << res << endl;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int n;
int add[24*60*60+10];

void solve() {
    rep(i,24*60*60+5) add[i]=0;
    
    rep(i,n) {
        int s1,s2,s3;
        int t1,t2,t3;
        scanf("%d:%d:%d",&s1,&s2,&s3);
        scanf("%d:%d:%d",&t1,&t2,&t3);

        add[s1*60*60+s2*60+s3] += 1;
        add[t1*60*60+t2*60+t3] += -1;
    }
    rep(i,24*60*60+5) {
        add[i+1]+=add[i];
    }

    int ans=0;
    rep(i,24*60*60+5) {
        ans=max(ans,add[i]);
    }
    cout<<ans<<endl;

    

}

int main() {
    while(cin>>n) {
        if(!n) return 0;
        solve();
    }

    return 0;
}

Measured memory_bytes: 1576
// B - Balance
'use strict'
function main(input) {
  input = input.trim().split('\n')
  const N = Number(input.shift())
  input = input[0].split(' ').map(v => Number(v))
  let l = [input[0]]
  let r = [input[N-1]]
  let ans = 100
  for (let i = 1; i < N; i++) {
    l.push(l[i-1]+input[i])
    r.push(r[i-1]+input[N-i-1])
  }
  for (let i = 0; i < N - 1; i++) {
    let temp = Math.abs(l[i] - r[N-i-2])
    if (ans > temp) ans = temp
  }
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include <cstdio>
#include <algorithm>

int count[100005];

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

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
                                                                                                
  
int main(void){
                                                                                                
      
    char s[200001];
   
      
    scanf("%s", s );

   
    printf("%d\n", strrchr( s,'Z' ) - strchr( s,'A' ) + 1 );


    return 0;
                                                          
}

Measured memory_bytes: 384
"use strict";

const main = arg => {
  const input = arg.trim().split("\n");
  const xs = input[0].split(" ").map(x => parseInt(x));
  for (let i = 0; i < 5; i ++) {
    if (xs[i] == 0) {
      console.log(i + 1);
      break;
    }
  } 
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29596
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

int n,t[2];
int c[100005],a[100005];
int map[5][100005];

inline void add(int x,int y){
	for(;x<=n;x+=x&(-x))c[x]+=y;
}
inline int query(int x){
	int ans=0;
	for(;x>0;x-=x&(-x))ans+=c[x];
	return ans;
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",map[1]+i);
	for(int i=1;i<=n;i++)scanf("%d",map[2]+i);
	for(int i=1;i<=n;i++)scanf("%d",map[3]+i);
	for(int i=1;i<=n;i++){
		int minv=min(map[1][i],map[3][i]);
		int maxv=max(map[1][i],map[3][i]);
		a[i]=maxv/3;
		if(minv%3!=1||map[2][i]!=minv+1||maxv!=minv+2||a[i]-i&1)
			return printf("No"),0;
		if(map[3][i]==minv)t[i&1]^=1;
	}
	for(int i=n-((n&1)^1);i>=1;i-=2)
		t[0]^=query(a[i])&1,add(a[i],1);
	memset(c,0,sizeof(c));
	for(int i=n-(n&1);i>=1;i-=2)
		t[1]^=query(a[i])&1,add(a[i],1);
	printf(t[0]||t[1]?"No":"Yes");
}

Measured memory_bytes: 2176
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll N, K, H[212345];

int main() {

	cin >> N >> K;
	rep(i, N) cin >> H[i];

	sort(H, H + N);

	ll ans = 0;
	rep(i, N - K) ans += H[i];

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 1792
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include<iomanip>

using namespace std;
const int N = 1e5 + 5;
vector<int> graph[N];

int deg[N];
int root;
int dp[N];
bool mark[N];
int n;

bool isPath()
{
	int cnt = 0;
	for (int i = 0; i < n; i++)
	{
		if (deg[i] == 1)
		{
			cnt++;
		}
		if (deg[i] > 2)
		{
			root = i;
			return false;
		}
		if (deg[i] == 2)
		{
			root = i;
		}
	}
	return cnt == 2;
}

void dfs(int v)
{
	mark[v] = true;
	vector<int> child;
	for (int i = 0; i < graph[v].size(); i++)
	{
		int u = graph[v][i];
		if (!mark[u])
		{
			dfs(u);
			child.push_back(u);
		}
	}
	int cnt = 0;
	for (int i = 0; i < child.size(); i++)
	{
		dp[v] += dp[child[i]];
		if (dp[child[i]])
		{
			cnt++;
		}
	}
	if (cnt < (int)child.size() - 1)
	{
		dp[v] += (int)child.size() - 1 - cnt;
	}
}



int main()
{
	cin >> n;
	for (int i = 0; i < n - 1; i++)
	{
		int u, v;
		cin >> u >> v;
		graph[u].push_back(v);
		graph[v].push_back(u);
		deg[u]++;
		deg[v]++;
	}
	if (isPath())
	{
		cout << 1 << endl;
		exit(0);
	}
	dfs(root);
	cout << dp[root] << endl;




}

	
            


 


Measured memory_bytes: 11776
import java.util.*

class Scanner(`in`: java.io.InputStream) {
    private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        if (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun nextLine(): String {
        return if (tokenizer?.hasMoreTokens() != true) {
            reader.readLine()
        } else tokenizer!!.nextToken("\n")
    }
}

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

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

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val K = sc.next().toInt()
        val S = sc.next().toInt()
        var ans = 0L
        for (x in 0..K) {
            for (y in 0..K) {
                val z = S - (x + y)
                if (z in 0..K) ans++
            }
        }
        pw.println(ans)
    }
}


Measured memory_bytes: 31388
#三井住友2019 D 貪欲法
def main():
    import sys
    N = int(sys.stdin.readline())
    S = sys.stdin.readline().rstrip()
    ans = 0
    for i in range(1000):
        num = str(i).zfill(3)
        L = []
        k = 0
        for j in range(N):
            #print(num, S[j])
            if int(S[j])==int(num[k]):
                #print('Yes', num)
                L.append(S[j])
                k+=1
            if len(L)==3:
                #print(L)
                ans +=1
                break
                
    print(ans)
        
    
if __name__=='__main__':
    main()


Measured memory_bytes: 68504
#include<iostream>

using namespace std;

int main()
{
    int a, b, c, d;

    cin >> a >> b >> c >> d;

    if (a+b > c+d) cout << "Left" << endl;
    else if (a+b == c+d)  cout << "Balanced" << endl;
    else cout << "Right" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, int> pli;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
        int n;
        scanf("%d", &n);
        lint cnt[10][10];
        rep(i, 10)rep(j, 10) cnt[i][j]=0;
        For(i, 1, n+1){
                string s=to_string(i);
                ++cnt[s[0]-'0'][s[s.size()-1]-'0'];
        }
        lint ans=0;
        For(i, 1, 10)For(j, 1, 10) ans+=cnt[i][j]*cnt[j][i];
        printf("%lld\n", ans);
}

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

using namespace std;

int main(){
    int num;
    cin >> num;

    vector<int> vec(num);
    for(int i=0; i<num; i++){
        cin >> vec.at(i);
    }

    int flag = 1;
    for(int i=0; i<num; i++){
        if(vec[i]%2 == 0){
            if(vec[i]%3 == 0 || vec[i]%5 == 0){}
            else{ flag = 0; break;}
        }
    }
    if(flag==0){
        cout << "DENIED" << endl;
    }
    else{
        cout << "APPROVED" << endl;
    }
    return 0;
}

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

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var a = Console.ReadLine();
            Console.WriteLine((a[0] - 'a') < 0 ? "A" : "a");
        }
    }
}


Measured memory_bytes: 25776
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
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 MIN = INF;
  REP(i,sz(S)-sz(T)+1){
    int cnt=0;
    REP(j,sz(T)){
      if(S[i+j]!=T[j]){
        cnt++;
      }
    }
    MIN=min(cnt,MIN);
  }
  cout << MIN << endl;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<stack>
#include<set>
using namespace std;
#define pb push_back
#define POP pop_back()
#define ll long long
#define db double
#define POP pop_back()
#define endl '\n'
#define PII pair<int,int>
#define FI first
#define SE second
#define VI vector<int>
#define QI queue<int>
#define SI stack<int>
#define debug cout<<"debug"<<endl;
#define PLL pair<ll,ll>
#define PDD pair<double,double>
#define ULL unsigned long long
#define fo(i,a,b) for (int i=a;i<=b;++i)
#define fd(i,a,b) for (int i=a;i>=b;--i)
#define mem(x,a) memset(x,a,sizeof(x))
const int maxn = 2e5 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
int a[maxn] , cnt[maxn] , n , b;
char s[10];
int main(){
	cin >> s;
	if(s[2] != s[3] || s[4] != s[5])cout << "No\n";
	else cout << "Yes\n";
	return 0;
}

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

struct stack{
  int a[101];
  unsigned n;
  stack():a(),n(0){}
  int pop(){return a[--n];}
  void push(int in){a[n++]=in;}
};

int main(){
  stack s;
  char buf[10];

  while(scanf("%s",buf) != EOF){
    int a,b;
    switch(buf[0]){
      case '+' : a = s.pop(); b = s.pop(); s.push(b+a); break;
      case '-' : a = s.pop(); b = s.pop(); s.push(b-a); break;
      case '*' : a = s.pop(); b = s.pop(); s.push(b*a); break;
      default  : s.push(atoi(buf));
    }
  }
  printf("%d\n",s.pop());
}

Measured memory_bytes: 964
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,A; cin >> H >> A;
    cout << (H+A-1)/A << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector <ll> a(n);
  ll max = 1e18;
  ll max2 =LONG_LONG_MAX;
  bool flag=false;
  rep(i,n)cin >> a[i];
  ll ans=1;
  rep(i,n){
    if(a[i]==0)flag=true;
  }
  if(flag==false)rep(i,n){
      if(ans >= max2 / a[i]){
	cout << "-1" << endl;
	return 0;
      }
      ans*=a[i];
      if(ans>max){
	cout << "-1" << endl;
	return 0;
      }
    }
  else if(flag==true){
    cout << "0" << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}


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



int N;


int main(){
	cin >> N;
	vector<int> a(N+1);
	vector<int> b(N+1);
	
	for ( int i = 1; i <= N; i++ ){
		cin >> a[i];
	}
	
	int ball = 0;
	for ( int i = N; i >= 1; i-- ){ // 後ろからだと一意に決まる
		int bsum = 0;
		for ( int j = i; j <= N; j += i )
			bsum += b[j];
		b[i] = a[i] ^ (bsum & 1);
		ball += b[i];
	}
	
	cout << ball << endl;
	for ( int i = 1; i <= N; i++ )
		if ( b[i] )
			cout << i << endl;
	
	return 0;
}



Measured memory_bytes: 2432
N, A = list(map(int, input().split()))
x = list(map(int, input().split()))
X = max(max(x), A)

dp=[[[0 for k in range(N*X+1)] for j in range(N+1)] for i in range(N+1)]

ans = 0
for j in range(N+1):
  for k in range(N+1):
    for s in range(N*X+1):
      if j==0 and k==0 and s==0:
        dp[j][k][s]=1
      elif j>=1 and s<x[j-1]:
        dp[j][k][s] = dp[j-1][k][s]
      elif j>=1 and k>=1 and s>=x[j-1]:
        dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-x[j-1]]
      else:
        dp[j][k][s] = 0
      if j==N and s==k*A:
        ans = ans + dp[j][k][s]
print(ans-1)


Measured memory_bytes: 97500
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<math.h>
#include<stdlib.h>
#include <iomanip>
using namespace std;
#define int long long
//#define double long double
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;
typedef pair<int, pii > pip;
typedef pair<pii, pii > piipii;
typedef pair<double, double> pdd;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define all(vec) vec.begin(), vec.end()
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60)
#define mod 1000000007
#define se second
#define fi first

int T[2], A[2], B[2], S[2];

int abss(int aa){
    if(aa < 0)return -aa;
    return aa;
}

signed main(){
    cin >> T[0] >> T[1];
    cin >> A[0] >> A[1];
    cin >> B[0] >> B[1];
    if(A[0] < B[0]){
        swap(A[0], B[0]);
        swap(A[1], B[1]);
    }
    S[0] = T[0] * A[0] - T[0] * B[0];
    S[1] = T[1] * A[1] - T[1] * B[1];
    
    if(S[0] + S[1] == 0){
        cout << "infinity" << endl;
        return 0;
    }
    if(S[0] + S[1] > 0){
        cout << 0 << endl;
        return 0;
    }
    int waru = abss(S[0] + S[1]);
    if(abss(S[0] % waru))cout << ((abss(S[0]) + waru - 1) / waru) * 2 - 1 << endl;
    else cout << ((abss(S[0]) + waru - 1) / waru) * 2 << endl;

    
    return 0;
}

/*

*/

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        x: i64,
    };
    let mut c = vec![];
    let mut a = vec![];
    for _ in 0..n {
        input! {
            c_i: i64,
            a_i: [i64; m],
        };
        c.push(c_i);
        a.push(a_i);
    }
    let inf = 1_000_000_000_000_i64;
    let mut ans = inf;
    for bits in 0..2_usize.pow(n as u32) {
        let (sc, sa) = c
            .iter()
            .zip(a.iter())
            .zip((0..n).map(|i| (bits >> i) & 1 == 1))
            .filter(|&(_, b)| b)
            .map(|(p, _)| p)
            .fold((0, vec![0_i64; m]), |(sc, mut sa), (c_i, a_i)| {
                a_i.iter().enumerate().for_each(|(j, &a_ij)| sa[j] += a_ij);
                (sc + c_i, sa)
            });
        if sa.iter().all(|&sa_j| sa_j >= x) {
            ans = std::cmp::min(ans, sc);
        }
    }
    println!("{}", if ans == inf { -1 } else { ans });
}


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

static const int maxn = 1000000 + 10;
int n, a[maxn];
vector <int> G;

void get_step(){
    G.resize(0);
    for (int i = 1; ;) {
        G.push_back(i);
        i = 3 * i + 1;
        if (i > n) break;
    }
}

void _out1(){
    printf("%d\n", G.size());
    for (int i = G.size()-1; i > 0; i--)
        printf("%d ", G[i]);
    printf("%d\n", G[0]);
}

int insertionSort(int g){
    int cnt = 0, v, j;
    for (int i = g; i < n; i++) {
        v = a[i];
        j = i - g;
        while (j >= 0 && a[j] > v) {
            a[j+g] = a[j];
            j = j - g;
            cnt++;
        }
        a[j+g] = v;
    }
    return cnt;
}

int shellSort(){
    int cnt = 0;
    for (int i = G.size()-1; i >= 0; i--)
        cnt += insertionSort(G[i]);
    return cnt;
}

void _out2(){
    for (int i = 0; i < n; i++)
        printf("%d\n", a[i]);
}

int main(){
    // freopen("data.in", "r", stdin);
    // freopen("data.out", "w", stdout);
    while(scanf("%d", &n) == 1){
        for (int i = 0; i < n; i++) scanf("%d", &a[i]);
        get_step();
        _out1();
        printf("%d\n", shellSort());
        _out2();
    }
    return 0;
}



Measured memory_bytes: 6712
package main

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

var (
	N      int
	S      string
	answer int
)

func readVariables() {
	N, S = nextInt(), nextStr()
}

func main() {
	readVariables()
	for i := 1; i < N; i++ {
		if S[i] != S[i-1] {
			answer++
		}
	}
	answer++
	fmt.Println(answer)
}

/* 以下、テンプレート*/

var scanner *bufio.Scanner

func init() {
	Max := 1001001
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, Max), Max)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

// MinInt は、2つの整数を受け取り、最小値を返します。
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt は、2つの整数を受け取り、最大値を返します。
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt は、整数の絶対値を返します。
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//ModPow は整数の累乗関数で、剰余もサポートします。
//base^exponentの値をmoduleで割った余りを返します。
//moduloが1以下の場合には、剰余演算をしません。
//baseが負の値である場合には、返す値が負になることがあります。
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd は、引数の整数全ての最大公約数を返します。
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm は、与えられた整数の最小公倍数を返します。
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}


Measured memory_bytes: 896
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")


using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 21;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;

int DP[(1 << N) + 10], n, m, K;
int num[N][N], Fi[(1 << N) + 10][N];

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m >> K;
	memset(num, -1, sizeof num);
	for (int i = 1; i <= K; i++){
		int c,a, b;
		cin >> a >> b >> c;
		num[a][b - 1] = c;
	}
	n--;
	for (int i = 0; i < (1 << n); i++){
		for (int j = 0; j < n; j++){
			Fi[i][j] = -1;
//			if (i == 1 && j == 1) return cout << 
			for (int K = j; K >= 0; K--){
				if (i & (1 << K)){
					Fi[i][j] = K;
					break;
				}
			}
		}
	}
	DP[0] = 1;
//	cout << Fi[1][1] << '\n';
	for (int i = 1; i <= m; i++){
		for (int j = 0; j < n; j++){
			for (int mask = 0; mask < (1 << n); mask++){
				if (mask & (1 << j)) continue;
				if (Fi[mask][j] != -1) DP[mask] = (DP[mask] + DP[(mask ^ (1 << j)) ^ (1 << Fi[mask][j])]) % MOD;
			}
		}
//		cout << i << '\n';
		for (int mask = 0; mask < (1 << n); mask++){
			if (Fi[mask][n - 1] != -1){
//				cout << mask << ' ' << (mask ^ (1 << Fi[mask][n - 1])) << '\n';
				DP[mask] = (DP[mask] + DP[mask ^ (1 << Fi[mask][n - 1])]) % MOD;
//				if (mask == 1) cout << "Fuck " << DP[mask] << '\n';
			}
		}
//		cout << i << '\n';
		for (int mask = 0; mask < (1 << n); mask++){
			for (int j = 0; j < n; j++){
				if (num[i][j] == -1) continue;
				if (((mask >> j) & 1) != num[i][j]) DP[mask] = 0;
			}
//			cout << mask << ' ' << DP[mask] << '\n';
		}
	}
	int ans = 0;
	for (int mask = 0; mask < (1 << n); mask++) ans = (ans + DP[mask]) % MOD;
	cout << ans;







	return 0;
}


Measured memory_bytes: 48680
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
W,H,x,y = map(int,input().split())

surface = W * H
ans = [0,0]
if 2*x==W and 2*y==H:
    ans = [surface/2,1]
else:
    ans = [surface/2,0]

print(*ans)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する



Measured memory_bytes: 2940
// copy from "????????°???????????°????????????????????\??????????????¢?????´???????????¨??????????§????" p.351

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

#define MAX 100000

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
template<class T> using vv=vector<vector< T > >;
typedef deque<int> di;
typedef deque<deque<int> > ddi;

vi G[MAX];
int N;
bool visited[MAX];
int prenum[MAX];
int parent[MAX];
int lowest[MAX];
int timer;

void dfs( int current, int prev ) {
  prenum[current] = lowest[current] = timer;
  timer += 1;

  visited[current] = true;

  int next;

  rep(i, G[current].size()) {
    next = G[current][i];
    if ( !visited[next] ) {
      parent[next] = current;

      dfs( next, current );
      lowest[current] = min( lowest[current], lowest[next] );
    } else if ( next != prev) {
      lowest[current] = min( lowest[current], prenum[next] );
    }
  }
}

void art_points() {
  rep(i, N) {
    visited[i] = false;
  }
  timer = 1;
  dfs(0, -1);

  set<int> ap;
  int np = 0;
  FOR(i, 1, N) {
    int p = parent[i];
    if ( p == 0 ) {
      np += 1;
    } else if ( prenum[p] <= lowest[i] ) {
      ap.insert(p);
    }
  }
  if ( np > 1 ) {
    ap.insert(0);
  }
  for ( auto ans : ap) {
    cout << ans << endl;
  }
}

int main() {
  int m;
  cin >> N >> m;
  rep(i, m) {
    int s, t;
    cin >> s >> t;
    G[s].pb(t);
    G[t].pb(s);
  }
  art_points();

  return 0;
}

Measured memory_bytes: 6924
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define cy cout << "Yes" << endl
#define cn cout << "No" << endl
typedef long long ll;
typedef pair<int,int> ipair;
typedef pair<string,string> spair;

struct Data{
   int ex_pos; 		// 元の位置
   ipair da; 		// 実際のデータ
};

struct Datas{
	int ex_pos;
	spair da;
};

bool greaterpair(const Data & l, const Data & r){
  if (l.da.first == r.da.first){return l.da.second < r.da.second;}
  else {return l.da.first < r.da.first;}
}

bool greaterpairs(const Datas & l, const Datas & r){
  return l.ex_pos < r.ex_pos;
}

void Main()
{
	int N, M;
  	cin >> N >> M;
  	//vector<pair<int,int>> PY(M);
  	//rep(i,M) cin >> PY[i].first >> PY[i].second;
  	
	vector<ipair> PY(M);
  	rep(i,M) {
      	cin >> PY[i].first >> PY[i].second;
    }
	
  	vector<Data> PYI(M);
  	rep(i,M){
		PYI[i].da = PY[i];
      	PYI[i].ex_pos = i;
    }
  
  	// 比較関数 greaterpair で並びかえ
  	sort(PYI.begin(), PYI.end(), greaterpair);
  
  	/*
  	rep(i,M){
      	cout << PYI[i].da.first << " " << PYI[i].da.second << " " << PYI[i].ex_pos << endl;
    }
  	*/
  
  	auto keta = [&](int n){
    	int ans = 0;
      	while(n){
         	n /= 10; 
          	ans++;
        }
    	return ans;
    };
	
	vector<spair> ans(M);	
    int temp;
  	int x = 1;
  		
  	rep(i,M){
      	if(i != 0){
			if(PYI[i].da.first == temp){x++;}
    		else{x = 1;}
        }
      	temp = PYI[i].da.first;	
      	int ketai = keta(PYI[i].da.first);
      	ans[i].first = string(6-ketai,'0') + to_string(PYI[i].da.first);
      	ketai = keta(x);
    	ans[i].second = string(6-ketai,'0') + to_string(x);
      	//cout << ans[i].first << ans[i].second << " " << PYI[i].ex_pos << endl;
    }
  	
  	vector<Datas> ansi(M);
	rep(i,M){
  		ansi[i].da = ans[i];
  		ansi[i].ex_pos = PYI[i].ex_pos;
	}
  
  	// PYI[i].ex_pos 順で並び替え
	sort(ansi.begin(), ansi.end(), greaterpairs);
  	rep(i,M){
  		cout << ansi[i].da.first << ansi[i].da.second << endl;
    }
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 16768
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 

int main()
{	
    std::ios_base::sync_with_stdio(0);
	  cin.tie(0);
	  cout.tie(0);
    
    ll s,w;
    cin>>s>>w;

    if(w>=s)
    {
        cout<<"unsafe"<<endl;
    }
    else
    {
        cout<<"safe"<<endl;
    }

}


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

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    vector<int> a(n);
    int target = 1;
    int ans = 0;
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
        if(a[i]==target) target++;
        else ans++;
    }
    cout<<(ans==n ? -1 : ans);
}


Measured memory_bytes: 1024
# Your code here!
N,C = gets.split.map(&:to_i)
weight = []
V = []
N.times{
    x  = gets.split.map(&:to_i)
    V << x[0]
    weight << x[1]
}

dp = Array.new(N+1).map{Array.new(C+1,0)}

N.times{|i|
    (C+1).times{|w|
        if w >= weight[i]
            dp[i+1][w] = [dp[i][w],dp[i][w-weight[i]]+V[i]].max
        else
            dp[i+1][w] = dp[i][w]
        end
    }
}

puts dp[N][C]


Measured memory_bytes: 14756
import java.util.*

fun main(args: Array<String>) {
    // 一筆書きでかけるかどうかを確認する，深さ優先探索で行えばよいか？
    // ノードがかぶっていないか -> 各探索で訪問したノードを記録しておく
    // パスがかぶっていないか -> 探索過程での分岐で保証

    // どのように訪問したノードを記録しておくか？？ -> スタックでどうか？？

    // 訪問したノードをスタックに入れていく
    
    
    
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }

    // 隣接リストを作成
    val adjList = Array(n) { mutableListOf<Int>()}
    for (i in 0 until m) {
        val (s, t) = readLine()!!.split(" ").map { it.toInt() }
        adjList[s-1].add(t-1)
        adjList[t-1].add(s-1)
    }

    var stack = ArrayDeque<Int>()
    var cnt = 0

    fun dfs(index: Int) {

        if (stack.size + 1 == n){
            cnt += 1
            return
        }

        stack.push(index)
        for (next in adjList[index]) {
            if(!stack.contains(next)){
                dfs(next)
            }
        }

        stack.pop()

        return
    }

    dfs(0)

    print(cnt)
}

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

namespace AtCoder.Question
{
    public class QuestionE
    {
        public static void Main(string[] args)
        {
            var n = ReadHelper.ReadValue<int>();
            var a = ReadHelper.ReadValues<long>();

            var allXor = a[0];
            for (int i = 1; i < a.Length; i++)
            {
                allXor ^= a[i];
            }
            for (int i = 0; i < a.Length; i++)
            {
                a[i] = allXor ^ a[i];
            }
            Console.WriteLine(String.Join(' ', a));
        }

        static class ReadHelper
        {
            internal static T ReadValue<T>()
            {
                return (T)Convert.ChangeType(Console.ReadLine(), typeof(T));
            }
            internal static (T1, T2) ReadValue<T1, T2>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)));
            }
            internal static (T1, T2, T3) ReadValue<T1, T2, T3>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)), (T3)Convert.ChangeType(input[2], typeof(T3)));
            }
            internal static (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>()
            {
                var input = Console.ReadLine().Split(' ');
                return ((T1)Convert.ChangeType(input[0], typeof(T1)), (T2)Convert.ChangeType(input[1], typeof(T2)), (T3)Convert.ChangeType(input[2], typeof(T3)), (T4)Convert.ChangeType(input[3], typeof(T4)));
            }
            internal static T[] ReadValues<T>()
            {
                var input = Console.ReadLine().Split(' ');
                return input.Select(x => (T)Convert.ChangeType(x, typeof(T))).ToArray();
            }
        }

        static class MathAlgorithm
        {
            internal static bool IsPrime(long n)
            {
                if (n == 2) return true;
                if (n < 2 || n % 2 == 0) return false;
                var sqrt = Math.Sqrt(n);
                for (int i = 3; i <= sqrt; i += 2) if (n % i == 0) return false;
                return true;
            }
            internal static IEnumerable<long> EnumeratePrimes(long n)
            {
                var i = 2L;
                while (i * i <= n)
                {
                    if (n % i == 0)
                    {
                        n /= i;
                        yield return i;
                    }
                    else
                    {
                        i += i == 2 ? 1 : 2;
                    }
                }
                if (n != 1) yield return n;
            }
        }
    }
}


Measured memory_bytes: 67924
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;

ll dp[100005][13];

int main()
{
  string s;
  cin >> s;
  
  if(s[0]=='?') REP(i,10) dp[0][i] = 1;
  else dp[0][s[0]-'0'] = 1;
  
  FOR(k,1,s.size()){
    if(s[k]=='?'){
      REP(i,13) REP(j,10){
        dp[k][(i*10 % 13 + j) % 13] += dp[k-1][i];
        dp[k][(i*10 % 13 + j) % 13] %= MOD;
      }
    }else{
      REP(i,13){
        dp[k][(i*10 % 13 + (s[k]-'0')) % 13] += dp[k-1][i];
        dp[k][(i*10 % 13 + (s[k]-'0')) % 13] %= MOD;
      }
    }
  }
  cout << dp[s.size()-1][5] << '\n';
  return 0;
}

Measured memory_bytes: 10624
package main

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

func main() {
	n := getInt()
	t := getInt()

	ts := make([]int, n)
	for i := range ts {
		ts[i] = getInt()
	}

	sum := t
	for i := 0; i < n-1; i++ {
		if ts[i+1]-ts[i] < t {
			sum += ts[i+1] - ts[i]
		} else {
			sum += t
		}
	}

	fmt.Println(sum)
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


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

#ifdef TESTING
  #include "dump.hpp"
#else
  #define DUMP(...)
  #define DEBUG(...)
#endif

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define INT(n) int n;assert(0<scanf("%d",&n))
#define AI(a,size,n) array<int,size> a;REP(i,n){assert(0<scanf("%d",&a[i]));}
#define VI(v,n) vector<int> v(n);REP(i,n){assert(0<scanf("%d",&v[i]));}

int main(){
  INT(n); VI(as, n);
  ll ans = as[0] == 0? 0: -1;
  REP(i, n - 1){
    if (as[i] + 1 < as[i + 1]){
      ans = -1;
    }
  }
  int cur = -1;
  if (ans != -1){
    REP(i, n, 0){
      if (cur != as[i]){
        ans += as[i];
      }
      cur = as[i] - 1;
    }
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    vector<int> k(4);
    for(int i=0;i<4;i++){
        k[i] = n%10;
        n=n/10;
    }
    if(k[0]==k[1]&&k[1]==k[2]){
        cout<<"Yes"<<endl;
    }
    else if(k[1]==k[2]&&k[2]==k[3]){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    a = [int(readline()) for _ in range(n)]

    if all([x % 2 == 0 for x in a]):
        print("second")
    else:
        print("first")


if __name__ == '__main__':
    main()


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

int main(){ 
    int n;
    cin >>n ;
    long long sunuke=1;
    for(int i=1;i<=n;i++){
        sunuke *= i;
        sunuke %= 1000000007;
    }
    
    cout << sunuke << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 112345
int a[N]={};

int main(){
	int n, m; scanf("%d%d", &n, &m);
	REP(i, m){
		int x, y; scanf("%d%d", &x, &y);
		a[x]++; a[y+1]--;
	}
	FOR(i, 1, N) a[i]+=a[i-1];
	int ans = 0;
	REP(i, N) if(a[i]==m) ans++;
	printf("%d\n", ans);
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
} 
int main(){
    ll n;cin >> n;
    vl v(n);rep(i,n)cin >> v[i],v[i]--;
    vl pls(n);
    rep(i,n)pls[v[i]]=i+1;rev(all(pls));
    //rep(i,n)cout << pls[i] <<endl;
    set<ll> st;
    st.ins(0);
    st.ins(n+1);
    ll ans=0;
    rep(i,n){
        //st.ins(pls[i]);
        auto itr=st.lower_bound(pls[i]),itrr=itr;
        itr--;ll l=*itr;itr--;ll l2=*itr;
        ll r=*itrr;itrr++;ll r2=*itrr;
        //cout << l2 <<" " << l <<" " << r <<" " << r2 <<endl;
        if(l!=0){
            ans+=(n-i)*(l-l2)*(r-pls[i]);
        }
        if(r!=n+1){
            ans+=(n-i)*(r2-r)*(pls[i]-l);
        }
        //cout << ans <<endl;
        st.ins(pls[i]);
    }
    cout << ans <<endl;
}

Measured memory_bytes: 9456
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100000
const int INF = 1e9;

int main() {
  int n;
  cin>>n;
  int ml[n];
  int L[n];
  for(int i=0;i<n;i++){
    cin>>L[i];
  }
  ml[0]=0;
  for(int i=0;i<n;i++){
    if(i%2==0){
      ml[0]+=L[i];
    }
    else{
      ml[0]-=L[i];
    }
  }
  for(int i=1;i<n;i++){
    ml[i]=(L[i-1]*2)-ml[i-1];
  }
  for(int i=0;i<n;i++)cout<<ml[i]<<" ";
  cout<<endl;
}

Measured memory_bytes: 2048
N = int(input())
As = [int(i) for i in input().split()]

def xorsum(X):
    x = X[0]
    for i in range(1,len(X)):
        x = x ^ X[i]
    return x

if xorsum(As) == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14116
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;

int main()
{
    ll x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    ll p[a],q[b],r[c];
    for(int i = 0; i < a; i++) cin >> p[i];
    for(int i = 0; i < b; i++) cin >> q[i];
    for(int i = 0; i < c; i++) cin >> r[i];
    sort(p,p+a);
    sort(q,q+b);
    sort(r,r+c);

    vector<ll> red;
    vector<ll> green;
    ll ans = 0;
    
    for(int i = 0; i < x; i++){
        red.push_back(p[a-1-i]);
    }
    for(int i = 0; i < y; i++){
        green.push_back(q[b-1-i]);
    }
    sort(red.begin(),red.end());
    sort(green.begin(),green.end());
    for(int i = 0; i < x; i++) ans += red[i];
    for(int i = 0; i < y; i++) ans += green[i];

    int rcnt = 0,gcnt = 0,cnt = 0;
    for(int i = c-1; i >= 0; i--){
        if(rcnt < x && gcnt < y){
            if(red[rcnt] > green[gcnt]){
                if(r[i] > green[gcnt]){
                    ans += r[i];
                    ans -= green[gcnt];
                    gcnt++;
                }
            }else{
                if(r[i] > red[rcnt]){
                    ans += r[i];
                    ans -= red[rcnt];
                    rcnt++;
                }
            }
        }else if(rcnt < x){
            if(r[i] > red[rcnt]){
                ans += r[i];
                ans -= red[rcnt];
                rcnt++;
            }
        }else if(gcnt < y){
            if(r[i] > green[gcnt]){
                ans += r[i];
                ans -= green[gcnt];
                gcnt++;
            }
        }
    }
    cout << ans ;
}

Measured memory_bytes: 4852
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = int(input())
    print(800 * N - 200 * (N // 15))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3944
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}
const int N=101;
int a[N];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin >> n >> m;
    REP(i,n) cin >> a[i];
    int s=0;
    REP(i,n) s+=a[i];
    int k=0;
    REP(i,n) {
    	if ( a[i]*4*m>=s ) k++;
    }
    if ( k>=m ) cout << "Yes" << '\n';
    else cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 256
import bisect
A, B, Q = map(int, input().split())
INF = 10**18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
x = [int(input()) for i in range(Q)]



def cost(start, s, t):
    if s == t:
        return abs(start - s)

    min_o = min(s, t)
    max_o = max(s, t)
    if start <= min_o:
        return max_o - start
    elif start <= max_o:
        return min(abs(start-min_o), abs(start-max_o)) + (max_o-min_o)
    else:
        return start - min_o


for start in x:
    s_r = bisect.bisect_right(s, start)
    s_l = s_r - 1
    t_r = bisect.bisect_right(t, start)
    t_l = t_r - 1


    res0 = cost(start, s[s_r], t[t_r])
    res1 = cost(start, s[s_r], t[t_l])
    res2 = cost(start, s[s_l], t[t_r])
    res3 = cost(start, s[s_l], t[t_l])
    print(min(res0, res1, res2, res3))

Measured memory_bytes: 16272
import java.util.Arrays;
import java.util.Scanner;



class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);

    	int A[] = new int[3];
    	for(int i = 0;i<3;i++){
    		A[i]=sc.nextInt();
    	}

    Arrays.sort(A);

    A[2]=A[2]*10;
    int B = A[1]+A[2];
    
    System.out.println(B+A[0]);



    }

}

Measured memory_bytes: 21844