akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
char a[100009];
int b[100009];
int n;
int f(int s1,int s2)
{
    b[1]=s1;
    b[2]=s2;
    for(int i=3; i<=n; i++)
    {
        if(a[i-1]=='o')
        {
            if(b[i-1]==1)
            {
                b[i]=b[i-2]^1;
            }
            if(b[i-1]==0)
            {
                b[i]=b[i-2];
            }
        }
        else if(a[i-1]=='x')
        {
            if(b[i-1]==0)
            {
                b[i]=b[i-2]^1;
            }
            if(b[i-1]==1)
            {
                b[i]=b[i-2];
            }
        }
    }
    if(b[1]==b[n-1]&&b[n]==b[2])
    {
        if(b[n]==0&&a[n]=='o'&&b[1]==0&&a[1]=='o')
        {
            return 1;
        }
        else if(b[n]==1&&a[n]=='x'&&b[1]==0&&a[1]=='o')
        {
            return 1;
        }
        else if(b[n]==1&&a[n]=='x'&&b[1]==1&&a[1]=='x')
        {
            return 1;
        }
        else if(b[n]==0&&a[n]=='o'&&b[1]==1&&a[1]=='x')
        {
            return 1;
        }
    }
    else if(b[1]!=b[n-1]&&b[n]==b[2])
    {
        if(b[n]==0&&a[n]=='x'&&b[1]==0&&a[1]=='o')
        {
            return 1;
        }
        else if(b[n]==1&&a[n]=='o'&&b[1]==1&&a[1]=='x')
        {
            return 1;
        }
        else if(b[n]==0&&a[n]=='x'&&b[1]==1&&a[1]=='x')
        {
            return 1;
        }
        else if(b[n]==1&&a[n]=='o'&&b[1]==0&&a[1]=='o')
        {
            return 1;
        }
    }
    else if(b[1]==b[n-1]&&b[n]!=b[2])
    {
        if(b[n]==0&&a[n]=='o'&&b[1]==0&&a[1]=='x')
        {
            return 1;
        }
        else if(b[n]==1&&a[n]=='x'&&b[1]==1&&a[1]=='o')
        {
            return 1;
        }
        else if(b[n]==0&&a[n]=='o'&&b[1]==1&&a[1]=='o')
        {
            return 1;
        }
        else if(b[n]==1&&a[n]=='x'&&b[1]==0&&a[1]=='x')
        {
            return 1;
        }
    }
    else if(b[1]!=b[n-1]&&b[n]!=b[2])
    {
        if(b[n]==0&&a[n]=='x'&&b[1]==0&&a[1]=='x')
        {
            return 1;
        }
        else if(b[n]==1&&a[n]=='o'&&b[1]==1&&a[1]=='o')
        {
            return 1;
        }
        else if(b[n]==0&&a[n]=='x'&&b[1]==1&&a[1]=='o')
        {
            return 1;
        }
        else if(b[n]==1&&a[n]=='o'&&b[1]==0&&a[1]=='x')
        {
            return 1;
        }
    }
    return 0;
}
int main()
{
    cin>>n;

    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
    }
    for(int i=0; i<=1; i++)
    {
        for(int j=0; j<=1; j++)
        {
            if(f(i,j))
            {
                for(int u=1; u<=n; u++)
                {
                    if(b[u]==1)
                    {
                        cout<<"W";
                    }
                    else
                    {
                        cout<<"S";
                    }
                }
                cout<<endl;
                return 0;
            }

        }
    }
    cout<<"-1"<<endl;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
