akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ss second
#define ff first

using namespace std;

int wys;
int szer;
int kasa[505][505];
queue <pair <pair <int, int>, pair <int, int> > > wypisz;
pair <pair <int, int>, pair <int, int> > pomoc;
int zlicz;

int main()
{
    ios_base::sync_with_stdio(0);

    cin>>wys>>szer;

    for(int q=1; q<=wys; q++)
        for(int w=1; w<=szer; w++)
            cin>>kasa[q][w];

    for(int q=1; q<wys; q++)
    {
        for(int w=1; w<szer; w++)
        {
            if(kasa[q][w]%2!=0)
            {
                kasa[q][w+1]++;
                pomoc.ff.ff=q;
                pomoc.ff.ss=w;
                pomoc.ss.ff=q;
                pomoc.ss.ss=w+1;
                wypisz.push(pomoc);
                zlicz++;
            }
        }
        if(kasa[q][szer]%2!=0)
        {
            kasa[q+1][szer]++;
            pomoc.ff.ff=q;
            pomoc.ff.ss=szer;
            pomoc.ss.ff=q+1;
            pomoc.ss.ss=szer;
            wypisz.push(pomoc);
            zlicz++;
        }
    }
    for(int w=1; w<szer; w++)
    {
        if(kasa[wys][w]%2!=0)
        {
            kasa[wys][w+1]++;
            pomoc.ff.ff=wys;
            pomoc.ff.ss=w;
            pomoc.ss.ff=wys;
            pomoc.ss.ss=w+1;
            wypisz.push(pomoc);
            zlicz++;
        }
    }
    cout<<zlicz<<endl;
    while(wypisz.size()>1)
    {
        cout<<wypisz.front().ff.ff<<" ";
        cout<<wypisz.front().ff.ss<<" ";
        cout<<wypisz.front().ss.ff<<" ";
        cout<<wypisz.front().ss.ss<<endl;
        wypisz.pop();
    }
    if(wypisz.size()==0)
        return 0;

    cout<<wypisz.front().ff.ff<<" ";
    cout<<wypisz.front().ff.ss<<" ";
    cout<<wypisz.front().ss.ff<<" ";
    cout<<wypisz.front().ss.ss;
}

Measured memory_bytes: 5248
open Batteries
open BatPrintf

let scan fmt f =
  Scanf.sscanf (read_line ()) fmt f

let scan_list cnv =
  read_line ()
  |> String.split_on_char ' '
  |> List.map cnv

let scan_listn n cnv =
  (0 --^ n) |> Enum.map (fun _ -> (cnv % read_line) ())

