akhauriyash/Code-Regression huggingface dataset:
#ifndef LOCAL
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    string s ;
    cin >> s ;
    int n = (int) s.size() ;
    int ans = 0 ;
    int cnt = 0 ;
    for(int i = 0; i < n; i++){
        if ( s[i] == 'R' ) cnt++ ;
        else cnt = 0 ;
        ans = max(ans, cnt) ;
    }
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 3632
n,a=map(int,input().split())
x=list(map(int,input().split()))
dp=[[0]*(n*a+1) for i in range(n+1)]
dp[0][0]=1
ans=0
for i in x:
    for j in range(n,0,-1):
        for k in range(n*a,i-1,-1):
            dp[j][k]+=dp[j-1][k-i]
for i in range(1,n+1):
    ans+=dp[i][i*a]
print(ans)

Measured memory_bytes: 4468
n=int(input())
ab=[list(map(int,input().split())) for i in range(n-1)]
c=list(map(int,input().split()))
c.sort(reverse=True)
l=[[] for i in range(n+1)]
ans=[0 for i in range(n+1)]
ans[1]=c[0]
q=[1]
ci=1
for a,b in ab:
    l[a].append(b)
    l[b].append(a)
while(len(q)>0):
    t=q.pop()
    tl=l[t]
    for i in tl:
        if(ans[i]==0):
            ans[i]=c[ci]
            ci+=1
            q.append(i)
print(sum(c[1:]))
print(" ".join(map(str,ans[1:])))

Measured memory_bytes: 7396
# ABC087 B - Coins
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                ans += 1
print(ans)



Measured memory_bytes: 3060
#include<iostream>
#include<cstring>

using namespace std;

const int N=1010;
char s[N];
char t[N];

