akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10,LOG=20;
int up[maxn][21],tin[maxn],tout[maxn],timer;
int n,T,dis[maxn];
struct edge{
    int u,col,w;
};
vector<edge> a[maxn];
void dfs(int nod,int pa){
    ++timer;
    tin[nod]=timer;
    up[nod][0]=pa;
    for(int i=1;i<=LOG;i++){
        up[nod][i]=up[up[nod][i-1]][i-1];
    }
    for(auto i:a[nod]){
        if(i.u!=pa){
            dis[i.u]=dis[nod]+i.w;
            dfs(i.u,nod);
        }
    }
    tout[nod]=++timer;
    return;
}
bool ancestor(int u,int v){
    return tin[u]<=tin[v]&&tout[u]>=tout[v];
}
int lca(int u,int v){
    if(ancestor(u,v))
        return u;
    if(ancestor(v,u))
        return v;
    for(int i=LOG;i>=0;i--){
        if(!ancestor(up[u][i],v))
            u=up[u][i];
    }
    return up[u][0];
}
int dp[maxn],ct[maxn],ans[maxn];
vector<int> q[maxn];
struct query{
    int col,w;
}b[maxn];
void dfs_2(int nod,int pa){
    for(int i:q[nod]){
        int f=(i<0?-2:1);
        i=abs(i);
        ans[i]+=(f*((ct[b[i].col]*b[i].w)-dp[b[i].col]+dis[nod]));
    }
    for(auto i:a[nod]){
        if(i.u!=pa){
            dp[i.col]+=i.w;
            ct[i.col]++;
            dfs_2(i.u,nod);
            dp[i.col]-=i.w;
            ct[i.col]--;
        }
    }
    return;
}

int main(){
    tout[0]=1e9;
    scanf("%d%d",&n,&T);
    int x,y,z,w;
    for(int i=1;i<n;i++){
        scanf("%d%d%d%d",&x,&y,&z,&w);
        a[x].push_back({y,z,w});
        a[y].push_back({x,z,w});
    }
    dfs(1,0);
    for(int i=1;i<=T;i++){
        scanf("%d%d%d%d",&b[i].col,&b[i].w,&x,&y);
        q[x].push_back(i);
        q[y].push_back(i);
        q[lca(x,y)].push_back(-i);
    }
    dfs_2(1,0);
    for(int i=1;i<=T;i++){
        printf("%d\n",ans[i]);
    }

}


Measured memory_bytes: 27772
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <map>
using namespace std;

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

int main()
{
    long long a,b,c,d;
    int t;
    scanf("%d",&t);
    while(t--)
    {
        long long x;
        scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
        if(a<b)
        {
            printf("No\n");
            continue;
        }
        if(a>c)
        {
            long long k=(a-c)/b;
            while(a-k*b>c) k++;
            x=a-k*b;
        }
        else x=a-b;
        if(d<b||x<0)
        {
            printf("No\n");
            continue;
        }
        if(c>=b)
        {
            printf("Yes\n");
            continue;
        }
        bool flag=1;
        long long tmp=gcd(d,b);
        if(tmp>=b-x) flag=1;
        else
        {
            if(tmp>c-x) flag=0;
            else
            {
                if(b-c>tmp) flag=0;
                else flag=1;
            }
        }
        if(b-c<=1) flag=1;
        if(flag==0) printf("No\n");
        else printf("Yes\n");
    }
	return 0;
}


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

#define int long long

using namespace std;


int dp[100005];


signed main(){
    int q=1;
    // cin>>q;
    while(q--){
        int k;
        cin>>k;
        int count=0,s=0;
        if(k%2==0){
            cout<<"-1";
            return 0;
        }
        while(count<2*(1e7)){
            count++;
            s = (s*10 + 7)%k;
            // cout<<s<<"\n";
            if(s%k==0) break;
        }
        if(count==2*(1e7)) cout<<-1<<"\n";
        else    cout<<count<<"\n";
    }
}


Measured memory_bytes: 3636
use proconio::input;
use num::integer::*;

fn main() {
  // aaa bbb aaa bbb ...
  input! {
    n: isize,
    a: isize,
    b: isize,
  }
  let (d,m) = n.div_mod_floor(&(a+b));
  println!("{}", d*a + m.min(a));
}


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