let bsearch_ge arr a =
  let l = Array.length arr in
  match Array.bsearch Int.ord arr a with
  | `All_lower -> l
  | `All_bigger -> 0
  | `Just_after n -> l - n -1
  | `At n -> l - n
  | `Empty -> 0

let rec zip xs ys =
  match xs, ys with
  | [], _ -> []
  | _, [] -> []
  | x::xs, y::ys ->
    (x, y) :: zip xs ys

let square x = x * x

let dbg n = Printf.eprintf "%s\n" @@ dump n; n

module CombMemo = struct
  let prime = 1_000_000_000+7
  let size = 2*1_00_000+1

  let memo = let arr = Array.make size None in
    arr.(0) <- Some 1;
    arr

  let ( *% ) a b = a * b mod prime
  let (-%) a b = (a+prime - b) mod prime
  let (+%) a b = (a + b) mod prime

  let rec pow n m =
    if m = 0 then 1
    else if m mod 2 = 0 then pow (n*%n) (m/2)
    else n *% pow (n*%n) (m/2)

  let rec fact n =
    match memo.(n) with
    | None ->
      let m = n *% fact (n-1) in
      memo.(n) <- Some m;
      m
    | Some a -> a

  let comb n k =
    if n <= 0 || k <= 0 then 1
    else
      fact n *% (pow (fact k) (prime-2)) *% (pow (fact (n - k)) (prime-2))
end

let (n, k) = scan "%d %d" Tuple.Tuple2.make

let () =
  let open CombMemo in
  (0 -- if k >= n-1 then n-1 else k)
  |> Enum.fold (fun s m -> s +% (comb n m *% comb (n-1) (n-m-1))) 0
  |> printf "%d\n"


Measured memory_bytes: 10496
#include<stdio.h>
int main(){
  
  int i;
  int z=0;
  char s[2];
  
  scanf("%s",s);
  
  for(i=0;i<3;i++)
  {
  	if(s[i]=='1'){
    z++;
    }
  }
   printf("%d\n",z);
    return 0;
  }

Measured memory_bytes: 128
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws java.lang.Exception
    {		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int x =Integer.parseInt(st.nextToken()),y=Integer.parseInt(st.nextToken());
		boolean f=false;
		for(int i=0; i<=x; i++) {
			if((i*2+ (x-i)*4)==y) 
			  {f=true; break;}
		}
		System.out.println(f?"Yes":"No");
	}

}

Measured memory_bytes: 32656
N,M,C =map(int, input().split())
B = list(map(int,input().split()))
A = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    A.append(array)

sum_a = [0]*N
count = 0
for i in range(0,N):
    for j in range(0,M):
        sum_a[i] += A[i][j]*B[j]

    sum_a[i] += C
    if(sum_a[i] > 0):
        count+=1
    

print(count)



Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		boolean[] c = new boolean[8];
		int fc = 0;
		
		for (int i = 0; i < N; i++) {
			int n = sc.nextInt();
			if (n < 400) {
				c[0] = true;
			} else if (n < 800) {
				c[1] = true;
			} else if (n < 1200) {
				c[2] = true;
			} else if (n < 1600) {
				c[3] = true;
			} else if (n < 2000) {
				c[4] = true;
			} else if (n < 2400) {
				c[5] = true;
			} else if (n < 2800) {
				c[6] = true;
			} else if (n < 3200) {
				c[7] = true;
			} else {
				fc++;
			}
		}
		
		int min = 0;
		for (int i = 0; i < c.length; i++) {
			if (c[i]) {
				min++;
			}
		}
		
		System.out.println(Math.max(1, min) + " " + (min + fc));
	}
}


Measured memory_bytes: 23124
data = []
20.times do
  data << $stdin.gets.to_i
end

scoreW = data[0..9].sort!{|p,q| q <=> p}[0..2].inject(:+)
scoreK = data[10..19].sort!{|p,q| q <=> p}[0..2].inject(:+)

printf "%d %d\n", scoreW, scoreK

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

void fnInput(vector<int>& rvnSeq)
{
  int nSeqSiz;
  cin >> nSeqSiz;
  rvnSeq.resize(nSeqSiz);

  for(int& rnSeq : rvnSeq)
    cin >> rnSeq;
}
  
int fnLowerCnt(const vector<int>& cnrvnSeq)
{
  vector<int> vnRevSeq(cnrvnSeq);
  reverse(begin(vnRevSeq), end(vnRevSeq));

  int nMaxSeqCnt = 0;
  int nFoward = 0;
  while (nFoward < vnRevSeq.size())
  {
    int nSeqCnt = 0;

    for (int n = nFoward; n < vnRevSeq.size(); n++)
      if (vnRevSeq[n] <= vnRevSeq[n + 1])
        nSeqCnt++;
      else
      {
        nFoward = n + 1;
        break;
      }

    nMaxSeqCnt = max(nMaxSeqCnt, nSeqCnt);
  }
  return nMaxSeqCnt;
}
  
int main()
{
  vector<int> vnSeq;

  fnInput(vnSeq);
  cout << fnLowerCnt(vnSeq) << endl;

  return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

class Main {

    public static int maxkouyakusu(int a, int b) {
        int l;
        while (true) {
            if (a % b == 0) {
                return b;
            } else {
                l = a % b;
                a = b;
                b = l;
            }
        }
    }

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

        int amntcity = scanner.nextInt();
        int syokiiti = scanner.nextInt();
        int[] cities = new int[amntcity];
        for (int i = 0; i < amntcity; i++) {
            cities[i] = scanner.nextInt();
        }
        scanner.close();

        int[] sa = new int[amntcity];
        for (int i = 0; i < sa.length; i++) {
            sa[i] = Math.abs(cities[i] - syokiiti);
        }

        try {
            int saidaikouyakusu = maxkouyakusu(sa[0], sa[1]);
            for (int i = 2; i < sa.length; i++) {
                int kouyakusu = maxkouyakusu(saidaikouyakusu, sa[i]);
                if (kouyakusu < saidaikouyakusu) {
                    saidaikouyakusu = kouyakusu;
                }
            }
            System.out.println(saidaikouyakusu);
        } catch (Exception e) {
            System.out.println(sa[0]);
        }

    }

}


Measured memory_bytes: 48724
#include <bits/stdc++.h>
using namespace std;
int main() {
    long int n,weight;
    cin>>n>>weight;

    long int w[n];
    long int val[n];
    long int i,j;
   long int a,b;
    for(i=0;i<n;i++)
    {
     cin>>a>>b;
     w[i]=a;
     val[i]=b;
    }

    long int k[n+1][weight+1];

    for(i=0;i<=n;i++)
    {
        for(j=0;j<=weight;j++)
        {
            if(i==0 || j==0) k[i][j]=0;

            else if(w[i-1]>j) k[i][j]=k[i-1][j];

            else
            k[i][j]=max(k[i-1][j],val[i-1]+k[i-1][j-w[i-1]]);
        }
    }
    cout<<k[n][weight]<<endl;
}


Measured memory_bytes: 82456
#include <stdio.h>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <vector>
#include <map>
#include <ctime>
#include <string.h>
#define inf 0x7fffffff
using namespace std;
//1232
int a,b,c,n,m,l[4],o[1140010],k,i,d,dx[10]={0,1,-1,0,0,-1,-1,1,1},dy[10]={0,0,0,-1,1,1,-1,1,-1};
long long x,y,z;
stack<int> s;
struct P
{
    int x,y;
    long long z;
    bool operator<(const P &a)const
    {
        return y>a.y;
    }
};
 //map<int, int> p;
queue<P> q;
string r[3];
vector<P> v[1000100];
//vector<long long> ;
bool sdf(P a,P b){return a.y<b.y;}


int main()
{
    scanf("%d %d %d",&a,&b,&c);
    for(int t=1;t<=b;t++)
        o[(a*t)%b]=1;
    if(o[c]) puts("YES");
    else puts("NO");
    return 0;
}

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef unsigned long long ull ;
typedef long double ld ;

const ll MOD = 1E9 + 7, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

ll parent[200005], cost[200005] ;

ll Find(ll x)
{
    if (parent[x] == x) return x ;
    return parent[x] = Find(parent[x]) ;
}

void make_Union(ll a, ll b)
{
    a = Find(a), b = Find(b) ;
    if (a != b) {
        parent[b] = a ;
        cost[a] += cost[b] ;
        cost[b] = 0 ;
    }
    return ;
}

int main()
{
    fastIO ;
    ll n, m, a, b, ans = 0 ;
    cin >> n >> m ;

    for (int i = 1; i <= n; i++) {
        parent[i] = i, cost[i] = 1 ;
    }
    for (int i = 0; i < m; i++) {
        cin >> a >> b ;
        make_Union(a, b) ;
    }

    for (int i = 1; i <= n; i++) {
        ans = max(ans, cost[i]) ;
    }
    cout << ans ;

    return 0 ;
}


Measured memory_bytes: 6752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define sz(x) (ll)x.size()
int N = 2e5 + 5;

void solve_test_case(){
	ll d,t,n;
	cin>>d>>t>>n;
	if((double)d/n <= t){
		cout<<"Yes\n";
		return;
	}cout<<"No\n";
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	//cin>>t;
	for(int i = 1;i <= t;++i){
		solve_test_case();
	}
}


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

pair <long long, long long> r[200005];

int main() {
    long long n, x, d;
    scanf("%lld%lld%lld", &n, &x, &d);
    
    r[0] = make_pair(0, 0);
    
    for (int i = 1; i <= n; i++) {
        long long lb = 1LL * (i - 1) * i / 2;
        long long ub = 1LL * (n - 1 + n - i) * i / 2;
        r[i] = make_pair(lb, ub);
    }
    
    long long res = 0;
    
    for (int i = 0; i <= n; i++) {
        res += r[i].second - r[i].first + 1;
    }
    
    if (d == 0 && x == 0) return 0 * printf("1\n");
    if (d == 0) return 0 * printf("%lld\n", n + 1);
    if (x == 0) return 0 * printf("%lld\n", 1LL * n * (n - 1) / 2 + 1);
    
    long long lcm = 1LL * x * d / __gcd(x, d);
    long long a = lcm / x;
    long long b = -lcm / d;
    
    if (a < 0) {
        a *= -1;
        b *= -1;
    }
    
    for (int i = a; i <= n; i++) {
        long long lb = max(r[i - a].first, r[i].first - b);
        long long ub = min(r[i - a].second, r[i].second - b);
        
        if (lb <= ub) res -= ub - lb + 1;
    }
    
    printf("%lld\n", res);
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int main(void){
  int n, k;
  cin >> n >> k;

  int ret = k;
  for (int i = 0; i < n - 1; i++){
    ret *= k - 1;
  }

  cout << ret << endl;

  return 0;
}


ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


Measured memory_bytes: 256
from sys import stdin, setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def solve(x, k, d):
    if x - k * d >= 0:
        return x - k * d
    else:
        j = x // d
        xj = abs(x - d * j)
        xj1 = abs(x - d * (j + 1))
        rem = k - j
        if rem % 2 == 0:
            return xj
        else:
            return xj1
        # print(x, k, d, j, xj, xj1, rem)
    # return None

def main():
    from builtins import int, map
    X, K, D = map(int, input().split())
    if X < 0:
        X *= -1
    print(solve(X, K, D))


if __name__ == '__main__':
    main()


Measured memory_bytes: 65316
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int maxn =10006;

int rank[maxn];
int v[maxn];

void make_set(int x)
{
    v[x]=x;
    rank[x]=0;
}

int find_set(int x)
{
    if(v[x]!=x) v[x]=find_set(v[x]);
    return v[x];
}

void Union(int x,int y)
{
    if(rank[x]>rank[y])
        v[y]=x;
    else if(rank[x]<rank[y])
        v[x]=y;
    else if(rank[y]==rank[x])
    {
        v[x]=y;
        rank[y]++;
    }
}

struct Edge
{
    int x,y,w;
}e[maxn];

bool cmp(Edge e1,Edge e2)
{
    return e1.w<e2.w;
}
int main()
{
    int n,m;
    while(cin>>n>>m,n||m)
    {
        for(int i=0;i<m;i++)
            cin>>e[i].x>>e[i].y>>e[i].w;
        sort(e,e+m,cmp);
        for(int i=1;i<=n;i++) v[i]=i;
        int s1,s2;
        vector<int>ans;
        for(int i=0;i<m;i++)
        {
            s1=find_set(e[i].x);
            s2=find_set(e[i].y);
            if(s1!=s2)
            {
                ans.push_back(e[i].w);
                Union(s1,s2);
            }
        }
        sort(ans.begin(),ans.end());
        cout<<ans[ans.size()/2]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1360
#include <iostream>
#include <cstring>
#include <algorithm>
#include <list>
#include <map>
#include <cmath>
#include <string>
#include <cstdio>
#include <vector>
 
using namespace std;

typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '
 
const int MAXN = 1e5+5;
ll n = 0, a[MAXN], BIT[MAXN];

ll largest(ll a, ll b){
	return (a<b)?b:a;
}
int smallest(ll a, ll b){
	if(a < b)return a;
	return b;
}

int main() {
	int a = 0;
	string s;
	cin >> a >> s;
	if(a >= 3200){
		cout << s << endl;
	}
	else{
		cout << "red" << endl;
	}

    return 0;
}	

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

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

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int N;
  cin>>N;
  bool ok=false;
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      if(N==i*j)ok=true;
    }
  }
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {
  int a [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  // 配列の添字は 0 から始まるので，a [0] は 0 にしている．
  int x , y ; cin >> x >> y ;
  cout << ( a [ x ] == a [ y ] ? " Yes " : " No ") << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 標準入力の取得
S = input()
T = input()

# 求解処理
result = ""
if (S == T[:-1]) and (len(T) == len(S) + 1):
    result = "Yes"
else:
    result = "No"

# 結果出力
print(result)


Measured memory_bytes: 9092
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i) 
typedef long long ll;
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
/*
	　　　  　 ,ﾍ／L──- 、
	　　　   　Lﾆ)r_」=＝= ｲ
	　　 　,ﾍ、i ﾉノλﾉﾊﾉﾍ
	　　   ,'　｀(ﾊﾘ ﾟ ヮﾟﾉi)　',
	　　 .i　　 >〈(つ,i!と)　　i
	　　  vﾍγk´_/___i,ゝﾍノ
	　　　　　 ｀ﾞr_,ｨ_ｧﾞ´
*/
int n;
cin >> n;
int sum = 0;
rep1(i, n) {
	sum += i;
}
cout << sum << endl;
return 0;
}


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

ll dp[100100];
int n, h[100100];
bool   vis[100100];

// func(pos) -> "pos" theke "n" jaite minimum cost koto lage?
ll func( int pos ) {
    if ( pos == n ) return 0;
    if ( vis[pos] ) return dp[pos];
    vis[pos] = 1;

    ll p = 2e9, q = 2e9;
    if ( pos + 1 <= n ) p = abs(h[pos + 1] - h[pos]) + func(pos + 1);
    if ( pos + 2 <= n ) q = abs(h[pos + 2] - h[pos]) + func(pos + 2);

    return dp[pos] = min(p, q);
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> h[i];
    cout << func(1) << endl;
    return 0;
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
constexpr ll INF = 1e18;
constexpr ll MOD = 1e9+7;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), V.end()

int main() {
  string S, T;
  cin >> S >> T;
  int S_len = S.length();

  int cnt = 0;

  for(int i = 0; i < S_len; i++) {
    if(S[i] == T[i]) cnt++;
  }

  if(cnt == S_len) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

struct mint {
  ll x;
  mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD)
      x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  /* 変数名.pow(n) */
  mint pow(ll t) const {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // 以降はMODが素数のみ
  mint inv() const {
    return pow(MOD - 2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

int main() {
  string S;
  cin >> S;

  mint dp[S.size() + 1][4];
  rep(i, S.size() + 1) {
    rep(j, 4) {
      dp[i][j] = 0;
    }
  }

  dp[0][0] = 1;
  rep(i, S.size()) {
    rep(j, 4) {
      if (S[i] == '?') {
        dp[i + 1][j] += dp[i][j] * 3;
      } else {
        dp[i + 1][j] += dp[i][j];
      }
    }
    if (S[i] == 'A' || S[i] == '?') {
      dp[i + 1][1] += dp[i][0];
    }
    if (S[i] == 'B' || S[i] == '?') {
      dp[i + 1][2] += dp[i][1];
    }
    if (S[i] == 'C' || S[i] == '?') {
      dp[i + 1][3] += dp[i][2];
    }
  }
  cout << dp[S.size()][3].x << endl;
}

Measured memory_bytes: 3584
C = input()
alphabet = {1:"a", 2:"b", 3:"c", 4:"d", 5:"e", 6:"f", 7:"g", 8:"h", 9:"i", 10:"j", 11:"k", 12:"l", 13:"m", 14:"n", 15:"o", 16:"p", 17:"q", 18:"r", 19:"s", 20:"t", 21:"u", 22:"v", 23:"w", 24:"x", 25:"y", 26:"z"}
keys = [k for k, v in alphabet.items() if v == C][0]
print(alphabet[int(keys) + 1])

Measured memory_bytes: 3064
using System;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split(' ');
            var a = int.Parse(ab[0]);
            var b = int.Parse(ab[1]);

            if (a >= 10 || b >= 10)
            {
                Console.WriteLine("-1");
            }
            else
            {
                Console.WriteLine(a * b);
            }
        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<math.h>
#include<queue>
#define mod 20123
#define inf 123456789
#define LL long long
#define big 1e18
#define mem(a,b) memset(a,b,sizeof(a))
using  namespace std;
int max(int a,int b){ return a>b?a:b;}
int maxn (int a,int b,int c){return max(max(a,b),max(b,c));}
LL min(LL a,LL b){return a<b?a:b;}
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    for(int i=1;i<=b;i++)
    {
        if(i*a%b==c)
        {
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    String s = next();

    if(s.equals("ABC")){
      System.out.println("ARC");
    }
    else{
      System.out.println("ABC");
    }



    //System.out.println();

  }

  static int lcm(int a,int b){
    return a*b*gcd(a,b);
  }

  static int gcd(int a,int b){
    if(a%b!=0){
      return gcd(b,a%b);
    }
    else{
      return b;
    }
  }

  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

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

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

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

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 35696
import math
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8
from numba import jit
import collections
import bisect
from collections import deque
from copy import copy, deepcopy
import time
 
def main():
    N = input()
    sum = 0
    for n in N:
        sum+=int(n)
    print("Yes" if sum%9==0 else "No")

if __name__ == '__main__':
    main()

Measured memory_bytes: 92040
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

bool isPrime(int x){
	for(int i=2;i<=sqrt(x);i++){
		if(x%i==0){
			return false;
		}
	}
	return true;
}

int main(){
	int N;
	cin>>N;
	vector<int> a;
	
	for(int i=2;a.size()<=55555;i++){
		if(isPrime(i) && i%5==1){
			a.push_back(i);
		}
		if(a.size()>=N){
			break;
		}
	}

	for(int i=0;i<a.size();i++){
		cout<<a[i]<<" ";
	}

	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
nums = [int(e) for e in input().split()]
import numpy as np

ans= np.zeros(max(nums)+1)

for i in nums:
    if ans[i] >1:
        continue
    else:
        ans[i::i] +=1

cnt = 0
for i in nums:
    if ans[i] ==1:
        cnt +=1

print(cnt)

Measured memory_bytes: 41788
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b)
	{
		cout << "YES";
	}
	else
	{
		cout << "NO";
	}
	cout << endl;

}

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

int n, c[550], s[500], f[500];

int main()
{
    cin >> n;
    rep(i, n - 1) cin >> c[i] >> s[i] >> f[i];
    
    rep(i, n)
    {
        int t = 0;
        for(int j = i; j < n - 1; j++)
        {
            if(t <= s[j])
            {
                t = s[j];
            }
            else
            {
                t = ((t + f[j] - 1) / f[j]) * f[j];
            }

            t += c[j];
        }
        cout << t << "\n";
    }
    
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef long long unsigned int llui;
typedef long long int lli;
typedef long double float64;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;

#define INF 1000000000
#define MOD 1000000007
#define EPS 1e-9
#define DEBUG(x) cout<< '>' << #x << ':' << x << "\n";
#define all(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define UNIQUE(x) (x).erase(unique((x).begin(),(x).end()),(x).end())
#define tr(container, it) \
    for(typeof(container.begin()) it = container.begin(); it != container.end(); it++) 


// #define sz(a) int((a).size())
// #define pb push_back
// #define fill(a,v) memset(a,v,sizeof a)


#define trace(x) cout << '>' << #x << ':' << x << endl;
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << endl;

#define trace3(x,y,z) cout<< '>' << #x << ':' << x \
        << " | " << #y << ':' << y <<" | " << #z << ':' << z << endl;

#define trace4(x,y,z,w) cout<< '>' << #x << ':' << x \
    << " | " << #y << ':' << y <<" | " << #z << ':' << z << " | " << #w << ':' << w << endl;



inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }

#define LSOne(S) (S&(-S))

const double pi = acos(-1);


template<class T> inline T gcd(T a,T b) //NOTES:__gcd(0,0) gives exception
  {if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}

int cmp(double x, double y = 0, double tol = EPS) {
    return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

/////////////////////////////////////////////////////////////////////

/*bool sortby(const pair<int,int> &a,const pair<int,int> &b)
{
    return (a.first < b.first);
}*/

const int MAX_N = 4123;

int arr[MAX_N];
 
int main() {
	int N,Y;
	ll y;
	scanf("%d %lld",&N,&y);
	Y=y/1000;
	for(int i=0;i<N+1;i++){
		for(int j=0;j<N+1-i;j++){
			int k=N-i-j;
			if(10*i+5*j+k==Y)
			{
				printf("%d %d %d\n",i,j,k);
				return 0;
			}
		}
	}
	printf("-1 -1 -1\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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 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 ll MOD = 1000000007LL;
/*メモ XOR問題のまとめ
性質 1「交換則、結合則が成り立つ」
　　 2「a xor a = 0」
　　 3「ある数xのb番目のビットが1である <=> x mod 2^(b+1) ≧ 2^b」
　　 4「0≦aのとき、4a, 4a+1, 4a+2, 4a+3のxor和は0」
方針 
!!!!!1「xor計算は各ビットで独立なので別々に計算」
　　 2「trieを使ったxorの最大最小探索がある解説」
・しゃくとり法は[ｌ,r)で考えるとわかりやすいよ！
*/
int main(){
    int n,t;
    std::cin >> n>>t;
    VEC(int,a,t);
    sort(all(a),greater<int>());
    int b=(n-a[0]);
    std::cout << max(a[0]-(b+1),0) << std::endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
people = {i:a for a,i in zip(A,[j for j in range(1,N+1)])}
#print(people)
people_sorted = sorted(people.items(),key=lambda x:x[1])
#print(people_sorted)
P = [i[0] for i in people_sorted]
for p in P:
    print(p,end =" ")

Measured memory_bytes: 26256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var vals = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var N = vals[0];
            var M = vals[1];

            var pp = new List<int[]>();
            foreach(var i in Enumerable.Range(0, M))
            {
                pp.Add(Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray());
            }

            var list = new List<Intercept>();
            foreach(var p in pp.OrderBy(x => x[0]).ThenBy(x => x[1]))
            {
                var item = new Intercept(p);
                var breaked = false;
                foreach(var j in Enumerable.Range(0, list.Count))
                {
                    var x = list[j].Prod(item);
                    if(x != null)
                    {
                        list[j] = x;
                        breaked = true;
                        break;
                    }
                }
                if (!breaked) list.Add(item);
            }

            Console.WriteLine(list.Count);
        }
    }

    public class Intercept
    {
        public int Start { get; set; }
        public int End { get; set; }

        public Intercept()
        {

        }
        public Intercept(int[] vals)
        {
            this.Start = vals[0];
            this.End = vals[1];
        }

        public Intercept Prod(Intercept target)
        {
            var st = Math.Max(this.Start, target.Start);
            var ed = Math.Min(this.End, target.End);

            if (st >= ed) return null;
            else
            {
                return new Intercept() { Start = st, End = ed };
            }
        }
    }
}


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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

using P = pair<int, int>;

class BinaryIndexedTree {
public:
    vector<int> data;
    BinaryIndexedTree(int _n) {
        int n = 1;
        while (n < _n) {
            n *= 2;
        }
        data.resize(n, 0);
    }
    void update(int n, int val) {
        for (n++; n < data.size(); n += (n & -n)) {
            data[n] += val;
        }
    }
    int query(int n) {
        int ans = 0;
        for (n++; n > 0; n -= (n & -n)) {
            ans += data[n];
        }
        return ans;
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<P> d(n);
    REP(i, 0, n) {
        cin >> d[i].second >> d[i].first;
    }
    sort(d.begin(), d.end());
    ll ans1 = 0;
    {
        BinaryIndexedTree BIT(100010);
        vector<int> res(n, 0);
        REP(i, 0, n) {
            int st = d[i].second, ed = d[i].first;
            res[i] = i - BIT.query(st) + 1;
            BIT.update(ed, 1);
            //dump(res[i]);
        }
        BIT = BinaryIndexedTree(100010);
        for (int i = n - 1; i >= 0; i--) {
            int st = d[i].second, ed = d[i].first;
            ll tmp = BIT.query(ed - 1);
            ans1 = max(ans1, tmp + res[i]);
            //dump(tmp);
            BIT.update(st, 1);
        }
    }
    ll ans2 = 0;
    {
        vector<int> imos(100010, 0);
        REP(i, 0, n) {
            int a = d[i].second;
            int b = d[i].first;
            imos[a]++;
            imos[b]--;
        }
        ans2 = imos[0];
        REP(i, 1, 100010) {
            imos[i] += imos[i - 1];
            ans2 = max(ans2, (ll)imos[i]);
        }
    }
    cout << ans1 << " " << ans2 << endl;
    return 0;
}



Measured memory_bytes: 6252
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr = ds.begin(); itr != ds.end(); ++itr)
#define mp make_pair
#define INF 2000000000
#define INFL 2000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;

int main() {
	ll N;
	cin >> N;
	N++;
	deque<int> a, b;
	int left = 1;
	while ((N >> left) > 0)left++;
	int num = 1;
	reprev(i, left - 1) {
		a.push_back(num);
		b.push_back(num);
		num++;
		if ((N >> i) % 2 == 1) {
			a.push_back(num);
			b.push_front(num);
			num++;
		}
	}
	cout << a.size() + b.size() << endl;
	while(!a.empty()) {
		cout << a.front() << ' ';
		a.pop_front();
	}
	while(!b.empty()) {
		cout << b.front();
		b.pop_front();
		if (!b.empty())cout << ' ';
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
# 整数の入力
A, B, C= map(int, input().split())
# 出力
if A==B and B==C:
 if A%2 ==0 and B%2==0 and C%2==0:
  print(-1)
  sys.exit()
count=0
while True:
 if A%2 ==1 or B%2==1 or C%2==1:
  print(count)
  sys.exit()
 else:
  A_a=B/2+C/2
  B_a=A/2+C/2
  C_a=A/2+B/2
  A=A_a
  B=B_a
  C=C_a
  count+=1


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int n, m, a, b;
vi g[1252];
int h[1252][1252];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	cin>>n>>m;
	REP(i, m){
		cin>>a>>b;
		--a;--b;
		g[a].push_back(b);
		h[a][b]=1;
	}
	REP(i, n){
		vi v;
		queue<pair<int, vi>> q;
		q.push(make_pair(i, v));
		while(q.size()){
			auto t=q.front();
			q.pop();
			int s=t.first;
			vi u=t.second;
			u.push_back(s);
			FORR(j, 0, u.size()){
				for(auto t : g[s]){
					if(t==u[j]){
						cout<<u.size()-j<<'\n';
						REP(k, u.size()-j){
							cout<<u[j+k]+1<<'\n';
						}
						return 0;
					}
				}
			}
			for(auto t : g[s]){
				q.push(make_pair(t, u));
			}
		}
	}
	cout<<-1<<'\n';
	return 0;
}


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

using namespace std;

#define int long long
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define Endl '\n'
#define cont continue
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/__gcd(a,b)
#define pb push_back
#define mp make_pair
#define mem(x) memset(x, 0, sizeof(x))

const ll inf=1e18;
const int mod=1e9+7;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
const int mxn = 2e5+10;

//ll fact[mxn];
//ll in_fact[mxn];
//fact[0] = 1;
//for(ll i = 1; i < mxn; i++) {
	//fact[i] = (i*fact[i-1])%mod;
//}
//in_fact[mxn-1] = bigmod(fact[mxn-1],mod-2);
//for(ll i = mxn-2; i >= 0; i--) {
	//in_fact[i] = (in_fact[i+1] * (i+1))%mod;
//}
//ll c(ll n,ll r) {
	//ll ans = (fact[n] * (in_fact[r] * in_fact[n-r]%mod))%mod;
	//return ans;
//}
bool chck(string tmp,string s) {
	int n = tmp.size();
	for(int i = 0; i < (int)s.size()-n; i++) {
		if(s.substr(i,n) == tmp) return true;
	}
	return false;
}

signed main(){
    fast;
	//freopen ("input.txt", "r", stdin);
	//freopen ("output.txt", "w", stdout);
    int tt = 1;
    //cin>>tt;
    for(int tc = 1; tc <= tt; tc++) {
        string s,t;
        cin>>s>>t;
        int sn = s.size(); 
        int tn = t.size();
        int ans = inf;
        for(int i = 0; i <= (sn-tn); i++) {
			int c = 0;
			for(int j = 0; j < tn; j++) {
				if(s[i+j] != t[j]) c++;
			}
			ans = min(ans,c);
		}
		cout<<ans<<endl;
        
        
    }



return 0;
}


Measured memory_bytes: 3620
n,q = map(int,input().split())
s = input()
lr = [list(map(int,input().split())) for i in range(q)]

aclist = [0,0]
acsum = 0

for i in range(1,n):
    if s[i-1] == "A" and s[i] == "C":
        acsum += 1
    aclist.append(acsum)

for i in range(q):
    ans = aclist [lr[i][1]] - aclist [lr[i][0]-1]
    if aclist [lr[i][0]] - aclist [lr[i][0]-1] != 0:
        ans -= 1
    print(ans)

Measured memory_bytes: 30704
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

N = int(readline().rstrip())
K = int(readline().rstrip())
X = list(map(int, readline().split()))

half = K / 2
ans = 0
for x in X:
    if half < x:
        ans += K - x
    else:
        ans += x

print(ans * 2)

Measured memory_bytes: 3188
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  lint X,K,D;
  cin>>X>>K>>D;
  if(X<0)X=-X;
  if(K>X/D){
    K-=X/D;
    X%=D;
    if(K%2==0)cout<<X<<endl;
    else cout<<D-X<<endl;
  }else{
    cout<<X-K*D<<endl;
  }
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

signed main(){
   IOS;
   int n; cin >> n;
   vector<int> a(n), ans(n);
   for(auto &x : a) cin >> x;
   int k = (a[0]^a[1]);
   for(int i = 2; i<n; i+=2) {
      k ^= (a[i]^a[i+1]);
   }
   for(int i = 0; i < n; i++) {
      cout << (a[i]^k) << " ";
   }
}

Measured memory_bytes: 6248
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	int X[2];
	cin >> X[0] >> X[1];
	int ans = 0;
	for(int i = 0; i < 2; i++) {
		if(X[i] == 3) ans += 100000;
		if(X[i] == 2) ans += 200000;
		if(X[i] == 1) ans += 300000;
	}
	if(X[0] == 1 && X[1] == 1) ans += 400000;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
import math
a,b = [int(i) for i in input().split()]
mod = 10**9 +7

if a+1 < b:
    print(0)
elif a > b+1:
    print(0)
elif a == b:
    print(math.factorial(a)%mod*math.factorial(b)%mod*2%mod)
else:
    print(math.factorial(a)%mod*math.factorial(b)%mod)

Measured memory_bytes: 4096
import java.util.*;
public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
    	int i, j, k;
    	String str = sc.next();
    	int q = sc.nextInt();
    	
    	for(i = 0; i < q; i++) {
    		String order = sc.next();
    		if(order.equals("print")) {
    			int pr1 = sc.nextInt();
    			int pr2 = sc.nextInt();
    			
    			System.out.println(str.substring(pr1, pr2 + 1));
    		}
    		if(order.equals("reverse")) {
    			int re1 = sc.nextInt();
    			int re2 = sc.nextInt();
    			
    			StringBuffer sb = new StringBuffer(str.substring(re1, re2 + 1));
    			String re = sb.reverse().toString();
    			str = str.substring(0, re1) + re + str.substring(re2 + 1, str.length());
    		}
    		if(order.equals("replace")) {
    			int rep1 = sc.nextInt();
    			int rep2 = sc.nextInt();
    			String rep3 = sc.next();
    			
    			str = str.substring(0, rep1) + rep3 + str.substring(rep2 + 1, str.length());
    		}
    	}
    }
}


Measured memory_bytes: 29952
#include <iostream>
using namespace std;
typedef long long lli;
#define N 300000
#define MOD 1000000007
lli h,w,a,b;
lli exeuclid(lli a,lli aa,lli x,lli xx,lli y,lli yy){
	lli q;
	if(a == 0) return aa > 0 ? xx : -xx;
	q = aa / a;
	return exeuclid(aa - q * a,a,xx - q * x,x,yy - q * y,y);
}

lli invarse(lli x){
	return (exeuclid(MOD,x,0,1,1,0) + MOD) % MOD;
}


lli factrial(lli x){
	static lli dp[N];
	if(dp[x]) return dp[x];
	if(x == 0) 	return dp[x] = 1;
				return dp[x] = (factrial(x-1) * x) % MOD;
}

lli combination(lli n,lli k){
    return (((factrial(n) * invarse(factrial(k))) % MOD) * invarse(factrial(n-k))) % MOD;
}
lli ans = 0;
int main(int argc, char const *argv[]) {
    cin >> h >> w >> a >> b;
    for(lli i = b;i < w;i++){
        ans += combination(i+h-a-1,i) * combination(a-1+w-i-1,a-1) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int n,m,l;
  cin>>n>>m;
  int ans=0;
  int a[n];
  int co[m];
  rep(i,m){
    co[i]=0;
  }
  rep(i,n){
    cin>>a[i];
    rep(j,a[i]){
      cin>>l;
      co[l-1]++;
    }
  }
  rep(i,m){
    if(co[i]==n){
      ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

void output(int ar[], int sz){
    for (int i = 0; i < sz - 1; i++) {
        cout << ar[i];
        cout << " ";
    }
    cout << ar[sz - 1];
    cout << endl;
}

int main(int argc, char const* argv[])
{
    int sz, ar[100];
    cin >> sz;
    for (int i = 0; i < sz; i++) {
        cin >> ar[i];
    }

    for (int i = 1; i < sz; i++) {
        output(ar, sz);
        int v = ar[i];
        int j = i - 1;
        while (j >= 0 && ar[j] > v) {
            ar[j+1] = ar[j];
            j--;
        }
        ar[j+1] = v;
    }
    output(ar, sz);
    return 0;
}

Measured memory_bytes: 1160
def main():
    N = int(input())
    S = str(input())
    ans = ''
    alphabet = ['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']
    for i in range(len(S)):
        c = alphabet.index(S[i]) + N
        if c > 25:
            c = c - 26
        ans = ans + alphabet[c]
    print(ans)
main()

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};
set<int> S;

bool check(int N)
{
    stringstream ss;
    string NS; 
    ss << N; ss >> NS;

    for (auto i : NS) {
        if (S.count(i-'0')) return false;
    }

    return true;
}


int main()
{
    int N, K;
    cin >> N >> K;
    rep(i, K) {
        int D; cin >> D;
        S.insert(D);
    }

    int ans = N;
    while (true) {
        if (check(ans)) {
            cout << ans << endl;
            return 0;
        }
        ans++;
    }
}



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

int main(){

  int N, M, C;
  cin >> N >> M >> C;
  int B[M];
  for(int i=0; i < M; ++i){
    cin >> B[i];
  }

  int ans = 0;
  for(int i=0; i < N; ++i){
    int v = C;
    for(int j=0; j < M; ++j){
      int a;
      cin >> a;
      v += B[j] * a;
    }
    if(v > 0){
      ans++;
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<vector>
#include<cmath>
#include<complex>
#include<string>
#include<algorithm>

using namespace std;

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;


int main(void)
{

    int x,a,b;
    int ans;

    cin >> x >> a >> b;
    x -= a;
    ans = x%b;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int N,d[100],last,ans=1;
int main(void){
	cin>>N;
	for(int i=0;i<N;i++)cin>>d[i];
	sort(d,d+N);
	last=d[0];
	for(int i=1;i<N;i++)
		if(d[i]!=last){
			ans++;
			last=d[i];
		}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256