akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        int[] a = sc.nextIntArray(n);
        Arrays.sort(a);
        int ans = 0;
        for(int i = 0; i < n; i++){
            for(int j = i+1; j < n; j++){
                for(int k = j+1; k < n; k++){
                    if(a[i]+a[j] > a[k] && a[i] != a[j] && a[j] != a[k] && a[k] != a[i]){
                        ans++;
                        //pw.println(i + " " + j + " " + k);
                    }
                    
                }
            }
        }
        pw.println(ans);
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

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

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


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

enum Query {
	Unit,
	Same,
};

class DisjointSet {
public :
	DisjointSet(int size) {
		rank.resize(size, 0);
		parent.resize(size, 0);
		for (int i = 0; i < size; i++) {
			MakeSet(i);
		}
	}

	bool Same(int x, int y) {
		return FindSet(x) == FindSet(y);
	}

	void Unit(int x, int y) {
		Link(FindSet(x), FindSet(y));
	}

private:
	void Link(int x, int y) {
		if (rank[x] > rank[y])
			parent[y] = x;
		else {
			parent[x] = y;
			if (rank[x] == rank[y])
				rank[y]++;
		}
	}

	//???????????°????????????
	//?????????????????????????????????????????????FindSet??????????????????????????????
	//(???????????????return????????¨???????????????????????????????????§???????????°??????????????????
	//????????\???????????????????????§???????????°??????????????????)
	void MakeSet(int x) {
		parent[x] = x;
		rank[x] = 0;
	}

	//?????????????????????
	//????????§???????????????????????°????????????????´°???p320???
	int FindSet(int x) {
		if (x != parent[x])
			parent[x] = FindSet(parent[x]);
		return parent[x];
	}

	vector<int> rank;
	vector<int> parent;
};

int main() {

	int number;
	int queryNum;

	cin >> number >> queryNum;
	DisjointSet* disSet = new DisjointSet(number);

	for (int i = 0; i < queryNum; i++) {
		int com;
		int x, y;
		cin >> com >> x >> y;

		if (com == 0)
			disSet->Unit(x, y);
		else if (com == 1)
			if (disSet->Same(x, y)) cout << 1 << endl;
			else                              cout << 0 << endl;
	}

	return 0;

}

Measured memory_bytes: 3184
N, T = map(int, input().split())
ans = 0
t_start = 0
t_stop = 0
for t in map(int, input().split()):
    if t >= t_stop:
        ans += t_stop - t_start
        t_start = t
    t_stop = t + T
print(ans + t_stop - t_start)


Measured memory_bytes: 19220
#include<iostream>

using namespace std;

int main(void)