int main() {
  int s, ans;
  cin >> s;
  
  set <int> S;
  ans = 0;
  while(true) {
    ans++;
    
    if(S.find(s)!=S.end()) {
      break;
    }
    
    S.insert(s);
    
    if(s%2==0) {
      s = s/2;
    } else {
      s = 3*s + 1;
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let X: usize = read();
    let Y: usize = read();
    let Z: usize = read();
    println!("{} {} {}", Z, X, Y);
}


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

int N, M;
vector< vector<int> > A;

int main(){
	cin >> N >> M;
	A = vector< vector<int> >(M + 1);
	int k, p;
	for (int i = 0;i  < M; i++ ){
		cin >> k;
		for(int j = 0; j < k; j++){
			cin >> p;
			A[i].push_back(p);
		}
	}
	vector<int> P(M + 2, 0);
	for(int i = 0; i < M; i++){
		int k;
		cin >> k;
		if(k == 1) { P[i] = 1; }
	}
	
	//generate all combinations of N items
		// enumerate the 2**N possible combinations
	int pwr = pow(2, N);
	vector<string> comb;
	int res = 0;
	for ( int i = 0; i < pwr; i ++){
		bool ok = 1;
		for ( int j = 0; j < M; j++){ // vamos a ver si la combinacion i, funciona para la bombilla j(M)
			int m = A[j].size();
			int cnt = 0;
			for ( int h = 0; h < m; h++){
				if ( (i >> (A[j][h] - 1)) % 2 == 1 ){
					cnt ++;
				}
			}
			if(cnt % 2 != P[j]){
				ok = 0;
				break;
			}
		}
		if(ok){ res ++; }
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 384
import Foundation

func readInts() -> [Int]{
    readLine()!.split(separator: " ").map { Int($0)! }
}

func main(){
    let nm = readInts()
    var n = nm[0]
    let a = readInts()
    
    for i in 0..<a.count {
        n -= a[i]
        if 0 > n {
            print(-1)
            return
        }
    }
    print(n)
}

main()


Measured memory_bytes: 13796
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
 
  int N;cin>>N;
  
  if(N==1){
    cout<<"Hello World"<<endl;
  }
  else{
    int A,B;cin>>A>>B;
    cout<<A+B<<endl;
  }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));

typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
//-0.4620981203755741
int main(){
    int n;
    std::cin >> n;
    VEC(ll,a,n);
    std::vector<ll> b(n+1);
    rep(i,n)b[i+1]=b[i]+a[i];
    sort(all(b));
    std::vector<ll> c;
    ll dum=1;
    rep(i,n){
        if(b[i]==b[i+1]){
            dum++;   
        }
        else{
            if(dum>=2)c.pb(dum);
            dum=1;
        }
    }
    if(dum>=2)c.pb(dum);
    ll ans=0;
    erep(i,c){
       ans+=(i*(i-1))/2;
    }
    std::cout << ans << std::endl;
    
}

Measured memory_bytes: 3456
n=gets.to_i
a=gets.chomp.split.map(&:to_i)
b=gets.chomp.split.map(&:to_i)

p=[]
1.upto(n) do |i|
  p << i
end
pp=p.permutation(n).to_a.sort

i=0
pp.each do |arr|
  break if a==arr
  i += 1
end
j=0
pp.each do |arr|
  break if b==arr
  j += 1
end
puts (i-j).abs


Measured memory_bytes: 7384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll A,B;
    cin >>A>>B;
    
    cout << max({A+B,A-B,A*B}) << endl;


    return 0;
    

}

Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<set>
#include<stdio.h>
#include<ctype.h>
using namespace std;
int main()
{
	
	long long int n;
	cin >> n;
	long long int a, b;
	cin >> a >> b;
	n %= 12;
	for (int i = 0; i < n; i++)
	{
		if ((i + 1) % 2 == 1)
		{
			a = a - b;
		}
		else
		{
			b = b + a;
		}
	}
	cout << a << " " << b << endl;
}




Measured memory_bytes: 3120
n = input()
if n[-1] == '2' or n[-1] == '4' or n[-1] == '5' or n[-1] =='7' or n[-1] == '9':
    print('hon')
elif n[-1] == '0' or n[-1] == '1' or n[-1] == '6' or n[-1] == '8':
    print('pon')
else:
    print('bon')


Measured memory_bytes: 9112
#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<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 998244353;
const ll INF = mod * mod;
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++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll x, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % m;
		x = x * x % m; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

void solve() {
	int n;ll k; cin >> n >> k;
	vector<int> a(n);
	rep(i, n)cin >> a[i];
	int le = 0, ri = 1000000007;
	while(ri-le>1) {
		int m = (le + ri) / 2;
		ll sum = 0;
		rep(i, n) {
			sum += (a[i] + m - 1) / m-1;
		}
		if (sum <= k) {
			ri = m;
		}
		else {
			le = m;
		}
	}
	cout << ri << "\n";
}




signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init_f();
	//cout << grandy(2, 3, false, false) << "\n";
	//int t; cin >> t; rep(i, t)
		solve();
	return 0;
}


