akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





int N, M; string S;
set<int> E[201010];
int ok[201010], ok2[201010];
int acnt[201010], bcnt[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M >> S;
    rep(i, 0, M) {
        int a, b; cin >> a >> b;
        a--; b--;
        E[a].insert(b);
        E[b].insert(a);
    }

    rep(cu, 0, N) {
        int a = 0, b = 0;
        fore(to, E[cu]) {
            if (S[to] == 'A') a++;
            else b++;
        }
        if (0 < a and 0 < b) ok[cu] = 1;
    }

    rep(cu, 0, N) if (ok[cu]) {
        fore(to, E[cu]) if(ok[to]) {
            if (S[to] == 'A') acnt[cu]++;
            else bcnt[cu]++;
        }
    }

    queue<int> ng;
    rep(cu, 0, N) if (ok[cu]) {
        if (acnt[cu] == 0 or bcnt[cu] == 0) {
            ng.push(cu);
            ok[cu] = 0;
        }
    }

    while (!ng.empty()) {
        int cu = ng.front(); ng.pop();

        fore(to, E[cu]) if (ok[to]) {
            if (S[cu] == 'A') acnt[to]--;
            else bcnt[to]--;

            assert(0 <= acnt[to] and 0 <= bcnt[to]);
            if (acnt[to] == 0 or bcnt[to] == 0) {
                ng.push(to);
                ok[to] = 0;
            }
        }
    }

    rep(cu, 0, N) if (ok[cu]) {
        printf("Yes\n");
        return;
    }
    
    printf("No\n");
}

Measured memory_bytes: 30544
#include <bits/stdc++.h>
# define ll int64_t
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll facctorial(ll k){
    ll sum = 1;
    rrep(i,k) {
        sum*=i;
    }
    return sum;
}

int main(){
    ll sum=0,mini=10000000;
    vector<ll> a(5),b(5);
    rep(i,5){
        cin>>a[i];
        if(a[i]%10!=0) b[i] = a[i]+(10-(a[i]%10));
        else b[i]=a[i];
        sum += b[i];
    }
    rep(i,5){
        if(sum-b[i]+a[i]<=mini) mini=sum-b[i]+a[i];
    }
    cout<<mini<<endl;
    return 0;
}


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

int main() {
    int a,b,c;
    cin >> a >> b >> c;

    if (a == b&&b == c)cout << 1 << endl;
    else if (a == b&&b != c)cout << 2 << endl;
    else if (a == c&&b != c)cout << 2 << endl;
    else if (c == b&&a != c)cout << 2 << endl;
    else if (a != b&&b != c&&a != c)cout << 3 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int ctoi(char c) {
	switch (c)
	{
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default:
		cout << "ERR_ctoi" << endl;
		return -1;
	}
}
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a >= b && a >= c) {
		PRI(a * 10 + b + c);
	}
	else if (b >= a && b >= c) {
		PRI(b * 10 + a + c);

	}
	else {
		PRI(c * 10 + a + b);

	}
	return 0;
}

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

const int inf = 1e9;
int main(){
	int n;
	cin>>n;
	vector<int> dp(n+1,inf);

	dp[0] = 0;
	dp[1] = 1;
	for(int i = 2; i <= n; i++){
		dp[i] = dp[i-1]+1;
		for(int j = 6; j<=i;j*=6){
			dp[i] = min(dp[i],dp[i-j]+1);
		}
		for(int j = 9; j<=i;j*=9){
			dp[i] = min(dp[i],dp[i-j]+1);
		}
	}

	cout<<dp[n];
}

Measured memory_bytes: 640
n,m = gets.split.map(&:to_i)
a = []
for i in 1..Math.sqrt(m).floor+1
  if m%i == 0
    a << i << m/i
  end
end

a = a.sort.reverse

a.each do |i|
  if m/i >= n
    puts i
    exit
  end
end

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

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

  int i, input;
  vector<int> heights;
  for (i = 0; i < 10; i++) {
    cin >> input;
    heights.push_back(input);
  }

  sort(heights.rbegin(), heights.rend());
  cout << heights.at(0) << endl;
  cout << heights.at(1) << endl;
  cout << heights.at(2) << endl;

  return 0;
}

Measured memory_bytes: 1220
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())
 
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


