akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <type_traits>
using namespace std;

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  double ans = 0;
  int n = read();
  REP(i, n) { ans += 1.0 / read(); }
  ans = 1.0 / ans;
  std::cout << ans << std::endl;
}


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

int main(){
    int N;
    string S;
    int left=0,right=0;
    string T;
    cin >> N >> S;
    T=S;
    while(1){
        int search=(int)S.find("()");
        if(search!=-1){
            S.erase(S.begin()+search,S.begin()+search+2);
        }else{
            break;
        }
    }
    REP(i,S.size()){
        if(S[i]==')'){
            left++;
        }else{
            right++;
        }
    }
    REP(i,left){cout << '(';}
    cout << T ;
    REP(i,right){cout << ')';}
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

int min(int a, int b);

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x);

P dequeue();

int main(){
  int elaps = 0, c, i, q;
  P u;
  
  scanf("%d %d", &n, &q);
  for ( i = 1; i <= n; i++){
    scanf("%s %d", Q[i].name, &Q[i].t);
  }
  head = 1;
  tail = n+1;

  while( head != tail ){
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if ( u.t > 0 ){
      enqueue(u);
    }else{
      printf("%s %d\n",u.name, elaps);
    }
  }  
  return 0;
}

int min(int a, int b){
  return a < b ? a : b;
}

void enqueue(P x){
  Q[tail] = x;
  if ( tail == LEN ) tail = 1;
  else tail++;
}

P dequeue(){
  P x = Q[head];
  if ( head == LEN ) head = 1;
  else head++;
  return x;
}



Measured memory_bytes: 11876
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#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;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
const int INF =1e+9;
int a[30];
int n;
int ans;
void dfs(int diff,int k){
  if(k == n){
    ans = min(ans,abs(diff));
  }else {
    dfs(diff+a[k],k+1);
    dfs(diff-a[k],k+1);
  }
}