Measured memory_bytes: 8212
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
string s;
LL dp[100000+10][13];
const int MOD=1e9+7;
int cont[13]={0,4,8,12,3,7,11,2,6,10,1,5,9};
int main(){
	dp[0][0]=1;
	cin>>s;
	int len=s.length();
//	int flag=0;
//	rb(i,0,len-1){
//		if(s[i]=='?'){
//			flag=1;
//		}
//	}
//	if(flag==0){
//		puts("0");
//		return 0;
////	}
//	if(len==1){
//		puts("1");
//		return 0;
//	}
	rb(i,1,len){
		rb(j,0,12){
		if(s[i-1]=='?'){
			if(i==1){
				if(j<10)
				dp[i][j]=1;
				continue;
			}
			rb(k,0,9){
				int las=j-k;
				if(las<0) las+=13;
				dp[i][j]+=dp[i-1][cont[las]];
				dp[i][j]%=MOD;
//				cout<<dp[i][j]<<" "<<j<<" "<<cont[las]<<endl;
			}
		}
		else{
			int las=j-(s[i-1]-'0');
			if(las<0) las+=13;
			if(i==1){
				dp[i][s[i-1]-'0']=1;
				break;
			}
			dp[i][j]=dp[i-1][cont[las]];
		}
//		cout<<i<<","<<j<<dp[i][j]<<"   ";	
		}
//		cout<<endl;
	}
//	rb(i,1,len){
//		rb(j,0,12){
//			cout<<dp[i][j]<<" ";
//		}
//		cout<<endl;
//	}
	printf("%I64d\n",dp[len][5]);
	return 0;
}

Measured memory_bytes: 10624
def resolve():
    import math
    n = int(input())
    a = list(map(int, input().split()))
    ans = [0] * n
    ans[math.floor(n/2):n] = a[math.floor(n/2):n]
    if n == 1 and a[0] == 1:
        print(1)
        print(1)
    else:
        for i in range(math.floor(n/2)-1, 0, -1):
            sumi = 0
            for j in range(i, n, i+1):
                sumi += ans[j]
                sumi %= 2
            if sumi == a[i]:
                ans[i] = 0
            else:
                ans[i] = 1
        if a[0] == sum(ans)%2:
            ans[0] = 0
        else:
            ans[0] = 1
        ansl = []
        for i, j in enumerate(ans):
            if j == 1:
                ansl.append(i+1)
        print(len(ansl))
        if len(ansl)!= 0:
            print(" ".join(map(str, ansl)))
resolve()

Measured memory_bytes: 81008
import sys
import math

n = int(input())

cost = sys.maxsize
tmp = 0
k = math.sqrt(n)
for i in range(1,int(k)+1):
    q, mod = divmod(n,i)
    if(mod==0):
        tmp = i + int(q) - 2
        cost = min(tmp,cost)
        tmp = 0

print(cost)


Measured memory_bytes: 3060
x = [0] * 3
x[0], x[1], x[2], N = map(int, input().split())
A = [[0]*(N+1) for _ in range(4)]
A[0][0] = 1

for k in range(3):
    for i in range(N+1):
        j = 0
        while i + x[k] * j <= N:
            A[k+1][i + x[k] * j] += A[k][i]
            j += 1

print(A[3][N])

Measured memory_bytes: 41068
attrs = Array.new
while line = $stdin.gets
  attrs << line.chomp.split
end

a,b = attrs[0].map{|a| a.to_i}
str = []
if a <= b then
  b.times {|i| str.push a}
else
  a.times {|i| str.push b}
end
puts str.join

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

int main() {
 int n,k,x;
 int a = 0;
 cin >> n >> k;
 for(int i = 0;i < n;i++){
   cin >> x;
   a += (x < k -x ? x*2:(k-x)*2);
 }
 cout << a << endl;
}

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

int main()
{
    int x,y,d,i,tmp;
    cin >> x >> y;

    if(x<y){
        tmp=x;
        x=y;
        y=tmp;
    }

    while(x%y!=0){
        x=x%y;
        tmp=x;
        x=y;
        y=tmp;
    }

    cout << y << endl;

    return 0;
}


Measured memory_bytes: 3088
#include <stdio.h>

int i,n,ans ;

int main(void){

    scanf ("%d",&n) ;
    
    for (i=0 ; i<n ; i++){
        
        int a[i] ;
        scanf ("%d,",&a[i]) ;
        
        while (a[i]%2==0){
            ans++ ;
            a[i] = a[i]/2 ;
        }
        
        
    }
    
    printf ("%d\n",ans) ;

    return 0 ;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
const int INF = 100000000;
typedef pair<int,int> P;

struct something{
	int x;
	int y;
}	ord[12];
char maze[1005][1005];
int h,w,n;


int d[1005][1005];

int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};
int bfs(something s,something g){
	queue<P> que;
	for (int i=1;i<=h;i++)
		for (int j=0;j<=w;j++) d[i][j] = INF;
		que.push(P(s.x,s.y));
		d[s.x][s.y] = 0;
		while (que.size()){
			P p=que.front();que.pop();
			if (p.first == g.x && p.second == g.y) break;
			for (int i=0;i<4;i++){
				int nx=p.first + dx[i],ny=p.second + dy[i];
				if (1<=nx && nx<=h && 1<=ny && ny<=w && maze[nx][ny]!='X' && d[nx][ny] == INF){
					que.push(P(nx,ny));
					d[nx][ny] = d[p.first][p.second] + 1;
				}
			}
		}
	return d[g.x][g.y];
}