{
    int n, i;
    double  m, a, h;
    cin>>n>>m;
    double ara[n], sum = 0, counter = 0;
    for(i = 0; i < n; i++){
        cin>>ara[i];
        sum += ara[i];
    }
    h = 1/(4*m);
    a = sum*h;
    for(i = 0; i < n; i++){
    if(ara[i] >= a)
        counter++;
    if(counter == m)
        break;
    }
    if(counter >= m)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(long long int i=a; i<n; i++)
#define rloop(i,a,n) for(long long int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcount(a)
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define stkll stack<ll>
#define qll queue<ll>
#define pqll priority_queue<ll>
#define mod 1000000007
#define M 998244353
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second<b.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second<b.second);
}
ll modinv(ll x, ll y, ll modulo)
{
    return ((x%modulo)*(P(y,modulo-2LL,modulo)%modulo))%modulo;
}
int main()
{
    FAST
    FO
    FI
    int n,m;
    IN n>>m;
    if(n==m) OUT "Yes";
    else OUT "No";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <time.h>
 
#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,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef double ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<ut,pr> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=5+3*1e+4;
const ut INF=1<<30;
const ld eps=1e-6;
const LL mod=1e+9 + 7;

int main() {
	string s;
	cin >> s;
	sort(BE(s));
	int ans = s.size();
	bool check[128] = {0};
	REP(i,s.size()){
		if(check[i])
			continue;
		
		char prev = s[i];
		int cnt = 1;
		check[i] = true;
		FOR(j,i+1,s.size()){
			if(check[j])
				continue;
			if(prev + 1 == s[j]){
				cnt++;
				check[j] = true;
				prev = s[j];
			}
		}
		if(cnt >= 4)
			ans -= cnt - 3;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
	double a, b, x;
	scanf("%lf%lf%lf",&a,&b,&x);
	if (a * a * b / 2 < x) {
		printf("%f", atan((2 * (a * a * b - x)) / (a * a * a)) * 180 / (atan(1) * 4));
	}
	else {
		printf("%f", atan((a * b * b) / (2 * x)) * 180 / (atan(1) * 4));
	}

	return 0;
}

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

int main() {
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin>>a.at(i);
	int p=0;
	for(int i=0;i<n;i++){
		int fl=1;
		for(int j=0;j<i;j++){
			if(a.at(i)==a.at(j)){
				fl=0;
				break;
			}
		}
		if(fl==1){
			p+=1;	
		}
	}
	cout<<p<<endl;
}
				
		

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

using namespace std;
long long x[10000010], y[10000010];
#define rep(i, n) for (int i = 0; i < (n); i++)
#define lep(j, n) for (int j = 0; j < (n); j++)
#define reps(i, n) for (int i = 1; i < (n); i++)
#define leps(i, n) for (int j = 1; j < (n); j++)
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define int long long
#define gsort(x, n) sort((x), (x) + (n), greater<int>());
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

signed main()
{

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

   string s;
   string a = "YAKI";
   cin >> s;

   rep(i, 4)
   {
      if (s[i] != a[i])
      {
         cout << "No" << '\n';
         return 0;
      }
   }
   cout << "Yes" << '\n';
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	ll r;
	r = b%a;
	if (r == 0)return a;
	else return gcd(r, a);

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
//MAX

ll MIN(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//MIN

bool func(ll p) {

	if (p == 1)return false;
	else if (p == 2)return true;
	else {

		bool flag = true;
		for (int i = 2; i <= sqrt(p); i++) {

			if (p%i == 0) {

				flag = false;
				break;

			}

		}
		return flag;

	}

}
//素数判定,素数=true,合成数=false

int main() {

	int a, b;
	cin >> a >> b;

	if ((a % 2 == 0 && b % 2 == 0) || (a % 2 == 1 && b % 2 == 1))cout << (a + b) / 2 << endl;
	else cout << (a + b + 1) / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
n,k,s = map(int,input().split())
ans = []
for i in range(k):
    ans.append(s)
if s < 10**9:
    for i in range(n-k):
        ans.append(s+1)
else:
    for i in range(n-k):
        ans.append(1)
print(" ".join(map(str,ans)))

Measured memory_bytes: 15000
n = int(input())
b_list = list(map(int, input().split()))
a_list = [0 for _ in range(n)]

i = 0
while i < n-1:
    if i == 0:
        a_list[i] = b_list[i]
    a_list[i+1] = b_list[i]
    if a_list[i] > b_list[i]:
        a_list[i] = b_list[i]
    i += 1

print(sum(a_list))


Measured memory_bytes: 3060
N = []
X = []
while 1:
    n,x = map(int, input().split())
    if n == 0 and x == 0:
        break
    N.append(n)
    X.append(x)

counter = [0] * len(N)
for h in range(len(N)):
    for i in range(1, N[h] + 1):
        for j in range(i, N[h] + 1):
            if j == i:
                continue
            for k in range(j, N[h] + 1):
                if k == i or k == j:
                    continue
                elif i + j + k == X[h]:
                    counter[h] += 1

    print(counter[h])




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

using namespace std;

typedef long long ll;

const int maxn = 2000 + 10;

int n, k, Q, a[maxn], b[maxn];

bool check(int x, int y){
	for (int i = 1; i <= n; i++){
		if (a[i] < x)
			b[i] = 0;
		else if (a[i] >= x and a[i] <= y)
			b[i] = 1;
		else
			b[i] = 2;
	}
	int t = 0, cnt = 0, len = 0;
	for (int j = 1; j <= n + 1; j++){
		if (b[j] == 0){
			t += max(0, min(len - k + 1, cnt));
			cnt = 0;
			len = 0;
		}
		else{
			if (b[j] == 1)
				cnt ++;
			len ++;
		}
	}
	return t >= Q;
}

int main(){
	ios_base::sync_with_stdio (false);
	cin >> n >> k >> Q;
	vector<int> v;
	for (int i = 1; i <= n; i++){
		cin >> a[i];
		v.push_back(a[i]);
	}
	sort(v.begin(), v.end());
	int answer = 1000 * 1000 * 1000 + 1;
	for (int j = 0; j < n; j++){
		int x = v[j];
		for (int i = 1; i <= n; i++)
			if (a[i] < x)
				b[i] = 0;
		int lo = j - 1, hi = n;
		while (hi - lo > 1){
			int mid = (lo + hi) >> 1;
			if (check(v[j], v[mid]))
				hi = mid;
			else
				lo = mid;
		}
		if (hi != n)
			answer = min(answer, v[hi] - v[j]);
	}
	cout << answer << endl;
}


Measured memory_bytes: 768
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
   int a,b;
   int x;
   int ans;
   
   cin >> a >> b;
   
   //これでもできるが…
   /*
   if((a+b) % 2 == 0){
          cout << (a+b)/2;
   }
        
    else{
          ans = ((a+b)/2) + 1;
          cout << ans;
    }
    */
    
    //こっちが速い
    cout << (a+b+1)/2;
   
  
   
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#define int long long
vector<int> inv, fact, ifact;
const int vmax = 2e5 + 5;
const int mod = 1e9 + 7;

int nCm(int n, int m) { return fact[n] * ifact[m] % mod * ifact[n - m] % mod; }

signed main() {
  int h, w, a, b;
  cin >> h >> w >> a >> b;

  inv.assign(vmax, 1);
  fact.assign(vmax, 1);
  ifact.assign(vmax, 1);

  for (int i = 2; i <= vmax; i++) {
    inv[i] = (mod - (mod / i)) * inv[mod % i] % mod;
    fact[i] = fact[i - 1] * i % mod;
    ifact[i] = ifact[i - 1] * inv[i] % mod;
  }

  int ans = 0;
  for (int i = b ; i < w; i++) {
    ans = (ans + nCm((h - a -1) + i, i ) *
                     nCm((a - 1 )+ w - 1-i , w- 1-i) % mod) %
          mod;
  }
  cout << ans << endl;
 // cout << nCm(10, 5) << endl;
}


Measured memory_bytes: 4992
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const k = Number(input.split(' ')[0]);

const s = Number(input.split(' ')[1]);

let result = 0;

for (let x = 0;x<k+1;x++) {
  for (let y = 0;y<k+1;y++) {
    const z = s - x - y;
    if (z > k || z < 0) {
      continue;
    }
    result++;
  }
}

console.log(result);

Measured memory_bytes: 7500
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("-1"),0;
#define mod 1000000007
#define N 500055
#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,x[N],p[N],l,r,ans,s,tot,z[N];
signed main(){
	n=read();s=read();
	F(i,1,n){
		x[i]=read();p[i]=read();
	}
	l=1;r=n;
	while (x[l]<s&&x[r]>s&&l<r){
		if (p[l]>=p[r]){
			p[l]+=p[r];z[++tot]=r;r--;
		}
		else{
			p[r]+=p[l];z[++tot]=l;l++;
		}
	}
	if (s>x[r]) F(i,l,r) z[++tot]=i;
	else D(i,r,l) z[++tot]=i;
	ans+=abs(s-x[z[tot]]);
	D(i,tot,2) ans+=abs(x[z[i]]-x[z[i-1]]);
	wrn(ans);
	return 0;
}

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


int main(){

 long double n;
 cin>>n;

 long double ans = (n/3);

 long double vol = (ans*ans*ans);


 cout<<fixed<<setprecision(12);
 //cout<<setprecision(12);
 cout<<vol<<endl;

return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

typedef long long ll;

void solve(long long N)
{
    int count = 0;
    for (int i = 1; i <= N; i++)
    {
        if (i % 2 == 1)
        {
            count++;
        }
    }
    printf("%.10f\n", (double)count / N);
}

int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int H = scan.nextInt();
        int W = scan.nextInt();
        int D = scan.nextInt();
        long[][] original = new long[H*W+1][2];
        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                int A = scan.nextInt();
                original[A][0] = i;
                original[A][1] = j;
            }
        }
        long[] s = new long[H*W+1];
        for (int i = 1; i <= H * W - D; i++) {
            s[i+D] += s[i];
            s[i+D] += Math.abs(original[i+D][0]-original[i][0]);
            s[i+D] += Math.abs(original[i+D][1]-original[i][1]);
        }
        int Q = scan.nextInt();
        for (int i = 0; i < Q; i++) {
            int L = scan.nextInt();
            int R = scan.nextInt();
            System.out.println(s[R]-s[L]);
        }
    }
}


Measured memory_bytes: 103468
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

# 全域木上で、解空間は1次式の集まり。

N,M = map(int,input().split())
UVS = [[int(x) for x in input().split()] for _ in range(M)]

graph = [[] for _ in range(N+1)]
for u,v,s in UVS:
    graph[u].append((v,s))
    graph[v].append((u,s))

x = [None] * (N+1) # start = 0, 1として求めた値

x[1] = (0,1)
q = [1]
while q:
    v = q.pop()
    for w,s in graph[v]:
        if x[w] is not None:
            continue
        x[w] = (s-x[v][0],s-x[v][1])
        q.append(w)

# 頂点vの値：x[v][0] + t(x[v][1]-x[v][0])
# tの範囲を絞り込む
INF = 10 ** 18
low, high = -INF,INF

# 頂点が正の整数
for v in range(1,N+1):
    a,b = x[v]
    b -= a
    if b == 1:
        low = max(low, 1-a)
    else:
        high = min(high, a-1)

# 各辺の値が適切
for u,v,s in UVS:
    a,b = x[u][0] + x[v][0], x[u][1] + x[v][1]
    b -= a
    # a + bt == s
    if b == 0:
        if a == s:
            continue
        else:
            high = -INF
            low = INF
            break
    else:
        # 一意に決まる
        q,r = divmod(s-a,b)
        if r != 0:
            high = -INF
            low = INF
            break
        else:
            high = min(high,q)
            low = max(low,q)

answer = high - low + 1
if answer < 0:
    answer = 0
print(answer)

Measured memory_bytes: 63976
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define SQ(x) ((x)*(x))
#define Mod(x, mod) (((x)+(mod)%(mod))
#define MP make_pair
#define PB push_back
#define Fi first
#define Se second
#define INF (1<<29)
#define EPS 1e-10
#define MOD 1000000007

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

string M[1024];
vector<int> G[1024];

void dfs(int n, int d)
{
  rep(i, d) cout << ".";
  cout << M[n] << endl;
  rep(i, G[n].size())
    dfs(G[n][i], d+1);
}

int main()
{
  int n;
  cin >> n;
  rep(i, n){
    int k;
    cin >> k >> M[i]; k--;
    G[k].push_back(i);
  }
  dfs(0, 0);
  return 0;
}

Measured memory_bytes: 1420
N=int(input())
V=list(map(int, input().split())) 
C=list(map(int, input().split()))
A=[]
for i in range(N):
  if V[i]-C[i]>0:
    A.append(V[i]-C[i])

A.append(0)
A.sort()
A.reverse()
print(sum(A))

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

#define pb push_back
#define ff first
#define ss second

const long long MAXN = 1e5 + 21, inf = 1e18 + 21, LG = 20;

long long a[3];

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> a[0] >> a[1] >> a[2];

    if (a[0] % 2 == 0 || a[1] % 2 == 0 || a[2] % 2 == 0)
        return cout << 0 << '\n', 0;

    sort(a, a + 3);

    cout << a[0] * a[1] << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int i, h, m, s; 
    cin >> i;
    h = i / 3600;
    m = ( i - h * 3600 ) / 60;
    s = i- h * 3600 - m * 60;
    cout << h <<":"<< m <<":"<< s << endl;
   
   return 0;
}


Measured memory_bytes: 3104
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))