int main()
{
  while(cin>>n,n){
    for(int i = 0;i < n;i++){
      cin >>a[i];
    }
    ans = INF;
    dfs(0,0);
    cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1000000007;
# define pi 3.141592
int b,c;
inline double f(double x){
	double v=(x*x+b*x+c)/sin(x);
	return v;
}
ll power(ll a,ll x){
    ll r=1;
    while(x!=0){
        if(x%2==1){
            r=r*a;
        }
        a=a*a;
        x=x/2;
    }
    return r;
}
int main() {
    
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
    	int n;cin>>n;
    	cout<<(n+1)/2;
    } 	
    return 0;   
}	

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cstdio>
#include<string>
#include<vector>
using namespace std;
int main() {
	long long int n, t;
	int q;
	cin >>n >>t >>q;
	vector<long long int> w;
	
	int home[100005] = { 0 };
	
	
	for (long long int i = 0; i < n; i++) {
		long long int a;
		cin >> a >> home[i];
		w.push_back(a);
	}
	
	int key[100005] = {0};
	for (int i = 0; i < q; i++) {
		int a;
		cin >> a;
		key[a - 1] = 1;
	}
	int west = 0;
	
	
	long long int east2 = 0;
	vector<long long int> talkpoint;
	long long int tp;
	for (long long int i = 0; i < n; i++) {
		
			if (home[i]==2) {
				if (west==0) {
					
						long long int b = w[i] - t;
						talkpoint.push_back(b);
				
				}
				else {
					talkpoint.push_back(tp);
					
					
				}
			}
			if (home[i]==1) {
				
					if (home[i + 1] == 2) {
						tp = (w[i] + w[i + 1]) / 2;
						for (long long int j = 0; j <= east2; j++) {
							talkpoint.push_back(tp);
						}
						west = 1;
						east2 = 0;
					}
					else if (i == n - 1) {
						
						for (long long int j = east2; j >=0; j--) {
							long long int d = w[i-j] + t;
							talkpoint.push_back(d);
							east2 = 0;
						}
						
					}
					else {
						east2++;
						west = 1;
					}
				

			}

		
	}
	for (long long int i = 0; i < n; i++) {
		if (key[i] == 1) {
			
			long long int e;
			if (talkpoint[i] < w[i]) {
				e = w[i] - talkpoint[i];
			}
			else {
				e = talkpoint[i] - w[i];
			}
			if (e <= t) {
				cout << talkpoint[i] << endl;
			}
			else {
				if (home[i] == 1) {
					cout << w[i] + t << endl;
				}
				else {
					cout << w[i] - t << endl;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 5840
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]


answer = set("1 2 3".split())
a = fetch_one_line()
b = fetch_one_line()

print(list(answer - set(a) - set(b))[0])



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

#define f first
#define s second

typedef long long ll;
typedef pair<ll,ll> pi;

const int MAXN = 50000005, INF = 1e9+7;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll h,n;
	cin >> h >> n;
	vector<pi> spells(n);
	for (int i = 0; i < n; ++i) cin >> spells[i].f  >> spells[i].s;
	vector<ll> dp(MAXN,INF);
	dp[0] = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j <= h; ++j) {
			if (j >= spells[i].f) {
				dp[j] = min(dp[j],dp[j-spells[i].f]+spells[i].s);
			} else {
				dp[j] = min(dp[j],spells[i].s);
			}
		}
	}
	cout<<dp[h];
	//for (int i = 0; i <= 10; ++i) cout << dp[i] << ' ';
    return 0;
}


Measured memory_bytes: 390912
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int h,w,a,b;
  cin>>h>>w>>a>>b;
  rep(i,h){
    rep(j,w){
      if(j<a && i<b) cout<<1;
      if(j>=a && i<b) cout<<0;
      if(j<a && i>=b) cout<<0;
      if(j>=a && i>=b) cout<<1;
    }
    cout<<endl;
  }

  return 0;
}


Measured memory_bytes: 1280
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int compare_char(const void* left, const void* right) {
    char *left_char = (char *)left;
    char *right_char = (char *)right;

    return strcmp( left_char, right_char );
}

int main(){
  int n;
  scanf("%d",&n);
  char s[200001][11];
  for(int i=0;i<n;i++){
    scanf("%s",s[i]);}
  qsort(s,n,sizeof(s[0]),compare_char);

  int ans=1;
  for(int i=1;i<n;i++){
    if(strcmp(s[i],s[i-1])!=0){
      ans++;}}
  printf("%d\n",ans);
  
  return 0;
}


Measured memory_bytes: 5740
#include <stdio.h>

	int sima[51][51];
	int cnt=0;
	int cflag=0;

int count_sima(int w,int h){
	if(w<0)return 0;
	if(h<0)return 0;
	if(sima[w][h]==3)return 0;
	if(sima[w][h]==0)return 0;

		if(cflag==0){
			cnt++;
			cflag=1;
		}
		

		sima[w][h]=0;

		count_sima(w,h+1);
		count_sima(w+1,h+1);
		count_sima(w+1,h);
		count_sima(w+1,h-1);
		count_sima(w,h-1);
		count_sima(w-1,h-1);
		count_sima(w-1,h);
		count_sima(w-1,h+1);


	return 0;
}


int main(void){
	int w2,h2; //島の大きさを格納する
	int p;

	scanf("%d %d",&w2,&h2);
	while(w2!=0 && h2!=0){

		//島配列をすべてを3にする
		for(int i=0; i<51; i++){
			for(int j=0; j<51; j++){
				sima[i][j]=3;
			}
		}

		//入力された地図のデータを設定
		for(int i=0; i<h2; i++){
			for(int j=0; j<w2; j++){
				scanf("%d",&p);
				sima[i][j]=p;
			}
		}

		//ここまで入力された地図のデータを設定

		for(int i=0; i<h2; i++){
			for(int j=0; j<w2; j++){
				count_sima(i,j);
				cflag=0;
			}
		}

		printf("%d\n",cnt);
		cnt=0;

		scanf("%d %d",&w2,&h2);
	}

	return 0;
}

Measured memory_bytes: 1140
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std ;
int N;
int main(){
    cin >> N;
    int d[N];
    for(int i=0;i<N;i++)cin >> d[i];
    int sum = 0;
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            sum += d[i] * d[j];
        }
    }
    cout << sum << "\n";
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "trace.h"
#else
#define trace(args...)
#endif

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()

void solve(int test) {
    int k;
    cin >> k;
    int num = 7 % k, cnt = 1;
    map<int, int> seen;
    while (seen.find(num) == seen.end()) {
        seen[num] = 1;
        if(!num) break;
        num = (10 * num + 7) % k;
        cnt++;
    }
    if (seen.find(0) == seen.end()) cnt = -1;
    cout << cnt << '\n';
}

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


Measured memory_bytes: 50520
from collections import deque

n = int(input())

adj = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int,input().split())
    adj[a-1].append([b-1,i])
    adj[b-1].append([a-1,i])

mx_color = 0    
for i in range(n):
    mx_color = max(mx_color,len(adj[i]))

dist = [-1]*n

res = [-1]*(n-1)

q = deque([])
q.append([0,-1])
dist[0] = 0

while len(q) > 0:
    v,c = q.popleft()
    color = 1
    
    if color == c:
        color += 1
        
    for nv,nc in adj[v]:
        if dist[nv] == -1:
            dist[nv] = dist[v] + 1
            q.append([nv,color])
            res[nc] = color
            color += 1
            if color == c:
                color += 1

print(mx_color)

for i in res:
    print(i)

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

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  int answer = 1;
  for (int i = 0; i < N; i++) {
    if (answer < K) {
      answer *= 2;
    } else {
      answer += K;
    }
  }
  cout << answer;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
zero = A.count(0)
one = A.count(1)

if zero >= 1:
    print(0)
elif (N - one) > 100:
    print(-1)