int main(){
	cin>>h>>w>>n;
	int ans = 0;
	for (int i=1;i<=h;i++)
		for (int j=1;j<=w;j++)	{
			cin>>maze[i][j];
			if (maze[i][j] - 48>= 1 && maze[i][j] - 48 <= 9 ){
				ord[maze[i][j] - 48].x = i;
				ord[maze[i][j] - 48].y = j;
			}else if (maze[i][j] == 'S'){
			 	ord[0].x = i;
			 	ord[0].y = j;
			}
		}
	for (int i=0;i<n;i++){
		ans += bfs(ord[i],ord[i+1]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6148
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define L INT_MIN
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;
const int mxn=100005;
vi adj[mxn];
int s[mxn];
int ans=0;

int dfs(vector<bool> &vis,int start,int init)
{
  // if(s[start]!=init)
  // {
  //   ans++;
  //   swap(s[i],s[start]);
  // }
  vis[start]=true;
  for(int i:adj[start])
  {
    if(!vis[i])
    {
      dfs(vis,i,init^1);
    }
  }
} 

int main()
{
  fastio;
 
  
  int n;
  cin>>n;
  vi a(n+1),b(n+1);
  range(i,1,n+1)
  {
    cin>>a[i];
    b[a[i]]=i;
  }
  range(i,1,n+1)
  {
    cout<<b[i]<<' ';
  }
}


Measured memory_bytes: 6328
import numpy as np
n=int(input())
hp = list(map(int, input().split()))
hp = np.array(hp)
m = min(hp)
while 1:
  temp = hp%m
  temp = temp[temp!=0]
  if len(temp):
    M = min(temp)
    if M < m:
      m = M
    else:
      break
  else:
    break
print(m)

Measured memory_bytes: 23104
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem B

if __name__ == '__main__':
    S = sorted(set(list(input())))
    alphabets = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
                 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
                 'y', 'z']

    if len(S) == 26:
        print('None')
    else:
        for alphabet in alphabets:
            if alphabet not in S:
                print(alphabet)
                break


Measured memory_bytes: 3956
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string weather;
  cin >> weather;
  if(weather == "Sunny") {
    cout << "Cloudy" << "\n";
  } else if (weather == "Cloudy") {
    cout << "Rainy" << "\n";
  } else if (weather == "Rainy") {
    cout << "Sunny" << "\n";
  }
  return 0;
}



Measured memory_bytes: 256
let create_int_array n = Array.init n (fun _ -> 0)

let calc x y z = x * x + y * y + z * z + x * y + y * z + z * x

let case x y z =
  if x = y then (if y = z then 1 else 3)
  else if y = z then 3
  else 6

let () =
  let n = read_int () in
  let a = create_int_array n in

  let rec f x =
    let k = 6 * x * x in
    if k <= n then
      let rec g y =
        let k = x * x + 3 * y * y + 2 * x * y in
        if n < k then f (x + 1)
        else
          let rec h z =
            let k = calc x y z in
            if n < k then g (y + 1)
            else
              let w = case x y z in
              a.(k - 1) <- a.(k - 1) + w;
              h (z + 1)
          in h y
      in g x
  in

  f 1;
  ignore (Array.map (fun i -> Printf.printf "%d\n" i) a);
  ()


Measured memory_bytes: 5616
N = int(input())
#それぞれの要素番号に対応する約数の表を作成
yakusuu_table = [0] * N
#今回調べるのは入力された値から-1
for i in range(1, N):
#iの倍数を調べる→iとばし
    for j in range(i,N,i):
        yakusuu_table[j] += 1
print(sum(yakusuu_table))

Measured memory_bytes: 16788
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import bellman_ford, NegativeCycleError


def reachable_nodes(s, edges):
    cur = {s}
    reachable = set()
    while cur:
        reachable |= cur
        cur = set().union(*(edges[node] for node in cur)) - reachable
    return reachable


def solve():
    N, M, P = map(int, input().split())
    A, B, C = [0] * M, [0] * M, [0] * M
    to = [[] for _ in range(N)]
    reverse_to = [[] for _ in range(N)]
    for i in range(M):
        a, b, c = map(int, input().split())
        A[i], B[i], C[i] = a - 1, b - 1, P - c
        to[a - 1].append(b - 1)
        reverse_to[b - 1].append(a - 1)
    
    reachable = reachable_nodes(0, to) & reachable_nodes(N - 1, reverse_to)
    
    edge_dict = dict()
    for a, b, c in zip(A, B, C):
        if a in reachable and b in reachable:
            edge_dict[(a, b)] = min(c, edge_dict.get((a, b), 10 ** 6))
    AA, BB, CC = [], [], []
    for (a, b), c in edge_dict.items():
        AA.append(a)
        BB.append(b)
        CC.append(c)
    
    graph = csr_matrix((CC, (AA, BB)), shape=(N, N))
    try:
        bf = bellman_ford(graph, indices=[0])
        print(max(0, -int(bf[0][N - 1])))
    except NegativeCycleError:
        print(-1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 16056
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <numeric>
#include <vector>
#include <unordered_set>

using namespace std;
using ll = long long;
template<typename T> void print(T t) {cout << t << endl;}


int main() {
	int N, a; cin >> N;
	unordered_set<int> ren;
	for (int i = 0; i < N; i++) {
		cin >> a;
		if (ren.find(a) == ren.end()) {
			ren.insert(a);
		}
		else {
			ren.erase(a);
		}
	}
	print(ren.size());
}

Measured memory_bytes: 7308
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int x; cin >> x;
    int res=0;
    int sum=0;
    for(int i=1; ; i++){
        sum+=i;
        if(sum>=x){
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3576
#include <iostream>

#include<vector>

#include<string>

#include<algorithm>

#include<cmath>

#include<cstdlib>

#include<utility> 

#include<cstdio> 

#define vii vector< pair<int,int> >

#define vi vector<int>

#define INF 1000000007

#define ff first

#define ss second

#define lli long long int

#define ulli unsigned long long int

using namespace std;

int main() {

 ios_base::sync_with_stdio(false);

    cin.tie(NULL);
     int n;
     cin>>n;
     cout<<(n^1)<<endl;
 

}


Measured memory_bytes: 3612
#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>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 998244353;
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-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int n; int a[100000];
int gcd(int x,int y) {
	if (x < y)swap(x, y);
	while (y) {
		int r = x % y; x = y; y = r;
	}
	return x;
}
bool tra() {
	int cnt = 0;
	rep(i, n) {
		if (a[i] % 2 == 0)cnt++;
	}
	if (cnt % 2)return true;
	else if (cnt != n - 1)return false;
	else {
		rep(i, n) {
			if (a[i] % 2) {
				if (a[i] == 1)return false;
				a[i]--;
			}
		}
		int g = a[0];
		Rep(i, 1, n) {
			g = gcd(g,a[i]);
		}
		rep(i, n) {
			a[i] /= g;
		}
		return !tra();
	}
}
int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	if (tra())cout << "First" << endl;
	else cout << "Second" << endl;
	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n;
vector<string> s;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n;
    s.resize(n);
    set<string> st;
    rep(i,n){
        cin>>s[i];
        st.insert(s[i]);
    }
    print(st.size());
    return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
  int N, P;
  
  cin >> N >> P;
  
  vector<int> A;
  
  for (int i = 0; i < N; i++) {
    int in;
    
    cin >> in;
    
    in = in % 2;
    
    A.push_back(in);
  }
  
  // used or not used.
  vector<vector<ll>>dp(N, vector<ll>(2, 0));
  vector<vector<ll>>dp1(N, vector<ll>(2, 0));
  
  dp[0][0]  = 1;
  dp[0][1]  = A[0] == 0;
  dp1[0][0] = 0;
  dp1[0][1] = A[0] == 1;
  
  for (int i = 1; i < N; i++) {
    // used
    if (A[i] == 1) {
      dp[i][1] = dp1[i - 1][0] + dp1[i - 1][1];
      dp1[i][1] = dp[i - 1][0] + dp[i - 1][1];
    } else {
      dp[i][1] = dp[i - 1][0] + dp[i - 1][1];
      dp1[i][1] = dp1[i - 1][0] + dp1[i - 1][1];
    }
    
    // not used
    dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
    dp1[i][0] = dp1[i - 1][0] + dp1[i - 1][1];
  }
  
  if (P == 0) {
    cout << dp[N - 1][0] + dp[N - 1][1] << endl;
  } else {
    cout << dp1[N - 1][0] + dp1[N - 1][1] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
long long x;
cin>>x;
long long ans=0;
long long sum=100;
for(long long i=0;;i++){
  sum=sum+sum/100;
  if(sum>=x){
    ans=i;
    break;
  }
}
cout<<ans+1<<endl;
return 0;

}

Measured memory_bytes: 3632
#include<stdio.h>
 
int main(void)
{
 int a,b,c,d,e,f,A;
 float x,y;
 
 
 while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f)!=EOF)
 {
  A = (a*e-b*d);
  x = (double)(c*e-b*f)/A+0;
  y = (double)(a*f-c*d)/A+0;
  printf("%.3f %.3f\n",x,y);
 }
 return 0;
}

Measured memory_bytes: 0
sx, sy, tx, ty = (int(i) for i in input().split())
w = tx-sx
h = ty-sy

res = "U"*h+"R"*w+"D"*h+"L"*(w+1)+"U"*(h+1)+"R"*(w+1)+"DR"+"D"*(h+1)+"L"*(w+1)+"U"
print(res)

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <utility>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cctype>
using namespace std;
 
#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

int n, m, h, r;
vector<pii> v;
int dp[201];

void solve() {
	sort(v.begin(), v.end());

	fill(dp, dp+201, 1);
	int l = v.size();

	rep(i,l) {
		repa(j,i+1,l-1) {
			if(v[i].first < v[j].first  && v[i].second < v[j].second) {
				dp[j] = max(dp[j], dp[i]+1);
			}
		}
	}

	int maxval = 0;
	rep(i,l) {
		maxval = max(maxval, dp[i]);
	}
	cout << maxval << endl;
}

int main() {
	while(cin>>n,n) {
		v.clear();
		rep(i,n) {
			cin>>h>>r;
			v.push_back(pii(h,r));
		}
		cin>>m;
		rep(i,m) {
			cin>>h>>r;
			v.push_back(pii(h,r));
		}
		solve();
	}
}

Measured memory_bytes: 1200
s = input()

if s == 'SUN':
	print(7)
elif s == 'MON':
	print(6)
elif s == 'TUE':
	print(5)
elif s == 'WED':
	print(4)
elif s == 'THU':
	print(3)
elif s == 'FRI':
	print(2)
elif s == 'SAT':
	print(1)


Measured memory_bytes: 3064
import java.io.*;
import java.util.*;
import java.math.*;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		TreeSet<String>ts=new TreeSet<>();
		int n=sc.nextInt();
		for(int i=0;i<n;i++) {
			ts.add(sc.next());
		}
		System.out.println(ts.size());
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public boolean ready() throws IOException {
			return br.ready();
		}
		public int[] nextArr(int n) throws IOException{
			int arr[]=new int[n];
			for(int i=0;i<n;i++)arr[i]=nextInt();
			return arr;
		}

	}
}