int main(){
    scanf("%s",s);
    scanf("%s",t);
    int len1=strlen(s);
    int len2=strlen(t);
    int res=N;
    for(int i=0;i+len2<=len1;++i){
        int cnt=0;
        for(int j=0;j<len2;++j){
            if(t[j]!=s[i+j]) cnt++;
        }
        res=min(res,cnt);
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3768
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=100000+19;
const ll oo=1ll<<60;

ll B[N],C[N],ans;
int A[N];
int n,m;

void gao(int x,int y){
	if (x<y){
		B[x+1]+=y+1;
		B[y+1]-=y+1;
		C[x+1]++;
		C[y+1]--;
		B[1]+=y-x;
		B[x+1]-=y-x;
		B[y+1]+=y-x;
		B[m+1]-=y-x;
		/*
		For(i,x+1,y+1) ans[i]+=y-i+1;
		For(i,1,x+1) ans[i]+=y-x;
		For(i,y+1,m+1) ans[i]+=y-x;
		*/
	} else{
		B[x+1]+=y+m+1;
		B[m+1]-=y+m+1;
		C[x+1]++;
		C[m+1]--;
		B[1]+=y+1;
		B[y+1]-=y+1;
		C[1]++;
		C[y+1]--;
		B[y+1]+=y-x+m;
		B[x+1]-=y-x+m;
		/*
		For(i,x+1,m+1) ans[i]+=y-i+m+1;
		For(i,1,y+1) ans[i]+=y-i+1;
		For(i,y+1,x+1) ans[i]+=y-x+m;
		*/
	}
}

int main(){
	n=IN(),m=IN();
	For(i,1,n+1) A[i]=IN();
	For(i,1,n){
		gao(A[i],A[i+1]);
	}
	For(i,1,m+1) B[i]+=B[i-1];
	For(i,1,m+1) C[i]+=C[i-1];
	ans=oo;
	For(i,1,m+1){
		ans=min(ans,B[i]-C[i]*i);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 2176
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val An = readLine()!!.split(" ").map(String::toInt)
    var count = 0L

    val acc_left_map: MutableMap<Int, Long> = mutableMapOf()
    val acc_right_map: MutableMap<Int, Long> = mutableMapOf()

    An.indices.map { 
        it - An[it]
    }.forEach { 
        acc_left_map[it] = acc_left_map.getOrDefault(it, 0L) + 1

    }
    An.indices.map { 
        it + An[it]
    }.forEach { 
        acc_right_map[it] = acc_right_map.getOrDefault(it, 0L) + 1
    }

    acc_left_map.keys.union(acc_right_map.keys).map { (acc_left_map[it]?: 0L) * (acc_right_map[it]?: 0L)}.fold(0L) {a, b -> a+b}.run(::println)

 }

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

class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s1 = br.readLine();
		String s2 = br.readLine();

		int len1 = s1.length();
		int len2 = s2.length();

		int[][] dp = new int[len1+1][len2+1];

		for (int i=0; i<=len1; i++)
			dp[i][0] = i;

		for (int j=0; j<=len2; j++)
			dp[0][j] = j;

		for (int i=1; i<=len1; i++) {
			for (int j=1; j<=len2; j++) {
				dp[i][j] = dp[i-1][j-1] + (s1.charAt(i-1) == s2.charAt(j-1) ? 0 : 1);
				dp[i][j] = Math.min(dp[i][j],Math.min(dp[i-1][j]+1,dp[i][j-1]+1));
			}
		}

		System.out.println(dp[len1][len2]);

		br.close();
	}
}

Measured memory_bytes: 24244
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

vector<int> xa, ya;
int d[100009], td[100009];

bool ps(vector<int> a)
{
	int s = 0;
	for (int i = 0; i < a.size(); i++)
		s += a[i];
	if (s % 2 == 1) return false;
	for (int i = 0; i <= s; i++) {
		d[i] = td[i] = 0;
	}
	d[0] = 1;
	for (int i = 0; i < a.size(); i++) {
		for (int j = 0; j <= s; j++)
			if (d[j] == 1) {
				if (0 <= j - a[i] && j - a[i] <= s) td[j - a[i]] = 1;
				if (0 <= j + a[i] && j + a[i] <= s) td[j + a[i]] = 1;
			}
		for (int j = 0; j <= s; j++) {
			d[j] = td[j]; td[j] = 0;
		}
	}
	if (d[0] == 1)
		return true;
	return false;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	string s; cin >> s; s += "T";
	int tx, ty; cin >> tx >> ty;
	bool f = true; int r = 0, c = 0;
	for (int i = 0; i < s.length(); i++) {
		if (f && s[i] == 'F') {
			tx--;
			continue;
		}
		else
			f = false;
		if (s[i] == 'T') {
			if (c > 0) {
				if (!r) xa.push_back(c);
				else ya.push_back(c);
			}
			c = 0; r = (r + 1) % 2;
		}
		else
			c++;
	}
	xa.push_back(abs(tx)); ya.push_back(abs(ty));
	if (ps(xa) && ps(ya)) cout << "Yes" << '\n';
	else cout << "No" << '\n';
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdlib.h>
using namespace std;
int query(int x)
{
	cout << x << endl;
	string ans;
	cin >> ans;
	if (ans=="Vacant")
	exit(0);
	return (ans=="Male");
}
int main()
{
	int n;
	cin >> n;
	cout.flush();
	int st=0,en=n-1,ast,aen;
	ast=query(st);
	aen=query(en);
	while (1)
	{
		int mid=(st+en)/2,cur=query(mid);
		if (((mid-st)%2 && ast==cur) || ((mid-st)%2==0 && ast!=cur))
		{
			en=mid;
			aen=cur;
		}
		else
		{
			st=mid;
			ast=cur;
		}
	}
}

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

typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    ll sum=0;
    for(ll i=1;i<=n;i++)
    {
       if(i%3==0||i%5==0)
       {
           continue;
       }
       else
       {
           sum+=i;
       }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 7;
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans /= (i + 1);
        ans %= mod;
    }
    return ans;
}

bool w(char a){
    if('A' <= a && a <= 'Z')return true;
    else return false;
}

int main(){
    ll a,b,c,d,n;
    string s;
    cin >> n >> a >> b >> c >> d >> s;
    --a;--b;--c;--d;
    if(c > d){
        bool f1 = true,f2 = false;
        nfor(i, a, c + 1)if(s[i] == '#' && s[i + 1] == '#')f1 = false;
        nfor(i, b - 1, d)if(s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.')f2 = true;
        if(f1 && f2)yes;
        else no;
    }else{
        bool f = true;
        nfor(i, a, d + 1)if(s[i] == '#' && s[i + 1] == '#')f = false;
        if(f)yes;
        else no;
    }
    return 0;
}


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  
  int ans=0;
  for(int i=0;i<N-2;i++){
    if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C') ans++;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <utility>
#include <iomanip>
#include <queue>
#include <set>
#include <numeric>
#include <unordered_set>

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

using namespace std;


int main(){
    
    string S;
    cin>>S;
    
    int max=0;
    int tmp=0;
    
    for(int i=0;i<S.size();++i){
        if(S[i]=='R'){
            ++tmp;
        }else{
            tmp=0;
        }
        max=tmp>=max?tmp:max;
    }
    cout<<max<<endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n,p;
    int m = 0;
    int ans = 0;

    Scd(n);
    Rep(i,n) {
        Scd(p);
        ans += p;
        m = max(m,p);
    }

    printf ("%d\n", ans - m/2 );

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ms(a) memset (a , 0 , sizeof a)
#define rr(i, a, b) for(register int i=a;i<=b;++i)
#define re(i, a, b) for(register int i=a;i>=b;--i)
#define reps(s) for(register int i=head[s];i;i=Next[i])
typedef long long ll ;

#define v(int) vector <int> 
#define pb push_back
#define pp push
#define fi first
#define se second
using namespace std ;

const int N = 100 ;
int qwq () {
	char ch = getchar () ;
	int x = 0 , f = 1 ;
	while (ch < '0' || ch > '9') {if (ch == '-') f = -1 ; ch = getchar() ;}
	while (ch >= '0' && ch <= '9') {x = x *10 + ch - '0' ; ch = getchar() ;}
	return x * f ;
}
#define q qwq () 

int main () {
	int a ;
	cin >> a ;
	cout << (ll)(a + a * a + a * a * a) << endl; 
	
	return 0 ; 
}


Measured memory_bytes: 3552
#include <stdio.h>
int main(void){
  int a[1000001]={};
  int n,i=1,ans;
  scanf("%d",&n);
  for(;i<=1000000;i++){
    if(a[n]){ printf("%d",i); return 0; }
    a[n]=1;
    n=(n%2)?(3*n+1):(n/2);
  }
}

Measured memory_bytes: 4096
/*   Then, everything changed when the Fire Nation attacked. */

#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define mod 1000000007
#define fi first
#define se second
using namespace std;
int n,m;
int a[502][502];
struct t
{
    int a, b, c, d;
};
vector<t>sol;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // shuffle(permutation.begin(), permutation.end(), rng);
    cin>>n>>m;
    int s=0;
    for(int i=1;i<=n;++i)
        for(int j=1;j<=m;++j)
            cin>>a[i][j];
    for(int i=1;i<=n;++i)
        for(int j=1;j<=m;++j)
        {
            if(a[i][j]%2==1)
            {
                if(i+1<=n)
                    sol.push_back({i, j, i+1, j}), a[i+1][j]++;
                else
                    if(j+1<=m)
                        sol.push_back({i, j, i, j+1}), a[i][j+1]++;
            }
        }
    cout<<sol.size()<<'\n';
    for(int i=0;i<sol.size();++i)
        cout<<sol[i].a<<" "<<sol[i].b<<" "<<sol[i].c<<" "<<sol[i].d<<'\n';
    return 0;
}


Measured memory_bytes: 5232
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        ArrayList<Integer>[] list = new ArrayList[3];
        for(int i=0;i<3;i++){
            list[i] = new ArrayList<Integer>();
            for(int j=0;j<n;j++){
                list[i].add(Integer.parseInt(sc.next()));
            }
            Collections.sort(list[i]);
        }
        long ans = 0;
        for(int i=0;i<n;i++){
            int c = list[1].get(i);
            ans += (long)(n-minIdx(list[2], c))*(long)(maxIdx(list[0], c));
        }
        System.out.println(ans);
    }
    
    
    public static int minIdx(ArrayList<Integer> list, int n){
        int min=0;
        int max = list.size();
        int ave=0, num;
        while(min<max){
            ave =(min+max)/2;
            num = list.get(ave);
            if(num<=n){
                min = ave+1;
            }else{
                max = ave;
            }
        }
        return max;
    }
    public static int maxIdx(ArrayList<Integer> list, int n){
        int min=0;
        int max = list.size();
        int ave=0, num;
        while(min<max){
            ave =(min+max)/2;
            num = list.get(ave);
            if(num<n){
                min = ave+1;
            }else{
                max = ave;
            }
        }
        return max;
    }
}


Measured memory_bytes: 69696
s = input() + "ZZZZZZZZZZZZZ"

i = 0
ans = "NO"

while(True):

 if s[i:i+5]=="dream":
  if s[i+5]=="d" or s[i+5]=="Z" or s[i+5:i+8]=="era":
   i += 5
  elif s[i+5:i+8]=="erd" or s[i+5:i+8]=="ere" or s[i+5:i+8]=="erZ":
   i += 7
  else:
   break
 
 elif s[i:i+5]=="erase":
  if s[i+5]=="d" or s[i+5]=="e" or s[i+5]=="Z":
   i += 5
  elif s[i+5]=="r":
   i += 6
  else:
   break

 elif s[i]=="Z":
  ans = "YES"
  break

 else:
  break

print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int N,K;
  string S;
  cin>>N>>K>>S;
  vector<int> B(0);
  char c;
  for(int i=0;i<N;i++){
    if(S[i]!=c){
      B.push_back(i);
      c=S[i];
    }
  }
  int M=B.size();
  for(int i=0;i<=2*K;i++)
    B.push_back(N);
  int ans=0;
  for(int i=0;i<M;i++){
    if(S[B[i]]=='0')
      ans=max(ans,B[i+2*K]-B[i]);
    else
      ans=max(ans,B[i+2*K+1]-B[i]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 5428
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cassert>
#include <string>
#include <set>
#include <map>
#include <random>
#include <bitset>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using ld = long double;

const int N = 200003;
vector<int> g[N];
int d[N], mv = 1;

void dfs(int v, int p) {
	if (d[v] > d[mv])
		mv = v;
	for (int u : g[v]) {
		if (u == p)
			continue;
		d[u] = d[v] + 1;
		dfs(u, v);
	}
}


int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, u, v;
	cin >> n;
	rep(i, n - 1) {
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1, -1);
	d[mv] = 0;
	dfs(mv, -1);
	if (d[mv] % 3 == 1)
		cout << "Second";
	else
		cout << "First";
}

Measured memory_bytes: 21376
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
const ll B=1e6+7;
const ll mod1=1e9+7,mod2=998244353;
struct segtree{
private:
  vector<ll> node;
  ll siz;
public:
  segtree(int n){
    siz=1;
    while(siz<=n) siz*=2;
    node.resize(siz*2+1,-1);
  }
  void upd(int pos,int x){
    pos+=siz-1;
    node[pos]=x;
    while(pos>0){
      pos=(pos-1)/2;
      int l=pos*2+1,r=pos*2+2;
      if(node[l]==-2||node[r]==-2) node[pos]=-2;
      else if(node[l]==-1){
        node[pos]=node[r];
      }
      else{
        if(node[l]==node[r]||node[r]==-1) node[pos]=node[l];
        else node[pos]=-2;
      }
    }
  }
  ll get_hash(int pos){
    pos+=siz-1;
    return node[pos];
  }
  ll debug(ll pos){
    return node[pos];
  }
  bool judge(){
    return node[0]!=-2;
  }
};
ll pow(ll x,ll y,ll mo){
  if(y==0) return 1;
  ll ret=pow(x,y/2,mo);
  ret%=mo;
  ret*=ret;
  ret%=mo;
  if(y%2==1) ret*=x;
  return ret%mo;
}
ll t_mod(ll x,ll m){
  if(x>=0) return x%m;
  else{
    ll x2=x*(-1);
    x2/=m;
    x2+=2;
    return (x+m*x2)%m;
  }
}
ll make_hash(string s,ll mod){
  int n=s.length();
  ll h=0;
  ll bk=1;
  for(int i=0;i<n;i++){
    int id=n-i-1;
    h+=bk*s[id];
    h%=mod;
    bk*=B;
    bk%=mod;
  }
  return h;
}
ll change_hash(ll h,int len,int n,char a,char b,ll mod){
  //n番目をa->bに変更(1-indexed)
  n=len-n;
  h-=a*pow(B,n,mod)%mod;
  h+=b*pow(B,n,mod)%mod;
  return t_mod(h,mod);
}
vector<ll> yaku(int n){
  //約数列挙
  vector<ll> ret;
  for(ll i=1;i<=n;i++){
    if(n%i==0) ret.push_back(i);
  }
  return ret;
}

int main(){
  int n,q;
  cin>>n>>q;
  vector<ll> yk=yaku(n);
  string s;
  cin>>s;

  vector<segtree> seg,seg2;
  for(int i=0;i<yk.size();i++){
    segtree kseg=segtree((n/yk[i])+4);
    seg.push_back(kseg);
    seg2.push_back(kseg);
  }
  for(int i=0;i<yk.size();i++){
    int wid=yk[i];
    for(int j=0;j<n/wid;j++){
      string ks=s.substr(j*wid,wid);
      seg[i].upd(j,make_hash(ks,mod1));
      seg2[i].upd(j,make_hash(ks,mod2));
    }
  }


  for(int qr=0;qr<q;qr++){
    int pos;
    cin>>pos;
    char c;
    cin>>c;
    pos--;
    char base=s[pos];
    s[pos]=c;
//    cout<<base<<" "<<c<<endl;

    for(int i=0;i<yk.size();i++){
      int wid=yk[i];
      int p1=pos/wid,p2=pos%wid;
    //  cout<<wid<<" "<<p1<<" "<<p2<<endl;
      ll bhash=seg[i].get_hash(p1);
      ll nhash=change_hash(bhash,wid,p2+1,base,c,mod1);
      seg[i].upd(p1,nhash);

      ll bhash2=seg2[i].get_hash(p1);
      ll nhash2=change_hash(bhash2,wid,p2+1,base,c,mod2);
      seg2[i].upd(p1,nhash2);

      /*if(wid==2){
        cout<<seg[i].get_hash(0)<<" "<<bhash<<" "<<nhash<<endl;
      }*/
    }

    for(int i=0;i<yk.size();i++){
      if(seg[i].judge()&&seg2[i].judge()) {
        cout<<yk[i]<<endl;
        break;
      }
    }
  }

}



Measured memory_bytes: 27028
a,b=map(int,input().split())

res = []
if a>10:
    while a>50:
        res.append("#."*50)
        res.append("#"*100)
        a -= 50
    while a>10:
        res.append("#."*10+ "#"*80)
        res.append("#"*100)
        a -= 10
    b -= 1
res.append("."*100)
while b > 50:
    res.append("#."*50)
    res.append("."*100)
    b-= 50
while b > 10:
    res.append("#."*10+ "."*80)
    res.append("."*100)
    b-= 10

if b>a:
    sa = b-a
    res.append("#."*sa+".."*(50-sa))
    res.append("."*100)
    for _ in range(a):
        res.append("#"*100)
        res.append("."*100)
    res.pop()
elif a>b:
    if b == 0:
        res.pop()
    res.append("#"*100)
    sa = a-b
    res.append(".#"*sa+"##"*(50-sa))
    res.append("#"*100)
    b -= 1
    for _ in range(b):
        res.append("."*100)
        res.append("#"*100)

else:
    for _ in range(a):
        res.append("#"*100)
        res.append("."*100)
    res.pop()

print(str(len(res))+" 100")
print("\n".join(res))

Measured memory_bytes: 38256
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <bitset>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

const int MAX_H = 2020;
int H, W;
char S[MAX_H][MAX_H];

int L[MAX_H][MAX_H], R[MAX_H][MAX_H], U[MAX_H][MAX_H], D[MAX_H][MAX_H];

int main(int argc, char **argv) {
    std::cin >> H >> W;

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            std::cin >> S[i][j];
        }
    }

    for (int i = 1; i <= H; i++) {
        int tmp = 0;
        for (int j = 1; j <= W; j++) {
            if (S[i][j] == '#') {
                tmp = j;
            } else {
                L[i][j] = tmp;
            }
        }
        tmp = W + 1;
        for (int j = W; 1 <= j; j--) {
            if (S[i][j] == '#') {
                tmp = j;
            } else {
                R[i][j] = tmp;
            }
        }
    }

    for (int j = 1; j <= W; j++) {
        int tmp = 0;
        for (int i = 1; i <= H; i++) {
            if (S[i][j] == '#') {
                tmp = i;
            } else {
                U[i][j] = tmp;
            }
        }
        tmp = H + 1;
        for (int i = H; 1 <= i; i--) {
            if (S[i][j] == '#') {
                tmp = i;
            } else {
                D[i][j] = tmp;
            }
        }
    }


    int ret = 0;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (S[i][j] == '.') {
                int tmp = R[i][j] - L[i][j] + D[i][j] - U[i][j] - 3;
                ret = std::max(ret, tmp);
                //if (tmp == 10) {
                //    std::cout << i << " " << j << " " << R[i][j] << " " << L[i][j] << " " << D[i][j] << " " << U[i][j] << std::endl; 
                //}
            }
        }
    }

    std::cout << ret << std::endl;

    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<long long> n(K);
  long long ans = 0;
  for (int i = 1; i <= N; ++i)
    ++n[i % K];
  for (int a = 0; a < K; ++a) {
    int b = (K - a) % K, c = (K - a) % K;
    if ((b + c) % K == 0)
      ans += n[a] * n[b] * n[c];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<string>

using namespace std;

struct node {
  int value;
  node *next;

  node(int value, node *next) : value(value), next(next) {};
};

#define INF ( 1 << 28 )

string lcs(string &a, string &b) {
  map< int, vector< int > > M;
  for(int i = b.size() - 1; i >= 0; i--) {
    M[b[i]].push_back(i);
  }
  vector< int > HM(a.size() + 1, INF);
  HM[0] = -INF;
  vector< node * > link(a.size() + 1);
  for(int i = 0; i < a.size(); i++) {
    if(M.count(a[i])) {
      vector< int > NEWHM = M[a[i]];
      for(int j = 0; j < NEWHM.size(); j++) {
        int k = distance(HM.begin(), lower_bound(HM.begin(), HM.end(), NEWHM[j]));
        HM[k] = NEWHM[j];
        link[k] = new node(b[NEWHM[j]], link[k - 1]);
      }
    }
  }
  string ans;
  for(node *p = link[distance(HM.begin(), lower_bound(HM.begin(), HM.end(), INF - 1)) - 1]; p; p = p->next) {
    ans += (char) p->value;
  }
  reverse(ans.begin(), ans.end());
  return ans;
}

int main() {
  int q;
  //cin >> q;
  q = 1;
  while(q--) {
    string a, b;
    cin >> a >> b;
    string ans = lcs(a, b);
    cout << ans << endl;
  }
}


Measured memory_bytes: 281600
N, M = map(int, input().split())

l_max = 1
r_min = N
for _ in range(M):
    l, r = map(int, input().split())
    l_max = max(l_max, l)
    r_min = min(r_min, r)

if r_min < l_max:
    print(0)
else:
    print(r_min-l_max+1)

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

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

void solve(void) {
  ll k; cin >> k;
  string s; cin >> s;
  
  if ((ll)s.size() <= k) {
    cout << s << endl;
    return;
  }

  string res = s.substr(0, k) + "...";
  cout << res << endl;
}

int main(void) {
  solve();
  return 0;
}

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

struct card{
  char mozi;
  int num;
};

bool compare_as_ints(card a,card b){
  return (a.num<b.num);
}
int partition(card A[],int p,int r){
  int i;
  card x,tmp;
  x=A[r];
  i=p-1;
  for(int j=p;j<=r-1;j++){
    if(A[j].num<=x.num){
      i=i+1;
      tmp=A[i];
      A[i]=A[j];
      A[j]=tmp;
     }
    }
  tmp=A[i+1];
  A[i+1]=A[r];
  A[r]=tmp;
  return i+1;
}

void quicksort(card A[],int p,int r){
  int q;
  if(p<r){
  q=partition(A,p,r);
    quicksort(A,p,q-1);
    quicksort(A,q+1,r);
  }
}

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

  card A[100000],B[100000];
  for(int i=0;i<n;i++){
    cin>>A[i].mozi>>A[i].num;
    B[i]=A[i];
  }

  quicksort(A,0,n-1);
  stable_sort(B,B+n,compare_as_ints);

  int miss=0;

for(int i=0;i<n;i++){
  if(A[i].mozi!=B[i].mozi){
    miss++;
  }
}
if(miss>0){
  cout<<"Not stable"<<endl;
}else{
  cout<<"Stable"<<endl;
}

  for(int i=0;i<n;i++){
    cout<<A[i].mozi<<' '<<A[i].num<<endl;
  }
  return 0;
}