typedef vector<int>V;
typedef priority_queue<int>Q;
V v[1000001];
Q que[100001];
int main(void){
	int n,m,h;
	int box[100001],x,y,cnt;
	int i,j;
	cin>>n>>m;
	for(i=1;i<=n;i++)	box[i]=0;
	for(i=1;i<=n;i++){
		cin>>h;
		box[i]=h;
	}
	for(i=0;i<m;i++){
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	for(i=1;i<=n;i++)	que[i].push(0);
	for(i=1;i<=n;i++){
		for(j=0;j<(int)v[i].size();j++){
			//cout<<"i="<<i<<"box="<<box[v[i][j]]<<endl;
			que[i].push(box[v[i][j]]);
		}
	}
	//cout<<"check1"<<endl;
	cnt=0;
	for(i=1;i<=n;i++){
		x=box[i];
		y=que[i].top();
		if(x>y){
			cnt++;
			//cout<<i<<endl;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 37092
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = (1 << 29);
const long long INFL = (1LL<<60);
const double eps = (1e-9);

ll calcSadness(const vector<int>& a, ll b)
{
  ll sadness = 0;
  for (auto it = a.begin(); it != a.end(); it++) {
    sadness += abs(*it - b);
  }
  return sadness;
}

int main(int argc, char* argv[])
{
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) {
    cin >> a[i];
    a[i] -= (i+1);
  }
  sort(a.begin(), a.end());
  ll ans = INFL;
  chmin(ans, calcSadness(a, a[n/2]));
  if (n >=2 ) {
    chmin(ans, calcSadness(a, a[n/2 +1]));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
int main(){
	int a,b,c;
	int count=0;
	cin>>a>>b>>c;
	for(int i=a;i<=b;i++){
		if(c%i==0)
			count++;
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 1164
#include "bits/stdc++.h"
using namespace std;

using ll = long long;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;

#define rep(a,b) for(int a=0; a<b; ++a)
#define Rep(a,b,c) for(int a=b; a<c; ++a)

int main(){
	int W,H; cin>>W>>H;
	char c; cin>>c;
	
	cout<<"+";
	rep(i,W-2) cout<<"-";
	cout<<"+"<<endl;
	
	Rep(i,1,H-1){
		cout<<"|";
		if(i==H/2){
			Rep(j,1,W/2) cout<<".";
			cout<<c;
			Rep(j,1,W/2) cout<<".";
		}
		else{
			Rep(j,1,W-1) cout<<".";
		}
		cout<<"|"<<endl;
	}
	
	cout<<"+";
	rep(i,W-2) cout<<"-";
	cout<<"+"<<endl;
}



Measured memory_bytes: 3080
import math
n,d = map(int,input().split())
ls = []
for i in range(n):
    x = list(map(int,input().split()))
    ls.append(x)

count = 0
m = 0
k = n-1
while m < k:
    for i in range(m,n-1):
        an = 0
        for j in range(d):
            an += abs(ls[m][j] - ls[i+1][j])**2
        if ((math.sqrt(an)).is_integer()) == True:
            count += 1
    m += 1
print(count)


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

int main() {
    long long n;
    cin >> n;

    vector<long long> A(n);
    vector<long long> B(n);
    for(long long i=1; i<n; i++){
        cin >> A.at(i);
        B.at(A.at(i)-1)++;
    }

    for(long long i=0; i<n; i++){
        cout << B.at(i) << endl;
    }
}


Measured memory_bytes: 6428
//package com.atcoder.contest171.e;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int n = fs.nextInt();
        long[] arr = new long[n];
        long[] a = new long[n];
        long xor = 0;
        for(int i=0; i<n; ++i) {
            a[i] = fs.nextLong();
            xor ^= a[i];
        }
        for(int i=0; i<n; ++i){
            arr[i] = a[i] ^ xor;
        }
        /**
         * a[0] = arr[1] ^ //arr[2] ^ //arr[3]
         * a[1] = //arr[0] ^ //arr[2] ^ //arr[3]
         * a[2] = //arr[0] ^ //arr[1] ^ arr[3]
         * a[3] = arr[0] ^ //arr[1] ^ arr[2]
         *
         * arr[0] = (arr[1] ^ arr[2] ^ arr[3]) ^ (arr[0]^arr[1]^arr[2]^arr[3])
         *
         * */
        for(long x : arr)
            System.out.print(x + " ");
        System.out.println();
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 63988
N = int(input())
A_list = []
for i in range(N):
    A_list.append(int(input()))
    
A_list.sort()

res = 0
cnt = 0
ans = 0
for a in A_list:
    if res == a:
        cnt += 1
    else:
        ans += cnt%2
        res = a
        cnt = 1
        
ans += cnt%2

print(ans)

Measured memory_bytes: 7388
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int X = sc.nextInt();
   int Y = sc.nextInt();
   
   if(X==1 && Y==1)      System.out.println(1000000);
   else {
     int money = 0;
     if( X == 1) money += 300000;
     if( Y == 1) money += 300000;
     if( X == 2) money += 200000;
     if( Y == 2) money += 200000;
     if( X == 3) money += 100000;
     if( Y == 3) money += 100000;
     System.out.println(money);
   }
   
 }
}

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  string weather[3] = {"Sunny", "Cloudy", "Rainy"}, s;
  cin >> s;

  if (s == weather[0])
    cout << weather[1] << "\n";
  else if (s == weather[1])
    cout << weather[2] << "\n";
  else
    cout << weather[0] << "\n";
}

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

int main(){
        char s[1001];
        cin >> s;
        int w;
        cin >> w;

        char ans[1001];
        ans[0]=s[0];
        int count=1;
        for(int i=1; s[i]!='\0'; i++){
                if(i%w==0){
                        ans[count]=s[i];
                        count ++;
                }
        }
        ans[count]='\0';

        cout << ans << endl;

        return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long[] times = new long[n];
        for (int i = 0; i < n; i++) {
            times[i] = sc.nextLong();
        }
        ArrayList<Long> arrayList = new ArrayList<>();
        for (int i = 0; i < n-1; i++) {
            long l = times[i+1] - (times[i] + 1);
            if(l > 0) arrayList.add(l);
        }
        arrayList.sort(Comparator.reverseOrder());

//        System.out.println("forEach");
//        arrayList.forEach(System.out::println);
//        System.out.println("end");

        long sum = arrayList.stream().limit(k-1).mapToLong(Long::longValue).sum();

        //System.out.println(sum);
        System.out.println(times[n-1]-times[0]+1-sum);
    }
}



Measured memory_bytes: 71816
#include <iostream>

using namespace std;

int main() {
    int H, N;
    cin >> H >> N;
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        H -= A;
    }
    if (H <= 0) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
}

Measured memory_bytes: 256
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>
#include <vector>
#include <string>
#include <queue>

using namespace std;

void solution() {
    long long n, a, b;
    cin >> n >> a >> b;
    long long x = a + b;
    long long ans = 0;
    ans = (n / x) * a;
    n %= x;
    ans += (n > a) ? a : n;
    cout << ans << endl;
}

/*-------------------*/

int main()
{
#ifdef Files
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    /*Test*/
    //freopen("input.txt", "w", stdout);

    double OcZ2X = clock();
#else
    //freopen("joke.in", "r", stdin);
    //freopen("joke.out", "w", stdout);
#endif

/*
　　     　 　          ∧_,,∧　　　
    　            ♪　  (・ω・)　♪
               ＿＿＿＿○＿＿つヾ＿＿＿＿＿
             /δ⊆・⊇ 。/†: :† /δ ⊆・⊇｡ /|
            |￣￣￣￣￣￣￣￣￣￣￣￣￣ | |
            |　　　*/solution();/* 　　| |
            |　　　　　　　　　　　　　 |
*/

#ifdef Time
    double P2HxQ = clock();
    printf("\n*** Total time = %.3f sec ***\n", (P2HxQ - OcZ2X) / CLOCKS_PER_SEC);
#endif
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_multiset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
//find_by_order(k) - k is the kth element of the multiset
//order_of_key(k) - Number of elements striclty samller than k
ll modularExponentiation(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return modularExponentiation((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;

}
ll modInverse(ll A,ll M=MOD)
{
    return modularExponentiation(A,M-2,M);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n;
	cin>>n;
	ll arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	sort(arr,arr+n);
	ll x=arr[n/2-1];
	ll y=arr[n/2];
	if(x==y)
	{
		cout<<"0"<<endl;
		return 0;
	}
	cout<<y-x<<endl;
}

Measured memory_bytes: 1024
n = int(input())
H = list(map(int,input().split()))


#print(H)

flag = True

for i in range(n-1):
    if H[i+1] > H[i]:
        H[i+1] -= 1
    
    if H[i+1] < H[i]:
        flag = False
        break

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 20504
#include <bits/stdc++.h>
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>
#define ALL(V) V.begin(),V.end()
#define f1(a,b) for(int a=1;a<=b;a++)
#define f0(a,b) for(int a=0;a<b;a++)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define de(x) cout<<#x<<": "<<x<<endl
using namespace std;
const LL N=1e6+69, base=1024*1024,mod=1e9+7;
int rep[N],war[N];
LL wynik;
int n,m,a,b;
set <int> huj;
multiset <int> S;
vector <int> vek[N];
int re(int v) {
    if(v!=rep[v]) rep[v]=re(rep[v]);
    return rep[v];
}
void uni(int a,int b) {
    b=re(b);
    a=re(a);
    rep[a]=b;
}
int32_t main(void) {
    boost;
    cin>>n>>m;
    f0(i,n) cin>>war[i];
    f0(i,n) rep[i]=i;
    f0(i,m) {
        cin>>a>>b;
        uni(a,b);
    }
    f0(i,n) {
        vek[re(i)].PB(war[i]);
        huj.insert(re(i));
    }
    int ile=huj.size();
    if(ile==1) {
        cout<<"0\n";
        return 0;
    }
    f0(i,n) {
        if(vek[i].empty()) continue;
        sort(ALL(vek[i]));
        wynik+=vek[i][0];
        //de(vek[i][0]);
        for(int j=1;j<vek[i].size()&&j<ile-1;j++) {
            S.insert(vek[i][j]);
        }
    }
    f0(i,ile-2) {
        if(S.empty()) {
            cout<<"Impossible\n";
            return 0;
        }
        wynik+=(*S.begin());
        //cout<<(*S.begin())<<endl;
        S.erase(S.begin());
    }
    cout<<wynik;
}
/*
12 5
0 1 2 3 4 5 6 7 8 9 10 11
1 2
2 3
1 4
4 0
5 6
*/


Measured memory_bytes: 34688
N,Y = map(int,input().split())
w = Y//1000
for x in range(N+1):
    if (w-N-9*x)%4==0:
        y = (w-N-9*x)//4
        if x+y<=N and y>=0:
            print(str(x) + " " + str(y) + " " + str(N-x-y))
            exit()
print("-1 -1 -1")

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
typedef long long ll;
int main() {
	ll a, b, x;
	cin >> a >> b >> x;
	if (a == b) {
		if (a % x == 0) {
			cout << "1" << endl;
			return 0;
		}
		else {
			cout << "0" << endl;
		}
		
		return 0;
	}
	if (a == 0 ) {
		cout << b/x+1<< endl;
		return 0;
	}
	if (a % x == 0) {
		cout << (b / x) - (a / x)+1 << endl;
	}
	else {
		cout << (b / x) - (a / x) << endl;
	}
	return 0;
}
	


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int cmp(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}

int main(){
  int n;
  scanf("%d", &n);
  int i,j,p[n],tmp;
  if(n%2==1) return 0;
  for(i=0;i<n;i++){
    scanf("%d", &p[i]);
  }
  qsort(p, n, sizeof(int), cmp);
  printf("%d", p[n/2] - p[n/2-1]);
  return 0;
}

Measured memory_bytes: 892
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let mut line = read_as_vec::<i32>();

    line.sort();

    println!("{}", line[2] - line[0]);
}


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

using namespace std;
using ll = long long;

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int (i) = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int (i) = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
	#define lcout(a) cout << a;
	#define lcoutln(a) cout << a << endl;
	#define lcerr(a) cerr << a;
	#define lcerrln(a) cerr << a << endl;
#else
	#define lcout(a) 
	#define lcoutln(a) 
	#define lcerr(a) 
	#define lcerrln(a) 
#endif

vector<char> v;

int main()
{
	CIN(string, s);
	rep(i, s.length()) v.PB(s[i]);
	UNIQUE(v);
	char x = 'a';
	for (char c : v) {
		if (c != x) {
			break;
		}
		x++;
	}
	if (x <= 'z') cout << x << endl;
	else cout << "None" << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define MAX 10005
#define mp make_pair
#define pb push_back
#define int long long
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define vi vector<int>
#define mii map<int,int>
#define pii pair<int,int>
#define len(x) (x.size())
#define all(a) a.begin(),a.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define T int tc;cin>>tc;for(int t=1;t<=tc;t++)
#define set_arr(arr,i) memset(arr,i,sizeof(arr))
#define trace1(x)							cerr << #x << ": " << x << endl;
#define trace2(x, y)						cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)						cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       			cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    			cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) 			cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << :  << f << endl;
using namespace std;

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

	int n;
	cin>>n;
	vi a(n);
	int ans = 0;
	rep(i,0,n){
		cin>>a[i];
	} 	
	int final = 0;
	rep(i,0,n-1){
		if(a[i+1]<=a[i]){
			ans += 1;
		}
		else{
			final = max(ans,final);
			ans = 0;
		}
	}
	final = max(ans,final);
	cout<<final;
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, T;
    cin >> N >> T;
    vector<pii> AB(N);
    cin >> AB;
    sort(all(AB));

    vvi dp(N + 1, vi(T + 1, -1));
    dp[0][0] = 0;
    rep(i, 0, N) {
        rep(j, 0, T) {
            if (dp[i][j] == -1) continue;
            chmax(dp[i + 1][min(j + AB[i].first, T)], dp[i][j] + AB[i].second);
            chmax(dp[i + 1][j], dp[i][j]);
        }
        chmax(dp[i + 1][T], dp[i][T]);
    }
    int ans = 0;
    rep(i, 0, T + 1) {
        chmax(ans, dp[N][i]);
    }
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 70784
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    int N;
    cin >> N;
    bool ans=true;
    int X=0,Y=0,time=0;
    rep(i,N){
        int t,x,y;
        cin >> t >> x >> y;
        int dis=abs(X-x)+abs(Y-y);
        int walk=t-time;
        int rem=walk-dis;
        if(rem<0) ans=false;
        else if(rem%2) ans=false;
        X=x,Y=y,time=t;
        if(!ans) continue;
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var H = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var diff = new long[N];

            for (var i = N - 2; i >= 0; i--)
                if (H[i] >= H[i + 1]) diff[i] = diff[i + 1] + 1;

            Console.WriteLine(diff.Max());
        }
    }
}


Measured memory_bytes: 27100
import java.util.Scanner;

public class Main {
	static Scanner in = new Scanner(System.in);
	public static void main(String[] args){
		long N = in.nextLong();
		long p = 1;
		
		for(int i = 1; i <= N; i++){
			p = (p * i) % 1000000007;
		}
		System.out.println(p);
		
	}
}

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

public class Main {
	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		while (stdin.hasNext()) {
			int n = stdin.nextInt();
			if (n == 0) break;
			Work work = new Work();
			for (int i = 0; i < n - 1; i++){
				int j = stdin.nextInt();
				int p = stdin.nextInt();
				work.add(j, p);
			} 
			System.out.println(work.getWidth() + " " + work.getHeight());
		}
		System.exit(0);
	}
}

class Work {
	private int xmin = 0;
	private int xmax = 0;
	private int ymin = 0;
	private int ymax = 0;
	private int n = 0;
	private ArrayList<Square> squares = new ArrayList<Square>();

	public Work(){
		addByPoint(0, 0);
	}

	private void addByPoint(int x, int y){
		squares.add(new Square(n++, x, y));
		if (xmin > x) xmin = x;
		if (xmax < x) xmax = x;
		if (ymin > y) ymin = y;
		if (ymax < y) ymax = y;
	}

	public void add(int index, int position) {
		int x = 0, y = 0;
		switch (position) {
		case 0:
			x = -1;
			y = 0;
			break;
		case 1:
			x = 0;
			y = -1;
			break;
		case 3:
			x = 0;
			y = 1;
			break;
		case 2:
			x = 1;
			y = 0;
			break;
		default:
			return;
		}
		addByPoint(squares.get(index).getX() + x, squares.get(index).getY() + y);
	}

	public int getHeight() {
		return ymax - ymin + 1;
	}

	public int getWidth() {
		return xmax - xmin + 1;
	}
}

class Square {
	private int index, x, y;

	public Square(int index, int x, int y){
		this.index = index;
		this.x = x;
		this.y = y;
	}

	public int getX(){
		return x;
	}

	public int getY(){
		return y;
	}
}

Measured memory_bytes: 34804
s=str(input())
arr=[]
for i in range(len(s)):
	arr.append(s[i])
ans=0
n=len(arr)
count=0
i=0
while(i<n-2):
	if(arr[i]+arr[i+1]+arr[i+2]=="ABC"):
		ans+=1
		arr[i]="B"
		arr[i+1]="C"
		arr[i+2]="A"
		j=i-1
		i+=2
		ans+=count
	else:
		if(arr[i]=="A"):
			count+=1
		else:
			count=0
		i+=1
print(ans)







Measured memory_bytes: 5096
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long int n;
	cin >> n;

	string ans;

	do {
		ans.push_back(97 + (--n % 26));
		n /= 26;
	} while (n > 0);

	reverse(ans.begin(), ans.end());
	cout << ans << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=55,INF=1<<30;
int H,W;
int cnt;
int state[MAX][MAX];
vector<int> dx={1,0,-1,0},dy={0,-1,0,1};

void DFS(int us,int ut){
    for(int i=0;i<4;i++){
        if(0<=us+dx[i]&&us+dx[i]<H&&0<=ut+dy[i]&&ut+dy[i]<W){
            if(state[us+dx[i]][ut+dy[i]]==0){
                cnt++;
                state[us+dx[i]][ut+dy[i]]=1;
                DFS(us+dx[i],ut+dy[i]);
            }
        }
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        cin>>W>>H;
        if(H==0&&W==0) break;
        
        int s,t;
        cnt=1;
        memset(state,0,sizeof(state));
        
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                char c;cin>>c;
                if(c=='@'){
                    s=i;
                    t=j;
                    state[i][j]=1;
                }else if(c=='#'){
                    state[i][j]=1;
                }
            }
        }
        
        DFS(s,t);
        
        cout<<cnt<<endl;
    }
}