else:
    ans = 1
    for a in A:
        ans *= a
    if ans > 10**18:
        print(-1)
    else:
        print(ans)

Measured memory_bytes: 21648
#include <bits/stdc++.h>
using namespace std;
long long oll = 0;
#define ll long long
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define pii pair<int,int>
#define lcm(a,b) a*b/__gcd(a,b)
#define fl(i,a,b) for(int i = a;i < b;i++)
#define lf(i,a,b) for(int i = b;i >= a;i--)
#define MEM(x,y) memset(x,y,sizeof(x))
#define mp make_pair


void solve()
{
    double l;
    cin>>l;
    l /= 3;
    printf("%0.8lf\n",l*l*l);
}

int main()
{
    //FIO;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.*

const val MOD: Long = (1e9+7).toLong()
fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun <T : Comparable<T>> Iterable<T>.argmax(): Int? = withIndex().maxBy{it.value}?.index
fun <T : Comparable<T>> Iterable<T>.argmin(): Int? = withIndex().minBy{it.value}?.index

fun main(args: Array<String>) {
    val reader = System.`in`.bufferedReader()
    val (n, k) = reader.readLine()!!.split(" ").map{it.toInt()}
    val v = reader.readLine()!!.split(" ").map{it.toInt()}

    var res = -Int.MAX_VALUE
    for (i in 0..k-1) {
        val x = k-i
        if (x >= n) {
            var list = v.toList()

            var sum = list.sum()
            list = list.toTypedArray().sorted().toList()
            for (y in 0..i-1) {
                if (y >= list.size) break
                if (list[y] < 0) {
                    sum -= list[y]
                }
            }
            if (sum > res) {
                res = sum
            }
        } else {
            for (j in -x..0) {
                var list = listOf<Int>()
                if (j < 0) {
                    list = list.plus(v.takeLast(-j))
                }
                list = list.plus(v.take(x+j))

                var sum = list.sum()
                list = list.toTypedArray().sorted().toList()
                for (y in 0..i-1) {
                    if (y >= list.size) break
                    if (list[y] < 0) {
                        sum -= list[y]
                    }
                }
                if (sum > res) {
                    res = sum
                }
            }
        }
    }
    println(if (res < 0) 0 else res)
}


Measured memory_bytes: 40404
import java.util.Scanner;
public class Main{
     
    public void solve(){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        for(int cnt=0;cnt<N;cnt++){
            int x = sc.nextInt();
            int y = sc.nextInt();
            int b = sc.nextInt();
            int p = sc.nextInt();
            int gokei=x*b+y*p;
            if(b<5){
                b=5;
            }
            if(p<2){
                p=2;
            }
            int waribikigo=(x*b+y*p)*8/10;
            if(gokei>=waribikigo){
                System.out.println(waribikigo);
            }else{
                System.out.println(gokei);
            }
        }
    }
    public static void main(String[]args){
        Main obj = new Main();
        obj.solve();
    }
}

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

const int64_t mx = 1e18;

int main() {
  int N;
  cin >> N;
  bool ng = false;
  int64_t ans = 1;

  for (int i = 0; i < N; i++) {
    int64_t A;
    cin >> A;

    if (A == 0) {
      cout << 0 << endl;
      return 0;
    }

    if (ng || (mx + 1)/ans < A || mx < A * ans) {
      ng = true;
    }
    
    ans *= A;

  }

  if (ng) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

// 最大公約数を求める(ユークリッドの互除法).
ll gcd (ll x, ll y) {
  if (y > x) swap(x,y);
  if (y == 0) return x;
  return gcd(x%y,y);
}

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n,0);
  ll mmax = 0;

  rep(i,n) {
    cin >> a[i];
    if (a[i] == k) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
    mmax = max(mmax, a[i]);
  }

  if (k >= mmax) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }

  ll c = a[0];
  for (auto itr : a) {
    c = gcd(c,itr);
  }

  if (k % c == 0) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define lli long long int
#define llu unsigned long long int
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

