akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

struct Node {
    Node *next;
    int val;
    Node(int v) : val(v), next(nullptr) {}
};

void printList(Node *head) {
    Node *now = head;
    while(now) {
        cout << now->val << endl;
        now = now->next;
    }
}

int main() {
    int N;
    cin >> N;
    vector<vector<int>> A(2, vector<int>(N, 0));
    for(int i = 0; i < 2; i++) {
        for(int j = 0; j < N; j++) {
            cin >> A[i][j];
        }
    }

    int ans = 0;
    for(int k = 0; k < N; k++) {
        int sum = 0;
        for(int j = 0; j <= k; j++) {
            sum += A[0][j];
        }
        for(int j = k; j < N; j++) {
            sum += A[1][j];
        }
        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
int main() {
    int N;
    scanf("%d", &N);

    for(int i=0; i<25 ; i++){
        for(int j =0; j<15; j++){
            if(N==4*i+7*j){
                printf("Yes");
                return 0;
            }
        }
    }
    printf("No");
    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<iomanip>
#include<math.h>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
using namespace std;

int main() {
    int N;
    long long wa = 0,s=0, R = 0, G = 0, B = 0;;
    char szBuf[10000] = { 'R' };
    cin >> N;
    cin >> szBuf;
    for (int x = 0; x < N; x++) {
        if (szBuf[x] == 'R')R++; 
        if (szBuf[x] == 'G')G++;
        if (szBuf[x] == 'B')B++;
    }
    wa = R * G * B;
    for (int x = 0; x < N; x++) {
        for (int y = x + 1; y < N; y++) {
            if (szBuf[x] == 'R' && szBuf[y] == 'G'&&szBuf[2 * y - x] == 'B')s++;
            if (szBuf[x] == 'R' && szBuf[y] == 'B'&&szBuf[2 * y - x] == 'G')s++;
            if (szBuf[x] == 'G' && szBuf[y] == 'B'&&szBuf[2 * y - x] == 'R')s++;
            if (szBuf[x] == 'G' && szBuf[y] == 'R'&&szBuf[2 * y - x] == 'B')s++;
            if (szBuf[x] == 'B' && szBuf[y] == 'R'&&szBuf[2 * y - x] == 'G')s++;
            if (szBuf[x] == 'B' && szBuf[y] == 'G'&&szBuf[2 * y - x] == 'R')s++;
        }
    }
    cout<<wa-s<<endl;
    return 0;
}

Measured memory_bytes: 3648
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::BTreeMap;

fn main() {
    let xs = read_vec_i64();
    let res = xs[0] - 1 + if xs[0] <= xs[1] { 1 } else { 0 };
    println!("{}", res);
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}


Measured memory_bytes: 4352
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

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

dp = [[-1] * 2 for _ in range(51)]

# dp[bit][smaller]
dp[50][0] = 0
for i in range(49, -1, -1):
    cnt = 0
    for a in A:
        cnt += a >> i & 1
    val0 = cnt << i
    val1 = (N - cnt) << i

    if dp[i + 1][1] >= 0:
        dp[i][1] = max(dp[i][1], dp[i + 1][1] + max(val0, val1))
    if dp[i + 1][0] >= 0:
        if K >> i & 1 > 0:
            dp[i][0] = max(dp[i][0], dp[i + 1][0] + val1)
            dp[i][1] = max(dp[i][1], dp[i + 1][0] + val0)
        else:
            dp[i][0] = max(dp[i][0], dp[i + 1][0] + val0)
print(max(dp[0][0], dp[0][1]))

        

Measured memory_bytes: 88452
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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;
}

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    int r;
    cin >> r;
    cout << r * r << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#define ll long long
#define mod 998244353
using namespace std;
ll fac[1000000],o[1000000];
vector<ll> vt;
ll mypow(ll x, ll y) {
	if (!y)return 1;
	if(y % 2)
		return (x*mypow(x, y - 1)) % mod;
	return mypow((x * x) % mod, y / 2) % mod;
}

int main()
{
	ll a, b, k, n;
	scanf("%lld %lld %lld %lld", &n, &a, &b, &k);
	for (ll i = 0; i <= n; i++)
	{
		vt.push_back(b*i);
	}
	fac[0] = 1;
	for (ll i = 1; i <= 300000; i++)
	{
		fac[i] = fac[i - 1] * i;
		fac[i] %= mod;
	}
	o[0] = 1;
	for (ll i = 1; i <= 300000; i++)
	{
		o[i] = o[i - 1] * mypow(i, mod - 2);
		o[i] %= mod;
	}
	ll sum = 0;
	for (ll i = 0; i <= n; i++)
	{
		if (i*a > k)break;
		ll xx = k - (i*a);
		ll ch = xx / b;
		if (i > n||ch>n)continue;
		if (xx%b != 0)continue;
		ll gap = fac[n] * o[i];
		gap%=mod;
		gap *= o[n - i];
		gap %= mod;
		gap *= fac[n];
		gap %= mod;
		gap *= o[ch];
		gap%=mod;
		gap *= o[n - ch];
		gap %= mod;
		sum += gap;
		sum %= mod;
	}
	printf("%lld", sum);
}

Measured memory_bytes: 12268
#include <iostream>
#include <string>
using namespace std;
int main(){
	string S,T;
	cin>>S>>T;
	for(int i=0;i<(int)S.size();i++){
		cout<<S[i];
		if(!(i<(int)T.size())){
			continue;
		}
		cout<<T[i];
	}
	cout<<endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	n = int(input())
	#b , c = tin()
	#s = input()
	#ret = max(b+c,b+b-1, c+c-1)
	#print(ret)
	al=lin()
	mh=al[0]
	ret=0
	for h in al:
		if mh <= h:
			ret += 1
			mh = h
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 62040
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		StringBuilder sb1 = new StringBuilder();
		StringBuilder sb2 = new StringBuilder();

		for (int i = 0; i < a; i++) {
			sb1.append(b);

		}

		for (int i = 0; i < b; i++) {
			sb2.append(a);
		}

		if (sb1.toString().compareTo(sb2.toString()) < 0) {
			System.out.println(sb1);
		} else {
			System.out.println(sb2);
		}

	}
}


Measured memory_bytes: 22996
/*
g++ -std=c++14 -o2 -Wall diverta2019B.cpp -o .\out\diverta2019B.out
.\out\diverta2019B.out
*/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int Rmax = N / R;
  int Gmax = N / G;
  int ans = 0;
  for (int r = 0; r <= Rmax; ++r) {
    for (int g = 0; g <= Gmax; ++g) {
      int res = N - r * R - g * G;
      if (res >= 0 && res % B == 0) {
        ans += 1;
      }
    }
  }
  cout << ans << "\n";
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N; scanf("%d", &N);
  map<string, int> blues;
  for (int i = 0; i < N; ++i) {
    string s; cin >> s;
    ++blues[s];
  }
  int M; scanf("%d", &M);
  vector<string> reds(M);
  for (int i = 0; i < M; ++i) {
    cin >> reds[i];
  }
  int ans = 0;
  for (map<string, int>::iterator iter = blues.begin(); iter != blues.end(); ++iter) {
    int val = iter->second - count(reds.begin(), reds.end(), iter->first);
    ans = max(ans, val);
  }
  printf("%d\n", ans);
  return 0;
}


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