Measured memory_bytes: 3112
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

struct edge { int to;string cost; };
int start;
string d[50][801]; //距離
vector<edge> vec[50];

void dijkstra() {
	REP(i, 50)REP(j, 801)d[i][j] = "|"; 
	priority_queue<pair<string, pair<int, int>>, std::vector<pair<string, pair<int, int>>>, std::greater<pair<string, pair<int, int>>>> pq;
	d[start][0] = "";
	pq.push(make_pair(d[start][0], make_pair(start, 0)));//cost,to
	while (!pq.empty()) {
		pair<string, pair<int, int>> p = pq.top();
		pq.pop();
		pair<int, int> i = p.second;
        if(i.second > 800)continue;
		if (d[i.first][i.second] < p.first)continue;
		for (int k = 0; k < (int)vec[i.first].size(); k++) {
			edge e = vec[i.first][k];
            if(i.second + (int)e.cost.size() > 800) continue;
			if (d[e.to][i.second + (int)e.cost.size()] <= d[i.first][i.second] + e.cost)continue;
			d[e.to][i.second + (int)e.cost.size()] = d[i.first][i.second] + e.cost;
			pq.push(make_pair(d[e.to][i.second + (int)e.cost.size()], make_pair(e.to, i.second + (int)e.cost.size())));
		}
	}
}