Measured memory_bytes: 4600
#include <bits/stdc++.h>
using namespace std;
const int mod =  1000000007;
const int LIM = 100005;
#define int long long
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(a) a.begin() , a.end()
#define vvi vector<vector<int>>
//#define double long double
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define endl '\n'
#define pb push_back
#define sp <<" "<<
#define ss second
#define ff first
int power(int x, int n){
    int res = 1;
    while(n){
          if(n&1){
                res = res * x % mod;
          }
          x = x * x % mod;
          n>>=1;
    }
    return res;
}

int32_t main()
{     //IOS;
      int tt=1,n,k,x,y,z,i,j;
      //cin>>tt;
      while(tt--)
      { string s;
        cin>>n>>s;
      i = 0;
      j = n-1;
      int ans=0;
      while(i<j)
      {
            if(s[i] == 'R')
            {
                  i++;
                  continue;
            }
            else if(s[j] == 'R')
            {
                  ans++;
                  s[i] = 'R';
                  s[j] = 'W';
                  i++;
            }
            j--;
      }
      cout<<ans;

      }
}


Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int n;
	cin >> n;
	VL a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(all(a));
	int ans = 0;
	rep(i, n) REP(j, i + 1, n) REP(k, j + 1, n) {
		if (a[i] == a[j] || a[j] == a[k] || a[i] == a[k]) continue;
		if (a[k] < a[i] + a[j]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
 
int str_cmp(const void *a, const void *b)
{
	return strcmp(*(char **)a, *(char **)b);
}
 
int main()
{
	int N;
	scanf("%d", &N);
	char str[N + 1][11];
	char **sort;
	sort = (char**)malloc(sizeof(char*) * N);
	int i = 0;
	int len;
	while (i < N)
	{
		scanf("%s", str[i]);
		len = strlen(str[i]);
		sort[i] = (char*)malloc(sizeof(char) * (len + 1));
		strcpy(sort[i], str[i]);
		i++;
	}
	qsort(sort, N, sizeof *sort, str_cmp);
 
	i = 0;
	int max[N];
	int top = 0;
	int n = 1;
	while (i < N)
	{
		max[i] = 0;
		if (i != N - 1)
		{
			if (strcmp(sort[i], sort[i + 1]) == 0)
				n++;
			else if (strcmp(sort[i], sort[i + 1]))
			{
				max[i] = n;
				if (max[i] >= top)
					top = max[i];
				n = 1;
			}
		}
		else if (i == N - 1)
		{
			max[i] = n;
			if (max[i] >= top)
					top = max[i];
		}
		i++;
	}
	i = 0;
	while (i < N)
	{
		if (max[i] == top)
			printf("%s\n", sort[i]);
		i++;
	}
	return (0);
}

Measured memory_bytes: 12652
#abc065 b
n=int(input())
a=[]
for i in range(n):
    x=int(input())
    a.append(x)

ans=-1
cnt=0
switch=1
while cnt<n:
    cnt+=1
    switch=a[switch-1]
    if switch==2:
        ans=cnt
        break
print(ans)

Measured memory_bytes: 7084
// IOI 2021
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 924844033;
 
////////////////////////////////////////////////////////////////////
 
const int N = 1e5 + 5;

int main() {
 
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));

	int n; cin >> n;
	cout << 1LL * n * (n - 1) / 2 << endl;

	return 0;
}


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

