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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll n;
vector<ll> a;

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

  cin>>n;
  a.resize(n);
  rep(i,n){
    cin>>a[i];
    a[i]--;
  }

  {
    bool sorted=true;
    rep(i,n)if(a[i]!=i)sorted=false;
    if(sorted){
      cout<<"YES"<<endl;
      return 0;
    }
  }

  rep(i,n)rep(j,i){
    vector<ll> b=a;
    swap(b[i],b[j]);
    bool sorted=true;
    rep(k,n)if(b[k]!=k)sorted=false;
    if(sorted){
      cout<<"YES"<<endl;
      return 0;
    }
  }

  cout<<"NO"<<endl;

  return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// 01Trie BIT CHT DFT FFT avl cmd cusum dijkstra dinic geo2 gin graph kruskal lca lcm matrix ncm next_combination ppuf segtree st tmp topcoder uf vi 

struct Monoid {
    using T = int;
    T operator()(const T &a, const T& b) { return a + b; }
    const T I = 0;
};
struct SegmentTree {
    using T = Monoid::T;
    Monoid op;
    int n;
    vector<T> d;
    SegmentTree(int m) {
        for (n = 1; n < m; n *= 2);
        d.assign(2 * n - 1, op.I);
    }
    void update(int k, T x) {
        k += n - 1;
        d[k] = x;
        while (k > 0) {
            k = (k - 1) / 2;
            d[k] = op(d[2 * k + 1], d[2 * k + 2]);
        }
    }
    T query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l)return op.I;
        if (a <= l&&r <= b)return d[k];
        T xl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        T xr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return op(xl, xr);
    }
    T query(int a, int b) {
        return query(a, b, 0, 0, n);
    }
};

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

    Int(n);
    string st;
    cin >> st;

    vi mmn(n+1, 0);
    rep(i, n) {
        if (st[i] == 'M') mmn[i+1] = 1;
    }
    rep(i, n) {
        mmn[i+1] += mmn[i];
    }
    vi funami(n+1, 0), kyoko(n+1, 0);
    rep(i, n) {
        if (st[i] == 'C') {
            funami[i+1] = mmn[i+1];
            kyoko[i+1] = 1;
        }
    }
    rep(i, n) {
        funami[i+1] += funami[i];
        kyoko[i+1] += kyoko[i];
    }

    
    Int(q);
    while (q--) {
        Int(k);
        int ans = 0;

        rep(i, st.size()) {
            if (st[i] == 'D') {
                ans += (funami[min(n, i+k)] - funami[i]) 
                    - mmn[i] * (kyoko[min(n, i+k)] - kyoko[i]);
            }
        }

        std::cout << ans << std::endl;
    }

    return 0;
}


Measured memory_bytes: 24860
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}

template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}

template<typename T> void sort(vector<T>& v) {sort(v.begin(), v.end());}

int main() {
  int n, m, t = 0;
  cin >> n >> m;
  vector<int> a(n);
  cin >> a;
  unordered_map<int, int> mp;
  int64_t res = 0;
  mp[0] = 1;
  for (int i : a) {
    t = (t + i) % m;
    res += mp[t];
    ++mp[t];
  }
  cout << res << endl;
}



Measured memory_bytes: 4108
import java.io.IOException;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		String a = scanner.nextBigInteger().subtract(BigInteger.ONE).toString();
		String b = scanner.next();
		M = scanner.nextInt();
		
		System.out.println((slove(b) - slove(a) + mod) % mod);
	}

	private int slove(String s) {
		n = s.length();
		num = new int[n];
		for (int i = 0; i < n; i++)
			num[n - i - 1] = s.charAt(i) - '0';
		dp = new int[2][2][10][n][M];
		for (int[][][][] dp1 : dp)
			for (int[][][] dp2 : dp1)
				for (int[][] dp3 : dp2)
					for (int[] dp4 : dp3)
						Arrays.fill(dp4, -1);
		int res = 0;
		for (int i = 0; i <n; i++)
			for (int j = 1; j <= (i == n - 1 ? num[i] : 9); j++) {
				res = (res + slove(i, j % M, j, 1, i == n - 1 && j == num[i]))
						% mod;
				if (i != 0)
					res = (res + slove(i, j % M, j, 0, i == n - 1
							&& j == num[i]))
							% mod;

			}
		return res % mod;
	}

	private int slove(int p, int m, int pre, int s, boolean b) {
		if (p == 0)
			return m == 0 ? 1 : 0;
		if (dp[s][b ? 1 : 0][pre][p][m] != -1)
			return dp[s][b ? 1 : 0][pre][p][m];
		int ans = 0;

		if (s == 0) {
			int size = (b ? num[p - 1] : 9);
			for (int i = pre + 1; i <= size; i++)
				ans += slove(p - 1, (m * 10 + i) % M, i, 1, b
						&& i == num[p - 1]);
		} else {
			int size = Math.min(b ? num[p - 1] : 9, pre - 1);
			for (int i = 0; i <= size; i++)
				ans += slove(p - 1, (m * 10 + i) % M, i, 0, b
						&& i == num[p - 1]);
		}
		return dp[s][b ? 1 : 0][pre][p][m] = ans % mod;

	}

	int M, n;
	int mod = 10000;
	int[] num;
	int[][][][][] dp;
}