void solve() {
    lli n, a;
    cin >> n;
    vector<lli> v;
    lli sum = 0;
    for (lli i = 0; i < n; i++) {
        cin >> a;
        sum += a;
        sum %= MOD;
        v.pb(a);
    }

    lli ans = 0;
    for (lli i = 0; i < n; i++) {
        sum -= v[i];
        sum += MOD;
        sum %= MOD;
        lli val = (v[i] * sum) % MOD;
        ans += val;
        ans %= MOD;
    }

    cout << ans << endl;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

Measured memory_bytes: 5328
#include <iostream>
#include <vector>
#include <boost/range/irange.hpp>
#include <algorithm>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    string s, d;
    for (auto &&i: irange(0U, 2U)){
        cin >> s >> d;
    }
    reverse(d.begin(), d.end());
    if (s==d){
        cout << "YES";
    } else {
        cout << "NO";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  vector<int> vec(a);
  bool flag = false;
  for (int i = 0; i < a; i++) {
    cin >> vec[i];
    if (vec[i] % 2 != 0) flag = true;
  }
  if (flag) cout << fixed << (long long)pow(2, a - 1) << endl;
  else if (!flag && b == 1) cout << 0 << endl;
  else cout << fixed << (long long)pow(2, a) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    while (cin>>n) {
        if (n==1) {
            break;
        }
        std::deque<int> deq;
        double SqrtNum=sqrt(n);
        for (int i=1;i<=SqrtNum;i++) {
            if (n%i==0) {
                if (i%7==1||i%7==6) {
                    deq.emplace_back(i);
                    if ((n/i)%7==1||(n/i)%7==6) {
                        deq.emplace_back(n/i);
                    }
                }
            }
        }
        std::deque<int> ans;
        for (int i=0;i<deq.size();i++) {
            if (deq[i]!=1) {
                SqrtNum=sqrt(deq[i]);
                std::deque<int> tmp;
                for (int j=1;j<=SqrtNum;j++) {
                    if (deq[i]%j==0) {
                        if (j%7==1||j%7==6) {
                            tmp.emplace_back(deq[i]);
                            if ((deq[i]/j)%7==1||(deq[i]/j)%7==6) {
                                tmp.emplace_back(deq[i]/j);
                            }
                        }
                    }
                }
                if (tmp.size()==2) {
                    ans.emplace_back(deq[i]);
                }
            }
        }
        sort(ans.begin(),ans.end());
        cout<<n<<": ";
        int last=0;
        for (int i=0;i<ans.size();i++) {
            if (i==0) {
                cout<<ans[i];
            } else {
                if (ans[i]!=last) {
                    cout<<" "<<ans[i];
                }
            }
            last=ans[i];
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3104
N=int(input())
ans=N
for i in range(N+1):
    element_cnt=0
    t=i
    '''Nを6の累乗で処理する部分(i)と9の累乗で処理する部分(j)に分ける
    ある数(i)を6で割った余りは6のゼロ乗の要素がいくつ含まれるかを示す
    ある数の6の商をさらに6で割った余りは、ある数に6の1乗がいくつ含まれるかを示す
    ある数の6の商の6の商をさらに6で割った余りは、ある数に6の2乗がいくつ含まれるかを示す
    したがって、ある数を6で割って余りと商を順に処理すれば6の累乗の要素がどれだけあるかがわかる。
    最終的に商がゼロになるまで繰り返す
    '''
    while t>0:
        element_cnt+=t%6
        t//=6
    j=N-i
    while j>0:
        element_cnt+=j%9
        j//=9
    ans = min(ans,element_cnt)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>

using namespace std;

template<typename T>
class Stack {
private:
    struct Node {
        T val;
        Node *next;
    };

    Node *top;

public:
    Stack() {
        top = new Node();
    }

    void push(T a) {
        Node *top_old = top;
        top = new Node();
        top->val = a;
        top->next = top_old;
        return;
    }

    T pop() {
        Node *top_old = top;
        T v = top_old->val;
        top = top_old->next;
        delete top_old;
        return v;
    }
};

int64_t calc(Stack<string> &s) {
    string str = s.pop();
    if (str == "+") {
        return calc(s) + calc(s);
    } else if (str == "-") {
        int64_t a = calc(s);
        int64_t b = calc(s);
        return b - a;
    } else if (str == "*") {
        return calc(s) * calc(s);
    } else {
        return stoi(str);
    }
}

int main() {
    string str;
    Stack<string> s;

    while (cin >> str) s.push(str);
    cout << calc(s) << endl;

    return 0;
}

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

fn main() {
    let n: usize = read();
    let k: usize = read();
    let mut h: Vec<i64> = (0..n).map(|_| read()).collect();
    h.sort();

    let mut ans = h[n - 1];
    for i in 0..n - k + 1 {
        let d = h[i + k - 1] - h[i];
        ans = std::cmp::min(ans, d);
    }
    println!("{}", ans);
}

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


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i;
  string s;
  cin>>n>>s;
  for(i=0;i<s.size();i++){
    s.at(i)+=n;
  if(s.at(i)>90)
    s.at(i)-=26;
  }
  cout<<s<<endl;
}

Measured memory_bytes: 256
import itertools
N = int(input())
L= list(map(int,input().split()))
#LList = (list(itertools.permutations(L,3)))
cnt = 0

for i in range(N):
    for j in range(i+1,N):
        for n in range(j+1,N):
            if (L[i] < L[j] + L[n]):
                if (L[j] < L[i] + L[n]):
                    if (L[n] < L[i] + L[j]):
                        if(L[n] != L[i]):
                            if(L[j] != L[i]):
                                if(L[n] != L[j]):
                                    cnt += 1
# for i in range(len(LList)):
#     if (LList[i][0] < LList[i][1] + LList[i][2]):
#         if (LList[i][1] < LList[i][0] + LList[i][2]) :
#             if (LList[i][2] < LList[i][0] + LList[i][1]) :
#                 if LList[i][0] != LList[i][1] :
#                     if LList[i][0] != LList[i][2] :
#                         if LList[i][1] != LList[i][2]:
#                             print(LList[i])
#                             cnt += 1

print(cnt)

Measured memory_bytes: 73936
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N,A;cin >> N >> A;
    vector<int> x(N,0);
    rep(i,N){
        cin >> x[i];
        x[i]-=A;
    }
    sort(All(x));
    int x_max = x[N-1];
    ll dp[55][5050];
    rep(i,55)rep(j,5050)dp[i][j]=0;
    dp[0][N*x_max]=1;
    for(int i=0;i<N;i++){
        for(int j=0;j<=5000;j++){
            dp[i+1][j]+=dp[i][j];//選ばない
            dp[i+1][j+x[i]]+=dp[i][j];//選ぶ
        }
    }
    cout << max(0LL,dp[N][N*x_max]-1LL) << endl;
    return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll r,D,x;cin>>r>>D>>x;
	For(i,0,10){
		x = r*x-D;
		cout<<x<<endl;
	}











	
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc131/tasks/abc131_b
#include <bits/stdc++.h>
using namespace std;

int main(void){
  int N, L;
  cin >> N >> L;
  int ans = 10000;
  int sum = 0;
  int tmp = 0;
  for (int i = 0; i < N; i++){
    ans = min(ans, abs(L + i));
    if (ans == abs(L + i)){
      tmp = L + i;
    }
      sum += L + i;
  }
  cout << sum - tmp << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

int n,m,a[305][305],p[305],cnt[305],mx,t,h[305],ans=1e9;

int32_t main(){
    ios_base :: sync_with_stdio(0);
    cin >> n >> m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin >> a[i][j];
        }
        h[i]=1;
    }
    for(int i=1;i<=m;i++){
        for(int k=1;k<=m;k++) cnt[k]=0;
        for(int j=1;j<=n;j++){
            cnt[a[j][h[j]]]++;
        }
        mx=0,t=0;
        for(int j=1;j<=m;j++){
            if(cnt[j]>mx) mx=cnt[j],t=j;
        }
        ans=min(ans,mx);
        p[t]=1;
        for(int j=1;j<=n;j++){
            while(p[a[j][h[j]]]) h[j]++;
        }
    }
    cout << ans;
}


Measured memory_bytes: 640
$MEMOS = {}

def exhaustive_search nums, target
  return $MEMOS[[nums, target]] if $MEMOS.has_key?([nums, target])

  num_len = nums.length
  if target == 0
    return true
  else
    if target < 0 || num_len == 0
      return false
    else
      sliced_nums = nums.slice(1..(num_len - 1))
      res = exhaustive_search(sliced_nums, target - nums[0]) || exhaustive_search(sliced_nums, target)
      $MEMOS[[nums, target]] = res
      return res ? true : false
    end
  end
end

n = gets.chomp.to_i
as = gets.chomp.split(' ').map(&:to_i)
q = gets.chomp.to_i
ms = gets.chomp.split(' ').map(&:to_i)
ms.each do |m|
  puts exhaustive_search(as, m) ? 'yes' : 'no'
end


Measured memory_bytes: 9632
#include<iostream>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

int main()
{
    int n;
    int i;
    int k;
    cin>>n;
    cin>>k;
    int array[n];
    int dp[n];
    for(i=0;i<n;i++)
    {
        cin>>array[i];
    }
    dp[0] = 0;
    dp[1] = abs(array[1] - array[0]); 
    int j;
    for(i=2;i<n;i++)
    {
        int prevMin = INT_MAX;
        for(j = 1; j<=k; j++)
        {
            if(i >= j)
                prevMin = min(dp[i-j] + abs(array[i] - array[i-j]), prevMin);
        }
        dp[i] = prevMin;
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[sz(V)-2])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define upmax(a,b) (a)=max((a),(b))
#define upmin(a,b) (a)=min((a),(b))
#define rb(x) ((x)&(-(x)))
#define INF (0x3f3f3f3f)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll pw(ll n) { return n*n; }
pll operator - (pll a, pll b) { return pll(a.first-b.first, a.second-b.second); }
ll operator * (pll a, pll b) { return a.first*b.second - b.first*a.second; }
ll ccw(pll a, pll b, pll c) { return a*b + b*c + c*a; }
ll dst(pll a) { return pw(a.first) + pw(a.second); }

const int MAXN = 305;

int dp[MAXN][MAXN][MAXN];

vector<int> V[26];

int A[MAXN];

int N, K;

int f(int s, int e, int k) {
	if(s > e || k < 0) return 0;
	if(s == e) return 1;
	int &ret = dp[s][e][k];
	if(0 <= ret) return ret;

	ret = 1;

	if(A[s] == A[e])
		upmax(ret, f(s+1, e-1, k) + 2);
	{
		int ei = (int)(upper_bound(allv(V[A[s]]), e) - V[A[s]].begin()) - 1;
		if(0 <= ei && s < V[A[s]][ei])
			upmax(ret, f(s+1, V[A[s]][ei]-1, k) + 2);
	}
	{
		int si = (int)(lower_bound(allv(V[A[e]]), s) - V[A[e]].begin());
		if(0 <= si && V[A[e]][si] < e)
			upmax(ret, f(V[A[e]][si]+1, e-1, k) + 2);
	}
	if(k) upmax(ret, f(s+1, e-1, k-1) + 2);
	upmax(ret, f(s, e-1, k));
	upmax(ret, f(s+1, e, k));

	return ret;
}
char str[MAXN] = {0};
int main() {
	{

		scanf(" %s", str+1);
		N = int(strlen(str+1));
		scanf("%d", &K);

		for(int i = 1; i <= N; i++)
			A[i] = str[i] - 'a';
	}

	for(int i = 1; i <= N; i++)
		V[A[i]].pb(i);

	for(int i = 0; i <= N; i++) for(int j = 0; j <= N; j++)
		fill(dp[i][j], dp[i][j]+N+1, -1);

	cout << f(1, N, K) << endl;

	return 0;
}

Measured memory_bytes: 110976
#include <iostream>
#include<math.h>
using namespace std;
int main(void){
   int i,j,n;
   cin>>n;
   string s;
   int c[100][26]={{0}};
   int min[26];
   
   for(i=0;i<n;i++){
       cin>>s;
       for(j=0;s[j]!=NULL;j++){
           c[i][s[j]-'a']++;
       }
   }
   
   for(i=0;i<26;i++){
       min[i]=c[0][i];
       for(j=1;j<n;j++){
           min[i]=fmin(min[i],c[j][i]);
       }
   }
   
   for(i=0;i<26;i++){
       for(j=0;j<min[i];j++){
           putchar('a'+i);
       }
   }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sc scanf
#define pr printf
#define pb push_back
#define ll long long int
int main()
{
    ll n,t=1;
    while(1)
    {
        cin>>n;
        if(n==1||n==2||n==4)
            break;
        if(n%2)
            n=3*n+1;
        else
            n/=2;
        t++;
    }
    cout<<t+3<<endl;



    return 0;
}


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

constexpr unsigned long MOD = 1000000007;
template<size_t maxN>
struct factmod{
    unsigned long val[maxN + 1];
    constexpr factmod() : val() {
        val[0] = 1;
        for(unsigned long i{1}; i <= maxN; ++i)val[i] = val[i - 1] * i % MOD;
    }
    constexpr unsigned long operator[](unsigned long i) const { return val[i]; }
};

constexpr factmod<2000002> fm = factmod<2000002>();

int main(){
    using namespace std;
    unsigned long r1, r2, c1, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    ++r2;
    ++c2;
    unsigned long N{r2 + c2};
    const auto& binom = [](unsigned long k, unsigned long c) -> unsigned long {
        unsigned long r{fm[k + c]}, a{fm[k] * fm[c] % MOD}, n{MOD - 2};
        while(n){
            if(n & 1)(r *= a) %= MOD;
            (a *= a) %= MOD;
            n >>= 1;
        }
        return r;
    };
    unsigned long f11{binom(r1, c1)}, f12{binom(r1, c2)}, f21{binom(r2, c1)}, f22{binom(r2, c2)};
    cout << (MOD * 2 + f22 + f11 - f12 - f21) % MOD << endl;
    return 0;
}

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

using namespace std;

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

    int N;
    cin >> N;

    long long ans = 0;

    for(int A = 1; A < N; A++){
        for(int B = 1; A*B < N; B++){
            if(N - A*B > 0) ans++;
        }
    }

    cout << ans << '\n';
    return 0;

}

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

int main(){
    long long n,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        if(i%3==0&&i%5==0){
            continue;
        }else if(i%3==0){
            continue;
        }else if(i%5==0){
            continue;
        }else{
            sum+=i;
        }
    }
    cout<<sum<<"\n";
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  string s;
  cin >> s;
  if (s.substr(0, 4) == "YAKI") cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
check=[i*i for i in range(1000)]
n,d=list(map(int,input().split()))

def distance(x,y):
  num=0
  for i in range(d):
    num=num+(x[i]-y[i])*(x[i]-y[i])
  return num

diff=[]
for i in range(n):
  x=list(map(int,input().split()))
  diff.append(x)

ans=0
for i in range(n-1):
  for j in range(i+1,n):
    k=distance(diff[i],diff[j])
    if k in check:
      ans+=1
  
print(ans)


Measured memory_bytes: 62288
n, m, x = map(int, input().split())
c = [None] * n
a = []
for i in range(n):
    l = list(map(int, input().split()))
    c[i] = l[0]
    l = l[1:]
    a.append(l)

ans = 1200001
for pat in range(2**n):
    score = [0 for i in range(m)]
    cost = 0
    for i in range(n):
        if pat & (2**i):
            for j in range(m):
                score[j] += a[i][j]
            cost += c[i]
    if cost < ans:
        f = True
        for sc in score:
            if sc < x:
                f = False
                break
        if f:
            ans = cost
if ans == 1200001:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 87464
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
int main()
{
    vector<int> a(5);
    for (int i = 0; i < 5; ++i) cin >> a[i];
    sort(a.rbegin(), a.rend());
    for (int i = 0; i < 4; ++i) cout << a[i] << ' '; cout << a[4] << endl;
    return 0;
}

Measured memory_bytes: 0
class Graph():  #non-directed
    def __init__(self, n, edge, indexed=1):
        self.n = n
        self.edge = edge
        self.indexed = indexed
        self.graph = [[] for _ in range(n)]
        for e in edge:
            self.graph[e[0] - indexed].append((e[1] - indexed, e[2]))
            self.graph[e[1] - indexed].append((e[0] - indexed, e[2]))

    def kruskal(self):  #UnionFind
        #edgemap = {self.edge[i]: i for i in range(len(self.edge))}
        sortedge = sorted(self.edge, key=lambda x: x[2])
        #sortedge = reversed(sortedge) コストの最大化
        uf = UnionFind(self.n)
        res = 0
        restored = []
        for e in sortedge:
            if uf.find(e[0] - self.indexed) != uf.find(e[1] - self.indexed):
                res += e[2]
                #restored.append(edgemap[e])
                uf.unite(e[0] - self.indexed, e[1] - self.indexed)
        return res#, restored

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        root = x
        while self.parents[root] != root:
            root = self.parents[root]
        while self.parents[x] != root:
            parent = self.parents[x]
            self.parents[x] = root
            x = parent
        return root

    def unite(self, x, y):
        xroot = self.find(x)
        yroot = self.find(y)
        if xroot == yroot: return
        xrank = self.rank[xroot]
        yrank = self.rank[yroot]
        if xrank < yrank:
            self.parents[xroot] = yroot
            self.size[yroot] += self.size[xroot]
        elif xrank == yrank:
            self.parents[yroot] = xroot
            self.rank[yroot] += 1
            self.size[xroot] += self.size[yroot]
        else:
            self.parents[yroot] = xroot
            self.size[xroot] += self.size[yroot]

import sys
input = sys.stdin.readline

N = int(input())
T = []

for i in range(N):
    x, y = map(int, input().split())
    T.append((x, y, i))

sort_by_x = sorted(T, key=lambda x: x[0])
sort_by_y = sorted(T, key=lambda x: x[1])

E = []

for i in range(N - 1):
    x1, y1, id1 = sort_by_x[i]
    x2, y2 ,id2 = sort_by_x[i + 1]
    E.append((id1, id2, min(abs(x1 - x2), abs(y1 - y2))))
    x1, y1, id1 = sort_by_y[i]
    x2, y2 ,id2 = sort_by_y[i + 1]
    E.append((id1, id2, min(abs(x1 - x2), abs(y1 - y2))))

g = Graph(N, E)

print(g.kruskal())

Measured memory_bytes: 122720
num = int(input())
A = [int(i) for i in input().split()]
max_move=0
tmp=0
for i in range(0,num-1):
    if(A[i] >= A[i+1]):
        tmp=tmp+1
        if(i+1==num-1 and max_move< tmp):
            max_move=tmp
    else:
        if(max_move<tmp):
            max_move=tmp
        tmp=0
print(max_move)


Measured memory_bytes: 14252
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int fw(const void *a, const void *b)
{
	return *(char*)a - *(char*)b;
}
int bw(const void *a, const void *b)
{
	return *(char*)b - *(char*)a;
}
int main() {
	char s[111], t[111];
	unsigned int l1, l2;
	scanf("%s%s", s, t);
	l1 = strlen(s);
	l2 = strlen(t);
	qsort(s, l1, sizeof(char), fw);
	qsort(t, l2, sizeof(char), bw);
	for (int i = 0; i <= l1; i++)
	{
		if (s[i] < t[i])
		{
			printf("Yes");
			return 0;
		}
		else if (s[i] == t[i]) {}
		else
		{
			break;
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, K;
	cin >> N >> K;

	vector<Int> a(N);
	for (Int i = 0; i < N; i++) {
		cin >> a[i];
	}

	vector<vector<mint>> dp(N+1, vector<mint>(K+1));//dp[i+1][j]:i番目までの生徒に飴をj個配る方法
	dp[0][0] = 1;

	vector<vector<mint>> s(N+1, vector<mint>(K+2));//累積和用
	fill(s[0].begin(), s[0].end(), 1);
	s[0][0] = 0;

	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j <= K; j++) {
			dp[i + 1][j] += s[i][j + 1] - s[i][max(0LL, j - a[i])];
		}

		//累積和の作成
		for (Int j = 0; j < K+1; j++) {
			s[i + 1][j + 1] = s[i + 1][j] + dp[i + 1][j];
		}
	}


	cout << dp[N][K] << "\n";
}


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

#define F                   first
#define S                   second
#define int                 long long int
#define pb                  push_back
#define mp                  make_pair
#define pii                 pair<int,int>
#define vi                  vector<int>
#define mii                 map<int,int>
#define pqb                 priority_queue<int>
#define pqs                 priority_queue<int,vi,greater<int> >
#define mod                 1000000007
#define endl                '\n'
#define rep(i,a,b)            for(int i=a;i<b;i++)
int n, m;
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
    c_p_c();

    cin >> n >> m;
    vector<vector<char>> a(n + 1, vector<char>(m + 1, 0));
    vector<vector<int>> dp(n + 1, vi(m + 1, 0));

    rep(i, 0, n) {
        rep(j, 0, m) {
            cin >> a[i][j];

        }
    }
    for (int i = n - 1; i >= 0; i--) {
        for (int j = m - 1; j >= 0; j--) {
            if (i == n - 1 and j == m - 1 ) {
                dp[i][j] = 1;
                continue;
            }
            if (a[i][j] == '#') {
                continue;
            }
            else {
                dp[i][j] = (dp[i + 1][j] % mod + dp[i][j + 1] % mod) % mod;
            }
        }
    }
    int ans = 0;
    cout << dp[0][0] % mod;

    return 0;
}

Measured memory_bytes: 12132
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
from functools import reduce
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
a=lin(n)

arr=Counter(a)
v=list(arr.values())
ans=0
for i in range(len(v)):
    if v[i]%2==1:
        ans+=1
print(ans)
    




Measured memory_bytes: 81240
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define mat vector<vector<int>>
const int inf = 1 << 30;
const ll linf = 1e18;
const db EPS = 1e-7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N, M;
int edge[710][710];
int st[710];
bool flag = true;
vector<pii> ps;

void dfs(int v, int* dat){
    dat[st[v]]++;
    int to = (st[v] + 1) & 1;
    for(int i = 1; i <= N; ++i){
        if(edge[v][i] == 0){
            if(st[i] == -1) st[i] = to, dfs(i, dat);
            else if(st[i] != to) flag = false;
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> M;
    for(int i = 1; i <= N; ++i) st[i] = -1, edge[i][i] = 1;
    for(int i = 0; i < M; ++i){
        int A, B;
        cin >> A >> B;
        edge[A][B] = 1;
        edge[B][A] = 1;
    }
    for(int i = 1; i <= N; ++i){
        if(st[i] != -1) continue;
        bool judge = false;
        for(int j = 1; j <= N; ++j){
            if(edge[i][j] == 0) judge = true;
        }
        if(judge){
            int dat[2] = {};
            st[i] = 0;
            dfs(i, dat);
            ps.push_back({dat[0], dat[1]});
        }
    }
    
    int cnt = 0;
    for(int i = 1; i <= N; i++) if(st[i] == -1) cnt++;
    if(flag){
        int t = 0, h = 0;
        bitset<710> ok = {};
        ok[0] = 1;
        for(auto u : ps){
            ok = (ok << u.first) | (ok << u.second);
        }
        bitset<710> res;
        for(int i = 0; i < N; ++i){
            if(ok[i] == 1){
                for(int j = 0; j <= cnt; ++j){
                    res[i + j] = 1;
                }
            }
        }

        int ans = inf;
        for(int i = 0; i <= N; ++i){
            if(res[i] == 1){
                auto culc = [] (int a){return a * (a - 1) / 2;};
                chmin(ans, culc(i) + culc(N - i));
            }
        }
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 2176
from sys import stdout


def upper(n):
    if n < 5:
        return ['*', ' ']
    else:
        return [' ', '*']


def lower(n):
    m = n % 5
    return ['*'] * m + [' '] + ['*'] * (4 - m)


def abacus(n):
    return upper(n) + ['='] + lower(n)


res = []
while True:
    try:
        ns = map(int, ('00000' + raw_input().strip())[-5:])
    except EOFError:
        break

    ab = []
    for n in ns:
        ab.append(abacus(n))

    for i in range(8):
        for j in range(5):
            res.append(ab[j][i])
        res.append('\n')
    res.append('\n')

stdout.write(''.join(res[:-1]))

Measured memory_bytes: 4908
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> l(n);
  long long ans = 0;
  for(int i = 0; i < n; i++) cin >> l[i];
  sort(l.begin(), l.end());
  for(int i = n-1; i >= 2; i--){
    int a = l[i];
    for(int j = i-1; j >= 1; j--){
      int b = l[j];
      if(j > (lower_bound(l.begin(), l.end(), a-b+1) - l.begin()))
        ans += j-(lower_bound(l.begin(), l.end(), a-b+1) - l.begin());
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256