akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{
	double zahyou[8];
	int n;
	double narrowAB;
	double narrowCD;
	int i;
	
	scanf("%d", &n);
	
	while (n-- != 0){
		for (i = 0; i < 8; i++){
			scanf("%lf", &zahyou[i]);
		}
		
		if (zahyou[0] == zahyou[2] || zahyou[4] == zahyou[6]){     // Ç¿ç©Ì¼üªy²É½sÈÆ«
			if (zahyou[0] == zahyou[2] && zahyou[4] == zahyou[6]){ // Ç¿çÌ¼üày²É½sÈÆ«
				printf("YES\n");
			}
			
			else {
				printf("NO\n");
			}
		}
		
		
		else {
			narrowAB = (zahyou[3] - zahyou[1])/(zahyou[2] - zahyou[0]);  //ôÌY¨xÀW 0ZªN«È¢æ¤ÉµÄ¢é.
			narrowCD = (zahyou[7] - zahyou[5])/(zahyou[6] - zahyou[4]);
			
			if (narrowAB == narrowCD){
				printf("YES\n");
			}
			
			else {
			printf("NO\n");
			}
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <iostream>
 
using namespace std;
 
int main(void) {
  int NUM;
  cin>>NUM;
  int flag=0;
  int final_flag=0;
  
  for (int i=0; i<NUM; i++){
    int ia;
    cin>>ia;
    
    if (ia % 2 ==0){
      flag = 1;
      if( ia % 3 !=0 && ia % 5 != 0){
        final_flag=1;
      }
    } 
  }
 
  if(final_flag!=1){
    cout<<"APPROVED";
  }else{
    cout<<"DENIED";
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	int i,j;
	for(i=1;i<=9;i++){
		for(j=1;j<=9;j++){
			if(i*j==n){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    int flag = 0;
    int ans = 0;
    for(int i = 0; i < N; i++){
        int d1, d2;
        cin >> d1 >> d2;
        if(d1 == d2) flag++;
        else flag = 0;
        if(flag == 3) ans = 1;
    }
    if(ans == 1) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3588
N = int(input())
T, A = map(int,input().split())
H = list(map(int,input().split()))

pointID = -1
min_diff = 9999999999

for i in range (N):
    #地点i の温度 と 平均気温の差(絶対値)
    diff = abs(T - H[i] * 0.006 - A)

    if diff < min_diff:
        pointID = i+1
        min_diff = diff

print(pointID)

Measured memory_bytes: 38384
N = int(input())
#A = list(reversed(sorted(list(map(int, input().split())))))
A = sorted(list(map(int, input().split())))
assert len(A) == N
mul = 1
for a in A:
  mul *= a
#  print(a, mul)
  if a == 0:
    print(0)
    break
  if mul > (10 ** 18):
    print(-1)
    break
else:
  print(mul)

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

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> cards(n);
  for (int i = 0; i < n; i++)
  {
    cin >> cards.at(i);
  }
  sort(cards.begin(), cards.end(), greater<int>());
  int pointAlice, pointBob = 0;
  for (int i = 0; i < n; i++)
  {
    if(i % 2 == 0)
    {
      pointAlice += cards.at(i);
    }
    else
    {
      pointBob += cards.at(i);
    }
  }
  cout << pointAlice - pointBob << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    var n = readLine()!!.toInt()
    var s = readLine()!!.toString()
    var c = mutableMapOf<Char, Int>('R' to 0, 'G' to 0, 'B' to 0)
    var num: Int
    for (i in s) {
        c[i]!!.let{c[i] = it + 1}
    }
    var diff = 0
    var ans = 1L
    for (d in 1..((n-1)/2)){
        for (i in 0..(n-d-d-1)) {
            if (s[i] != s[i+d] && s[i+d] != s[i+d+d] && s[i+d+d] != s[i]) {
                diff += 1
            }
        }
    }
    for ((x, y) in c){ans *= y}
    println(ans-diff)
}


Measured memory_bytes: 36764
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//#include <ext/pb_ds/detail/standard_policies.hpp>
#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>
#include <fstream>


#define f first
#define s second
#define pb push_back
#define lp(i,a,n) for(int (i)=(a);(i)<=(int)(n);(i)++)
#define lpd(i,n,a) for(int (i)=(n);(i)>=(a);--(i))
#define mp make_pair
#define clr(a, b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define eps 1e-8
#define infi 2000000007
#define infll 1e15
#define MX 1000000
#define X real()
#define Y imag()
#define polar(r,t) ((r)* exp(point(0,(t))))
#define length(a) hypot( (a).X , (a).Y )
#define angle(a) atan2( (a).Y , (a).X )
#define vec(a,b) ( (b) - (a) )
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define lengthsqr(a) dot(a,a)
#define reflect(V,M) (conj((V)/(M)) * (M))
//#define rotate(a, theta) (a) * (polar(1.0, (theta) ))
#define normalize(a)   ((a)/length(a))
#define ccw(a,b,c) cross(vec(a,b) , vec(a,c)) > eps
#define cosRule(a,b,c) (acos(((a)*(a)+(b)*(b)-(c)*(c))/(2*(a)*(b))))
#define cosDot(a,b) (acos(dot(a,b)/length(a)/length(b)))
#define EQ(a,b) (fabs((a) - (b)) <= eps) /* equal to */
#define NE(a,b) (fabs((a) - (b)) > eps)  /* not equal to */
#define LT(a,b) ((a) < (b) - eps)        /* less than */
#define GT(a,b) ((a) > (b) + eps)        /* greater than */
#define LE(a,b) ((a) <= (b) + eps)       /* less than or equal to */
#define GE(a,b) ((a) >= (b) - eps)       /* greater than or equal to */
#define mod1 100050001
#define mod2 100030001
#define base1 37
#define base2 31
#define PI acos(-1)
#define sz(a) (int) (a).size()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef complex<long double> point;
typedef pair<point, point> line;
typedef pair<double , point> Circle;
typedef long double ld;

const int N = 100002;

int n,k,a[N];


int main(){
    scanf("%d%d",&n,&k);
    lp(i, 1, n) scanf("%d",&a[i]);
    
    printf("%d\n", (int)ceil((n-1)/(k-1.0)));
   
}

/*
 */



Measured memory_bytes: 640
import sys
n, k, q = [int(i) for i in sys.stdin.readline().split()]
score_dict ={i:0 for i in range(n)}
for i in range(q):
    a = int(sys.stdin.readline())
    score_dict[a-1] += 1
for i in range(n):
    if k + score_dict[i] - q > 0:
        print("Yes")
    else:
        print("No")

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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

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

    string s;
    cin>>s;
    cout<<string(s.size(),'x');
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,rem,val,cnt=0;
    cin>>n;
    while(n!=0)
    {
        rem=(n%10);
        if(rem==7)
        {
            cnt++;
            break;
        }
        n=n/10;
    }
    if(cnt==0)
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3592
parseInt(x) = parse(Int, x)
parseArray(x::Array{SubString{String}, 1}) = map(parseInt, x)

function main()
  N,M = readline() |> split |> parseArray
  L,R=zeros(Int,M),zeros(Int,M)
  for i in 1:M
    L[i],R[i] = readline() |> split |> parseArray
  end

  result=minimum(R)- maximum(L)
  if result>=0
    result+=1
  else
    result=0
  end

  println(result)
end

main()


Measured memory_bytes: 169328
#include <stdio.h>
int main(void){
	int A, B, C;

	scanf("%d %d %d", &A, &B, &C);

	if((A==5 && B==5 && C==7)||
		(A==7 && B==5 && C==5)||
		(A==5 && B==7 && C==5)){
		
		printf("YES\n");
	}
	else
		printf("NO\n");
		

	return 0;
}

Measured memory_bytes: 128
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Thu Apr  5 19:20:40 2018
//
package main

import (
	"fmt"
)

var N, P int

func pow2(n int) int64 {
	ret := int64(1)
	for i := 0; i < n; i++ {
		ret *= 2
	}
	return ret
}

func main() {
	fmt.Scan(&N, &P)

	evens := 0
	odds := 0
	for i := 0; i < N; i++ {
		var A int
		fmt.Scan(&A)
		if A%2 == 0 {
			evens++
		} else {
			odds++
		}
	}

	if evens == N {
		if P == 0 {
			fmt.Println(pow2(N))
		} else {
			fmt.Println(0)
		}
	} else {
		fmt.Println(pow2(N - 1))
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  for(int i=0; i<N; i++){
    string s;
    cin >> s;
    if(s == "Y"){
      cout << "Four" << endl;
      break;
    } else if(i == N-1) {
      cout << "Three" << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
#define rep(i,n) for(int i=1;i<=(int) (n);i++)
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
using namespace std;
int main(){
  ll n,ans=0;
  cin>>n;
  rep(i,n){
    if(i%3!=0){
      if(i%5!=0)ans+=i;
    }
  }

  cout<<ans;
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
using namespace std;
 
#define MAX_W 100
#define MAX_H 100
char farm[MAX_W][MAX_H];
int W, H;
const int direction[4][2] = {
	{ -1, 0 },
	{ 1, 0 },
	{ 0, -1 },
	{ 0, 1 },
};
 
void dfs(const int& x, const int& y, const char tree)
{
	farm[x][y] = 'x';
	for (int i = 0; i < 4; ++i)
	{
		int nx = x + direction[i][0];
		int ny = y + direction[i][1];
		if (nx >= 0 && nx < W && ny >= 0 && ny < H && farm[nx][ny] == tree)
		{
			dfs(nx, ny, tree);
		}
	}
}
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
 
	while (cin >> H >> W, W > 0)
	{
		int res = 0;
		int x, y;
		for (y = 0; y < H; ++y)
		{
			for (x = 0; x < W; ++x)
			{
				cin >> farm[x][y];
			}
		}
 
		for (y = 0; y < H; ++y)
		{
			for (x = 0; x < W; ++x)
			{
				if (farm[x][y] != 'x')
				{
					dfs(x, y, farm[x][y]);
					++res;
				}
			}
		}
		cout << res << endl;
	}
 
	return 0;
}


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

int main() {
    int N, M, L, R, l, r;
    cin >> N >> M;
    L = 0;
    R = N;
    for (int i = 0; i < M; i++) {
        cin >> l >> r;
        if (L <= l){
            L = l;
        }
        if (R >= r){
            R = r;
        }
        if (L > R) {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << R - L + 1 << endl;
}

Measured memory_bytes: 256
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

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

    ll X, K, D;
    cin >> X >> K >> D;

    X = abs(X);

    ll Q = X / D;
    ll R = X % D;

    if (Q <= K)
    {
        if (Q % 2 == K % 2)
            cout << R << endl;
        else
        {
            ll RM = abs(R - D);
            ll RP = abs(R + D);
            cout << (RM < RP ? RM : RP) << endl;
        }
    }
    else
        cout << X - K * D << endl;

    return 0;
}


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

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << "Line " << __LINE__ << ": " <<  #x << " = " << (x) << "\n";
#define spa << " " <<
#define fi first
#define se second
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()

using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;

template<typename T> using V = vector<T>;
template<typename T> using P = pair<T, T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){os << "(" << v.first << ", " << v.second << ")"; return os;}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<vector<T>> &v){ for(auto &e : v){os << e << "\n";} return os;}
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

template <class T> void UNIQUE(vector<T> &x) {sort(ALL(x));x.erase(unique(ALL(x)), x.end());}
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 (a>b) { a=b; return 1; } return 0; }
void fail() { cout << -1 << '\n'; exit(0); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<"\n";}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<"\n";};

const ll INF = (1ll<<62);
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
const ll mod = (int)1e9 + 7;
//const ll mod = 998244353;

int main(){

    ll N, M;
    cin >> N >> M;
    V<ll> a(N), b(M);
    REP(i, N) cin >> a[i];
    REP(i, M) cin >> b[i];

    auto c = convolution(a, b);

    REP(i, N+M-1){
        cout << c[i] << " ";
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 27216
#include <stdio.h>

#define N 100000
#define Nill -1

struct Tree{int p,l,r;};
int n;
struct Tree T[N];
int D[N];
void getDepth(int u,int p){
	D[u] = p;
	if(T[u].r!= Nill) getDepth(T[u].r,p);
	if(T[u].l != Nill) getDepth(T[u].l,p+1);
}

void Print(int r){
	getDepth(r,0);
	int i;
	int g;
	for(i=0;i<n;i++){
		printf("node %d: parent = %d, depth = %d, ",i,T[i].p,D[i]);
		if(T[i].p == Nill) printf("root, ");
		else if(T[i].l != Nill) printf("internal node, ");
		else printf("leaf, ");
		if(T[i].l!= Nill){
			printf("[%d",T[i].l);
			g = T[i].l;
			while(1){
				if(T[g].r != Nill)printf(", %d",T[g].r);
				else {
					printf("]\n");
					break;
				}
				g = T[g].r;
			}
		}
		else printf("[]\n");
	}
}

int main(){
	scanf("%d",&n);
	int i,m,c,j;
	for(i=0;i<n;i++)T[i].p=T[i].l=T[i].r=Nill;
	int op,l;
	for(i=0;i<n;i++){
		scanf("%d%d",&m,&c);
		for(j=0;j<c;j++){
			scanf("%d",&op);
			if(j==0)T[m].l = op;
			else	T[l].r = op;
			l = op;
			T[op].p = m;
		}
	}
	for(i = 0;i < n; i++){
		if(T[i].p == Nill) break;
	}
	Print(i);

	return 0;
}

Measured memory_bytes: 7288
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

n,d,a=map(int,input().split())
xh=[list(map(int,input().split())) for i in range(n)]
xh.sort()
r,tama=[],[0]

for i in range(n):
    x,h=xh[i]
    tmpr=bisect.bisect_left(r,x)
    h-=(tama[-1]-tama[tmpr])*a
    tmp=0
    if h>0:
        tmp=math.ceil(h/a)
    tama.append(tmp)
    tama[i+1]+=tama[i]
    r.append(x+2*d)

print(tama[-1])
# print(r)

Measured memory_bytes: 122712
#include <iostream>

using namespace std;

int main(){
	int a, b, ans;
	char op;
	while(true){
		cin >> a >> op >> b;
		if(op == '?')
			break;
		if(op == '+'){
			ans = a + b;
		}else if(op == '-'){
			ans = a - b;
		}else if(op == '*'){
			ans = a * b;
		}else if(op == '/'){
			ans = a / b;
		}
		cin.clear();
		cin.ignore();
		cout << ans << endl;
	}
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll k; cin >> k;
    ll n = 50;
    ll q = k/50;
    ll r = k%50;
    vi a(n);
    rep(i, n) a[i] = i+q;
    rep(i, r) rep(j, n) (i == j) ? a[j] += n : a[j]--;
    cout << n << endl;
    for(ll i=0; i<a.size(); i++) cout << a[i] << (i==a.size()-1 ? endl : " ");
}

Measured memory_bytes: 3560
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h>
typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void Cll(){}
template <class Head,class... Tail>
void Cll(Head&& head,Tail&&... tail){
cin>>head;
Cll(move(tail)...);
}
#define CIN(...) ll __VA_ARGS__;Cll(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;Cll(__VA_ARGS__)

//#include <boost/multiprecision/cpp_ll.hpp>
//using namespace boost::multiprecision; // cpp_ll

#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
#define L list<ll>

#define pb(a) push_back(a)
#define mp make_pair


ll gcd(ll m,ll n){
  if(0==n)return m;
  return gcd(n,m%n);
}

ll lcm(ll m,ll n){
  ll g=gcd(m,n);
  return (m/g*n);
}

int main(){
  CIN(n); V t(n);VECCIN(t);
  if(n==1){COUT(t[0]);return 0;}
  ll ans=lcm(t[0],t[1]);
  FOR(i,2,n)ans=lcm(ans,t[i]);
  COUT(ans);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mn(a,b) (a < b ? a : b)
#define mx(a,b) (a > b ? a : b)
#define f first
#define s second
#define mp make_pair
#define all(v) (v).begin(),(v).end()

using namespace std;

char mat[51][51];
int n, m;

int funt(int i, int j){
    int con = 0;
    if(j + 1 <= m && mat[i][j + 1] == '#') con++;
    if(mat[i][j - 1] == '#' && j - 1 >= 0) con++;
    if(mat[i + 1][j - 1] == '#' && i + 1 <= n && j - 1 >= 0) con++;
    if(mat[i - 1][j - 1] == '#' && i - 1 >= 0 && j - 1 >= 0) con++;
    if(mat[i + 1][j + 1] == '#' && i + 1 <= n && j + 1 <= m) con++;
    if(mat[i - 1][j + 1] == '#' && i - 1 >= 0 && j + 1 <= m) con++;
    if(mat[i - 1][j] == '#' && i - 1 >= 0) con++;
    if(mat[i + 1][j] == '#' && i + 1 <= n) con++;
    return con;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++)
            cin>>mat[i][j];
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(mat[i][j] == '#')
                cout<<"#";
            else
                cout<<funt(i, j);
        }
        cout<<"\n";
    }
    return 0;
}


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

using namespace std;

string afunc(string str)
{
	string res = "NA";
	if(str[0] == '#'){
		return res;
	}
	
	for(int i = 0, j = str.size()-1; i <= j; i++, j--){
		if(i == j){
			if(str[i] == '#'){
				res = "A";
			}
		} else if(str[i] != '=' || str[j] != '='){
			break;
		}
	}
	
	return res;
}

string bfunc(string str)
{
	string res = "B";
	if(str.size() == 0){
		return "NA";
	}
	for(int i = 0; i < str.size(); i+=2){
		if(str[i] != 'Q' || str[i+1] != '='){
			res = "NA";
			break;
		}
	}
	
	return res;
}

int main()
{
	int n;
	string str, res;
	
	while(cin >> n && n){
		while(n--){
			cin >> str;
			res = "NA";
			if('>' == str[0]){
				str.erase(str.begin());
				int l = str.size();
				if(str[0] == '\'' && str[l-1] == '~'){
					str.erase(str.end()-1);
					str.erase(str.begin());
					if(str.size()%2 == 1){
						res = afunc(str);
					}
				} else if(str[0] == '^' && str[l-1] == str[l-2] && str[l-1] == '~'){
					str.erase(str.end()-1);
					str.erase(str.end()-1);
					str.erase(str.begin());
					
					if(str.size()%2 == 0){
						res = bfunc(str);
					}
				}
			}
			
			cout << res << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
int main(){
    int n,a[1000];
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;i++){
        printf("node %d: key = %d,",i,a[i]);
        if(i>1)printf(" parent key = %d,",a[i/2]);
        if(i*2<=n)printf(" left key = %d,",a[i*2]);
        if(i*2+1<=n)printf(" right key = %d,",a[i*2+1]);
        printf(" \n");
    }
}

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

int main(){

int n,l;cin>>n>>l;
if(l<0&&l+n-1<0){
 int t=0;
  for(int i=0;i<n-1;i++){
  t+=l+i;
  }
  cout<<t<<endl;
}
else if(l<0&&l+n-1>=0){
 int t=0;
  for(int i=0;i<n;i++){
  t+=l+i;
  }
  cout<<t<<endl;
}
  else {
 int t=0;
  for(int i=1;i<n;i++){
  t+=l+i;
  }
  cout<<t<<endl;
}

}

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

main(){
	
	int d,n ;
	int tool[110][3] ; // ?¢????????????????????¨?????????????????¨????
	int table[110][110] ; // HP(?????????????????°),level,?????°???????????????
	
	while( cin >> d >> n , d ){
		for( int i=0 ; i<n ; i++ )
			for( int j=0 ; j<3 ; j++ )
				cin >> tool[i][j] ;
		
		for( int i=0 ; i<110 ; i++ )
			for( int j=0 ; j<110 ; j++ )
				table[i][j] = 300 ;
		
		int ans = 300 ;
		table[0][0] = 0 ;
		for( int i=0 ; i<d ; i++ ){
			for( int j=0 ; j<=100 ; j++ ){
				if( table[i][j] != 300 ){
					for( int k=0 ; k<n ; k++ ){
						int tmp1 = i+tool[k][0] ;
						int tmp2 = j+tool[k][1] ;
						if( tmp1 > d ) tmp1 = d ;
						if( tmp2 > 100 ) tmp2 = 100 ;
						if( j >= tool[k][2] ){
							table[tmp1][tmp2] = min( table[tmp1][tmp2] , table[i][j]+1 ) ;
							//cout << tmp1 << " " << tmp2 << " " << table[tmp1][tmp2] << endl ;
						}
					}
				}
			}
		}
		
		for( int i=0 ; i<=100 ; i++ ) ans = min( ans , table[d][i] ) ;
		
		if( ans != 300 ) cout << ans << endl ;
		else cout << "NA" << endl ;
	}
	
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int r,d;
	int x;
	ll t=0;
	cin>>r>>d>>x;

	t=x;
	rep(i,10){
		t=r*t-d;
		cout<<t<<endl;
	}
	return 0;

}


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


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

    int N, M;
    cin >> N >> M;
    int Num[N];
    bool exist[N];
    for(int i=0; i<N; i++){
      Num[i] = 1;
    }
    memset(exist, false, sizeof(exist));
    exist[0] = true;
    for(int i=0; i<M; i++){
      int x, y;
      cin >> x >> y;
      x--; y--;
      if(exist[x]){
        if(Num[x] >= 2){
          exist[y] = true;
        }else{
          exist[x] = false;
          exist[y] = true;
        }
      }
      Num[x]--;
      Num[y]++;
    }
    int ans = 0;
    for(int i=0; i<N; i++){
      if(exist[i]) ans++;
    }
    cout << ans << endl;
}


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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF 1e9

int main() {
   int h, w;
   cin >> h >> w;

   vvi field(h, vi(w, 0));
   REP(y, h) REP(x, w) {
       char c;
       cin >> c;
       c -= '0';
       field[y][x] = c;
   }

   vvi dp(2, vi(w, INF));
   dp[0][0] = 0;
   REP(y, h) {
       dp[1][0] = dp[0][0] + field[y][0];
       FOR(x, 1, w) {
           dp[1][x] = min(dp[0][x] + field[y][x], dp[1][x-1] + field[y][x]);
       }
       dp[0] = dp[1];
   }
   cout << dp[0][w-1] << endl;
}

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

int main()
{
    double L, n;
    cin >> L;
    n = L / 3;
    printf("%.12f\n", n * n * n);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

class KnuthMorrisPratt{
	public:
		vector<int> fail;
		string t; // 探す文字列
		KnuthMorrisPratt(string& t) {
			this->t = t;
			int m = t.size();
			fail = vector<int>(m + 1);
			int j = fail[0] = -1;
			for (int i = 1; i <= m; ++i) {
				while (j >= 0 && t[j] != t[i - 1]) j = fail[j];
				fail[i] = ++j;
			}
		}
		vector<int> match(string& s){ // s に含まれる連続する部分文字列 t のインデックスを返す
			int n = s.size(), m = t.size();
			vector<int> res;
			for (int i = 0, k = 0; i < n; ++i) {
				while (k >= 0 && t[k] != s[i]) k = fail[k];
				if (++k >= m) {
					res.emplace_back(i - m + 1); // match at s[i-m+1 .. i]
					k = fail[k];
				}
			}
			return res;
		}
};

int main(){
	string s, t;
	cin >> s >> t;
	KnuthMorrisPratt kmp(t);
	for(auto i : kmp.match(s)){
		cout << i << endl;
	}
}



Measured memory_bytes: 8580
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}


ll modpow(ll a,ll b){
    ll ret = 1;
    while(b>0){
        if(b&1)ret = (ret*a)%MOD;
        a = (a*a)%MOD;
        b = b>>1;
    }
    return ret;

}


int main(){

ll n;
cin>>n;
if(n==1){
    cout<<0<<endl;
    return 0;
}



ll ten =modpow(10,n);
ten%=MOD;
ll nine = modpow(9,n);
    nine%=MOD;
ll eight = modpow(8,n);
    eight%=MOD;

ll k = ten-nine;
k%=MOD;
if(k<0)k+=MOD;

k*=2;
k%=MOD;

k+=eight;
k%=MOD;
k-=ten;
    k%=MOD;
    if(k<0)k+=MOD;
k%=MOD;

cout<<k<<endl;










return 0;
}


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

//#define int long long
#define ll long long
#define F first 
#define S second 
#define pb push_back
#define ld long double

using namespace std ; 

const int MAXN = 201 * 1001 , MOD =  1e9 + 7 , L = 18 ;

int n , x , y ;

int fact[MAXN] , inv[MAXN] ; 

int tv(int x , int y)
{
	if(!y) return 1 ; 
	ll ans = tv(x,y/2) ; 
	ans *= ans , ans %= MOD ; 
	if(y&1) ans *= x ;
	return ans % MOD ; 
}


int c[MAXN] , w[MAXN] ; 

priority_queue<pair<int,int>> s[40] ;

unordered_map<int,int> cnt[MAXN] ; 

set<int> S[MAXN] ; 
/*
inline void erase(int c , int w )
{
	S[c].erase(w) ; 
	for(int i = 0 ; i < L ; i ++ ) {
		if(c&(1<<i))
			s[i].erase({w,c}) ; 
		else
			s[i+L].erase({w,c});
	}
	
}
*/
vector<pair<int,int>> v; 

void dfs(int C , int W )
{
//	cout << '*' << C << ' ' << W << endl ; 
	v.pb({C,cnt[C][W]}) ; 
	S[C].erase(W) ; 	
//	erase(C,W) ;
	
	if(!cnt[C][W]) return ;

	cnt[C][W] = 0 ;
	
//	v.pb({C,W}) ; 
	int w = y - W ; 
	//cout << w << endl ; 
	for(int i = 0 ; i < 2 * L ; i +=  rand()%3 ) 
	{
		if(C&(1<<i)&&i<L) continue ; 
		if(!(C&(1<<(i-L)))&&i>=L) continue ; 
	//	if(C==3&&W==2)cout << i << endl ;
	//	if(i==20) cout << ' ' << s[i].size() << (s[i].begin()->F) << endl ;
		while(s[i].size())
		{
			pair<int,int> p = s[i].top() ; 
			p.F *= -1 ; 
			if(p.F>w) break ;
			s[i].pop()  ; 
			dfs(p.S,p.F) ;  
		}
	}

	w = x - W ;
	while(S[C].size()&&*S[C].begin()<=w)
	{
		dfs(C,*S[C].begin()) ; 
	}
}

int32_t main()
{
//	ios::sync_with_stdio(0) ;
	fact[0] = inv[0] = 1 ;
	for(int i = 1 ; i < MAXN ; i ++ ) fact[i]  = 1LL * i * fact[i-1] % MOD , inv[i] = tv(fact[i],MOD-2); 
//	s[0].push({1,2}) ; 
//	s[0].push({2,3}) ; 
//	cout << s[0].top().F << endl ; 
	//	cin >> n >> x >> y ; 
	scanf("%d%d%d",&n,&x,&y) ; 
	for(int i = 0 ; i < n ; i ++ ) 
	{
		//cin >> c[i] >> w[i] ; 
		scanf("%d%d",&c[i],&w[i]) ;
		cnt[c[i]][w[i]] ++ ;
		for(int j = 0 ; j < L ; j ++ ) 
		{
			if(c[i]&(1<<j))
				s[j].push({-w[i],c[i]}) ; 
			else{
	//			if(c[i]==2) cout << '&' << j << endl ; 
				s[j+L].push({-w[i],c[i]}) ; 
			}
		}
		S[c[i]].insert(w[i]) ; 
	}
	ll ans = 1 ; 
	for(int i = 0 ; i < n ; i ++ ) 
	{
		if(!cnt[c[i]][w[i]]) continue ; 
		v.clear() ; 
		dfs(c[i],w[i]) ; 
		int C = 0 ; 
		sort(v.begin(),v.end()) ; 
		int prv = -1 , x = 0 ; 
		for(auto u : v)
		{
	//		cout << u.F << ' ' << u.S << endl ;
			C += u.S ; 
			if(u.F==prv) x += u.S ; 
			else ans *= inv[x] , ans %= MOD , prv = u.F , x = u.S ; 
		}
	//	cout << endl << endl ; 
		ans *= inv[x] ; ans %= MOD ; 
		ans *= fact[C] ; ans %= MOD ;
	//	cout << C << endl ;
	}
	cout << ans << endl ; 
}


Measured memory_bytes: 122740
while 1:
	n , x = map(int , raw_input().split())
	if n == x == 0:
		break
	else :
		cnt = 0
		for i in range(1,n - 1):
			for j in range(i + 1 , n):
				for k in range(j + 1, n + 1):
#					print i,j,k
					if i + j + k == x:
#						print i,j,k
						cnt += 1
		print cnt

Measured memory_bytes: 4204
#include <iostream>
#include <vector>
using namespace std;
const long long INF = 1LL<<60; // 仮想的な無限大の値

int main() {
    // 入力
    int N, K;
    while (cin >> N >> K) {
        if (N == 0) break;
        vector<long long> a(N);
        for (int i = 0; i < N; ++i) cin >> a[i];

        // 累積和を前計算
        vector<int> s(N+1, 0);
        for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];

        // 答えを求める
        long long res = -INF; // 最初は無限小の値に初期化しておく
        for (int i = 0; i <= N-K; ++i) {
            long long val = s[K+i] - s[i];
            if (res < val) res = val;
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 3888
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <fstream>
#include <iostream>
#include <algorithm>
using namespace std;

int *c;

struct job {
	int id;
	job(int i){
		this->id = i;
	}
	bool operator<(job j) const {
		return c[this->id] > c[j.id];
	}
};

int main() {
	int n;
	scanf("%d", &n);
	
	c = new int[n];
	vector<vector<pair<int, int> > > paths;
	
	for(int i = 0; i < n; i++){
		int u, k;
		scanf("%d %d", &u, &k);
		
		vector<pair<int, int> > path;
		c[u] = u ? INT_MAX : 0;
		while(k--){
			int v, c;
			scanf("%d %d", &v, &c);
			path.push_back(make_pair(v, c));
		}
		paths.push_back(path);
	}
	
	priority_queue<job> q;
	q.push(job(0));
	while(q.size()){
		int i = q.top().id;
		q.pop();
		
		for(int j = 0; j < paths[i].size(); j++){
			int dest = paths[i][j].first;
			int cost = paths[i][j].second;
			if(c[dest] > c[i] + cost){
				c[dest] = c[i] + cost;
				q.push(job(dest));
			}
		}
	}
	
	for(int i = 0; i < n; i++){
		printf("%d %d\n", i, c[i]);
	}
}

Measured memory_bytes: 5224
#include <stdio.h>

int main(void)
{
	int a,b,c,m=110,M=0;
	scanf("%d %d %d",&a,&b,&c);
	if(a<m){
		m=a;
	}
	if(a>M){
		M=a;
	}
	if(b<m){
		m=b;
	}
	if(b>M){
		M=b;
	}
	if(c<m){
		m=c;
	}
	if(c>M){
		M=c;
	}
	printf("%d\n",M-m);
	return 0;
}

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

const int inf = 1e9;
const int maxn = 1e6 + 5;
int dp[maxn][2], val[maxn];
int tot = 0;
int main(){
	char c;
	while(true){
		c = getchar();
		if(c >= '0' && c <= '9'){
			val[++tot] = c - '0';
		}
		else break;
	}
	std::reverse(val+1, val+tot+1);
	dp[1][0] = val[1], dp[1][1] = 10 - val[1];
	for(int i=2;i<=tot;i++) dp[i][0] = dp[i][1] = inf;
	for(int i=2;i<=tot;i++){
		if(val[i] != 9){
			dp[i][0] = std::min(dp[i-1][0] + val[i], dp[i-1][1] + val[i] + 1);
			dp[i][1] = std::min(dp[i-1][0] + 10 - val[i], dp[i-1][1] + 9 - val[i]);
		}
		else{
			dp[i][0] = dp[i-1][0] + val[i];
			dp[i][1] = std::min(dp[i-1][0] + 1, dp[i-1][1]);
		}
	}
	printf("%d\n", std::min(dp[tot][0], dp[tot][1] + 1));
	return 0;
}

Measured memory_bytes: 11904
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int len=s.length();
    if(len>n)
    {
        string temp="";
        for(int i=0;i<n;i++)
        {
            temp+=s[i];
        }
        temp+="...";
        cout<<temp<<endl;
    }
    else
    {
        cout<<s<<endl;
    }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
 
#define PB push_back
#define MP make_pair
#define S second
#define F first
//#define D cout<<"*\n";
#define fast ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define mod 1000000007 
const double pi = 3.14159265358979323846; 


signed main()
{
    fast
    int t=1;
   // cin>>t;
    
    while(t--)
    {
      int n;
	  cin>>n;
	  int a[n+1];
	  for(int i=0;i<n;i++)
	  {
	  	cin>>a[i+1];
		  }	
		int dp[n+1];
		dp[0]=0;
		dp[1]=0;
		a[0]=10e8;
		for(int i=2;i<=n;i++)
		{
			dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
		  }  
		  cout<<dp[n];
    }
	return 0;
}

	

Measured memory_bytes: 1792
use proconio::derive_readable;
use proconio::input;

#[derive_readable]
#[derive(Debug)]
struct Query {
    a: usize,
    b: usize,
    c: usize,
    d: i32,
}

fn dfs(i:usize, n:usize, m:usize, mut seq: &mut [usize;11], qu: &Vec<Query>) -> i32 {
    if i > n {
        qu.iter().fold(0,|s,q|{
            if seq[q.b] - seq[q.a] == q.c {
                s + q.d
            } else {
                s
            }
        })
    } else {
        (seq[i - 1] ..= m).map(|j|{
            seq[i] = j;
            dfs(i + 1, n, m, &mut seq, qu)
        }).max().unwrap()
    }
}

fn main() {
    input! {
        n: usize,
        m: usize,
        q: usize,
        qu: [Query; q]
    };
    let ans = dfs(1,n,m, &mut [1;11], &qu);
    println!("{:?}", ans);
}


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

#define ll long long
#define fast_io ios::sync_with_stdio(0); cin.tie(0)
#define infl 1e18L+9
#define inf 1e9L+9
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()

const int mod=1e9L+7; 

void solve(){
  string s, t; cin>>s>>t; 
  int ans=0; 
  for(int i=0;i<sz(s);i++) ans+=(s[i]==t[i]); 
  cout<<ans<<endl; 
}

int main()
{
	fast_io;
	clock_t beg=clock(); 
	solve(); 
	clock_t end=clock(); 
	fprintf(stderr,"%.2lf sec\n",(double)(end-beg)/CLOCKS_PER_SEC); 
	return 0;
}

Measured memory_bytes: 256
import sys

N, X, M = map(int, input().split())

if N == 1: #例外
  print(X)
  sys.exit()

ans = 0
ans += X - (X%M) #XがMより大きい場合、超過分を先に計上する。
X %= M #これで 0 <= X <= M-1 が成り立つようにできた。

def fun(x): #問題の関数を用意（いちいち中身を書いていると面倒くさいため）
  return (x * x) % M

appear_set = {X} #すでに現れた数を格納する


i_0 = 1 #今までに調べた個数。現在は「X」の1つだけ。
x = X #このxに何度も関数funを作用させる
sum_0 = x #現在までの和

# ①：すでに出現したことのある数が現れるまで、ループを回す。
#  　この途中で目標回数Nに到達するなら、その時点で答えを出力する(31-33行目)。
while fun(x) not in appear_set: #次のxが初めて現れる数なら続ける。
  x = fun(x) #xにfunを作用
  appear_set.add(x) #xを「現れたものリスト」に格納
  sum_0 += x #和の更新
  i_0 += 1   #調べた個数の更新
  
  if i_0 == N: #目標回数に到達したら、その時点で答えを出力して終了。
    print(ans + sum_0)
    sys.exit()

# 現在、xには系列に初めて現れた最後の数が入っている。
# 次の数であるfun(x)は、前に現れたことのある数。したがって、ここからループが始まる。
# 整理のため、ここまでの和を計上し、残り回数も減らしておく。
ans += sum_0
N -= i_0

# ②：ループの性質を調べるため、もう一度ループを回したい。
#　欲しいものは3つ。
#   1.ループ１週の和
#   2.ループの途中までの和を記録した配列。
#   3.ループの長さ

#　以下、先ほどと異なる部分を中心に説明する。
x = fun(x) # 次の数へ行く(ループの最初の数)
appear_set_2 = {x} 
sum_1 = x        # 欲しいもの1。ループ１周の和を記録する。
sum_list = [0,x] # 欲しいもの2。i番目の要素がi番目までの数までの和を示すよう、この後要素を追加する。
i_1 = 1 # すでに調べた個数をカウントする。現在は「x」の1個だけ。
# このi_1が、最終的にループの長さ(欲しいもの3)になる。

# 以下、60行目以外の処理は先ほどと同様。
while fun(x) not in appear_set_2:
  x = fun(x)
  appear_set_2.add(x)
  sum_1 += x 
  sum_list.append(sum_1) #途中までの和を記録。
  i_1 += 1
  
# ③：上で求めた３つの情報（一周の和sum_1, 途中までの和の記録sum_list, ループ長i_1）
#    を使って答えを求める。
ans += sum_1 * (N // i_1) + sum_list[(N % i_1)]

print(ans)

Measured memory_bytes: 87388
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

const auto gcu = getchar_unlocked;
const auto pcu = putchar_unlocked;
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;if(n<0)pcu('-'),n*=-1;
	if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10; while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

struct T {
	int i, s;
	bool operator < (const T a) const { return s < a.s; }
};

int main() {
	for (int n; (n = in());) {
		vector<T> l(n);
		for (T &t:l) {
			t.i = in();
			for (int i = 0; i < 4; i++) {
				t.s += in() * 60;
				t.s += in();
			}
		}
		partial_sort(l.begin(), l.begin() + 2, l.end());
		outl(l[0].i);
		outl(l[1].i);
		nth_element(l.begin(), l.begin() + n - 2, l.end());
		outl(l[n - 2].i);
	}
}


Measured memory_bytes: 2648
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a[200],b[200],i=0,k[200],count[200];
    for(i=0;i<200;i++){
        count[i]=0;
    }
    i=0;
    while(scanf("%d %d",&a[i],&b[i])!=EOF){
        k[i]=a[i]+b[i];
        count[i]=1;
        while(k[i]>=10){
        k[i]=k[i]/10;
        count[i]++;
        }
        i++;
    }
    
    i=0;
    while(count[i]!=0){
    printf("%d\n",count[i]);
        i++;
    }
    return 0;
}

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

int main(void) {
    string s[3];
    cin >> s[0] >> s[1] >> s[2];
    queue<char> q[3];
    for(int i = 0; i < 3; ++i) {
        for(size_t j = 0; j < s[i].length(); ++j) q[i].push(s[i][j]);
    }
    
    char t = 'a';
    int w = -1;
    while(true) {
        int n;
        if(t == 'a') n = 0;
        else if(t == 'b') n = 1;
        else if(t == 'c') n = 2;
        if(q[n].empty()) w = n;
        if(w >= 0) break;
        t = q[n].front();
        q[n].pop();
    }
    if(w == 0) cout << 'A' << endl;
    else if(w == 1) cout << 'B' << endl;
    else if(w == 2) cout << 'C' << endl;
    return 0;
}

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

#define i64 long long int

i64 n;

int main() {
	cin>>n;
	
	i64 ans = 0;
	for(i64 i=1;i*i<=n;i++) {
		i64 x = n-i;
		if(x%i) continue;
		i64 y = x/i;
		if(y<=i) continue;
		ans += y;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define ull unsigned long long
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
int INF = 1001001001;
const int MOD=1e9+7;
int main(void) {
int h;
	cin >> h;
	int w;
	cin >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}

	vector<bool> row(h, false);
	vector<bool> col(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}

	for (int i = 0; i < h; i++) {
		if (row[i]) {
			for (int j = 0; j < w; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}


Measured memory_bytes: 256
a = int(input())
s = [list(map(int,input().split()))for i in range(a)]
count = 0
for i in range(a):
    if s[i][0] ==s[i][1]:
        count +=1
    else:
        count=0
    if count >=3:
        print('Yes')
        exit()
print('No')

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int n,k;
  string s;
  cin>>n>>k>>s;
  k--;
  s[k]+='a'-'A';
  cout<<s<<endl;
}




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

#define fi first
#define se second

const int N = 200100;

using namespace std;

long long n;
long long a[N], b[N], A[N], B[N];

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

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        cin >> n;
        long long S = 0;
        for(int i = 0; i < n; i++){
                cin >> a[i];
                S += a[i];
        }
        if(S % (n * (n + 1) / 2)){
                cout << "NO" << "\n";
                return 0;
        }
        long long k = S / (n * (n + 1) / 2);
        for(int i = 0; i < n; i++){
                a[i] -= k;
                if(a[i] < 0){
                        cout << "NO" << "\n";
                        return 0;
                }
        }
        for(int i = 0; i < n; i++){
                b[i] = a[i] - a[(i - 1 + n) % n];
                b[i] = k - b[i];
                if(b[i] < 0 || b[i] % n){
                        cout << "NO" << "\n";
                        return 0;
                }
                b[i] /= n;

                A[i] += b[i];
                A[i + n] -= b[i];
                B[i] += - b[i] * i;
                B[i + n] -= - b[i] * i;

        }
        for(int i = 1; i < 2 * n; i++){
                A[i] += A[i - 1];
                B[i] += B[i - 1];
        }
        for(int i = 0; i < n; i++){
                if(a[i] != B[i] + B[i + n] + A[i] * i + A[i + n] * (n + i)){
                        cout << "NO" << "\n";
                        return 0;
                }
        }
        cout << "YES" << "\n";
}


Measured memory_bytes: 6400
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = 10 ** 9 + 1
NIL = - 1


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

max_value = - INF
counter = 0
for i in range(1, N):
    if H[i] - H[i-1] <= 0:
        counter += 1
    else:
        max_value = max(max_value, counter)
        counter = 0

max_value = max(max_value, counter)
print(max_value)


Measured memory_bytes: 59632
#include<cstdio>
using namespace std;
int n;
long long a[200005];
int main()
{
    scanf("%d",&n);
    long long v=0,sum=0,e=1;
    int left=1,right=1;
    for(;right<=n;right++)
    {
        scanf("%d",&a[right]);
        while((v^a[right])!=v+a[right])
        {
            sum+=right-left;
            v^=a[left++];
        }
        v+=a[right];
    }
    printf("%lld",sum+e*(n-left+2)*(n-left+1)/2);
    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main(){
  lli n,k;
  cin>>n>>k;
  lli arr[n];
  float f[n];
  for(lli i=0;i<n;++i){
    cin>>arr[i];
    f[i]=((arr[i]+1)*1.0)/2.0;
  }
  double curr=0;
  double max=0;
  for(lli j=0;j<k;++j)
      curr+=f[j];
    max=curr;
  for(lli i=k;i<n;++i){
    curr-=f[i-k];
    curr+=f[i];
    
    if(curr>max)
      max=curr;
  }
  cout<<std::fixed<<setprecision(10)<<max;
}


Measured memory_bytes: 2560
n=int(input())
p=2
from itertools import product
iterator=product(range(p),repeat=n)
#for idxs in iterator:
#    print(idxs)

L=[[] for i in range(n)]
for i in range(n):
    a=int(input())
    for _ in range(a):
        L[i].append(list(map(int,input().split())))
ans=0
for idxs in iterator:
    cnt_honest=0
    for i in range(n):
        cnt=0
        if idxs[i]==1:
            for j in L[i]:
                if idxs[j[0]-1]==j[1]:
                    cnt+=1
            if cnt==len(L[i]):
                cnt_honest+=1
    if cnt_honest==sum(idxs):
        ans=max(sum(idxs),ans)
print(ans)

Measured memory_bytes: 9192