int main() {
    int N, M;
    cin >> N ;

    vector<string> blues(N);
    for (int i = 0; i < N; i++) cin >> blues.at(i);

    cin >> M ;
    vector<string> reds(M);
    for (int i = 0; i < M; i++) cin >> reds.at(i);

    sort(blues.begin(), blues.end());
    sort(reds.begin(),  reds.end());

    for (int i = 0; i < N; i++) {
        string blue = blues.at(i);
        for (int j = 0; j < M; j++) {
            string red = reds.at(j);
            if (blue == red) {
                blues.at(i) = "";
                reds.at(j)  = "";
                break;
            }
        }
    }

    int sum = 0, max_sum = 0;
    string prev = "";
    for (int i = 0; i < N; i++) {
        string curr = blues.at(i);
//        cout << "curr1: " << curr << endl;
        if (curr != "") {
            if (curr != prev) {
//                cout << "curr: " << curr << ", prev: " << prev << endl;
                sum = 1;
            } else {
                sum++;
//                cout << "sum: " << sum << endl;
            }

            if (sum > max_sum) {
                max_sum = sum;
            }

        }
        prev = curr;
    }

    cout << max_sum << endl;
}


Measured memory_bytes: 3588
N = int(input())

A = {1, 2, 3, 4, 5, 6, 7, 8, 9}
flag = 0

for i in A:
	for j in A:
		if N == i*j:
			flag = 1

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


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

string S;
long dp[2020];
long dpnext[2020];