Measured memory_bytes: 55896
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		System.out.println(gcd(a,b));
	}
	
	public static int gcd(int x, int y) {
		if (x % y == 0) {
			return y;
		}
		else {
			return gcd(y, x % y);
		}
	}
}


Measured memory_bytes: 26176
fun main() {
    val first = readString()
    val second = readString()

    println(if (second.startsWith(first)) "Yes" else "No")
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 

#define INF 1000000000000000000
#define MOD 10007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

int main(){
  int N,K;
  cin>>N>>K;
  string S;
  cin>>S;

  vector<pair<char,int> >s;
  for(int i=0;i<S.size();i++){
    if(S[i]=='0'){
      int j=1;
      if(i+1<S.size())for(;S[i+1]=='0';i++,j++);
      s.push_back({'0',max(1,j)});
    }
    else{
      s.push_back({'1',1});
    }
  }

  /*
  cout<<s.size()<<endl;
  for(auto it:s)cout<<it.first;
  cout<<endl;
  for(auto it:s)cout<<it.second;
  cout<<endl;
  */

  int r=0;
  int z=0;
  int sum=0;
  int ans=-100000000;
  for(int l=0;l<s.size();l++){
    while(r<s.size()&&z<=K){
      if(s[r].first=='0')z++;
      if(z>K){
        z--;
        break;
      }
      sum+=s[r].second;
      ++r;
    }

    ans=max(ans,sum);

    if(r==l)++r;
    else{
      if(s[l].first=='0')z--;
      sum-=s[l].second;
    }

  }

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



Measured memory_bytes: 1528
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,m;
	int minn=100000;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		if(b<=m)
			minn=min(minn,a);
	}
	if(minn==100000)
		cout<<"TLE"<<endl;
	else cout<<minn<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define INFITY 1000000001
#define SIZE 100000

typedef struct {
    char pat;
    int val;
}card;

void merge(card* A, int left, int mid, int right) {
    int n1, n2;
    int i, j, k;
    card L[SIZE], R[SIZE];

    n1 = mid - left;
    n2 = right - mid;

    for (i = 0; i < n1; i++) L[i] = A[left + i];
    
    for (i = 0; i < n2; i++) R[i] = A[mid + i];
    
    L[n1].val = INFITY;
    R[n2].val = INFITY;
    i = 0;
    j = 0;

    for (k = left; k < right; k++) {
        if (L[i].val <= R[j].val) {
            A[k] = L[i];
            i++;
        }
        else {
            A[k] = R[j];
            j++;
        }
    }
}
void mergeSort(card* A, int left, int right) {
    int mid;

    if (left + 1 < right) {
        mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int partition(card* A, int p, int r) {
    int x;
    int i, j;
    card temp;
    x = A[r].val;
    i = p - 1;
    for (j = p; j < r; j++) {
        if (A[j].val <= x) {
            i++;
            temp = A[i];
            A[i] = A[j];
            A[j] = temp;
        }
    }
   
    temp = A[i + 1];
    A[i + 1] = A[r];
    A[r] = temp;

    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() {
    card mer[SIZE], qui[SIZE];
    int n, val;
    int i,flag=1;
    char pat;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf(" %c%d", &pat, &val);
        mer[i].pat = qui[i].pat = pat;
        mer[i].val = qui[i].val = val;
    }

    mergeSort(mer, 0, n);
    quickSort(qui, 0, n - 1);

    for (i = 0; i < n; i++) {
        if (qui[i].val == mer[i].val && mer[i].pat != qui[i].pat) {
            flag = 0;
            break;
        }
    }

    if (flag == 0) printf("Not stable\n");
    else printf("Stable\n");
    for (i = 0; i < n; i++) {
        printf("%c %d\n", qui[i].pat, qui[i].val);
    }

    return 0;
}



Measured memory_bytes: 4088
#include <stdio.h>

int main()
{
        int n;
        scanf("%d", &n);

        char design;
        int  num;
        int card[52];

        for (int i = 0; i < 52; i++) {
                card[i] = 0;
        }

        for (int i = 0; i < n; i++) {
                scanf(" %c %d", &design, &num);
                if (design == 'S') {
                    card[num - 1] = num;
                } else if (design == 'H') {
                    card[num + 12] = num;
                } else if (design == 'C') {
                                card[num + 25] = num;
                } else if (design == 'D') {
                                card[num + 38] = num;
                }
        }

        for (int i = 0; i < 52; i++) {
                if (card[i] == 0) {
                        if (i < 13) {
                                printf("S %d\n", i + 1);
                        } else if (i < 26) {
                                printf("H %d\n", (i % 13) + 1);
                        } else if (i < 39) {
                                printf("C %d\n", (i % 13) + 1);
                        } else {
                                printf("D %d\n", (i % 13) + 1);
                        }
                }
        }
}



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

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (a+b == 15) {
        cout << '+' << endl;
    } else if (a*b == 15) {
        cout << '*' << endl;
    } else {
        cout << 'x' << endl;
    }
}

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

static const int N = 200000;

int main() {
  int i, n, minr, maxr, diff;
  int r[N];

  cin >> n;
  for (i = 0; i < n; i++) cin >> r[i];

  // init
  if (r[0] > r[1]) {
    minr = maxr = r[1];
  } else {
    minr = r[0];
    maxr = r[1];
  }
  diff = r[1] - r[0];

  for (i = 2; i < n; i++) {
    if (r[i] >= maxr) {
      maxr = r[i];
      diff = max(diff, maxr - minr);
    } else if (r[i] < minr) {
      minr = r[i];
      maxr = minr;
    }
  }
  
  cout << diff << endl;

  return 0;
}



Measured memory_bytes: 3852
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, q, ans = 0;
    string s;
    cin >> n >> q >> s;
    vector<int> sum(n + 1);
    for(int i = 2; i <= n; i++){
        if(s[i - 2] == 'A' && s[i - 1] == 'C'){
            sum[i]++;
        }
    }
    partial_sum(begin(sum), end(sum), begin(sum));
    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        // l--;
        cout << sum[r] - sum[l] << endl;
    }
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main () {
    long long S = 0, N;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            S += i;
        }
    }
    cout << S << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define int long long