Measured memory_bytes: 138132
import sys
input = lambda: sys.stdin.readline()[:-1]
n,m=map(int,input().split())
data=[list(map(int,input().split())) for i in range(m)]
for i in range(m):
	data[i].append(i)
data.sort(key=lambda tup:(tup[0],tup[1]))
ansdata=[0]*m
now,count=0,0
for e in data:
	if now==e[0]:
		count+=1
		ansdata[e[2]]='0'*(6-len(str(now)))+str(now)+'0'*(6-len(str(count)))+str(count)
	else:
		now=e[0]
		count=1
		ansdata[e[2]]='0'*(6-len(str(now)))+str(now)+'0'*(6-len(str(count)))+str(count)

for i in ansdata:
	print(i)



Measured memory_bytes: 79580
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  char s;
  int flag=0;

  cin >> n;

  for(int i=0;i<n;i++){
    cin >> s;
    if(s == 'Y'){
      cout << "Four" << endl;
      flag=1;
      break;
    }
  }

  if(flag != 1)
    cout << "Three" << endl;
  
    
}

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

using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define REP(i, n) for(int i=1;i<=n;i++)
typedef long long ll;

ll dp[100005][2];

int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	
	dp[0][0] = a[0];
	dp[0][1] = -a[0];
	
	REP(i, n - 1) {
		dp[i][0] = max(dp[i - 1][0] + a[i], dp[i - 1][1] - a[i]);
		dp[i][1] = max(dp[i - 1][0] - a[i], dp[i - 1][1] + a[i]);
	}
	
	ll ans = dp[n - 1][0];
	
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 2560
#include <iostream>
using namespace std;
typedef long long ll;
ll counts(ll s)//sum of the digits of s
{
	if(s == 0)
	{
		return 0;
	}
	return s % 10 + counts(s / 10);
}
ll nxt(ll x,ll y)//ceil(x/y)
{
	return (x + y - 1) / y;
}
int main()
{
	ll K;
	cin>>K;
	ll cur = 2,p = 1;
	while(K)
	{
		ll n = cur * p - 1;
		ll m = nxt(cur,10) * p * 10 - 1;
		if(n * counts(m) > m * counts(n))
		{
			cur = nxt(cur,10);
			p *= 10;
		}
		else
		{
			cout<<n<<endl;
			K--;
			cur++;
		}
		// printf("cur = %lld,p = %lld\n",cur,p);
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

const (
	SCANNER_BUF_SIZE = 2 << 20

	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

var (
	writer  *bufio.Writer
	scanner *bufio.Scanner
)

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(writer, f, a...)
}

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func sstring() string {
	scanner.Scan()
	return scanner.Text()
}

func gcd(a, b int64) int64 {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

func abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

func main() {
	defer writer.Flush()
	n := sint64()
	a := make([]int64, n)
	for i := range a {
		a[i] = sint64()
	}
	total := int64(0)
	for _, ai := range a {
		total ^= ai
	}
	for _, ai := range a {
		printf("%d ", total^ai)
	}
}


Measured memory_bytes: 8076
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 2005


int N;
ll P[SIZE],Q[SIZE];
ll cycle[SIZE],ok_count[SIZE];

ll gcd(ll x,ll y){

	x = abs(x);
	y = abs(y);

	if(x < y){
		swap(x,y);
	}
	if(y == 0){
		return x;
	}else{
		return gcd(y,x%y);
	}
}

ll extgcd(ll a,ll b,ll &x,ll &y){
	ll d = a;
	if(b != 0){
		d = extgcd(b,a%b,y,x);
		y -= (a/b)*x;
	}else{
		x = 1;
		y = 0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}

//A[i]*x≡B[i](mod M[i])のxを求める
pair<ll,ll> linear_congruence(const vector<ll>&A, const vector<ll>&B,const vector<ll>&M){

	ll x = 0,m = 1;
	for(int i = 0; i < A.size(); i++){
		ll a = A[i]*m,b = B[i]-A[i]*x,d = gcd(M[i],a);
		if(b%d != 0)return make_pair(0,-1); //解がない
		int t = b / d * mod_inverse(a/d,M[i]/d) % (M[i]/d);
		x = x+m*t;
		m *= M[i]/d;
	}
	return make_pair(x%m,m);
}

int main(){

	scanf("%d",&N);

	for(int i = 1; i <= N; i++){

		scanf("%lld",&P[i]);
	}

	for(int i = 1; i <= N; i++){

		scanf("%lld",&Q[i]);
	}

	vector<ll> A,B,M;

	for(int i = 1; i <= N; i++){

		ll first = P[i],tmp = P[i];
		int count = 0;

		ok_count[i] = -1;

		while(true){

			if(tmp == i){

				ok_count[i] = count;
			}
			tmp = Q[tmp];
			count++;

			if(tmp == first){
				cycle[i] = count;
				break;
			}
		}

		if(ok_count[i] == -1){

			printf("-1\n");
			return 0;
		}

		A.push_back(1);
		B.push_back(ok_count[i]);
		M.push_back(cycle[i]);
	}

	pair<ll,ll> ans = linear_congruence(A,B,M);

	if(ans.second == -1){

		printf("-1\n");

	}else{

		printf("%lld\n",(ans.first+ans.second)%ans.second);
	}

	return 0;
}



Measured memory_bytes: 3276
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#define ll long long int
#define rep(i,n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair

using namespace std;

vector<bool> bo;
vector<vector<int> > e;

void dfs(int c,int p){
    bo[c] = true;
    rep(i,e[c].size()){
        if(e[c][i] != p && bo[e[c][i]] != true){
            dfs(e[c][i],c);
        }
    }
}

int main(){
    int n,m;
    cin >> n >> m;
    bo.resize(n);
    e.resize(n);
    rep(i,n) bo[i] = false;
    vector<pair<int,int> > p(m);
    int a,b;

    rep(i,m){
        cin >> a >> b;
        a--;
        b--;
        e[a].pb(b);
        e[b].pb(a);
        p[i] = mp(a,b);
    }

    ll ans = 0;

    rep(i,m){
        dfs(p[i].first,p[i].second);
        //dfs(p[i].second,p[i].first);
        rep(j,n){
            if(bo[j] == false){
                ans++;
                break;
            }
        }
        rep(k,n) bo[k] = false;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const long m = 1000000007;

long pow(long n, int k) {
    long r = 1;
    while (k > 0) {
        if ((k & 1) == 1) {
            r = r * n % m;
        }
        n = n * n % m;
        k >>= 1;
    }
    return r;
}
int main() {
    long n;
    cin >> n;
    long res = pow(10, n);
    res = (res + m - pow(9, n)) % m;
    res = (res + m - pow(9, n)) % m;
    res = (res + pow(8, n)) % m;
    cout << res << endl;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
int main(){
char a[10];
scanf("%s",a);
int i=0;
int count=0;
int max=0;
while (a[i]!='\0') {
  if(a[i]=='A' || a[i]=='T' || a[i]=='C' || a[i]=='G'){count+=1;}
  else {count=0;}
  i++;
  if(max<count)max=count;
}
printf("%d\n",max);
return 0;
}


Measured memory_bytes: 128
A=[list(map(int,list(input().split()))) for i in range(3)]  
N=int(input())
b=[int(input()) for _ in range(N)]

#print(A[0][0])

A_new = []
for bi in b:
  #print(bi)
  for i in range(3):
    #print(A[1][1])
    A_ = [0 if bi==A[i][j] else A[i][j] for j in range(3)]
    #print(A_)
    A[i] = A_

import numpy as np
A = np.array(A)
t = np.sum(A, axis=0)
y = np.sum(A, axis=1)
n1 = A[0][0]+A[1][1]+A[2][2]
n2 = A[0][2]+A[1][1]+A[2][0]

if 0 in t:
  print('Yes')
elif 0 in y:
  print('Yes')
elif n1==0 or n2==0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 12488
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;
 
//const int MOD=998244353;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
    
    int ans=0;
    for(int i=1; i<n; i++){
        int x=n-i;
        if(x<i) ans++;
    }
    cout<<ans;
    
    
    
    return 0;
}

Measured memory_bytes: 256
m,d = gets.split.map {|x| x.to_i}

cnt = 0
1.upto(m) { |_m|
  1.upto(d) { |_d|
    d1 = _d / 10
    d2 = _d % 10
    if d1 > 1 and d2 > 1 and _m == d1 * d2
      cnt += 1
    end
  }
}

puts cnt


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define pb push_back
#define long long long
#define pll pair < long , long >
#define vll vector < pll >
#define ml map < long , long >
#define mll map < pll , long >
#define x first
#define y second
#define vl vector < long >
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main()
{
    io
    string s;
    cin>>s;
    long i,n=s.length();
    for(i=0;i<n-1;++i)
    if(s[i]=='A' && s[i+1]=='C') {cout<<"Yes";return 0;}
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  vector<int> price = {a, b, c};
  
  sort(all(price));
  
  cout << price[0]+price[1] << endl;
  
}



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

bool check(string s){
  if(s.size() < 4){
    return false;
  }
  return s.substr(0, 4) == "YAKI";
}

int main(){
  string s;
  cin >> s;
  if(check(s)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back


signed main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    
    vector<bool> use(n,false);
    
    int m = 0;
    rep(i,n){
        if(a[i]==2 or a[i]==-2)use[i] = true;
        if(a[i]==-2)m++;
    }
    
    if(m%2==1){
        rep(i,n){
            if(a[i]==-1){
                use[i] = true;
                m++;
                break;
            }
        }
    }
    if(m%2==1){
        for(int i=n-1;i>=0;i--){
            if(a[i]==-2){
                use[i] = false;
                m--;
                break;
            }
        }
    }
    
    assert(m%2==0);
    
    vector<int> ans;
    rep(i,n){
        if(use[i])ans.pb(i+1);
    }
    cout<<ans.size()<<endl;
    rep(i,ans.size()){
        cout<<ans[i]<<endl;
    }
}



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

int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(1)
  {
      c=c-b;
      a=a-d;
      if(c<=0)
      {
        cout<<"Yes";
        break;
      }
      else if(a<=0)
      {
       cout<<"No";
        break;
      }
  }
}


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

typedef vector<double> V;

int main () {
    int N, T, L, B;
    while (cin >> N >> T >> L >> B, N || T || L || B) {
        V lose(L,0), back(B,0);

        for (int i = 0; i < L; i++) cin >> lose[i];
        for (int i = 0; i < B; i++) cin >> back[i];

        vector<V> dp(T+3, V(N+1));
        dp[0][0] = 1.L;

        for (int i = 0; i < T; i++) {
            dp[i+1][N] += dp[i][N];
            for (int j = 0; j < N; j++) {
                if (dp[i][j] > 0) {
                    for (int k = 1; k < 7; k++) {
                        int next = j + k <= N ? j + k : N * 2 - (j + k);
                        if (find(lose.begin(), lose.end(), next) != lose.end()) {
                            dp[i+2][next] += dp[i][j] / 6;
                        } else if (find(back.begin(), back.end(), next) != back.end()) {
                            dp[i+1][0] += dp[i][j] / 6;
                        } else {
                            dp[i+1][next] += dp[i][j] / 6;
                        }
                    }
                }
            }
        }

        printf("%.6f\n", dp[T][N]);
    }

    return 0;
}

Measured memory_bytes: 1344
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(i, n) for (ll i = 0; i < (n); i++)
#define fori(i, b, e) for (ll i = (b); i < (e); i++)
#define forr(i, b, e) for (ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin >> n;
	ll ans = 0;
	for (ll x = 1; x * x < n; x++)
	{
		if (n % x)
			continue;
		ll y = n / x;
		if (y - x < 2)
			continue;
		ans += y - 1;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){

    int N;
    cin >> N;

    string S[N];
    for(int i = 0;i<N;i++) cin >> S[i];
    string s;

    int a = 0,b = 0,c = 0,d = 0;

    for(int i = 0;i<N;i++){
        s = S[i];
        if(s == "P") a = 1;
        else if(s == "W") b = 1;
        else if(s == "G") c = 1;
        else d = 1;
    }

    if(a+b+b+d == 4) cout << "Four" << endl;
    else cout << "Three" << endl;

    return 0;
}

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

using namespace std;

int main() {
   ios_base::sync_with_stdio(false);
   int N, M;
   cin >> N >> M;
   N = (1 << N) - 1;
   M = (1 << M) - 1;
   vector<vector<int>> ans(N, vector<int>(M));
   function<void(int, int, int, int)> go = [&](int xl, int xr, int yl, int yr) {
      int xm = (xl + xr) >> 1;
      int ym = (yl + yr) >> 1;
      ans[xm][ym] = 1;
      if (xl < xr && yl < yr) {
         go(xl, xm - 1, yl, ym - 1);
         go(xl, xm - 1, ym + 1, yr);
         go(xm + 1, xr, yl, ym - 1);
         go(xm + 1, xr, ym + 1, yr);
      }
   };
   go(0, N - 1, 0, M - 1);
   for (int i = 0; i < N; ++i) {
      for (int j = 0; j < M; ++j) {
         cout << ans[i][j];
      }
      cout << "\n";
   }
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int f(int n)
{
	int i,s=1;
	while(n!=0)
	{
		s*=10;
		n/=10;	
	}
	return s;
}
int main()
{
	int a,b,i;
	scanf("%d %d",&a,&b);
	a=a*f(b)+b;
	if(((int)sqrt(a))*((int)sqrt(a))==a)
		printf("Yes");
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define repn(i,x) for(int i=1;i<=x;i++)
ll f[405],r[405],rui[405][405][135];
int n,a[405],b[405],pos[405],pos2[405],t[405][405];
int main(){
	cin>>n;
	repn(i,n)cin>>a[i],pos[a[i]]=i;
	repn(i,n)cin>>b[i],pos2[b[i]]=i;
	f[0]=1;r[400]=622119051;
	repn(i,400)f[i]=f[i-1]*1LL*i%mod,r[400-i]=r[401-i]*1LL*(401-i)%mod;
	repn(i,n)repn(j,n)repn(k,n)if(pos[k]<=i||pos2[k]<=j)t[i][j]++;
	repn(k,n/3)repn(x,n)repn(y,n){
		rui[x][y][k]=rui[x-1][y][k]+rui[x][y-1][k]-rui[x-1][y-1][k];
		if(x<pos[b[y]]&&y<pos2[a[x]]&&2*k<=t[x][y]&&t[x][y]<=3*k-1){
			rui[x][y][k]+=(rui[x-1][y-1][k-1]+(k==1))*r[3*k-3-t[x-1][y-1]]%mod*f[3*k-t[x][y]]%mod;
		}
		rui[x][y][k]%=mod;
	}
	ll ans=rui[n][n][n/3];
	repn(i,n)if(i%3!=0)ans=ans*1LL*i%mod;
	cout<<(ans%mod+mod)%mod<<endl;
}


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

int main(){
  
  int N,Q;
  scanf("%d\n",&N);
  vector<int> count(1000010,0);
  long long ans = 0;
  for( int i=0; i<N; i++){
    int x;
    scanf("%d",&x);
    ans += x;
    count[x]++;
  }
  
  scanf("\n%d\n",&Q);
  for( int i=0; i<Q; i++){
    
    int b,c;
    scanf("%d%d\n",&b,&c);
    int y =count[b];
    count[c] += y;
    count[b] = 0;
    
    ans += (c-b)*y;
    printf("%lld\n",ans);
  }
  
  return 0;
  
}

Measured memory_bytes: 7232
#!/usr/bin/env python3
import sys


def solve(K: int):
    A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
         1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    print(A[K-1])
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
// G++ MACRO.CPP -STD=C++17
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair

int main(){
  CIN(h,w);
  vector<V> v(h,V(w,0));
  REP(i,h){
    SCIN(s);
    REP(j,w)
      v[i][j]=(s[j] == '#');
  }
  vector<V> flag(h,V(w,false));
  REP(i,h){
    REP(j,w){
      if(i!=h-1 && (v[i][j] && v[i+1][j])){
        flag[i][j]=1;
        flag[i+1][j]=1;
      }
      if(j!=w-1 && (v[i][j] && v[i][j+1])){
        flag[i][j]=1;
        flag[i][j+1]=1;
      }
    }
  }
  REP(i,h)
    REP(j,w)
      if(v[i][j]&&(!flag[i][j]))
        EN(No);
  EN(Yes);


  return 0;
}

Measured memory_bytes: 256
flag = 1
H,W = map(int,input().split())
L = []
for i in range(H) :
    L.append(input())
dxy = [(1,0),(-1,0),(0,1),(0,-1)]

for x in range(W) :
    for y in range(H) :
        if L[y][x] == "#" and flag == 1 :
            for dx,dy in dxy :
                nx,ny = x+dx,y+dy
                if (0 <= nx <= W-1) and (0 <= ny <= H-1) :
                    if L[ny][nx] == "#" :
                        flag = 1
                        break
                    else :
                        flag = 0
if flag == 1 :
    print("Yes")
else :
    print("No")
    

Measured memory_bytes: 3064
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::string S;

  std::cin >> S;

  for (int i = 0, size = S.size(); i <= size; i ++)
    for (int j = i; j <= size; j ++) {
      std::string s(S.substr(0, i)), t(S.substr(j, size - j)), T(s + t);

      if (T == "keyence") {
        std::cout << "YES" << std::endl;

        return 0;
      }
    }
  
  std::cout << "NO" << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int search(int A[],int n, int key){
    int i=0;
    A[n] = key;
    while(A[i] != key){
        i++;
    }
    return i != n;
}

int main(){
    int i, n, A[10000+1],key,q,sum =0;
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }

    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&key);
        if(search(A,n,key)){
            sum++;
        }
    }
    printf("%d\n",sum);

    return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
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; }

long long n;

int main() {
    cin >> n;
    vector<long long> A(n, 0);
    map<long long, long long> mpsum;
    map<long long, long long> mpabs;
    for(int i = 0; i < n; ++i) {
        cin >> A.at(i);
        long long sum = A.at(i)+i+1;
        long long asb = (i+1) - A.at(i);
        mpsum[sum]++;
        mpabs[asb]++;
    }

    long long ansss = 0;
    for(auto x : mpsum) {
        long long check = x.second;
        long long cnt = mpabs[x.first];
        ansss += check*cnt;
    }

    cout << ansss << endl;
}

Measured memory_bytes: 39072
import java.util.Scanner;

public class Main {

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

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

		int N = sc.nextInt();
		int[] B = new int[N];
		for (int i = 0; i < N; i++) {
			B[i] = sc.nextInt();

			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 3; k++) {
					if (B[i] == A[j][k]) {
						flg[j][k] = true;
					}
				}
			}
		}

		boolean isBingo = false;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (flg[i][0] && flg[i][1] && flg[i][2]) {
					isBingo = true;
				}
				if (flg[0][j] && flg[1][j] && flg[2][j]) {
					isBingo = true;
				}
				if (flg[0][0] && flg[1][1] && flg[2][2]) {
					isBingo = true;
				}
				if (flg[0][2] && flg[1][1] && flg[2][0]) {
					isBingo = true;
				}
			}
		}

		if (isBingo) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();
	}

}