int main(){
	cin >> S;

	long long ans = 0;
	for(long long i = 0; i < ((long long)S.size()); i++) {
		long long num = S[i] - '0';
		for(long long j = 0; j < 2019; j++) {
			dpnext[(j*10+num)%2019] += dp[j];
		}
		dpnext[num] += 1;

		ans += dpnext[0];
		swap(dp, dpnext);
		for(long long j = 0; j < 2019; j++) {
			dpnext[j] = 0;
		}
		
	}
	cout << ans << endl;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    int multof4 = 0;
    int multof2 = 0;
    int other = 0;
    for(int i = 0; i < n; i++){
        if(a[i] % 4 == 0) multof4++;
        else if(a[i] % 2 == 0) multof2++;
        else other++;
    }

    if(multof2 == 0){
        if(multof4 >= n/2) cout << "Yes" << endl;
        else cout << "No" << endl;
    }else{
        if(multof4 >= (n-multof2+1)/2) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3716
#include<stdio.h>

int main()
{
    int n,k,x,y,a,b,c;
    scanf("%d%d%d%d",&n,&k,&x,&y);
    if(n>k){
    a=n-k;
    b=a*y;
    c=k*x;
    printf("%d\n",b+c);
    }
    else{
        printf("%d",n*x);
    }


    return 0;
}


Measured memory_bytes: 128
/*input
3 5
...#.
.#.#.
.#...
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll maxn=20+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll sub(ll a,ll b){
    ll x=a-b;
    while(x<0) x+=MOD;
    while(x>MOD) x-=MOD;
    return x;
}
ll mult(ll a,ll b){
    return a*b%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=(res*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
char arr[maxn][maxn];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int n,m;
int dist[maxn*maxn][maxn*maxn];
bool isin(int x,int y){
    if(x<0 or x>=n or y<0 or y>=m) return false;
    return true;
}
int to(int a,int b){
    return a*m+b;
}
int main(){
    cin>>n>>m;
    REP(i,n) REP(j,m){
        cin>>arr[i][j];
    }
    REP(i,maxn*maxn) REP(j,maxn*maxn) dist[i][j]=INF;
    REP(i,maxn) dist[i][i]=0;
    REP(i,n) REP(j,m){
        if(arr[i][j]=='#') continue;
        REP(k,4){
            if(isin(i+dx[k],j+dy[k]) and arr[i+dx[k]][j+dy[k]]!='#'){
                dist[to(i,j)][to(i+dx[k],j+dy[k])]=dist[to(i+dx[k],j+dy[k])][to(i,j)]=1;
            }
        }
    }
    REP(k,maxn*maxn) REP(i,maxn*maxn) REP(j,maxn*maxn) MNTO(dist[i][j],dist[i][k]+dist[k][j]);
    int mx=0;
    REP(i,maxn*maxn) REP(j,maxn*maxn){
        if(dist[i][j]<INF) MXTO(mx,dist[i][j]);
    }
    cout<<mx;
}

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


int main()
{
	string S;
	cin>>S;
	ll K;
	cin>>K;
	rep(i,S.size())
	{
		K--;
		if(K<=0||S[i]!='1')
		{
			cout<<S[i]<<endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <set>
#include <queue>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 10;
int N, M, L;
set<int> T[MAX_N];
vector<int> scnt, tcnt, sdist, tdist;
void search(int s, int t, bool flag)
{
    queue<int> que;
    vector<int> dist(N, INF);
    vector<int> cnt(N, 0);
    dist[s] = 0;
    que.push(s);
    while(que.size())
    {
        int v = que.front(); que.pop();
        for(auto u : T[v])
        {
            if(dist[u] > dist[v] + 1)
            {
                dist[u] = dist[v] + 1;
                que.push(u);
            }
        }
    }
    for(int i = 0; i < N; i++)
    {
        if(dist[i] == INF) continue;
        cnt[dist[i]]++;
    }
    if(flag == false)
    {
        sdist = dist;
        scnt = cnt;
    }
    else
    {
        tdist = dist;
        tcnt = cnt;
    }
}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int s, t; cin >> N >> M >> s >> t;
    s--, t--;
    for(int i = 0; i < M; i++)
    {
        int x, y; cin >> x >> y;
        if(x == y) continue;
        x--, y--;
        T[x].insert(y);
        T[y].insert(x);
    }
    search(s, t, 0);
    search(t, s, 1);
    L = sdist[t];
    ll ans = 0;
    for(int i = 0; i < N; i++)
    {
        int dist = L - 2 - sdist[i];
        if(dist < 0) continue;
        ans += tcnt[dist];
    }
    cout << ans << endl;
    return 0;
}




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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    string s;
    cin >> s;

    // 処理
    int cnt = 0;
    int ans = 0;
    rep(i, s.size()) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            cnt++;
            ans = max(cnt, ans);
        } else {
            cnt = 0;
        }
    }

    // 出力
    cout << ans << endl;

    return 0;
}


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

using namespace std ;

map < char , int > mp1 ;

int main ()
{
    int a , b , c [ 101 ] ;
    cin >> a >> b ;
    for ( int i = 0 ; i < a ; ++ i ){
        cin >> c [ i ] ;
        c [ i ] -= b ;
    }
    int d = a * 25 ;
    long long dp [ a + 1 ] [ d * 2 ] ;
    for ( int i = 0 ; i <= a ; ++ i ){
        for ( int j = 0 ; j < d * 2 ; ++ j ){
            dp [ i ] [ j ] = 0 ;
        }
    }
    dp [ 0 ] [ d ] = 1 ;
    for ( int i = 1 ; i <= a ; ++ i ){
        for ( int j = 0 ; j < d * 2 ; ++ j ){
            dp [ i ] [ j ] = dp [ i - 1 ] [ j ] + dp [ i - 1 ] [ j - c [ i - 1 ] ] ;
        }
    }
    cout << dp [ a ] [ d ] - 1 ;
    return 0 ;
}


Measured memory_bytes: 1280
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 LN           PIC X(500).
01 N            PIC 9(3).
01 cur          PIC 9(10) VALUE 1.
01 i            PIC 9(18) VALUE 1.
01 j            PIC 9(18).
01 len          PIC 9(10). 
01 A            PIC 9(4) VALUE 1.
01 FLG          PIC 9(1) VALUE 1.

PROCEDURE DIVISION.
MAIN.
ACCEPT N.
ACCEPT LN.
PERFORM N TIMES
    PERFORM VARYING j FROM cur BY 1 UNTIL LN(j:1) = SPACE
    END-PERFORM
    COMPUTE len = j - cur
    MOVE LN(cur:len) TO A
    IF FUNCTION MOD(A, 2) = ZERO AND FUNCTION MOD(A, 3) NOT = ZERO
        AND FUNCTION MOD(A, 5) NOT = ZERO THEN
        MOVE ZERO TO FLG
        EXIT PERFORM
    END-IF
    COMPUTE cur = j + 1
    ADD 1 TO i
END-PERFORM.
IF FLG = 1
    DISPLAY "APPROVED"
ELSE
    DISPLAY "DENIED"
END-IF.

MAIN-EXIT.
STOP RUN.


Measured memory_bytes: 384
package main
import (
	"fmt"
	"bufio"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var a,b,c int
	var temp int
	fmt.Fscan(r,&a,&b,&c)
	if(a>b){
		temp=a
		a=b
		b=temp
	}
	if(b>c){
		temp=b
		b=c
		c=temp
	}
	if(a>b){
		temp=a
		a=b
		b=temp
	}
	fmt.Printf("%d %d %d\n",a,b,c)
}


Measured memory_bytes: 1172
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()

mod=10**9+7

MAX_N=n+5
fac = [1,1] + [0]*MAX_N
finv = [1,1] + [0]*MAX_N
inv = [0,1] + [0]*MAX_N
for i in range(2,MAX_N):
  fac[i] = fac[i-1] * i % mod
  inv[i] = mod - inv[mod % i] * (mod // i) % mod
  finv[i] = finv[i-1] * inv[i] % mod

def nCk(n,k):
  if n<k:
    return 0
  if n<0 or k<0:
    return 0
  return fac[n] * (finv[k] * finv[n-k] % mod) % mod

max_x=0
for i in range(k-1,n):
  max_x+=a[i]*nCk(i,k-1)
  max_x%=mod

min_x=0
for i in range(n-k+1):
  min_x+=a[i]*nCk(n-i-1,k-1)
  min_x%=mod

print((max_x-min_x)%mod)

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

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

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

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

	if (m == 1)
		return 0;

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

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

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

	if (x < 0)
		x += m0;

	return x;
}

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

int main(int argc, char* argv[])
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s,t;
	cin>>s>>t;
	int a,b;
	cin>>a>>b;
	map<string,int> mp;
	mp[s]=a;
	mp[t]=b;
	string k;
	cin>>k;
	mp[k]--;
	cout<<mp[s]<<' '<<mp[t];
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

inline int read()
{
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}

map<ll, int> cnt; int n;

int main()
{
	n = read(); ll s = 0, ans = 0;
	cnt[0] = 1;
	for (int i = 1; i <= n; i ++)
	{
		int x = read();
		s += x;
		ans += cnt[s];
		++ cnt[s];
	}
	printf("%lld\n", ans);
	
	return 0;
}


Measured memory_bytes: 12800
import itertools
import numpy as np

n, m, x = map(int, input().split())
l = np.array([list(map(int, input().split())) for _ in range(n)])
num = [i for i in range(n)]

ans = 10**10
for i in range(1, n+1):
  for v in itertools.combinations(num, i):
    tmp = 0
    rikaido = np.array([0 for _ in range(m)])
    
    for each in v:
      tmp += l[each][0]
      rikaido += l[each][1:]
    
    if np.min(rikaido) >= x:
      ans = min(ans, tmp)
      
if ans == 10**10:
  print(-1)
else:
  print(ans)
      

Measured memory_bytes: 27260
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char=小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define Yay(ans) if(ans)cout<<"Yay!"<<rt;else cout<<":("<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define str string
#define please return
#define AC 0
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef long double ldouble;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

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

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

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

int keta(int n) {
	int sum = 0;
	while (n > 0) {
		sum += n % 10; n /= 10;
	}
	return sum;
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {

	int n;
	cin >> n;

	int x = nine;

	rop(i, n - 1) {
		int a = i;
		int b = n - i;
		x = min(x, keta(a) + keta(b));
	}
	cout << x << rt;

	please AC;
}

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

int main() {
    
    vector<int> v;
    vector<int> a = {5, 5, 7};

    for (int i=0; i<3; ++i) {
        int n;
        cin >> n;
        v.push_back(n);
    }
    
    sort(v.begin(), v.end());

    if (v == a) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

	int n, m;
	int a, b;
	int count[50] = { 0 };

	cin >> n >> m;

	for (int i = 0;i < m;i++) {
		cin >> a >> b;
		count[a]++;
		count[b]++;
	}

	for (int i = 1;i <= n;i++) {
		cout << count[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
//****************************//
/**********  main *************/
//****************************//
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<b;i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())


int main() {

	std::cin.tie(0);

	int tmp,len;
	int n,m;
	string s,ss;
	string s_tmp,a_tmp,b_tmp;
    int flag = 0;
	cin >> s ;
	
	s_tmp = ss = s;
	reverse(s_tmp.begin(),s_tmp.end());
	if(s == s_tmp) flag += 1;

    //cout << s << endl << s_tmp << endl ;


	len = s.length();
	tmp = (len+3)/2-1 ;
	
	//cout << tmp;
	
	a_tmp = s.substr(0,(len-1) / 2);
		//cout << a_tmp << endl;

	b_tmp = ss.substr(tmp,(len-1) / 2);
    //	b_tmp = ss.substr(4,3);
		//cout << b_tmp << endl;
    
    s = a_tmp ;
    reverse(a_tmp.begin(),a_tmp.end());
    if(s == a_tmp) flag += 1;

    s = b_tmp ;
    reverse(b_tmp.begin(),b_tmp.end());
    if(s == b_tmp) flag += 1;

    flag == 3 ? (cout << "Yes" << endl) : (cout << "No" << endl);
    

    return 0;
}


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

int main(){
    int w, h, x, y, r;
    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
    
    if((x-r)<0 || (x+r)>w){
        printf("No\n");
    } else if((y+r)>h||(y-r)<0){
        printf("No\n");
    } else{
        printf("Yes\n");
    }
    
    return 0;
}


Measured memory_bytes: 3160
/*
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
//*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb push_back
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

int n , m;
int type[maxn];
string s;
set < int > adj[maxn][2];
queue < int > q;
set < int > st;

bool bad(int v){
    return(adj[v][0].size() == 0 or adj[v][1].size() == 0);
}

void remove(int v){
    st.erase(v);
    for(auto u : adj[v][0]){
        adj[u][type[v]].erase(v);
        if(st.count(u) and bad(u))
            q.push(u);
    }
    for(auto u : adj[v][1]){
        adj[u][type[v]].erase(v);
        if(st.count(u) and bad(u))
            q.push(u);
    }
}

int32_t main(){
    migmig
    cin >> n >> m;
    cin >> s;
    int cnt = 1;
    for(auto i : s)
        type[cnt++] = (i=='A');
    for(int i = 0 ; i < m ; i ++){
        int u , v;
        cin >> u >> v;
        adj[u][type[v]].insert(v);
        adj[v][type[u]].insert(u);
    }
    for(int i = 1 ; i <= n ; i ++)
        st.insert(i);
    for(int i = 1 ; i <= n;  i ++)
        if(bad(i))
            q.push(i);
    while(q.size()){
        int v = q.front();
        q.pop();
        remove(v);
    }
    cout << (st.size()?"Yes" : "No");
    return(0);
}

Measured memory_bytes: 312476
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

int main()
{
  int i,j,tmp,ans;
  int a[3];
  scanf("%d%d%d",&a[0],&a[1],&a[2]);
  sort(a,a+3);
  ans=100000;
  do
  {
    tmp=abs(a[0]-a[1])+abs(a[1]-a[2]);
    if (tmp<ans) ans=tmp;
  }while (next_permutation(a,a+3));
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define INF 1000000000
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	string s,t;
	cin>>s>>t;
	for(int i=s.size()-t.size();i>=0;i--){
		for(int j=t.size()-1;j>=0;j--){
			if(s[i+j]==t[j] || s[i+j]=='?'){
				if(j==0){
					for(int k=t.size()-1;k>=0;k--){
						s[i+k]=t[k];
					}
					REP(i,s.size()){
						if(s[i]=='?') s[i]='a';
					}
					cout<<s<<endl;
					return 0;
				}
			continue;
			}
			else break;
		}
	}
	cout<<"UNRESTORABLE"<<endl;
	return 0;
}
	
	

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

int main(){
  string N;
  cin >> N;
  int cnt=0;
  for(int i=0; i<2; i++){
    if(N.at(i)==N.at(i+1) && N.at(i+1)==N.at(i+2)) cnt++;
  }
  if(cnt>0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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



int main() {
  int n;
  while (cin >> n, n != -1) {
    int cost = 1150;
    if (n > 10) cost += min(10, n - 10) * 125;
    if (n > 20) cost += min(10, n - 20) * 140;
    if (n > 30) cost += (n - 30) * 160;
    cout << 4280 - cost << endl;
  }
}

Measured memory_bytes: 1160
using System;

namespace A
{
	class Program
	{
		static void Main(string[] args)
		{
			string S = Console.ReadLine();
			if (S[2] == S[3] && S[4] == S[5])
			{
				Console.WriteLine("Yes");
			}
			else
			{
				Console.WriteLine("No");
			}
		}
	}
}


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

int main() {
    int n, ret = 0; cin >>n;
    map<int, int> a;
    for (int i = 0; i < n; i++) {
        int t; cin >>t;
        a[t] += 1;
        ret += (a[t]%2==1) ? 1 : -1;
    }
    cout << ret << endl;
    return 0;
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

ll func(string s){
    int n = s.size();
    ll sum = 0;
    for(int i=0,j=0; i<n; i=j){
        while(s[i]==s[j])j++;
        sum += (j-i)/2;
    }
    return sum;
}
int main() {
    string s;
    cin >> s;
    set<char>st;
    ll k;
    cin >> k;
    int m = s.size();
    rep(i, 0, m){
        st.insert(s[i]);
    }
    ll a = func(s);
    ll b = func(s+s);
    if(st.size()==1)cout << (ll)m*k/2 << endl;
    else cout << a+(b-a)*(k-1) << endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;

int N;
ll A[200010];
map < ll , ll > cnt;

int main() {

    cin >> N;
    REP(i,N) cin >> A[i];

    cnt[0] = 1;

    ll ans = 0;
    ll acc = 0;
    for (int i = 0; i < N; i++) {
    	ll t = acc + A[i];
    	ans += cnt[t];
    	acc += A[i];
    	cnt[acc]++;
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

int n;
vector<vector<int>> g;
vector<int> a, dp, ans;

void dfs(int x, int p = -1){
	auto it = lower_bound(dp.begin() + 1, dp.end(), a[x]) - (dp.begin() + 1);
	int old = dp[it + 1];
	dp[it + 1] = a[x];
	ans[x] = it;
	if(p != -1)
		ans[x] = max(ans[x], ans[p]);
	for(int y : g[x]){
		if(y != p)
			dfs(y, x);
	}
	dp[it + 1] = old;
}

int main(void){
	cin >> n;
	a.resize(n + 1);
	dp.resize(n + 1);
	ans.resize(n + 1);
	g.resize(n + 1);
	for(int i = 1 ; i <= n ; i++) cin >> a[i];
	for(int i = 1 ; i < n ; i++){
		int x, y;
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	for(int i = 1 ; i <= n ; i++){
		dp[i] = INT_MAX;
	}
	dp[1] = 0;
	dfs(1);
	for(int i = 1 ; i <= n ; i++){
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 27932
N=2*10**5+3
mod=10**9+7
fac=[1]*(N+1)
for i in range(1,N+1):
    fac[i]=fac[i-1]*i%mod
inv_fac=[1]*(N+1)
inv_fac[N]=pow(fac[N],mod-2,mod)
for i in range(N-1,0,-1):
    inv_fac[i]=inv_fac[i+1]*(i+1)%mod
def nCr(n,r):
    if n<=0 or r<0 or r>n:
        return 0
    return fac[n]*inv_fac[r]%mod*inv_fac[n-r]%mod

n,k=map(int,input().split())
def count(n,x):
    ret=nCr(n,x)*nCr(n-1,n-x-1)%mod
    return ret

ans=0
x=0
if k==1:
    x=1
while x<=k and x<n:
    ans=(ans+count(n,x))%mod
    x+=1
print(ans)

Measured memory_bytes: 18804
N = int(input())

ans = 1
mcnt = 0

for i in range(1, N+1):
    a = i
    cnt = 0
    while a % 2 == 0:        
        a /= 2
        cnt += 1
    if cnt > mcnt:
        mcnt = cnt
        ans = i
        
print(ans)



Measured memory_bytes: 2940
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")



void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll aa , bb;} fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->aa - ((fr*)q)->aa;}

/*-------------------------------------------------*/
// Union Find              添字に注意!!!!!!!!!!
typedef struct{
    ll num; //number
    ll par; //parent
    ll height; //height
}UF;
void UFmake(ll n, UF b[n]){for(ll i=0;i<n;i++){
    b[i].par = i;
    b[i].num = i;
    b[i].height = 1;
    }
}
ll UFroot(ll n, ll a,UF b[n]){ return a==b[a].par?a:UFroot(n,b[a].par,b); }
void UFunite(ll n, ll x, ll y, UF b[n]){
    if(b[UFroot(n,x,b)].height > b[UFroot(n,y,b)].height) b[UFroot(n,y,b)].par = UFroot(n,x,b);
    else{ b[UFroot(n,x,b)].par = UFroot(n,y,b); b[UFroot(n,y,b)].height = max2(b[UFroot(n,y,b)].height,b[UFroot(n,x,b)].height+1);}
}
ll UFsame(ll n, ll x, ll y, UF b[n]){ return UFroot(n,x,b) == UFroot(n,y,b) ? 1 : 0; }

int main(void){
    // char ;
    ll n,m,ans=0;
    scanf("%lld%lld",&n,&m);
    ll x[m],y[m],z[m];
    rep(i,0,m){
        scanf("%lld%lld%lld",&x[i],&y[i],&z[i]);
    }
    UF a[n];
    UFmake(n,a);
    rep(i,0,m){
        UFunite(n,x[i]-1,y[i]-1,a);
    }
    ll r[n];
    rep(i,0,n){
        r[i]=UFroot(n,i,a);
    }
    sortup(r,n);
    ans=n;
    rep(i,1,n){
        if(r[i-1]==r[i]){
            ans--;
        }
    }

    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 6396
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int A, B, C;
int N;
int D[333];
int ta[1000], tb[1000], tc[1000];
int x;

int main() {
  while (cin >> A >> B >> C) {
    if (A == 0 && B == 0 && C == 0) break;
    cin >> N;
    for (int i=0; i<333; i++) D[i] = 2;
    x = 0;
    for (int i=0; i<N; i++) {
      int a, b, c, r;
      cin >> a >> b >> c >> r;
      if (r == 1) {
        D[a-1] = 1;
        D[b-1] = 1;
        D[c-1] = 1;
      }
      else {
        ta[x] = a-1;
        tb[x] = b-1;
        tc[x] = c-1;
        x++;
      }
    }
    for (int k=0; k<1; k++) {
      for (int i=0; i<x; i++) {
        int a = ta[i], b = tb[i], c = tc[i];
        if      (D[a] == 2 && D[b] == 1 && D[c] == 1) D[a] = 0;
        else if (D[a] == 1 && D[b] == 2 && D[c] == 1) D[b] = 0;
        else if (D[a] == 1 && D[b] == 1 && D[c] == 2) D[c] = 0;
      }
    }
    for (int i=0; i<A+B+C; i++) {
      cout << D[i] << "\n";
    }
  }
  return 0;
}

Measured memory_bytes: 3084
import math
n = int(input())

t = int(math.sqrt(n))
a, b = 1, n

for i in range(t):
  if n%(t-i) == 0:
    a = t-i
    b = n // (t-i)
    break

keta_a = math.floor(math.log10(a)+1)
keta_b = math.floor(math.log10(b)+1)

print(max(keta_a, keta_b))

Measured memory_bytes: 3060
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

struct MP<T: std::cmp::PartialEq> {
    pi: Vec<i32>,
    s: Vec<T>,
}

impl<T: std::cmp::PartialEq> MP<T> {
    fn new(s: Vec<T>) -> MP<T> {
        let mut pi = vec![0; s.len() + 1];
        pi[0] = -1;
        let mut j = -1;
        for i in 0..s.len() {
            while j >= 0 && s[i] != s[j as usize] {
                j = pi[j as usize];
            }
            j += 1;
            pi[i + 1] = j;
        }
        MP { pi: pi, s: s }
    }

    fn matched_indexes(&self, t: &Vec<T>) -> Vec<usize> {
        let mut j = 0;
        let mut res = vec![];
        for i in 0..t.len() {
            while j >= 0 && self.s[j as usize] != t[i] {
                j = self.pi[j as usize];
            }
            j += 1;
            if j as usize == self.s.len() {
                res.push(1 + i - j as usize);
                j = self.pi[j as usize];
            }
        }
        res
    }
}

fn reduce(a: &Vec<u32>) -> Vec<u32> {
    let mut res = vec![0; a.len() - 1];
    for i in 0..a.len() - 1 {
        res[i] = a[i] ^ a[i + 1];
    }
    res
}

fn main() {
    let n = read::<usize>();
    let mut org_a = read_vec::<u32>();
    let org_b = read_vec::<u32>();
    let mut a_clone = org_a.clone();
    org_a.append(&mut a_clone);
    let a = reduce(&org_a);
    let b = reduce(&org_b);

    // debug!(a);
    // debug!(b);

    let mp = MP::new(b);
    let indexes = mp.matched_indexes(&a);
    for k in indexes {
        if k == n {
            break;
        }
        let x = org_a[k] ^ org_b[0];
        println!("{} {}", k, x);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 19436
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>

#define INT long long
#define MOD 1000000007

using namespace std;
string s;
int k, val[100010];
int main()
{
    cin>>s>>k;
    for(int i = 0 ; i < s.size() ; i++ )
        val[i] = ('z' - s[i]) + 1, val[i]%=26;
    for(int i = 0 ; i < s.size()-1 ; i++ )
        if( k >= val[i] ) printf("a"), k-=val[i];
        else printf("%c", s[i]);
    printf("%c",((s[s.size()-1]-'a')+k)%26+'a');
    puts("");
    return 0;
}


Measured memory_bytes: 896
# Your code here!
k,s=gets.chomp.split(" ").map(&:to_i);
ans=0

x=0
while x<=k
    y=0
    while y<=k
        z=s-x-y
        if 0<=z&&z<=k
            ans=ans+1
            #puts(x,y,z,11)
        end
        y=y+1
    end
    x=x+1
end

puts(ans)



Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <set>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
int main(){
    string s;
    cin >> s;
    if(s[0] == '1'){
        s[0] = '9';
    }
    else{
        s[0] = '1';
    }
    if(s[1] == '9'){
        s[1] = '1';
    }
    else{
        s[1] = '9';
    }
    if(s[2] == '1'){
        s[2] = '9';
    }
    else{
        s[2] = '1';
    }

    cout << s << endl;
}

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

int main(){

	int t, tt;

	tt = 0;
	for(int i=0; i<4; i++){
		cin >> t;
		tt += t;
	}

	cout << tt / 60 << endl << tt - (tt / 60) * 60 << endl;

	return 0;

}

Measured memory_bytes: 1160
from collections import defaultdict


def main():
    number = int(input())
    numcount = defaultdict(int)
    for x in input().split():
        numcount[int(x)] += 1
    queries = int(input())
    ans = sum(num * count for num, count in numcount.items())
    for _ in range(queries):
        before, after = [int(x) for x in input().split()]
        tmp = numcount[before]
        numcount[before] -= tmp
        numcount[after] += tmp
        ans += (after - before) * tmp
        print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  int n,m,Q;
  cin >> n >> m >> Q;
  vector<vector<int>>p(n+1,vector<int>(n+1));
  rep(i,0,m){
    int L,R;
    cin >> L >> R;
    p[L][R]++;
  }
  rep(i,1,n+1) rep(j,1,n+1) p[i][j] += p[i][j-1];
  rep(i,1,n+1) rep(j,1,n+1) p[i][j] += p[i-1][j];
  rep(i,0,Q){
    int L,R;
    cin >> L >> R;
    cout << p[R][R]+p[L-1][L-1]-p[R][L-1]-p[L-1][R] << endl;
  }
}

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

int n, m, i, j;
int a[200000];
long long int ans;

int main(){
	scanf("%d%d", &n, &m);
	for(i=0; i<n; i++){
		scanf("%d%d", &a[i<<1], &a[(i<<1)+1]);
	}
	qsort(a, n, sizeof(int)*2, compare_pair);
	for(i=0; i<n; i++){
		if(m <= a[(i<<1)+1]){
			ans += (long long int)a[i<<1]*m;
			break;
		}else{
			ans += (long long int)a[i<<1]*a[(i<<1)+1];
			m -= a[(i<<1)+1];
		}
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 1788
# -*- coding: utf-8 -*-
import collections
# factrize
def factorize(target_number):
    factor = 2
    factor_list = []
    while factor * factor <= target_number:
        while target_number % factor == 0:
            target_number //= factor
            factor_list.append(factor)
        factor = factor + 1
    if target_number > 1:
        factor_list.append(target_number)
    return factor_list

N = int(input())

fact_list = factorize(N)

fact_counter_dict = collections.Counter(fact_list)
ans = 0
for fact, freq in fact_counter_dict.items():
    freq_copy = freq
    for i in range(1, freq + 1):
        freq_copy -= i
        if freq_copy < 0:
            break
        ans += 1
print(ans)

Measured memory_bytes: 9464
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0)
#define sz(a) (a).size()


using namespace std;

const ll N = 1e3;
const ll big = 1e18;
const ll block = 800;
const ll mod = 1e6;

ll n;

ll a[N];

int main() {
    speed;
	cin >> n;
	for(int i = 0 ; i < 2 * n ; i++)
		cin >> a[i];
	sort(a, a + n * 2);
	ll ans = 0;
	for(int i = 0 ; i <= n ; i++)
		ans += a[i * 2];
	cout << ans;
}

/*
	Code written by
	Codeforces : I_Love_Trott
	mail : dzhon.snoudin@mail.ru
*/



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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double[] a = new double[n];
		double[] b = new double[n];
		double[] c = new double[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			b[i] = sc.nextInt();
		}
		for (int i = 0; i < n; i++) {
			c[i] = sc.nextInt();
		}
		Arrays.sort(a);
		Arrays.sort(b);
		Arrays.sort(c);

		long ans = 0;
		for (int i = 0; i < n; i++) {
			long idx1 = -1 - Arrays.binarySearch(a, b[i] - 0.1);
			long idx2 = n + 1 + Arrays.binarySearch(c, b[i] + 0.1);
			ans += idx1 * idx2;
		}

		System.out.print(ans);
	}
}

Measured memory_bytes: 99272