using namespace std;
map<string,int> mp;
main()
{
    int n;
    cin>>n;
    while(n--){
        string s;
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<endl;
    cout<<"WA x "<<mp["WA"]<<endl;
    cout<<"TLE x "<<mp["TLE"]<<endl;
    cout<<"RE x "<<mp["RE"];
}


Measured memory_bytes: 3560
#include <iostream>
#include <vector>
#include <cctype>

constexpr int ALP_SIZE = 26;
constexpr int NUM_SIZE = 10;

int main()
{
    std::string S;
    std::cin >> S;
    
    std::vector<int> cnt_alp(ALP_SIZE);
    std::vector<int> cnt_num(NUM_SIZE);
    
    for (char c : S) {
        if (islower(c)) {
            cnt_alp[c - 'a'] += 1;
        } else {
            cnt_num[c - '0'] += 1;
        }
    }

    int res = 0;
    bool update = true;
    
    while (update) {
        update = false;
        for (int i = 0; i < ALP_SIZE; i++) {
            int j = i;
            
            while (j < ALP_SIZE && cnt_alp[j] > 0) j++;
            
            if (j - i >= 3) {
                for (int k = i; k < j; k++) {
                    cnt_alp[k] -= 1;
                }
                
                res += 3;
                update = true;
                
                break;
            }
        }
        
        for (int i = 0; i < NUM_SIZE; i++) {
            int j = i;
            
            while (j < NUM_SIZE && cnt_num[j] > 0) j++;
            
            if (j - i >= 3) {
                for (int k = i; k < j; k++) {
                    cnt_num[k] -= 1;
                }
                
                res += 3;
                update = true;
                
                break;
            }
        }
    }
    
    for (int i = 0; i < ALP_SIZE; i++) {
        res += cnt_alp[i];
    }
    
    for (int i = 0; i < NUM_SIZE; i++) {      
        res += cnt_num[i];
    }
    
    std::cout << res << std::endl;
    
    return 0;
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define y_n(ans) cout<<(ans?"Yes":"No")<<endl;

int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<int> left_w(n+1), right_r(n+1);
    left_w[0] = 0;
    right_r[n] = 0;
    for (int i=0; i<n; ++i) {
        left_w[i+1] = left_w[i];
        if (s[i] == 'W') left_w[i+1]++;
    }
    for (int i=n; i>0; --i) {
        right_r[i-1] = right_r[i];
        if (s[i-1] == 'R') right_r[i-1]++; 
    }
    int ans = 1e9;
    for (int i=0; i<=n; ++i) {
        ans = min(ans, max(left_w[i], right_r[i]));
    }
    cout << ans << endl;
}

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

typedef long long int ll;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
 
	ll i,j,t,k,l,m,n,x,y,z,c,a;

	string s;

	cin >> s;


	s += 'S';
	n = s.size();

	ll ans = -1;
	l = 0;

	for(i=0;i<n;i++)
	{
		if(s[i] == 'R')
			l++;

		if(s[i] == 'S')
		{
			ans = max(ans,l);
			l = 0;
		}
	}

	cout << ans << '\n';


	
 
	
	
 
}