vector<int> tb(200001);
int main(){
  int n,k; cin >> n >> k;
  vector<int> v(n); rep(i,n) cin >> v[i];
  rep(i,200001) tb[i] = 0;
  rep(i,n) tb[v[i]]++;
  sort(tb.begin(),tb.end(), greater<int>());
  int ans=0;
  for(int i=k;i<200001;i++) ans+=tb[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

all = sum(a)
for i in range(n):
    if a[i] >= b[i]:
        a[i] -= b[i]
        continue
    else:
        if a[i+1] >= b[i] - a[i]:
            a[i+1] -= b[i] - a[i]
            a[i] = 0
            continue
        else:
            a[i] = 0
            a[i+1] = 0

print(all-sum(a))

Measured memory_bytes: 18624
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll a,b,c;
int main(){
	cin >> a >> b >> c;

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


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

int main(){
    cin >> n;
    cin >> s;
    if ( n % 2 == 1) cout << "No" << endl;
    else {
        for (int i = 0; i < n / 2; i ++){
            if (s[i] != s[i + (n / 2)]){
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
        return 0;
    }
}

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

int main() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  a*=100;
  b*=100;
  double min=-1;
  int reswt=0, ressg=0;
  for (int i=0; i*a<=f; i++) {
    for (int j=0; i*a+j*b<=f; j++) {
      for (int k=0; i*a+j*b+k*c<=f; k++) {
        for (int l=0; i*a+j*b+k*c+l*d<=f; l++) {
          double wt = i*a+j*b+k*c+l*d;
          double sg = k*c+l*d;
          if ((i*a+j*b)*e/100<sg) break;
          double cc = sg/wt;
          if (cc>min) {
            reswt=wt; ressg=sg; min=cc;
          }
        }
      }
    }
  }
  printf("%d %d\n", reswt, ressg);
  return 0;
}


Measured memory_bytes: 256
N_str, q_str = raw_input().split()
N = int(N_str)
q = int(q_str)

A = []
B = []

for i in range(N):
    a = raw_input().split()
    A.append([a[0], int(a[1])])

total_time = 0
while A:
    name, time = A.pop(0)
    if time <= q:
        total_time += time 
        B.append("%s %d" % (name, total_time))
    else:
        time -= q
        A.append([name, time])
        total_time += q
print '\n'.join(B)

Measured memory_bytes: 17384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n - 1); i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using priority_queuel = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T>
constexpr int sz(const T &a) { return (int)a.size(); }
template <class T>
constexpr T pow2(const T a) { return a * a; }
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class A, int N, class T>
void fillArray(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

int n, m;
vector<int> g[605];
ld dp[605];
ld f(int idx) {
    dp[n - 1] = 0;
    repd(v, n - 1) {
        ld sum = 0.0L;
        ld ma = 0.0L;
        auto cnt = sz(g[v]);
        each(nv, g[v]) {
            sum += dp[nv];
            maxs(ma, dp[nv]);
        }
        if (v == idx && cnt > 1) {
            --cnt;
            sum -= ma;
        }
        dp[v] = sum / ld(cnt) + 1;
    }
    return dp[0];
}
void solve() {
    cin >> n >> m;
    rep(i, m) {
        int s, t;
        cin >> s >> t;
        --s, --t;
        g[s].emplace_back(t);
    }
    ld ans = ldinf;
    rep(i, n) mins(ans, f(i));
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout.flush();
    return 0;
}


Measured memory_bytes: 1408
import math
import collections
def calc_combi2(n):
    if n<=1:
        return 0
    return math.factorial(n)/(math.factorial(n-2)*math.factorial(2))
n=int(input())
data=list(map(int,input().split()))
data_cnt=collections.Counter(data)
count=0
ans=collections.Counter()
for i in data_cnt.values():
    count+=calc_combi2(i)
for a,b in data_cnt.items():
    if 2<=b:
        ans[a]=int(count-b+1)
    else:
        ans[a]=int(count)
for i in data:
    print(ans[i])

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    i64 n, d;
    cin >> n >> d;

    vector<i64> a(n);
    for(auto& x : a)
        cin >> x;
    i64 ans = 0;
    for(i64 i = 0; i < n; ++i){
        i64 c = (d + a[i] % (d + 1)) % (d + 1);
        ans ^= c;
    }
    cout << (ans ? "First" : "Second") << endl;
}



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

#define rep(i, a, b) for(int i = (a); i < (b); i++)
typedef long long ll;

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

    vector<string> s(N);
    rep(i, 0, N)
    {
        cin >> s[i];
    }

    unordered_map<string, int> mp;
    rep(i, 0, N)
    {
        sort(s[i].begin(), s[i].end());
        mp[s[i]]++;
    }

    ll ans = 0;
    for(auto& p : mp)
    {
        int x = p.second;
        ans += (ll)x * (x - 1) / 2;
    }

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

Measured memory_bytes: 17700
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define cin(x) cin >> x

const long double PI = 3.141592653589;

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ld a = 0, b =0, x =0;
    cin >> a >> b >> x;

    ld len = b - x/(a*a);
  
  cout << fixed << setprecision(10);
  
    if(2*len<b){
    ld radian = atan2(a,2*len);
    ld degree = radian * 180/PI;

    cout << 90 - degree;
    }
    else{
    ld radian = atan2(2*x/(a*b),b);
    ld degree = radian * 180/PI;

    cout << 90 - degree;
    }
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}


Measured memory_bytes: 3884
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	s := readString()

	counter := make(map[rune]int, 0)
	for _, v := range s {
		counter[v]++
	}
	if len(counter) >= 2 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

int main(){
  int n; cin>>n;
  vector<int> h(n);
  for(int i=0;i<n;++i) cin>>h[i];
  
  int ans=0;
  // [l, r)の区間は全て正
  for(int l=0;l<n;++l){
    while(h[l]>0){
      int r;
      for(r=l+1;r<n;++r){
        if(h[r]==0)break;
      }
      
      // ここで閉じている左端もついでに引いておく
      for(int i=l;i<r;++i){
        --h[i];
      }
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n,k;
        cin>>n>>k;
        int a[n];
        for(int i=0;i<n;i++)cin>>a[i];
        int l = 1,r = 1e9,ans = 1;
        while(l <= r)
        {
            int m = (l+r)>>1LL;
            int chk = 0;
            for(int i=0;i<n;i++)chk += (a[i]/m) - ((a[i]%m) == 0);
            if(chk <= k)r=m-1,ans=m;
            else l=m+1;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 5160
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a!=b&&b!=c&&a!=c) {
    cout << 3 << endl;
    return 0;
  }
  if((a==b&&b!=c)||(a!=b&&b==c)||(a!=b&&a==c)) {
    cout << 2 << endl;
    return 0;
  }
  if(a==b&&b==c) {
    cout << 1 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll dp[1111][BITLE(13)];
vector<pair<ll,ll>> key(1111);
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  for(int i=0;i<m;i++){
    ll a,b;cin>>a>>b;
    ll num=0;
    for(int j=0;j<b;j++){
      ll c;cin>>c;
      num+=BITLE(c-1);
    }
    key[i]=mp(a,num);
  }
  for(int i=0;i<BITLE(12
                     );i++)
    for(int j=0;j<1111;j++)
      dp[j][i]=llINF;
  dp[0][0]=0;
  for(int i=0;i<m;i++){
    for(int j=0;j<BITLE(n);j++){
      if(dp[i][j]!=llINF){
	//	cout<<i<<" "<<j<<endl;
	//cout<<key[i].S<<" "<<key[i].F<<endl;
	dp[i+1][j|key[i].S]=min(dp[i+1][j|key[i].S],dp[i][j]+key[i].F);
	dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
      }
    }
  }
  if(dp[m][BITLE(n)-1]==llINF)
    cout<<-1<<endl;
  else cout<<dp[m][BITLE(n)-1]<<endl;
  return 0;
}


Measured memory_bytes: 69888
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vector<int> A, B;
string S, T;

void input() {
  int x, y, z;
  cin >> S;
  ;
}
void solve() {
  set<char> st;
  rep(i, 0, 25) { st.insert('a' + i); }
  for (auto x : S) {
    st.erase(x);
  }
  if (st.size())
    cout << *st.begin() << endl;
  else
    cout << "None" << endl;
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

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

int main() {
    string s;
    cin >> s;
    int a = s[0] - '0';
    int b = s[1] - '0';
    int c = s[2] - '0';
    int d = s[3] - '0';
    
    if(a + b + c + d == 7){
        cout << a << "+" << b << "+" << c << "+" << d << "=" << 7 << endl;
        return 0;
    }else if(a - b + c + d == 7){
        cout << a << "-" << b << "+" << c << "+" << d << "=" << 7 << endl;
        return 0;
    }else if(a + b - c + d == 7){
        cout << a << "+" << b << "-" << c << "+" << d << "=" << 7 << endl;
        return 0;
    }else if(a - b - c + d == 7){
        cout << a << "-" << b << "-" << c << "+" << d << "=" << 7 << endl;
        return 0;
    }else if(a + b + c - d == 7){
        cout << a << "+" << b << "+" << c << "-" << d << "=" << 7 << endl;
        return 0;
    }else if(a - b + c - d == 7){
        cout << a << "-" << b << "+" << c << "-" << d << "=" << 7 << endl;
        return 0;
    }else if(a + b - c - d == 7){
        cout << a << "+" << b << "-" << c << "-" << d << "=" << 7 << endl;
        return 0;
    }else if(a - b - c - d == 7){
        cout << a << "-" << b << "-" << c << "-" << d << "=" << 7 << endl;
        return 0;
    }
}



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

int main(){
  int n;

  cin >> n;
  long *data = new long[n];
  long min,max,sum=0;

  for(int i=0; i<n; i++){
    cin >> data[i];
    
    if(i==0){
      min=max=sum=data[0];
    }else{
      if(min>data[i]){
        min=data[i];
      }
      if(max<data[i]){
        max=data[i];
      }
      sum += data[i];
    }
  }

  cout << min << " " << max << " " << sum << endl;
  
  return(0);
}

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

int main(){
    int N, K;
    cin >> N >> K;
    int h[N];
    rep(i, N){
        cin >> h[i];
    }
    int dp[N];
    dp[0] = 0;
    for(int i=1;i<N;i++){
        int MIN;
        for(int j=1;j<=min(i, K);j++){
            if(j==1){
                MIN = dp[i-j] + abs(h[i] - h[i-j]);
            }else{
                MIN = min(MIN, dp[i-j] + abs(h[i] - h[i-j]));
            }
        }
        dp[i] = MIN;
    }

    printf("%d\n", dp[N-1]);
    return 0;
}

Measured memory_bytes: 1024
n=gets.to_i
a=gets.split.map(&:to_i)


xor_all=a.inject{|a,b|a^b}
#全部の排他的論理和→求めたい解全てのxorになる

#２個つけたら0になる
puts a.map{|ai|ai^xor_all}.join(" ")

Measured memory_bytes: 37460