Measured memory_bytes: 23252
import sys
import re
INPUT = sys.stdin.readline
#入力関数
def SORO_INT(): return int(INPUT())
def MULT_INT_LIST(): return list(map(int, INPUT().split()))
def MULT_INT_MAP(): return map(int, INPUT().split())
def SORO_STRING(): return INPUT()
def MULT_STRING(): return INPUT().split()
 
K,X = MULT_INT_LIST()
ans = []
kuro_min = X-K+1
kuro_max = X+K-1
for i in range(kuro_min,kuro_max+1):
    ans.append(i)
ans = str(ans)
ans = ans.replace(",", "")
ans = ans.strip('[]') 
print(ans)

Measured memory_bytes: 3188
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

#define rep(i, n) for (int i = 0; i < n; ++i)

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };



int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		bool s[64][32];
		CLEAR(s, 0);
		for (int i = 0; i < n; ++i)
		{
			int f;
			scanf("%d", &f);
			while (f--)
			{
				int t;
				scanf("%d", &t);
				s[i][t] = true;
			}
		}

		ll part[64];
		for (int i = 0; i < n; ++i)
			part[i] = 1LL << i;

		int res = -1;
		for (int d = 1; d <= 30; ++d)
		{
			ll p = 0;
			for (int i = 0; i < n; ++i)
				if (s[i][d])
					p |= part[i];
			for (int i = 0; i < n; ++i)
				if (s[i][d])
					part[i] = p;

			if (p == (1LL << n) - 1)
			{
				res = d;
				break;
			}
		}

		printf("%d\n", res);
	}
}