int main() {
	int n;
	cin >> n;
	double a = n * 3.14159*2;
	cout << a << endl;

	return 0;
}


Measured memory_bytes: 3784
n, x = map(int, input().split())
l = list(map(int, input().split()))

i = 0
d = 0
while True:
    d = d + l[i]
    if d <= x:
        i += 1
    elif d > x:
        break
    
    if i == len(l):
        break
print(i + 1)

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

int main(){
	int N;
	const int MAX_N = 200;
	int num[MAX_N][3];
	int exist[101], point[MAX_N];
	
	for(int i = 0; i < MAX_N; i++) point[i] = 0;
	
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		for(int j = 0; j < 3; j++) scanf("%d", &num[i][j]);
	}
	
	for(int i = 0; i < 3; i++){
		for(int j = 0; j <= 100; j++) exist[j] = 0;
		for(int j = 0; j < N; j++){
			exist[num[j][i]]++;
		}
		for(int j = 0; j < N; j++){
			if(exist[num[j][i]] < 2) point[j] += num[j][i];
		}
	}
	
	for(int i = 0; i < N; i++) printf("%d\n", point[i]);
	
	return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int sum = max({a, b, c});
    for (int i = 0; i < k; i++) sum *= 2;
    cout << (a + b + c - max({a, b, c}) + sum) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