int n, a, s, g;

int main(){
    while(cin >> n >> a >> s >> g && (n | a | s | g)){
        start = s;
        REP(i, 50)vec[i].clear();
        REP(i, a){
            int x, y;
            string t;
            cin >> x >> y >> t;
            vec[x].emplace_back(edge{y, t});
        }
        dijkstra();
        string ans = "|";
        REP(i, 801){
            ans = min(d[g][i], ans);
        }
        if(ans == "|" || (int)ans.size() > 240){
            cout << "NO" << endl;
        }else{
            cout << ans << endl;
        }
    }
}



Measured memory_bytes: 72088
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
vec< vec< pair< int, int > > > g;
int N, Q, K;
vec< int > cost;
void dfs(int id, int tmpCost) {
  cost[id] = tmpCost;
  FORA(e, g[id]) {
    if (cost[e.first] == INF) {
      dfs(e.first, tmpCost + e.second);
    }
  }
  return;
}
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  cin >> N;
  g.resize(N, vec< pair< int, int > >());
  REP(i, N - 1) {
    int a0, a1, a2;
    cin >> a0 >> a1 >> a2;
    a0--, a1--;
    g[a0].pb(mp(a1, a2));
    g[a1].pb(mp(a0, a2));
  }
  cin >> Q >> K;
  K--;
  cost.assign(N, INF);
  dfs(K, 0);
  REP(i, Q) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    print(cost[x] + cost[y]);
  }
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        int w = in.nextInt();

        long[] dp = new long[w + 1];
        for (int i = 0; i < n; i++) {
            int weight = in.nextInt();
            long val = in.nextLong();
            for (int j = w; j >= weight; j--) {
                dp[j] = Math.max(dp[j], dp[j - weight] + val);
            }
        }

        out.println(dp[w]);
        out.close();

    }


    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(InputStream i) {
            br = new BufferedReader(new InputStreamReader(i));
            st = new StringTokenizer("");
        }
        public String next() throws IOException {
            if (st.hasMoreTokens()) {
                return st.nextToken();
            }
            else
                st = new StringTokenizer(br.readLine());
            return next();
        }
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
        public String nextLine() throws IOException {
            if (!st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
                return nextLine();
            }

            String ret = "";
            while (st.hasMoreTokens()) {
                ret += st.nextToken();
            }
            return ret;
        }
        public int[] nextIntArr(int size) throws IOException {
            int[] arr = new int[size];
            for (int i = 0; i < arr.length; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }
        public long[] nextLongArr(int size) throws IOException {
            long[] arr = new long[size];
            for (int i = 0; i < arr.length; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
        public double[] nextDoubleArr(int size) throws IOException {
            double[] arr = new double[size];
            for (int i = 0; i < arr.length; i++) {
                arr[i] = nextDouble();
            }
            return arr;
        }
    }
}

Measured memory_bytes: 33864
import itertools
import math
X=int(input())
arr=[]
arr2=[]
arr3=[]
for i in range(0,640):
    arr.append(i**5)
    arr.append(-i**5)
l=itertools.combinations_with_replacement(arr,2)
for i in l:
    arr2.append(i[0]-i[1])
    arr3.append([i[0],i[1]])
ans=arr3[arr2.index(X)]
print(int(math.pow(abs(ans[0]), 1/5))*(1 if ans[0]>=0 else -1), int(math.pow(abs(ans[1]), 1/5))*(1 if ans[1]>=0 else -1))

Measured memory_bytes: 119240
#include <bits/stdc++.h>
using namespace std;
const int N=4010;
const int mod=924844033;
int i,j,k,n,m,x,y,t,f[N][N][2],g[N],e[N],en[N],l,b[N],fac[N];
void dfs(int x){
	b[x]=1;e[++l]=x;
	if (x>n){
		if (x-n+k>n)en[l+1]=1;
		else dfs(x-n+k);
	}
	else{
		if (x+n+k>n*2)en[l+1]=1;
		else dfs(x+n+k);
	}
}
int add(int x,int y){x+=y;if (x>=mod)x-=mod;if (x<0)x+=mod;return x;}
int main(){
	scanf("%d%d",&n,&k);
	for (i=1;i<=n;i++){
		if (!b[i])dfs(i);
		if (!b[i+n])dfs(i+n);
	}
	f[1][0][0]=1;
	for (i=2;i<=l;i++)
		for (j=0;j<=n;j++){
			f[i][j][0]=add(f[i][j][0],add(f[i-1][j][0],f[i-1][j][1]));
			if (j&&!en[i])f[i][j][1]=add(f[i][j][1],f[i-1][j-1][0]);
		}
	fac[0]=1;for (i=1;i<=n;i++)fac[i]=1ll*i*fac[i-1]%mod;
	for (i=0;i<=n;i++)g[i]=1ll*add(f[l][i][0],f[l][i][1])*fac[n-i]%mod;
//	for (i=0;i<=n;i++)printf("%d\n",g[i]);
//	for (i=1;i<=l;i++)printf("%d ",e[i]);printf("\n");
//	for (i=1;i<=l;i++)printf("%d ",en[i]);printf("\n");
	int ans=0;
	for (i=0;i<=n;i++)if (i&1)ans=add(ans,-g[i]);else ans=add(ans,g[i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 124672
#include "bits/stdc++.h"
using namespace std;
int main() {
  int A, B, C, K, minas;
  cin >> A >> B >> C >> K;
  minas = K - A - B;
  if (K <= A){
    cout << K << endl;
  }else if (K > A && K <= A+B){
    cout << A << endl;
  }else if (K > A && K > A+B){
    cout << A - minas << endl;
  }
}

Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
using I=long long;
#define rep(i,n) for(I i=0;i<n;++i)

I get(I x,I k){return (x>>k)&1;}
int main(){
  I n;
  cin>>n;
  vector<I> a(n);
  rep(i,n)cin>>a[i];
  vector<I> es;
  I ans=0;
  rep(k,62){
    I cnt=0;
    rep(i,n)cnt+=get(a[i],k);
    if(cnt%2)ans+=1LL<<k;
    else es.push_back(k);
  }
  reverse(es.begin(),es.end());
  I cur=0;
  for(I k:es){
    if(n==0)continue;
    rep(i,n){
      if(get(a[i],k)){
        swap(a.back(),a[i]);
      break;}
    }
    I p=a.back();
    if(!get(p,k))
      continue;
    a.pop_back();
    n--;
    rep(i,n){
      if(get(a[i],k))
        a[i]^=p;
    }
    if(!get(cur,k))
      cur^=p;
  }
  for(I k:es)
    if(get(cur,k))
      ans+=2LL<<k;
  cout<<ans<<endl;
}
    


Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
const int N=105;
char ss[N];
int n;
char a[N];
int main()
{
	scanf("%s",ss+1);
	n=strlen(ss+1);
	if (n<7)
	{
		printf("NO\n");
		return 0;
	}
	//keyence
	a[1]='k';
	a[2]='e';
	a[3]='y';
	a[4]='e';
	a[5]='n';
	a[6]='c';
	a[7]='e';
	bool tf=false;
	for (int u=1;u<=7;u++)
	{
		if (ss[u]!=a[u]) break;
		bool ok=true;
		int j=n;
		for (int i=7;i>u;i--) 
		{
			if (a[i]!=ss[j])
			{
				ok=false;
				break;
			}
			j--;
		}
		tf|=ok;
	}
	if (tf==false) printf("NO\n");
	else printf("YES\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}


int main() {
  ll n;
  cin >> n;
  map<string , ll> a;
  rep(i,n){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    a[s]++;
  }
  ll ans=0;
  for(auto p:a){
    auto k=p.second;
    ans+=k*(k-1)/2;
  }
  cout << ans << endl;
}

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

int main(){
  //inputs
  int N;
  int lim = 1e5+1;
  ll A[lim];
  ll maxB[lim];
  cin >> N;
  for (int i=0; i<=N; i++)
    cin >> A[i];
    
  // handle corner cases
  if (A[0]>0){
    if(A[0]==1 and N==0){
      cout << 1 << endl;
      return 0;
    }
    else{
      cout << -1 << endl;
      return 0;
    }
  }
  
  // compute maxB's upwards from the bottom 
  maxB[N] = 0;
  for (int i=N; 0<i; i--)
    maxB[i-1] = maxB[i] + A[i];
  
  // compute total number of nodes
  ll sum = 1;
  ll B = 1;
  for (int i=1; i<=N; i++){
    B = min( maxB[i], 2*B-A[i] );
    sum += B + A[i];
    //handle invalide case
    if (B<0){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 5188
#include <iostream>
#define MAX_N 300000/6+1

using namespace std;


int main(){
  int v[90000]; // jyj
  int p[40000]; // jyjf
  int vI=0, pI=0;

  //  v.push_back( 1 );
  v[vI++]=6;
  for( int i=7; i<MAX_N;i+=7 ){
    v[vI++]=i+1;
    v[vI++]=i+6;
  }

  p[pI++] = v[0];
  for( int i=1,j;i<vI;i++ ){
    for( j=0;j<i;j++ )
      if( v[i]%v[j]==0 )
	break;
    if( j==i )
      p[pI++]=v[i];
  }
  /*
  cout << "v.size="<<vI << " last="<<v[vI-1]<<endl;
  cout << "p.size="<<pI << " last="<<p[pI-1]<<endl;
  for( int i=0;i<30;i++ )
    cout << "v:"<<v[i]<<", p:"<<p[i] << endl;
  */

  int n;
  while( cin>>n && n!=1 ){
    cout << n << ":";
    int i, count=0;
    for(  i=0; i<pI && p[i]<=n ;i++ ){
      if( n%p[i]==0 ){
	cout << " " << p[i];
	count++;
      }
    }
    if( count==0 )
      cout << " " << n;

    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 956
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  int n,m,c;
  int count=0;
  cin>>n>>m>>c;
  vector<int>b(m);
  vector<vector<int>>a(n,vector<int>(m));
  for(int i=0;i<m;i++)cin>>b[i];
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++)cin>>a[i][j];
  }
  for(int i=0;i<n;i++){
    int sum=0;
    for(int j=0;j<m;j++){
      sum+=a[i][j]*b[j];
    }
    sum+=c;
    if(sum>0)count++;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define N 212345
using namespace std;
int n,m,sum,res,flag;
char s[N];
int main()
{
    int i,j,k,T,cas,x,y,t;
    scanf("%s",s);
    res=0;
    n=strlen(s);
    x=n;y=0;
    for(i=0;i<n;i++)
    {
        if(s[i]=='A')x=min(x,i);
        if(s[i]=='Z')y=max(y,i);
        res=max(res,y-x+1);
    }
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 384
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sn = new Scanner(System.in);
		
		int a = sn.nextInt();
		int b = sn.nextInt();
		
		int sum = a + b;
		int minus = a - b;
		int kakeru = a * b;
		
		if (sum >= minus && sum >= kakeru) {
			System.out.println(sum);
		} else if (minus >= sum && minus >= kakeru) {
			System.out.println(minus);
		} else if (kakeru >= sum && kakeru >= minus) {
			System.out.println(kakeru);
		}
	}
	
}


Measured memory_bytes: 22996
#include <stdio.h>
int main(void){
    int a,b,c,d,K,ans,mae,ato;
    
    scanf("%d%d%d%d%d",&a,&b,&c,&d,&K);
    
    ato=c*60+d;
    mae=a*60+b;
    ans=ato-mae-K;
    
    printf("%d\n",ans);
    
    return 0;
}

Measured memory_bytes: 2152
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define vec vector<int>
using namespace std;
main()
{
  int n;
  cin>>n;
  int a[n],i;
  for(i=0;i<n;i++)
    cin>>a[i];
  priority_queue<int> pq;
  for(i=0;i<n;i++)
    pq.push(a[i]);
  int ans=pq.top();
  pq.pop();
  i=1;
  while(i<n-1)
  {
     ans+=pq.top();
     i++;
     if(i>=n-1)
        break;
     ans+=pq.top();
     pq.pop();
     i++;
  }
  cout<<ans<<"\n";
}


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

const int mod=1e9+7;

int main(){
    long long N,K; cin >> N >> K;
    long long sum[N+1]={};
    for(int i=0;i<N;i++){
        sum[i+1]=sum[i]+(i+1);
    }
    long long ans=0;
    for(long long i=K;i<=N;i++){
        ans+=sum[N]-sum[N-i]-sum[i-1]+1;
        ans%=mod;
    }
    cout << ans+1 << endl;
}

Measured memory_bytes: 5160
from itertools import accumulate
from operator import add

N, x = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

if sum(A) == x:
    print(N)
else:
    t = len(list(filter(lambda y: y <= x, accumulate(A, func=add))))
    if t == N:
        print(N - 1)
    else:
        print(t)


Measured memory_bytes: 3188
#include <iostream>
using namespace std;
//using ll=long long;

int main(){
    int R;
    cin >> R;
    if(R >= 0 && R < 1200) cout << "ABC" << endl;
    else if(R >= 1200 && R < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
    
    return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int k,n,sum=0,i;
 cin>>k>>n;
 int array[n];
 for(i=1;i<=n;i++)
 {
     cin>>array[i];
     sum=sum+array[i];
 }
 if(sum>=k)
 {
     cout<<"Yes";
 }
 else
 {
     cout<<"No";
 }
    return 0;

}

Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>

int main(){

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

    int i;
    long long int A[100000+1], ans=1;
    long long int THR = pow(10,18);
    for(i=1;i<=N;i++){
        scanf("%lld", &A[i]);
        if( A[i] == 0 ){
            printf("0\n");
            return 0;
        }
    }

    for(i=1;i<=N;i++){
        
        if( ans > THR/A[i] ){
            printf("-1\n");
            return 0;
        }
        ans *= A[i];
    }

    printf("%lld\n", ans);

    return 0;
}



Measured memory_bytes: 2440
#include <iostream>
using namespace std ;
int main()
{
	int a=0 , b=0 ;
	cin >> a >> b ;
	if (a<b)
	{
		cout << "a < b" << endl ;
	}
	else if (a>b)
	{
		cout << "a > b" << endl ;
	}
	else
	{
		cout << "a == b" << endl ;
	}
	return 0 ;
}




Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define endl "\n"
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

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

  ll A,B,C,D,E,F;
  cin>>A>>B>>C>>D>>E>>F;

  int res1, res2;
  double maxv = 0;
  rep(i,100) rep(j,100) rep(k,100) rep(l,100) {
    ll water = 100*A*i+100*B*j;
    ll sugar = C*k+D*l;
    if(water+sugar<=F && sugar<=water/100*E){
      double val = 100.0*sugar/(water+sugar);
      if(val >= maxv) {
        res1 = water+sugar; res2 = sugar;
        maxv = val;
      }
    }
  }
  cout << res1 << " " << res2 << endl;

//  ll res1, res2;
//  double maxv = 0;
//  for(int i=0; i<=F/(100*A); i++) {
//    for(int j=0; j<=F/(100*B); j++) {
//      for(int k=0; k<=F/C; k++) {
//        for(int l=0; l<=F/D; l++) {
//          ll water = 100*A*i+100*B*j;
//          ll sugar = C*k+D*l;
//          if(water==0 || sugar==0) continue;
//          if(water+sugar > F) continue;
//          if(sugar > water/100*E) continue;
//          double val = 100.0*sugar/(water+sugar);   // 100 -> 100.0
//          if(val > maxv) {
//            maxv = val;
//            res1 = water+sugar; res2 = sugar;
//          }
//        }
//      }
//    }
//  }
//  cout << res1 << " " << res2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
 
template<int N, typename T, T M>
struct factorial_mod
{
	T mod[N + 1];
	T inv_mod[N + 1];
 
	constexpr factorial_mod() : mod(), inv_mod()
	{
		mod[0] = 1;
		for (int i = 0; i < N; ++i)
		{
			mod[i + 1] = (mod[i] * (i + 1)) % M;
		}
		inv_mod[N] = power(mod[N], M - 2);
		for (int i = N - 1; i >= 0; --i)
		{
			inv_mod[i] = (inv_mod[i + 1] * (i + 1)) % M;
		}
	}
 
	constexpr T power(T a, T b) const
	{
		T r = 1;
		for (; b; b >>= 1, a = 1ll * a * a % M)
			if (b & 1) r = 1ll * r * a % M;
		return r;
	}
 
	constexpr T comb(T n, T r) const
	{
		if (r < 0 || r > n || n < 0) return 0;
		return (((mod[n] * inv_mod[r]) % M) * inv_mod[n - r]) % M;
	}
 
	constexpr T H(T n, T r) const
	{
		return comb(n + r - 1, r);
	}
};
 
constexpr long long MOD = 1000000007;
constexpr factorial_mod<500000, long long, MOD> fmod;
 
int main()
{
	long long n, k;
	scanf("%lld%lld", &n, &k);
	long long zeromax = std::min(n, k);
	long long ans = 0;
	for (long long i = 1; i <= zeromax; ++i)
	{
		long long room = n - i;
		long long nn = n - room;
		ans = (ans + fmod.comb(n, room) * fmod.H(room, nn)) % MOD;
	}
	if (k >= 2)
	{
		ans = (ans + 1) % MOD;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128