Measured memory_bytes: 880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,0,n) cin>>a[i];
  ll dp[n+1][3];
  rep(i,0,3) dp[0][i]=0;
  dp[1][0]=a[0];
  dp[1][1]=0;
  dp[1][2]=0;
  rep(i,1,n){
    rep(j,0,3){
      if((i+1)%2==0){
        dp[i+1][0]=max(dp[i-1][0]+a[i],dp[i][0]);
        dp[i+1][1]=max(dp[i-1][1]+a[i],dp[i][1]);
        dp[i+1][2]=max(dp[i-1][2]+a[i],dp[i][2]);
      }
      else{
        dp[i+1][0]=dp[i-1][0]+a[i];
        dp[i+1][1]=max(dp[i-1][1]+a[i],dp[i][0]);
        dp[i+1][2]=max(dp[i-1][2]+a[i],dp[i][1]);
      }
    }
  }
  if(n%2==0) cout<<dp[n][0]<<endl;
  else cout<<dp[n][1]<<endl;
}

Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a)  (a).begin(),(a).end()
 
const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;
 
template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}
 
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}

ll bi( ll num){
  if (num ==1) return 1;
  ll ret = bi(num - 1);
  ret= (ret*num) %mod;
  return ret;
}

int main(){
    ll n;
  cin >> n;
  vector<ll> a(n);
  cin >> a;

  bool ans = true;

  for (ll i = 0; i < n; i++)
  {
    if (a[i]%2==0 ){
      if (a[i] %3==0 || a[i]%5==0 ){
      
      }else{
        ans = false;
    }
    }
  }
  



  cout << ((ans==true)?"APPROVED":"DENIED");


}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define MuhammedAly ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define popc(x) __builtin_popcount(x)
#define LLMX 1e18
#define NotinRange(n,m) i<0||i>=(n)||j<0||j>=(m)
#define mem(x,y) memset((x),(y),sizeof (x));
#define sz(a) (int)(a).size()
#define inFile(s) freopen((s),"r",stdin)
#define	outFile(s) freopen((s),"w",stdout)
#define biEdge(v, a, b) (v)[(a)].pb((b)), (v)[(b)].pb((a))
#define pi (2 * acos(0))
#define X real()
#define Y imag()
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define vec(a,b) ((b) - (a))
#define ll long long
typedef long double ld;
typedef complex<double>point;
typedef tuple<int, int, int> line;
typedef pair<point, point>segment;
typedef vector<point>polygon;
const int N = 18, M = 100 + 5, OO = 0x3f3f3f3f, mod = 1e9 + 7, base = 131, mod2 = 1000136437, mod3 = 998244353;
const double EPS = 1e-9;