#include <numeric>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

const int kN = 100002;
bool card[kN];
int N, K, val[kN];

int solve() {
  int cnt = 0, lb = -1;
  memset(val, 0, sizeof val);
  for (int i = 1; i <= N+1; ++i) {
    if (!card[i]) {
      if (cnt > 0) {
        // printf("[%d - %d] : fill\n", lb, i);
        fill(val + lb, val + i, cnt);
        cnt = 0;
      }
      continue;
    }
    if (cnt == 0) lb = i;
    ++cnt;
  }
  // rep(i,N+1) printf("%2d", i); puts("");
  // rep(i,N+1) printf("%2d", val[i]); puts("");
  
  if (!card[0]) return *max_element(val + 1, val + N + 1); 

  int ret = 0;
  for (int i = 1; i <= N; ++i) {
    if (card[i]) continue;
    ret = max(ret, val[i-1] + val[i+1] + 1);
  }
  return ret;
}

int main() {
  while (scanf("%d%d", &N, &K), N) {
    memset(card, false, sizeof card);
    int t = 0;
    rep(i,K) {
      scanf("%d", &t);
      card[t] = true;
    }
    printf("%d\n", solve());
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <map>
using namespace std;
int main(){
  int N;
  cin >> N;
  string s;
  cin >> s;
  string ans(N,'!'), sw = "SW";
  map<char,int> m;
  m['o'] = 0;
  m['x'] = 1;
  m['S'] = 0;
  m['W'] = 1;
  bool f = true;
  for(int bit = 0; bit < 4; ++bit){
    ans[0] = sw[bit/2];
    ans[1] = sw[bit%2];
    for(int i = 2; i < N; ++i){
      int t = m[s[i-1]];
      if(ans[i-1] == 'W') t = 1-t;
      if(t == 0) ans[i] = ans[i-2];
      else ans[i] = sw[1-m[ans[i-2]]];
    }
    int t = m[s[N-1]];
    if(ans[N-1] == 'W') t = 1-t;
    if((t == 0 && ans[N-2] != ans[0]) || (t == 1 && ans[N-2] == ans[0])){
      continue;
    }
    t = m[s[0]];
    if(ans[0] == 'W') t = 1-t;
    if((t == 0 && ans[N-1] != ans[1]) || (t == 1 && ans[N-1] == ans[1])){
      continue;
    }
    cout << ans << endl;
    f = false;
    break;
  }
  if(f) cout << -1 << endl;
  return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e5 + 5;






int n;
string k;
ll d;
ll dp[maxn][101][2];



ll solve(int i, ll sumD, bool lower) {
    if (i==n) {
	return (sumD==0);
    }

    if (~dp[i][sumD][lower]) return dp[i][sumD][lower];
    ll &res = dp[i][sumD][lower] = 0;

    for (ll x=0; x<=(lower? 9: ll(k[i]-'0')); x++) {
	ll digit = x;
	res += solve(i+1, (sumD+digit)%d, lower || (x<ll(k[i]-'0')));
	res %= mod;
    }

    return res;
}


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

    cin>>k>>d;
    memset(dp,-1,sizeof(dp));

    n = k.length();

    ll res = solve(0, 0, false);
    res += (mod-1);//remove 0
    res %= mod;
    cout<<res<<endl;
        
    
    return 0;
}


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

int main()
{
	int last = 4280;
	int w;
	int mon=0;
	while(cin >> w){
		mon = 1150;
		if(w<0)
			break;
		for(int i=1;i<=w;i++){
			if(i<=10)
				mon=1150;
			else if(10<i && i<=20)
				mon+=125;
			else if(20<i && i<=30)
				mon+=140;
			else
				mon+=160;
		}
		cout << last-mon << endl;
	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    long int sum=0;
    long int uuu=0;
    long int min;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }

    for(int i=0;i<n;i++){
        sum=sum+a[i];
    }

    

    for(int i=0;i<n;i++){
        uuu=uuu+a[i];
        long int xxx = sum-uuu;
        long int yyy;
        if(xxx>uuu){
            yyy = xxx - uuu;
        }else{
            yyy = uuu - xxx;
        }
        //cout << xxx << endl;
        
        if(i==0){
            min=yyy;
        }
        if(min>yyy){
            min=yyy;
        }
    }

    cout << min << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define pb push_back
#define in(x) int x; cin>>x;
#define in(x, y) int x, y; cin>>x>>y;
#define mi unordered_map<int,int>
#define mem(x, y) memset(x, y, sizeof(x))
using namespace std;

int32_t main(void){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	
	in(n, k);
	int arr[n];
	int dp[k+1];
	mem(dp, 0);
	rep(i, 0, n) cin>>arr[i];
	
	rep(i, 1, k+1)
	{
		rep(j, 0, n)
		{
			if(i-arr[j] >= 0 && !dp[i-arr[j]]) dp[i] = 1;
		}
	}	
	
	if(dp[k]) cout<<"First";
	else cout<<"Second";
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#define LEN 100005 //オブジェクト形式マクロ　すべての"LEN"を数値に置き換える。

typedef struct pp { //構造体を宣言し、Ｐと置く。
    char name[100];
    int t;
}P;

P Q[LEN]; //構造体の配列を定義。
int head, tail, n; 

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

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

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

int main(){
    int elaps = 0, c;
    int i, q;
    P u;
    scanf("%d %d", &n, &q);
    
    for( i = 1; i <= n; i++){
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 1; tail = n + 1;
    
    while( head != tail){
        u = dequeue();
        c = min(q, u.t);
        u.t -= c;
        elaps += c;
        if( u.t > 0) enqueue(u);
        else{
            printf("%s %d\n", u.name, elaps);
        }
    }
    
    return 0;
}


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

int main() {
    int n, t, a;
    cin >> n >> t >> a;

    double minv = 1e9;
    int ans = 0;
    rep(i, n) {
        int h;
        cin >> h;
        double tmp = abs(a - (t - h * 0.006));
        if (tmp < minv) {
            ans = i + 1;
            minv = tmp;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		String a[] = new String[n];

		int ac = 0;
		int wa = 0;
		int tle = 0;
		int re = 0;

		for(int i=0;i<n;i++) {
			a[i] = in.next();
		}

		for(int i=0;i<n;i++) {
			if(a[i].contentEquals("AC")) {
				ac = ac + 1;
			}else if(a[i].contentEquals("WA")) {
				wa++;
			}else if(a[i].contentEquals("TLE")) {
				tle++;
			}else {
				re++;
			}
		}

		System.out.println("AC x "+ac);
		System.out.println("WA x "+wa);
		System.out.println("TLE x "+tle);
		System.out.println("RE x "+re);

	}

}


Measured memory_bytes: 63372
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define vec         vector<int>
#define map         map<int,int>
#define scn(t)      scanf("%d",&t);
#define lscn(t)      scanf("%lld",&t);
#define mod         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define endl        "\n"
using namespace std;
const int N=2e5+5;
 
int main()
{
    string s;
    cin>>s;
 
    int l=s.length();
 
    for(int i=0;i<l-1;i++)
    {
        if(s[i]==s[i+1])
        {
            cout<<i+1<<" "<<i+2<<endl;
            return 0;
        }
    }
 
    for(int i=0;i<l-2;i++)
    {
        if(s[i]==s[i+2])
        {
            cout<<i+1<<" "<<i+3<<endl;
            return 0;
        }
    }
 
    cout<<-1<<" "<<-1<<endl;
}

Measured memory_bytes: 3732
N = int(input())
a = map(int, input().split())

other = mult_2 = mult_4 = 0
for t in a:
    if t % 4 == 0:
        mult_4 += 1
    elif t % 2 == 0:
        mult_2 += 1
    else:
        other += 1

if other - 1 + (1 if mult_2 > 0 else 0) <= mult_4:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 80620
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) std::cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) std::cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) std::cout << x << endl;
#define println(x) std::cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll n;
    cin >> n;
    vector<ll> A(3 * n);
    rep(i, 3 * n) {
        cin >> A[i];
        A[i]--;
    }

    ll INF = 1e18;
    vector<vector<ll> > dp(n+1, vector<ll>(n+1, -INF));
    vector<ll> ma(n+1, -INF);
    dp[A[0]][A[1]] = 0;
    ma[A[0]] = 0;
    ma[A[1]] = 0;

    ll score = 0;
    rep(i, n-1) {
        sort(A.begin() + 2 + 3 * i, A.begin() + 2 + 3 * i + 3);
        ll x = A[2 + 3 * i];
        ll y = A[2 + 3 * i + 1];
        ll z = A[2 + 3 * i + 2];

        // a, b, x, y, zで並んでいる


        // x==y==z
        if (x == z) {
            score++;
            continue;
        }

        vector<vector<ll> > cand;
        if (x == y) {
            rep(p, n) {
                cand.push_back({
                    z,
                    p,
                    max(dp[x][p], dp[p][x]) + 1,
                });
            }
        }
        if (z == y) {
            rep(p, n) {
                cand.push_back({
                    x,
                    p,
                    max(dp[z][p], dp[p][z]) + 1,
                });
            }
        }

        rep(p, n) cand.push_back({ p, x, ma[p] });
        rep(p, n) cand.push_back({ p, y, ma[p] });
        rep(p, n) cand.push_back({ p, z, ma[p] });

        // 左２つがxyzのどれかと等しい場合
        cand.push_back({ x, y, dp[z][z] + 1});
        cand.push_back({ x, z, dp[y][y] + 1});
        cand.push_back({ y, z, dp[x][x] + 1});

        // 右3つのどれかを残す時、とにかく前回で一番成績が良いものを選ぶ
        ll tmp = -1;
        rep(p, n) tmp = max(ma[p], tmp);
        cand.push_back({ x, y, tmp});
        cand.push_back({ x, z, tmp});
        cand.push_back({ y, z, tmp});

        for (auto& c: cand) {
            dp[c[0]][c[1]] = max(dp[c[0]][c[1]], c[2]);
            ma[c[0]] = max(ma[c[0]], c[2]);
            ma[c[1]] = max(ma[c[1]], c[2]);
        }
    }

    ll res = max(0LL, *max_element(all(ma)));
    res = max(res, dp[A[3 * n - 1]][A[3 * n - 1]] + 1);    //
    res += score;

    put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 35484
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;

void solve(){
    cin >> n;
    int ans=0;
    rep(i,n) {
        int a;
        cin >> a;
        if (a%2==1) ans+=1;
    }
    if (ans%2==1) cout << "NO" << endl;
    if (ans%2==0) cout << "YES" << endl;
}

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

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

int main() {
  int a, b, h, m;
  scanf("%d %d %d %d", &a, &b, &h, &m);
  double sx = a * cos((h + m / 60.0) * 30 / 180 * M_PI),
         sy = a * sin((h + m / 60.0) * 30 / 180 * M_PI),
         lx = b * cos(m * 6 / 180.0 * M_PI), ly = b * sin(m * 6 / 180.0 * M_PI);
  printf("%.14lf\n", sqrt((sx - lx) * (sx - lx) + (sy - ly) * (sy - ly)));
}

Measured memory_bytes: 4112
# -*- coding:utf-8 -*-
from math import factorial

MOD = 10**9+7

def combination_formula(n, r):
    _max, _min = max(n-r, r), min(n-r, r)
    bunsi, bunbo = 1, 1
    for i in range(_min):
        bunsi *= (n-i)
        bunbo *= (i+1)
        bunsi %= MOD
        bunbo %= MOD
    # フェルマーの小定理を使って、modの世界のbunsi/bunboを計算する
    # 1/bunbo ≡ bunbo^{p-2} より、
    bunbo = pow(bunbo, MOD-2, MOD)
    ans = (bunsi*bunbo) % MOD
    return ans

def solve():
    n, a, b = list(map(int, input().split()))
    ans = pow(2, n, MOD)
    ans -= 1  # nC0を除外
    ans -= combination_formula(n, a)
    ans -= combination_formula(n, b)
    while ans < 0:
        ans += MOD
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
int main(){
    int i,j,a;
    string x;
    for(;;){
    cin>>x;
    if(x=="0"){
        break;
    }
    for(i=0;i<x.size();i++){
        x[i]=x[i]-'0';
        a+=x[i];
    }
    cout<<a<<endl;
        a=0;
    }
    return 0;
}

Measured memory_bytes: 3228
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;


int main(){
    int n, x = 0, ans = 0;
    cin >> n;
    char c;
    for (int i = 0; i < n; i++) {
        cin >> c;
        if(c=='I') x++;
        else x--;
        ans = max(ans, x);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

inline long long read(){
   long long w=1,s=0;
   char ch=getchar();
   while(ch<'0'||ch>'9') {if (ch=='-') w=-1;ch=getchar();} 
   while(ch>='0'&&ch<='9')  s=s*10+ch-'0',ch=getchar();
   return s*w;
}

int a[1000000],b[1000000];
struct node{
int num,sum;
}la[1000000],lb[1000000];

int tmp(node a1,node a2){
    return a1.num>a2.num;
}

int main(){
    int n=read();
    for(int i=1;i<=n/2;i++) a[i]=read(),b[i]=read();
    sort(a+1,a+n/2+1);sort(b+1,b+n/2+1);
    int num=1,cnt=0;
    for(int i=1;i<=n/2;i++){
    if (a[i]==a[i+1]) num++;
    else {
    la[++cnt].num=num;
    la[cnt].sum=a[i];
    num=1;
    }
    }
     num=1;int cnt1=0;
    for(int i=1;i<=n/2;i++){
    if (b[i]==b[i+1]) num++;
    else {
    lb[++cnt1].num=num;
    lb[cnt1].sum=b[i];
    num=1;
    }
    }
    sort(la+1,la+cnt+1,tmp); sort(lb+1,lb+cnt1+1,tmp);

      
    if (la[1].sum!=lb[1].sum) cout<<n-la[1].num-lb[1].num;
    else if (cnt==1&&cnt1==1) cout<<n-max(la[1].num,lb[1].num);
    else if (cnt==1) cout<<min(n-lb[2].num-la[1].num,n-lb[1].num);
    else if (cnt1==1) cout<<min(n-la[2].num-lb[1].num,n-la[1].num);
    else cout<<min(n-la[2].num-lb[1].num,n-la[1].num-lb[2].num);
    return 0;
}

Measured memory_bytes: 8832
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

mat mul(mat &A, mat &B){
    mat C(A.size(), vec(B[0].size()));
    for (int i = 0; i < A.size(); i++){
        for (int k = 0; k < B.size(); k++){
            for (int j = 0; j < B[0].size(); j++){
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % mod;
            }
        }
    }
    return C;
}

mat pow(mat A, ll n){
    mat B(A.size(), vec(A.size()));
    for (int i = 0; i < A.size(); i++){
        B[i][i] = 1;
    }
    while(n > 0){
        if(n & 1) B = mul(B, A);
        A = mul(A, A);
        n >>= 1;
    }
    return B;
}

int main(){
    ll n, m;
    cin >> n >> m;
    ll s[n], t[m];
    rep(i, n) cin >> s[i];
    rep(i, m) cin >> t[i];
    ll dp[n+1][m+1];
    dp[0][0] = 1;
    rep(i, n)dp[i+1][0] = 1;
    rep(i, m)dp[0][i+1] = 1;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= m; j++){
            if(s[i-1] == t[j-1]){
                dp[i][j] = dp[i-1][j] + dp[i][j-1];
            }else{
                dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1] + mod;
            }
            dp[i][j] %= mod;
        }
    }
    // rep(i, n + 1){
    //     rep(j, m + 1){
    //         cout << dp[i][j] << " ";
    //     }cout << endl;
    // }
    cout << dp[n][m] << endl;    
}

Measured memory_bytes: 34944
n=int(input())
A=list(map(int, input().split()))

res=0
xor_sum=0
add_sum=0
right=0
for left in range(n):
  while right<n and xor_sum^A[right]==add_sum+A[right]:
    xor_sum^=A[right]
    add_sum+=A[right]
    right+=1
  res+=(right-left)
  if right==left:
    right+=1
  else:
    xor_sum^=A[left]
    add_sum-=A[left]
print(res)

Measured memory_bytes: 24840
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    n=n%10;
    if(n==2||n==4||n==5||n==7||n==9)
    cout<<"hon";
    else
    {
        if(n==0||n==1||n==6||n==8)
        cout<<"pon";
        else
        {
            cout<<"bon";
        }
        
    }
    
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e9;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[4] = {1,0,-1,0};
constexpr ll ny[4] = {0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a = 1,n;
    cin >> n;
    while((a+1)*(a+1) <= n){
        a++;
    }
    PRINT(a*a);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
const int INF = 100000000;
int dx[] = {0,1,-1,0,1,-1,1,-1};
int dy[] = {1,0,0,-1,1,-1,-1,1};

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    vector<tuple<int, int, int, int>> v;
    for(int i = 1; i <= m; i++){
        int p, y, x = 0;
        scanf("%d%d", &p, &y);
        v.emplace_back(p, y, x, i);
    }
    sort(v.begin(), v.end());
    int tmp = 0;
    int num = 1;
    for(auto &t: v){
        if(get<0>(t) != tmp){
            tmp = get<0>(t);
            num = 1;
            get<2>(t) = num;
            num++;
        }else{
            get<2>(t) = num;
            num++;
        }
    }
    vector<tuple<int, int, int, int>> ans(m+1);
    for(auto t: v)
        ans[get<3>(t)] = t;
    for(auto t: ans){
        if(get<0>(t) == 0) continue;
        printf("%06d%06d\n", get<0>(t), get<2>(t));
    }
}


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

int main(){
    int r, g, b, n, ans = 0;
    scanf("%d%d%d%d", &r, &g, &b, &n);
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            int rem = n-i*r-j*g;
            if(rem < 0 || rem%b != 0) continue;
            ans++;
        }
    }   
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b;
int main(){
    scanf("%d%d",&a,&b);
    for(int i=0;i<=10000;i++){
        if(int(i*0.08)==a&&int(i*0.1)==b){
            printf("%d\n",i);
            return 0;;
        }
    }
    printf("-1\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pb push_back
#define vl vector<ll>
#define vs vector<string>
#define MP make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define vi vector<int>
#define vii vector<pii>
#define F first
#define S second
using namespace std;
const int N=1e5+5;
ll n,x[N],sum;
signed main()
{
	std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>sum>>n;
	rep(i,n)
	{
		cin>>x[i];
		sum-=x[i];
	}
	if(sum<=0)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    vector<int> dp_all(1000001, 1000000);
    vector<int> dp_odd(1000001, 1000000);

    dp_all[0] = dp_odd[0] = 0;
    for(int i = 1; i <= 181; ++i) {
        int n = i*(i+1)*(i+2)/6;
        for(int j = 0; j+n <= 1000000; ++j) {
            dp_all[j+n] = min(dp_all[j+n], dp_all[j] + 1);
            if(n % 2 == 1) dp_odd[j+n] = min(dp_odd[j+n], dp_odd[j] + 1);
        }
    }

    while(true) {
        int N;
        cin >> N;
        if(!N) break;

        cout << dp_all[N] << ' ' << dp_odd[N] << endl;
    }
    return 0;
}

Measured memory_bytes: 8596
#include <bits/stdc++.h>
using namespace std;
#define FAST  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int 

//power of 2 ...n&(n-1)==0

int main()
{
	FAST;
	//#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	//	freopen("output.txt","w",stdout);
	//#endif
	 //ll testcase;
	 //cin>>testcase;
	 //for(ll t=0;t<testcase;t++)
	{
		// use long long
		//donot memeset other than 0 or 1 or -1
		//segmentation fault-> check for uninitialized global variable or out of bounds
		//always check for bottle neck (whether original constraints can be reduced by introducing some condition)
		//dont rush to writing code think through the logic	
		//implement dijkstra again ---it is bfs because we vis all the points connected to the current point first
		//from every not visited cell we will update the distances of cell which can be visited
		int a,b;
		cin>>a>>b;
		cout<<a*b<<'\n';
		
		
	}
	return 0;
}





























































Measured memory_bytes: 3564
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
    }

    let mut vec: Vec<i64> = vec![0; 202020];
    for i in 1..n + 1 {
        let mut x = (i % k);
        vec[x] += 1;
    }
    let mut res: i64 = 0;
    res += vec[0] * vec[0] * vec[0];
    if k % 2 == 0 {
        res += vec[k / 2] * vec[k / 2] * vec[k / 2];
    }
    println!("{:?}", res);
}


Measured memory_bytes: 2772