int main() {
    int N,L;
    cin>>N>>L;
    VS s(N);
    REP(i,N){
        cin>>s[i];
    }
    SORT(s);
    string ans;
    REP(i,N){
        ans += s[i];
    }
    cout << ans<< endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;
using namespace std;

#define ll long long

map<ll, int> prime(ll n) {
  map< ll, int > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

ll a,b;
int main() {
    cin >> a >> b;
    map<ll, int> p = prime(__gcd(a, b));
    cout << p.size() + 1;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for(int i = (s); i < (e); i++)
#define FOE(i,s,e) for(int i = (s); i <= (e); i++)
#define FOD(i,s,e) for(int i = (s); i >= (e); i--)
#define ll long long
#define pb push_back
#define mp make_pair

int n, m, x, y, z, k, w;

int main ()
{
	scanf("%d %d", &x, &y);
	if (x * y % 2 == 0) printf("Even\n");
	else printf("Odd\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
int main() {
    int n,m;
    cin>>n>>m;
    int a[m],total=0;
    rep(i,m){
        cin>>a[i];
        total+=a[i];
    }
    if(total>n) cout<<"-1"<<endl;
    else cout<<n-total<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

const pid_t pid = getpid();
// Problem Specific Parameter:

int main(void){
	int n;
	cin >> n;
	
	if(__builtin_popcount(n) == 1){
		puts("No");
		return 0;
	}

	puts("Yes");

	int m = 1;
	while(2 * m + 1 <= n) m = 2 * m + 1;

	rep(i, m - 1) cout << i + 1 << " " << i + 2 << endl;
	cout << m << " " << n + 1 << endl;
	rep(i, m - 1) cout << n + i + 1 << " " << n + i + 2 << endl;
	
	if(m < n){
		m++;
		cout << 1 << " " << m << endl;
		cout << m << " " << m + 1 << endl;
		cout << n + 1 << " " << n + m + 1 << endl;
		cout << n + m + 1 << " " << n + m << endl;
	}

	int mode = 0, val = 2;
	rep(i, m + 2, n + 1){
		if (mode == 0) {
			cout << i << " " << n + m + 1 << endl;
			cout << n + val << " " << n + i << endl;	
		}

		if (mode == 1) {
			cout << i << " " << m << endl;
			cout << val << " " << n + i << endl;	
			val += 2;
		}

		if (mode == 2) {
			cout << i << " " << m << endl;
			cout << val << " " << n + i << endl;	
		}

		if (mode == 3) {
			cout << i << " " << n + m + 1 << endl;
			cout << n + val << " " << n + i << endl;	
			val += 2;
		}

		mode = (mode + 1) % 4;
	}

	return 0;
}

Measured memory_bytes: 2816
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.NoSuchElementException;

	
public class Main{
	
	public static void main(String[] args) {
		new Main().run();
	}
	
	final long MOD=998244353;

	long pow(long a,long n) {
		return n!=0?pow(a*a%MOD,n/2)*(n%2==1?a:1)%MOD:1;
	}
	
	long inv(long a) {
		return pow(a,MOD-2);
	}
	

	void run() {
		FastScanner sc=new FastScanner();
		int N=sc.nextInt();
		int S=sc.nextInt();
		int[] A=new int[N];
		for (int i=0;i<N;++i) A[i]=sc.nextInt();	
		long[] dp=new long[S+1];
		dp[0]=1;
		long i2=inv(2);
		for (int i=0;i<N;++i) {
			for (int j=S;j>=0;--j) {
				int nj=j+A[i];
				if (nj>S) continue;
				dp[nj]=(dp[nj]+dp[j]*i2%MOD)%MOD;
			}
		}
		System.out.println(dp[S]*pow(2,N)%MOD);
	}
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 32680
#include <cassert>
#include <functional>
#include <iostream>
#include <vector>
#include <map>

int main(int argc, char const* argv[])
{
    int n, m;
    std::cin >> n;
    std::map<std::string, int> map;

    auto blues = std::vector<std::string>(n);
    for(auto &blue: blues)
    {
        std::cin >> blue;
        auto count = map.count(blue);
        if(count == 0)
        {
            map[blue] = 1;
        }
        else
        {
            map[blue]++;
        }
    }

    std::cin >> m;
    auto reds = std::vector<std::string>(m);
    for(auto &red: reds)
    {
        std::cin >> red;
        auto count = map.count(red);
        if(count == 0)
        {
            map[red] = 0;
        }
        else
        {
            map[red]--;
        }
    }

    int result = 0;
    for(auto& mm: map)
    {
        result = std::max(result, mm.second);
    }
    std::cout << result << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <bitset>
//#include <math.h>
using namespace std ;
//using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	string s ; cin >> s ;
	bool ok = false ;
	for(int i=1;i<s.size();i++) if(s.at(i-1)=='A'&&s.at(i)=='C') ok = true ;
	cout << yorn(ok) << endl ;
}


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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

		var inputArray = retreiveLongArray();
			var inputCount = 3;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			long M = inputArray[1];
			long K = inputArray[2];


			//黒の数  f(n,m)=n*M +m*N -2mn

			var answers = new List<long>();
			for (int n = 0; n <= N; n++) {
				for (int m = 0; m <= M; m++) {
					answers.Add(n * M + m * N - 2 * m * n);
				}
			}

			if (answers.Contains(K)) {
				Console.WriteLine("Yes");
			}
			else {
				Console.WriteLine("No");
			}


		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 29280
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!int).array;
    auto X = A.map!(a => log2(a)).array;

    auto plus = new long[](N);  // +の項の先頭インデックスがiであるときの+側の最小操作回数
    auto minus = new long[](N); // -の項の末尾インデックスがiであるときの-側の最小操作回数
    minus[0] = 1;

    auto queue = new DList!(Tuple!(real, real, int, int));
    queue.insertBack(tuple(X[0], X[0], 0, 0));

    foreach (i; 1..N) {
        minus[i] = minus[i-1] + 1;
        auto t = tuple(X[i], X[i], i, i);
        while (!queue.empty && t[0] > queue.back[1]) {
            long diff = ceil(t[0] - queue.back[1]).to!long;
            if (diff % 2 == 1) diff += 1;
            minus[i] += diff * (queue.back[3] - queue.back[2] + 1);
            queue.back[0] += diff;
            queue.back[1] = t[1];
            queue.back[3] = t[3];
            t = queue.back;
            queue.removeBack;
        }
        queue.insertBack(t);
    }

    queue = new DList!(Tuple!(real, real, int, int));
    queue.insertFront(tuple(X[N-1], X[N-1], N-1, N-1));

    foreach_reverse (i; 0..N-1) {
        plus[i] = plus[i+1];
        auto t = tuple(X[i], X[i], i, i);
        while (!queue.empty && t[1] > queue.front[0]) {
            long diff = ceil(t[1] - queue.front[0]).to!long;
            if (diff % 2 == 1) diff += 1;
            plus[i] += diff * (queue.front[3] - queue.front[2] + 1);
            queue.front[0] = t[0];
            queue.front[1] += diff;
            queue.front[2] = t[2];
            t = queue.front;
            queue.removeFront;
        }
        queue.insertFront(t);
    }


    long ans = 1L << 59;

    foreach (i; 0..N+1) {
        if (i == 0) {
            ans = min(ans, plus[0]);
        } else if (i == N) {
            ans = min(ans, minus[N-1]);
        } else {
            ans = min(ans, minus[i-1] + plus[i]);
        }
    }

    ans.writeln;
}

Measured memory_bytes: 36720
import numpy as np
N = int(input())
a=0
list1 = np.array([0] * N)
list2 = np.array([0] * N)
ans = np.array([[0] * 10 for i in range(10)])
for i in range(N):
    s=str(i+1)
    list1[i]=int(s[-len(s)])
    list2[i]=(i+1)%10

for i in range(N):
    ans[list1[i]][list2[i]]+=1

for i in range(10):
    for j in range(10):
        a+=ans[i][j]*ans[j][i]

print(a)

Measured memory_bytes: 17120
text = list(input())
num = int(input())

for i in range(num):
    orderList = list(input().split(" "))
    start, end = int(orderList[1]), int(orderList[2])
    loopCount = end - start + 1
    
    if orderList[0] == 'replace':
        replaceText = list(orderList[3])
        for i in range(loopCount):
            text[i + start] = replaceText[i]
            
    elif orderList[0] == 'reverse':
        tmpList = []
        for i in range(loopCount):
            tmpList.append(text[i + start])
        for i in range(loopCount):
            text[i + start] = tmpList[loopCount - i - 1]
            
    else:
        answer = []
        for i in range(loopCount):
            answer += text[i + start]
        answer = "".join(answer)
        print(f"{answer}")
            
        
        
        
        


Measured memory_bytes: 5636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String reg = "(hi)*";
		if(s.matches(reg)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
	}

}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define int long 
#define double long double
#define pb push_back
#define mp make_pair
 #define mod 1000000007
 const int N=100005;
 const int inf=1e18;
int pow(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int ans=0;
	int n;
	cin>>n;
	for(int x=1;x<=n;x++){
		if((1+int(log10(x)))%2==1){
			ans++;
		}
	}
	cout<<ans;
	
	








	
return 0;
}


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

int main(){
  int N, M;
  cin >> N >> M;
  
  vector<int> A(N);
  
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  sort(A.begin(), A.end());
  
  vector<pair<int, int>> BC(M);
  
  for (int i = 0; i < M; i++) {
    cin >> BC.at(i).second >> BC.at(i).first;
  }
  
  sort(BC.begin(), BC.end());

  int count = 0, B, C;

  for (int i = M - 1; i >= 0; i--) {
    B = BC.at(i).second;
    C = BC.at(i).first;

    if (count >= N || A.at(count) >= C){
      break;
    }
    
    for (int j = 0; j < B; j++) {
      if (count < N && A.at(count) < C) {
        A.at(count) = C;
        count += 1;
      }
    }
  }
  
  long long output = 0;
  
  for (int i = 0; i < N; i++) {
    output += A.at(i);
  }
  
  cout << output << endl;
  
  return 0;
}

Measured memory_bytes: 1408
#pragma GCC optimize "O3"
#include<bits/stdc++.h>

using namespace std;

constexpr int N = 1e5 + 1;

int w, h, k, n, dp[N];
vector<bool> dogs[N];

int main() {
  scanf("%d %d %d %d", &w, &h, &k, &n); --h, --w;
  if(k < (w+2)/2) {
    puts("-1");
    return 0;
  }
  k -= (w+2) / 2;
  for(int i = 0; i <= h; ++i)
    dogs[i].resize(w+1);
  for(int i = 0; i < n; ++i) {
    int x, y; scanf("%d %d", &x, &y); --x, --y;
    dogs[y][x] = true;
  }
  int ans = 0, bad = 0;
  for(int i = 2; i <= h; i += 2) {
    fill(dp, dp+w+1, 0);
    dp[0] = dogs[i-1][0] + 1;
    if(w >= 2)
      dp[2] = min(dp[0] + dogs[i-1][2] + 1, (dogs[i-1][1] + 1) * 2);
    for(int j = 4; j <= w; j += 2)
      dp[j] = min(dp[j-2] + dogs[i-1][j] + 1,
                  dp[j-4] + (dogs[i-1][j-1] + 1) * 2);
    bad += (dp[w] - (w+2) / 2);
    ans += dp[w];
  }
  printf("%d\n", max(0, ans - k - min(k, bad)));
}

Measured memory_bytes: 19340
s = str (input())
bflag = True
lflag = True
if not(s[0] + s[1] in ['01','02','03','04','05','06','07','08','09','10','11','12']):
    bflag = False
if not(s[2] + s[3] in ['01','02','03','04','05','06','07','08','09','10','11','12']):
    lflag = False
if bflag:
    if lflag:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if lflag:
        print('YYMM')
    else:
        print('NA')




Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		int N = in.nextInt();
		int T = in.nextInt();
		int A = in.nextInt();
		
		int ans = 0;
		double min = 100000;
		
		for(int i=1; i<=N; i++) {
			double sub = Math.abs(A -  (T - in.nextInt() * 0.006));
			if(sub < min) {
				min = sub;
				ans = i;
			}
		}
		
	
		System.out.println(ans);
		
		in.close();
	}
}


Measured memory_bytes: 23380
#include <stdio.h>

void merge_sort(long long x[], int n)
{
	static long long y[100001] = {};
	if (n == 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p] < x[q])? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, N;
	long long A[100001], B[100001];
	scanf("%d", &N);
	for (i = 0; i < N; i++) scanf("%lld %lld", &(A[i]), &(B[i]));
	
	long long C[100001], ans = 0;
	for (i = 0; i < N; i++) {
		C[i] = A[i] + B[i];
		ans += A[i] - B[i];
	}
	merge_sort(C, N);
	for (i = 0; i < N / 2; i++) {
		ans += C[N-i*2-1] - C[N-i*2-2];
	}
	if (N % 2 == 1) ans += C[0];
	
	printf("%lld\n", ans / 2);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 3328
using System;

class Greatest_Common_Divisor
{
  public static void Main()
  {
    string str_num = Console.ReadLine();
    string[] sp_num = str_num.Split();
    int x = int.Parse(sp_num[0]);
    int y = int.Parse(sp_num[1]);
    int q = x%y;
    
    while(q!=0)
    {
      x = y; 
      y = q;
      q = x%y;
    }
    
    Console.WriteLine(y);
  }
}

Measured memory_bytes: 9116
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>

using namespace std;

const int maxn = 100010;

typedef long long ll;

ll Ans = 1e18;

int n, X;
ll b[maxn], l[maxn], u[maxn], in[maxn];
ll sum[maxn], val[maxn];

bool cmp(int x, int y) {
	return val[x] > val[y];
}

int main() {
	scanf("%d%d", &n, &X);
	for (int i = 1; i <= n; i++) scanf("%lld%lld%lld", &b[i], &l[i], &u[i]);
	for (int i = 1; i <= n; i++) {
		in[i] = i;
		val[i] = 1LL*(X-b[i])*u[i]+1LL*l[i]*b[i];
	}
	sort(in+1, in+n+1, cmp);
	ll s = 0;
	for (int i = 1; i <= n; i++) s += -1LL*b[i]*l[i];
	for (int i = 1; i <= n; i++) sum[i] = sum[i-1] + val[in[i]];
	if (s >= 0) {
		puts("0");
		return 0;
	}
	for (int t = 1; t <= n; t++) {
		int i = in[t];
		ll cs = s - min(-X*l[i], -X*u[i]+b[i]*u[i]-b[i]*l[i]);
		int L = 0, R = n, ans = -1;
		while (L <= R) {
			int mid = (L + R) >> 1;
			ll v = sum[mid];
			if (mid >= t) v -= val[i];
			if (v+cs >= 0) {
				ans = mid;
				R = mid-1;
			} else L = mid+1;
		}
		ll cnt = ans;
		if (cnt >= t) -- cnt;
		ll v = sum[ans];
		if (ans >= t) v -= val[i];
		if (v+s >= 0) {
			Ans = min(Ans, 1ll*X*cnt);
			continue;
		}
		//v+s + x*l[i] >= 0
		//x >= -v-s/l[i]
		if ((-v-s+l[i]-1)/l[i] <= X) {
			Ans = min(Ans, 1ll*X*cnt+1ll*(-v-s+l[i]-1)/l[i]);
		}
		//v+s + x*u[i] + b[i]*l[i] - u[i]*l[i] >= 0
		ll tmp = -v-s-b[i]*l[i]+u[i]*b[i];
		if ((tmp+u[i]-1)/u[i] <= X) {
			Ans = min(Ans, 1ll*X*cnt+1ll*(tmp+u[i]-1)/u[i]);
		}
	}
	printf("%lld\n", Ans);
	return 0;
}

Measured memory_bytes: 4992
import collections

N = int(input())
A = list(map(int, input().split()))

prev = collections.defaultdict(list)

ans = 0
for i, h in enumerate(A):
    #i - i_prev = h + h_prev
    #i = h + h_prev + i_prev

    comp = i - h

    if comp in prev:
        ans += len(prev[comp])
    prev[i + h].append(0)

print(ans)


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

int main()
{
	int N;
	cin >> N;
	vector<ll> cnt(5);
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		if (s[0] == 'M') {
			cnt[0]++;
		}
		if (s[0] == 'A') {
			cnt[1]++;
		}
		if (s[0] == 'R') {
			cnt[2]++;
		}
		if (s[0] == 'C') {
			cnt[3]++;
		}
		if (s[0] == 'H') {
			cnt[4]++;
		}
	}
	ll res = 0;
	for (int i = 0; i < 5; i++) {
		for (int j = i + 1; j < 5; j++) {
			for (int k = j + 1; k < 5; k++) {
				res += cnt[i] * cnt[j] * cnt[k];
			}
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int s;
    scanf("%d",&s);
    
    int t = s / 3600;
    int m = (s - t * 3600) / 60;
    int se = s % 60;
    
    printf("%d:%d:%d\n",t,m,se);
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  
  int y, m, d;
  
  y = (s[0] - '0') * 1000 + (s[1] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');
  m = (s[5] - '0') * 10 + (s[6] - '0');
  d = (s[8] - '0') * 10 + (s[9] - '0');
  
  int h = 0;
  
  if(y < 2019){
    h = 1;
  }else if( y == 2019 && m < 5){
    h = 1;
  }
  
  if( h == 1){
    cout << "Heisei" << endl;
  }else{
    cout << "TBD" << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#define neko 100010
#define qwq return printf("YES"),0
#define orz return printf("NO"),0
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~i))
int n;
typedef long long ll;
ll A,B,C,D,now;
ll swap(ll &x,ll &y){ll t=x;x=y,y=t;}
int main()
{
	scanf("%d%lld%lld%lld%lld",&n,&A,&B,&C,&D);
	if(A>B)swap(A,B);now=B-A;
	f(i,1,n-1)if(now>=(C*i-D*(n-1-i))&&now<=(D*i-C*(n-1-i)))qwq;
	orz;
}

Measured memory_bytes: 128
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10**9+7
cnt = 0
cnt2 = 0
for i in range(n):
  for j in range(n):
    if i < j and a[i] > a[j]:
      cnt += 1
    if a[i] > a[j]:
      cnt2 += 1
ans = (cnt*k + (k*(k-1)//2)*cnt2)%mod
print (ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define debug(x) cout<<x
#define pb push_back
#include<string.h>
int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);                    
    cout.tie(NULL);
    ll T=1;
    //cin>>T;
    while(T--){
    	ll n,cnt=0;
    	cin>>n;
    	ll arr[n+1];
    	for(int i=0;i<=n;i++) arr[i]=0;
    	for(int x=1;x*x<=n;x++){
    		for(int y=1;y*y<=n;y++){
    			for(int z=1;z*z<=n;z++){
    				if((x*x+y*y+z*z+x*y+y*z+z*x)<=n)arr[(x*x+y*y+z*z+x*y+y*z+z*x)]++;
    			}
    		}
    	}
    	for(int i=1;i<=n;i++) cout<<arr[i]<<endl;
    }
   	return 0; 
}

Measured memory_bytes: 3596
n, q = map(int, input().split())
values = [0] * (n + 1)
parents = [0] * (n + 1)
results = [0] * (n + 1)
for i in range(n - 1):
  a, b = map(int, input().split())
  parents[b] = a
for _ in range(q):
  p, x = map(int, input().split())
  values[p] += x
for i in range(1, n + 1):
  results[i] = values[i]
  if parents[i] != 0:
    results[i] += results[parents[i]]
print(*[results[i] for i in range(1, n + 1)])


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

int main(){

  int N;

  cin>>N;

  int v[21],c[21];

  for(int i=0;i<N;i++){
	cin>>v[i];
  }

  long long ans=0;

  for(int i=0;i<N;i++){
	cin>>c[i];
	if(v[i]-c[i]>=0){
	  ans+=v[i]-c[i];
	}
  }

  cout<<ans<<endl;

  return 0;
}


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

int main()
{
  int n;
  cin >> n;
  int hap[n][3];
  for (int i = 0; i < n; i++)
  {
    cin >> hap[i][0] >> hap[i][1] >> hap[i][2];
  }
  int dp[n][3];
  dp[0][0] = hap[0][0];
  dp[0][1] = hap[0][1];
  dp[0][2] = hap[0][2];
  for (int i = 1; i < n; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      vector<int> x;
      for (int k = 0; k < 3; k++)
      {
        if (k != j)
          x.push_back(k);
      }
      dp[i][j] = max(dp[i - 1][x[0]], dp[i - 1][x[1]]) + hap[i][j];
    }
  }

  cout << max(max(dp[n - 1][0], dp[n - 1][1]), dp[n - 1][2]) << endl;
}


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

int main() {
	vector<string> vec;
	vec = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
	
	string s;
	cin >> s;
	
	for (int i = 0; i < vec.size(); i++) {
		if (s == vec.at(i)) {
			cout << 7 - i << endl;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
	ll h,w,a,b;
	cin>>h>>w>>a>>b;
    // 前処理
    COMinit();
	h--,w--,a--,b--;
	ll ans=0;
	for(int i=b+1;i<=w;i++){
		//cout << i<<endl;
		ans+=COM(h-a-1+i,i)*COM(a+w-i,w-i);
		ans%=inf;
	}
	cout << ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 12160
namespace Coder {
  class Scanner {
    private buffer: string = '';
    private stdinQueue: any = [];

    constructor() {
      process.stdin.resume();
      process.stdin.setEncoding('utf8');
      process.stdin.on(
        'data',
        (chunk): void => {
          this.buffer += chunk;
          while (this.stdinQueue.length > 0) {
            const i = this.buffer.indexOf('\n');
            if (i < 0) {
              break;
            }
            let line = this.buffer.substr(0, i);
            if (line.endsWith('\r')) {
              line = line.slice(0, -1);
            }
            this.buffer = this.buffer.substr(i + 1);
            this.stdinQueue.shift()(line);
          }
        },
      );
    }
    public getLine(): Promise<string> {
      return new Promise((resolve, reject) => {
        const i = this.buffer.indexOf('\n');
        if (i >= 0 && this.stdinQueue.length === 0) {
          let line = this.buffer.substr(0, i);
          if (line.endsWith('\r')) {
            line = line.slice(0, -1);
          }
          this.buffer = this.buffer.substr(i + 1);
          resolve(line);
        } else {
          this.stdinQueue.push(resolve);
        }
      });
    }

    public close(): void {
      process.stdin.pause();
    }
  }

  async function slove() {
    const sc = new Scanner();
    const M = +(await sc.getLine());
    console.log(48 - M);
    sc.close();
  }

  slove();
}


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

// #include "../cxx-prettyprint/prettyprint.hpp" // vecの内容をきれいに表示

using namespace std;
typedef long long ll;

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

#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define INF ((1LL<<62)-(1LL<<31)) /*オーバーフローしない程度に大きい数*/
#define MOD 1000000007

int main(){
// ここに処理を記述

	// 入力受け取り
	int N, W;
	cin >> N >> W;

	vector< vector<int> > val;
	int temp1, temp2;
	val.push_back({0, 0}); // 1-indexed
	for(int i=0; i<N; i++){
		cin >> temp1 >> temp2;
		val.push_back({temp1, temp2}); // val[i][0] = w[i] val[i][1] = v[i]
	}

	// dpテーブル : minをとるので初期値はINF
	// dpを回す順番は下からなのでdp[0][0]のみ0
	vector< vector<ll> > dp(N+1, vector<ll>(100001, INF));
	dp[0][0] = 0;
	FOR(i,1,N+1){
		REP(j,100001){
			if(j - val[i][1] >= 0){
				dp[i][j] = min(dp[i-1][j],dp[i-1][j-val[i][1]] + val[i][0]);
			}
			else{
				dp[i][j] = dp[i-1][j];
			}
		}
	}

	// cout << dp << "\n";

	// 答えはdp[N][j]がW以下となる最大のj
	int ans = 100000;
	while(dp[N][ans] > W)ans--;

	cout << ans << "\n";

return 0;
}

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

int main(){
	string s,t;
	cin >> s >> t;
	
	int cnt = 0;
	
	rep(i,3){
		if(s[i] == t[i]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi v(n), c(n);
    int ans = 0;
    rep(i, n) cin >> v[i];
    rep(i, n) cin >> c[i];
    rep(i, n) {
        if (v[i] > c[i]) ans += v[i] - c[i];
    }
    cout << ans << endl;
}

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

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

#define REPR(i,n) for(int i =n; i >=0; --i)

#define _REP(i,m,n) for(int i =m; i <n; ++i)

#define INF 2e9

using namespace std;

int main(){
   int a,b;
   cin >> a >> b;

   bool f = false;

   if(a > 9)f = true;
   if(b > 9)f = true;

   if(f)cout << "-1" << endl;
   else cout << a*b << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int i,j,k,N;
    char s[4];
    int YYMM=1,MMYY=1;

    scanf("%s",s);

    if(s[2]>'0' && s[3]>'2') YYMM = 0;
    if(s[2]=='0' && s[3]=='0') YYMM = 0;
    if(s[0]>'0' && s[1]>'2') MMYY = 0;
    if(s[0]=='0' && s[1]=='0') MMYY = 0;

    if(YYMM==1 && MMYY==1) printf("AMBIGUOUS\n");
    else if(YYMM==1 && MMYY==0) printf("YYMM\n");
    else if(YYMM==0 && MMYY==1) printf("MMYY\n");
    else if(YYMM==0 && MMYY==0) printf("NA\n");
    
    return 0;
}

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

int N,M;

bool d[100001];
int v[100001];
vector<pair<int,int>>e[100001];

void dfs(int i,int x){
	d[i]=true;
	v[i]=x;
	for(auto a:e[i]){
		if(d[a.first]){
			if(v[i]+a.second!=v[a.first]){
				cout<<"No";
				exit(0);
			}
		}else{
			dfs(a.first,v[i]+a.second);
		}
	}
}

main(){
	cin>>N>>M;
	for(int i=0;i<M;++i){
		int L,R,D;
		cin>>L>>R>>D;
		e[L].push_back({R,D});
		e[R].push_back({L,-D});
	}
	for(int i=1;i<=N;++i){
		if(!d[i]){
			dfs(i,0);
		}
	}
	cout<<"Yes";
}


Measured memory_bytes: 11136
imos = [[0 for j in range(501)]for i in range(501)]
query = []
N,M,Q = map(int,input().split())
for i in range(M):
    L,R = map(int,input().split())
    imos[L][R] += 1
for i in range(Q):
    p,qq = map(int,input().split())
    query.append([p,qq])
for i in range(501):
    for j in range(1,501):
        imos[i][j] += imos[i][j-1]
for i in range(501):
    for j in range(1,501):
        imos[i][j] += imos[i-1][j]
for q in query:
    print(imos[N][q[1]]-imos[q[0]-1][q[1]])


Measured memory_bytes: 27156
#![allow(non_snake_case)]                                                   
use std::cmp::Ordering;   
use std::io::{stdin, BufRead, BufReader};
use std::f64;


fn main(){
    let input = BufReader::new(stdin());
    let mut V:Vec<i32> = Vec::new();
    for line in input.lines() {
        let values: Vec<i32> = line.unwrap()
            .split_whitespace()
            .filter_map(|x| x.parse::<i32>().ok())
            .collect();
        if values[0]==0{
            if let Some(top)=V.pop(){
                println!("{:?}",top);
            }
        }
        else{
            V.push(values[0]);
        }
    }
    
}
    

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
 
pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(
    String,
    bool,
    f32,
    f64,
    isize,
    i8,
    i16,
    i32,
    i64,
    usize,
    u8,
    u16,
    u32,
    u64
);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);



Measured memory_bytes: 5032
#include <chrono>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

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

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
    #else
//        freopen("capitals.in", "r", stdin);
//        freopen("capitals.out", "w", stdout);
    #endif
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(all(a));
//    a.resize(unique(all(a)) - a.begin());
    n = a.size();
    int kek = a[0];
    bool one = 0;
    for (int i = 0; i < n; i++) {
        kek = (kek * a[i]) / gcd(kek, a[i]);
        if (kek > m) {
            one = 1;
            break;
        }
    }
    int val = -1;
    for (int i = (a[n - 1] >> 1); i <= m; i += a[n - 1]) {
        bool ok = 1;
        for (int j = 0; j < n - 1; j++) {
            if ((i - (a[j] >> 1)) % a[j]) {
                ok = 0;
                break;
            }
        }
        if (ok) {
            val = i;
            break;
        }
    }
    if (one) {
        if (val != -1) cout << 1;
        else cout << 0;
        return 0;
    }
    if (val == -1) {
        cout << 0;
        return 0;
    }
    cout << (m - val) / kek + 1;
}
/*

*/


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

using namespace std;
#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

int main ()
{
  char a;

  cin >> a;

  if (a >= 'a' && a<='z')
    cout << "a" << endl;
  else
    cout << "A" << endl;
  return 0; 
}

Measured memory_bytes: 3592
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef long double LD;
typedef vector<LD> vld;
typedef vector<pair<LD, LD>> vpld;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
typedef pair<ll, PL> TL;
typedef vector<TL> vtl;
typedef vector<vtl> vvtl;
typedef long double ld;
typedef vector<ld> vld;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T> T gcd(T a, T b) {return (a == 0) ? b : gcd(b%a, a);}
template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b;}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec /* copy */){
    sort(ALL(vec)); vec.erase(unique(vec.begin(), vec.end()), vec.end()); return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const tpl& lhs, const tpl& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}

bool bit(ll st, ll b){return ((st>>b)&1) == 1;}


int main(){
#ifdef __DEBUG_LOCAL__
    ifstream file("../../../../../in.txt"); if(file.is_open()) cin.rdbuf(file.rdbuf());
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    
    ll A, B; cin >> A >> B;
    
    rep(i, 200000){
        ll at = i*108/100 - i;
        ll bt = i*110/100 - i;
        if(at == A && bt == B){
            cout << i << endstr; return 0;
        }
    }
    cout << -1 << endstr;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main(){
 string a[3];
  for(int i=0;i<3;i++) cin >> a[i];
  
  
  int cnt[3]={0},ptr=0;
  
  while(1){
    cnt[ptr]++;
    if(cnt[ptr]==a[ptr].length()+1) break;
    ptr=int(a[ptr].at(cnt[ptr]-1)-'a');
  }
  
  cout << char(ptr+'A') << endl;
 
}

Measured memory_bytes: 256