Measured memory_bytes: 3644
#include <iostream>

int main() {
  int i = 1;
  int n;
  while(1) {
    std::cin >> n;
    if(n == 0) {
      break;
    }
    std::cout << "Case " << i << ": " << n << std::endl;
    ++i;
  }
  return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
map<string, string> m;
int main() {
  m["Rainy"] = "Sunny";
  m["Sunny"] = "Cloudy";
  m["Cloudy"] = "Rainy";
  string a; cin >> a;
  cout << m[a] << endl;
}

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

// definitions
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i, l, r) for (long long i = (l); i < (long long)(r); i++)
#define repb(i, r, l) for (long long i = (r); i > (long long)(l); i--)
#define pb push_back
#define mod1 998244353
#define mod 1000000007
#define MAX_CHAR 256

using namespace std;
typedef vector<long long> vl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector< pair<long long, long long> > vp;
typedef vector<tuple<long long , long long , long long> > vtup;
typedef deque <long long> dq;
typedef long long int lli;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;


// standard functions
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
} 
 


ll modexp(ll x, ll ex, ll modp) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x)%modp;
        ex >>= 1ll;
        x = (x * x)%modp;
    }
    return ans;
} 
 
ll nCrModp(ll n, ll r, ll p) 
{ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1; 
    for (ll i = 1; i <= n; i++) 
    { 
        for (ll j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
}
 
bool isPrime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true;  
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
vl countFreq(ll arr[], ll n) 
{ 
    unordered_map<ll, ll> mp; 
    vector <ll> v;
    
    for (ll i = 0; i < n; i++) 
        mp[arr[i]]++; 
   
    for (auto x : mp) 
        v.pb(x.second);
    
    return v;
}

ll binarySearch(ll arr[], ll l, ll r, ll x) 
{ 
    while (l <= r) 
    { 
        ll m = l + (r - l) / 2; 
        if (arr[m] == x) 
            return m; 
        if (arr[m] < x) 
            l = m + 1; 
        else
            r = m - 1; 
    }
    return -1; 
}

const ll MAXSIEVE=(1e3);
ll spf[MAXSIEVE];
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXSIEVE; i++) 
        spf[i] = i; 

    for (ll i=4; i<MAXSIEVE; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXSIEVE; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (ll j=i*i; j<MAXSIEVE; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
}

// code beigns in main
int main()
{
    
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll t=1;
    // cin >> t;
    
    while(t--)
    {
        ll n,k;
        cin >> n >>k;
        
        ll sum=0;
        rep(i,k,n+2)
        {
            ll val=((i%mod)*(n-i+1)%mod)%mod+1;
            // cout << val << endl;
            sum+=val%mod;
            sum=sum%mod;
        }
        cout << sum << endl;

    }
}



Measured memory_bytes: 3628
package main

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

func main() {
	log.SetFlags(log.Lshortfile)
	sc := newScanner()
	H := sc.nextInt()
	W := sc.nextInt()
	a := make([]string, H)
	for i := 0; i < W+2; i++ {
		fmt.Print("#")
	}
	fmt.Println("")
	for i := 0; i < H; i++ {
		fmt.Print("#")
		a[i] = sc.nextLine()
		fmt.Print(a[i])
		fmt.Println("#")
	}
	for i := 0; i < W+2; i++ {
		fmt.Print("#")
	}
	fmt.Println("")
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) nextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) nextInt() int {
	v, _ := strconv.Atoi(s.next())
	return v
}

func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640