int main()
{
	MuhammedAly
	int n,x;
	cin >> n  >> x;
	int h[n+1],ans[n+1];
	for(int i =0;i<n;cin >> h[i++]);
	ans[0] = 0,ans[1] = abs(h[1] - h[0]);
	for(int i =2;i<n;i++)
	{
		ans[i] = 1e9;
		for(int j =i-1;j>=max(i-x,0);j--)
			ans[i] = min(ans[j]+abs(h[i]-h[j]),ans[i]);
	}
	cout << ans[n-1];
	return 0;
}


Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	int a,b;
	public void solve(){

		a = nextInt();
		b = nextInt();

		if(a <= 0 && 0 <= b){
			out.println("Zero");
			return;
		}

		if(a < 0){

			if(0 <= b){
				if(-a % 2 == 0){
					out.println("Positive");
				}else{
					out.println("Negative");
				}
			}else{

				if((b - a) % 2 == 0){
					out.println("Negative");
				}else{
					out.println("Positive");
				}
			}
			return;
		}
		out.println("Positive");

	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

int main(){
while(1){
	int n,m,a,ans=0;
	vector<int> p,pp;
	scanf("%d%d",&n,&m);
	if(n==0&&m==0)break;
	p.push_back(0);
	for(int i=0;i<n;i++){
		scanf("%d",&a);
		p.push_back(a);
	}
	sort(p.begin(),p.end());
	for(int i=0;i<=n;i++){
		for(int j=i;j<=n;j++){
			if(p[i]+p[j]>m)break;
			pp.push_back(p[i]+p[j]);
		}
	}
	sort(pp.begin(),pp.end());
	int s=pp.size()-1;
	for(int i=0;i<=s;i++){
		while(pp[i]+pp[s]>m)s--;
		if(ans<pp[i]+pp[s])ans=pp[i]+pp[s];
	}
	printf("%d\n",ans);
}
}

Measured memory_bytes: 5012
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;


int gcd(int a, int b) {
    if(a<b) int tmp=a, a=b, b=tmp;
    if(b==0) return a;
    return gcd(b, a%b);
}


int main(){
    int n;
    cin >> n;
    int A[n];
    REP(i, n) cin >> A[i];

    int l_gcd[n+1], r_gcd[n+1];
    for(int i=0; i<=n; i++){
        if(i==0) l_gcd[i]=0;
        else l_gcd[i] = gcd(l_gcd[i-1], A[i-1]);
    }
    for(int i=n; 0<=i; i--){
        if(i==n) r_gcd[i]=0;
        else r_gcd[i] = gcd(r_gcd[i+1], A[i]);
    }

    int ma=-1;
    for(int i=0; i<=n-1; i++)
        ma = max(ma,gcd(l_gcd[i], r_gcd[i+1]));
    cout << ma << endl;
    return 0;
}

Measured memory_bytes: 1408
import collections

N = int(input())

s = []
ps = []
for i in range(N):
    ps = sorted(list(input()))
    s.append(''.join(ps))

d = collections.Counter(s)

cnt = 0
for v in d.values():
    if v != 1:
        cnt += int(v * (v-1) / 2)

print(cnt)


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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	int alice = 0;
	int bob = 0;
	rep(i, n) {
		if (i % 2 == 0) {
			alice += a[i];
		} else {
			bob += a[i];
		}
	}
	cout << alice - bob << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<functional>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

vector<pair<int, int>> vp; // identifier, size

int main()
{
	int N;
	while (cin >> N, N) {
		vp.clear();
		vp.push_back(make_pair(-1, 1000000001));

		char com;
		REP(i, 0, N) {
			cin >> com;

			if (com == 'W') {
				int l, s;
				cin >> l >> s;

				for (auto itr = vp.begin(); itr != vp.end(); itr++){
					if (itr->first == -1) {
						if (itr->second >= s) {
							itr->second -= s;
							vp.insert(itr, make_pair(l, s));
							break;
						}
						else {
							itr->first = l;
							s -= itr->second;
						}
					}
				}
			}

			else if (com == 'D') {
				int l;
				cin >> l;

				for (auto itr = vp.begin(); itr != vp.end(); itr++){
					if (itr->first == l) itr->first = -1;
				}
			}

			else {
				int p;
				cin >> p;

				for (auto itr = vp.begin(); itr != vp.end(); itr++) {
					if (itr->second > p) {
						cout << itr->first << endl;
						break;
					}
					p -= itr->second;
				}
			}
		}

		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3172
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int N,ans=0;
  cin>>N;
  
  if(N<=9) ans=N;
  else if(N>=10 && N<=99) ans=9;
  else if(N>=100 && N<=999) ans=N-90;
  else if(N>=1000 && N<=9999) ans=909;
  else if(N>=10000 && N<=99999) ans=N-9090;
  else ans=90909;
  
  cout<<ans<<endl;
}


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

int main(){
    int x,y;
    cin>>x>>y;
    if(x==1||x==3||x==5||x==7||x==8||x==10||x==12){
        if(y==1||y==3||y==5||y==7||y==8||y==10||y==12){
            cout<<"Yes"<<endl;
            }else{
                cout<<"No"<<endl;
            }
    }else if(x==4||x==6||x==9||x==11){
        if(y==4||y==6||y==9||y==11){
            cout<<"Yes"<<endl;
        }else{
                cout<<"No"<<endl;
            }
    }else if(x==2){
        if(y==2){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

ll fac[200007],finv[200007],inv[200007];
void cominit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<200007;i++){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
ll com(ll n,ll k){
    if(n<k)return 0;
    if(n<0 || k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cominit();
    ll s;
    cin >> s;
    ll ans = 0;
    for(ll i = 1; i <= s / 3 ; i++){
        ll num = s - i * 3;
        ans += com(i + num - 1, num);
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8252
//xsharawi is back
//SPEEEEEEEEEED IS KEEEEEEEEEEY
//REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEAD
#include <bits/stdc++.h>
using namespace std;
typedef string s;
typedef long long ll;
typedef long double ld;
#if !defined(ONLINE_JUDGE)
#include "C:\debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define pb push_back
#define ins insert
#define vl vector<ll>
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
int main(){
    speed;
    int n;
    cin >> n;
    while(n>1000)n-=1000;
    cout<<max(0,1000-n)<<endl;






















return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/


Measured memory_bytes: 3652
#include <stdio.h>

int main(void)
{
	int i,d=0,H,A,B;
	scanf("%d %d %d",&H,&A,&B);
	for(i=A;i<=B;i++) if(H%i==0) d++;
	printf("%d\n",d);
		
	return 0;
}


Measured memory_bytes: 2092
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author CodeMonk
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int t = in.nextInt();
            Long ans = 0L;
            while (t-- > 0) {
                Long l = in.nextLong();
                Long r = in.nextLong();
                ans += r - l + 1;
            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 24532
#  =========     /\       /|    |====/|
#      |        /  \       |    |   / |
#      |       /____\      |    |  /  |
#      |      /      \     |    | /   |
#  ========= /        \  =====  |/====|  
#  code

if __name__ == "__main__":
    n = int(input())
    x = range(n)
    dp = [ [0,0,0] for i in x]
    d = []
    for i in x:
        d.append(tuple(map(int,input().split())))

    dp[0][0] = max(d[0][1],d[0][2])
    dp[0][1] = max(d[0][0],d[0][2])
    dp[0][2] = max(d[0][1],d[0][0])

    for i in x:
        if i == 0:
            continue
        
        dp[i][0] = max(dp[i-1][1] + d[i][1] , dp[i-1][2] + d[i][2])
        dp[i][1] = max(dp[i-1][0] + d[i][0] , dp[i-1][2] + d[i][2])
        dp[i][2] = max(dp[i-1][1] + d[i][1] , dp[i-1][0] + d[i][0])
    print(max(dp[n-1]))



Measured memory_bytes: 40364
#include<stdio.h>

int main(void){
	int n,i,a,b,scoreA,scoreB;

	while(1){
		scanf("%d",&n);
		if(n==0){break;}
		scoreA=0;scoreB=0;
		for (i=0;i<n;i++){
			scanf("%d %d",&a,&b);
			if(a>b){scoreA+=(a+b);}
			else if(b>a){scoreB+=(a+b);}
			else{scoreA+=a;scoreB+=a;}
		}
		printf("%d %d\n",scoreA,scoreB);
	}
	return 0;
}

Measured memory_bytes: 600