akhauriyash/Code-Regression huggingface dataset:
using System;

namespace ChokudaiScanner
{
    class MainClass
    {
        static void Main()
        {
            Scanner cin = new Scanner();

            int N = cin.NextInt();
            int K = cin.NextInt();
            int[] A = cin.ArrayInt(N);

            for(int i = 0; i < N - K; i++)
            {
                int x = A[i];
                int y = A[i + K];

                if (x < y)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }

        }
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public string[] ArrayNext(int N)
        {
            string[] Array = new string[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Next();
            }
            return Array;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 45488
# include <cstdio>
# include <iostream>
# include <cstring>
# define R register int

using namespace std;

const int maxn=2003;
int n,k,x[maxn],y[maxn],firs[maxn],h,dep[maxn],t;
struct edge { int too,nex; }g[maxn<<1];

void add (int x,int y)
{
    g[++h].nex=firs[x];
    g[h].too=y;
    firs[x]=h;
}

void dfs (int x)
{
    if(dep[x]-1>(k/2)) t++;
    int j;
    for (R i=firs[x];i;i=g[i].nex)
    {
        j=g[i].too;
        if(dep[j]) continue;
        dep[j]=dep[x]+1;
        dfs(j);
    }
}

int main()
{
    scanf("%d%d",&n,&k);
    for (R i=1;i<n;++i)
    {
        scanf("%d%d",&x[i],&y[i]);
        add(x[i],y[i]); add(y[i],x[i]);
    }
    int ans=n;
    if(k%2==0)
    {
        for (R i=1;i<=n;++i)
        {
            t=0;
            memset(dep,0,sizeof(dep));
            dep[i]=1;
            dfs(i);
            ans=min(ans,t);
        }
    }
    else
    {
        for (R i=1;i<n;++i)
        {
            t=0;
            memset(dep,0,sizeof(dep));
            dep[ x[i] ]=1;
            dep[ y[i] ]=1;
            dfs(x[i]);
            dfs(y[i]);
            ans=min(ans,t);
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>


using namespace std;

int main(){
	
	int H, W;
	cin >> H >> W;

	vector<vector<char>> S(H, vector<char>(W));

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> S.at(i).at(j);
	}
	}


	vector<bool> h(H, false);
	vector<bool> w(W, false);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S.at(i).at(j) == '#') {
				h.at(i) = true;
				w.at(j) = true;
			}
		}
	}

	for (int i = 0; i < H; i++) {
		if (h.at(i)) {
			for (int j = 0; j < W; j++) {
				if (w.at(j)) {
					cout << S.at(i).at(j);
				}
			}
			cout << endl;
		}
	
	}
}

Measured memory_bytes: 256
x=list(map(int, input().split()))
t=0
if x[0]<4:
	t=t+((4-x[0])*100000)
if x[1]<4:
	t=t+((4-x[1])*100000)
if x[0]==1 and x[1]==1:
	t=t+400000
print(t)

Measured memory_bytes: 2940
N = int(input())
lis = list(map(int,input().split()))

if sum(lis)/N - sum(lis)//N > 0.5:
    mid = sum(lis)//N +1
else :
    mid = sum(lis)//N
result = 0
for i in lis:
    result += (i-mid)**2

print(result)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


// ----------------------------------------------------------------------------

int main(){
  vector<int> faces(7);
  for(int i=1; i<=6; i++){
    cin >> faces[i];
  }
  vector<vector<int>> right(7,vector<int> (7));
  right[1] = {0,0,3,5,2,4,0};
  right[2] = {0,4,0,1,6,0,3};
  right[3] = {0,2,6,0,0,1,5};
  right[4] = {0,5,1,0,0,6,2};
  right[5] = {0,3,0,6,1,0,4};
  right[6] = {0,0,4,2,5,3,0};
  int q;
  cin >> q;
  for(int i=0; i<q; i++){
    int a,b;
    cin >> a >> b;
    for(int j=1; j<=6; j++){
      if(faces[j] == a){
        a = j;
        break;
      }
    }
    for(int j=1; j<=6; j++){
      if(faces[j] == b){
        b = j;
      }
    }
    for(int j=1; j<=6; j++){
      if(a == j){
        cout << faces[right[a][b]] << endl;
      }
    }
  }
  return 0;
}



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

int main() {
    ll W, H, x, y; cin >> W >> H >> x >> y;
    double ans = W * H / 2.0;
    cout << setprecision(13) << ans;
    if (x * 2 == W && y * 2 == H) cout << " 1" << endl;
    else cout << " 0" << endl;

}


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

int main() {
  int n, S = 0;
  ll d;
  cin >> n >> d;
  d *= d;
  for(int i = 0;i < n;i++) {
    ll a, b;
    cin >> a >> b;
    if(a * a + b * b <= d) S++;
  }
  cout << S << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
const int mod = 1000000007;
const int INF = 1000000001;
const long long LINF = 1e18;
const int MAX = 510000;

int main(){
	int n;
	cin >> n;
	vector<int> t(n+1);
	for (int i = 0; i < n; i++) {
		cin >> t.at(i);
	}
	int m;
	cin >> m;
	vector<int> p(m+1), x(m+1);
	
	for (int i = 0; i < m; i++) {
		cin >> p.at(i) >> x.at(i);
	}

	int ans = INF;
	int d = 0;
	for (int i = 0; i < n; i++) {
		d += t.at(i);
	}
	int total = d;
	//cout << total << endl;
	for (int i = 0; i < m; i++) {
		
		total -= t.at(p.at(i)-1);
		total += x.at(i);
		cout << total << endl;
		total = d;
	}
	
	
	
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
// ------------------------------

int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    rep(i, N) cin >> L[i];
    sort(ALL(L));
    // set<int> S(ALL(tmp));
    // vector<int> L(ALL(S));
    int ans = 0;
    // N = L.size();
    for (int i = 0; i < N - 2; ++i) {
        for (int j = i + 1; j < N - 1; ++j) {
            for (int k = j + 1; k < N; ++k) {
                if (L[i] + L[j] > L[k] && L[i] != L[j] && L[j] != L[k]) {
                    ans += 1;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

		// 文字列を指定した区切り文字(" ")によって分割し,それぞれの配列の要素として格納する
		String[] str = brstr.split(" ");
		int x = Integer.parseInt(str[0]);
		int y = Integer.parseInt(str[1]);
		System.out.println(x * y + " " + (x + y) * 2);
	}

}

Measured memory_bytes: 16892
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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 (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



int N, P, R;
int wrong[55][15];
int point[55][15];

int t, p, s;
string str;

int main() {
    while (cin >> N >> P >> R) {
        if (N == 0) break;
        memset(wrong, 0, sizeof(wrong));
        memset(point, 0, sizeof(point));
        for (int i = 0; i < R; ++i) {
            cin >> t >> p >> s >> str;
            if (str == "WRONG") ++wrong[t][p];
            else {
                if (point[t][p] > 0) continue;
                point[t][p] = 1200 * wrong[t][p] + s;
            }
        }
        
        vector<vector<int> > vec(N);
        for (int i = 0; i < N; ++i) {
            vint tmp(3, 0);
            for (int j = 0; j <= 14; ++j) {
                if (point[i+1][j] > 0) ++tmp[0];
                tmp[1] -= point[i+1][j];
            }
            tmp[2] = -(i+1);
            vec[i] = tmp;
        }
        sort(ALL(vec), greater<vint>());
        
        for (int i = 0; i < vec.size(); ++i) cout << -vec[i][2] << " " << vec[i][0] << " " << -vec[i][1] << endl;
    }
    return 0;
}


Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
int p=1000000007;
 
 
signed main() {
	string k;
	cin >> k;
	int n=k.length();
	int a[n];
	for(int i=0;i<n;i++){
		a[i]=k[n-1-i]-'0';
	}
	int d;
	cin >> d;
	int b1[n][d],b2[n][d][10];
	for(int i=0;i<n;i++){
		for(int j=0;j<d;j++){
			b1[i][j]=0;
			for(int k=0;k<=9;k++){
				b2[i][j][k]=0;
			}
		}
	}
	for(int k=0;k<=a[0];k++){
		b1[0][k%d]++;
		b1[0][k%d]=b1[0][k%d]%p;
	}
	for(int j=0;j<=9;j++){
		for(int k=j;k<=9;k++){
			b2[0][j%d][k]++;
			b2[0][j%d][k]=b2[0][j%d][k]%p;
		}
	}
	for(int i=1;i<n;i++){
		for(int j=0;j<d;j++){
			b2[i][j][0]+=(b2[i-1][j][9]%p);
			b2[i][j][0]=b2[i][j][0]%p;
			for(int k=1;k<=9;k++){
				b2[i][j][k]+=((b2[i][j][k-1]%p)+(b2[i-1][(j-k+d*k)%d][9]%p))%p;
				b2[i][j][k]=b2[i][j][k]%p;
			}
		}
	}
	for(int i=1;i<n;i++){
		for(int j=0;j<d;j++){
			b1[i][j]+=(b1[i-1][(j-a[i]+a[i]*d)%d]%p);
			b1[i][j]=b1[i][j]%p;
			if(a[i]>=1){
				b1[i][j]+=(b2[i][j][a[i]-1]%p);
				b1[i][j]=b1[i][j]%p;
			}
		}
	}
	cout << (b1[n-1][0]-1+p)%p;
	// your code goes here
	return 0;
}

Measured memory_bytes: 86272
s = input()
mod = 2019
remains = [0]*mod

ans = 0
now = 0
remains[0] = 1
for i,val in enumerate(s[::-1]):
    now += int(val) * pow(10,i,mod )
    now %= mod
    ans += remains[now]
    remains[now] += 1

print(ans)

Measured memory_bytes: 74012
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <map>


using namespace std;

int a, b, loop, angka[105];

int main(){

	int pos=1;
	cin>>a>>b>>loop;
	loop=min(b-a+1,loop);
	for(int x=a;x<a+loop;x++){
		angka[pos]=x;
		pos++;
	}
	for(int x=b-loop+1;x<=b;x++){
		if(angka[pos-1]>=x)continue;
		angka[pos]=x;
		pos++;
	}
	for(int x=1;x<pos;x++){
		cout<<angka[x]<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

bool dpX[4005][16005];  // dpX[i+1][j] : i番目の演算まででx座標がjの位置にいられるならtrue
bool dpY[4005][16005];  // dpY[i+1][j] : i番目の演算まででy座標がjの位置にいられるならtrue
 
int main() {
    string s;
    ll gx, gy;
    cin >> s >> gx >> gy;
    ll n = s.size();
    // x,y座標ともに+nだけ平行移動して考える
    gx += n;  gy += n;

    vl vx, vy;
    ll cntF = 0, cntT = 0; 
    rep(i, n) {
        if(s[i] == 'F') {
            cntF++;
        }
        else if(s[i] == 'T') {
            if(cntT%2 == 0) {
                vx.pb(cntF);
            }
            else {
                vy.pb(cntF);
            }
            cntF = 0;
            cntT++;
        }
    }
    if(s[n-1] == 'F' && cntT%2 == 0) {
        vx.pb(cntF);
    }
    if(s[n-1] == 'F' && cntT%2 == 1) {
        vy.pb(cntF);
    }

    /*cout << "\n";
    for(auto p : vx) {
        cout << p << " ";
    }

    cout << "\n";
    for(auto p : vy) {
        cout << p << " ";
    }*/

    ll mx = vx.size();
    dpX[0][n] = true;
    rep(i, mx) {
        exrep(j, 0, 2*n) {
            if(j - vx[i] >= 0 && dpX[i][j - vx[i]]) {
                dpX[i+1][j] = true;
            }
            if(i > 0 && j + vx[i] <= 2*n && dpX[i][j + vx[i]]) {
                dpX[i+1][j] = true;
            }
        }
    }

    ll my = vy.size();
    dpY[0][n] = true;
    rep(i, my) {
        exrep(j, 0, 2*n) {
            if(j - vy[i] >= 0 && dpY[i][j - vy[i]]) {
                dpY[i+1][j] = true;
            }
            if(j + vy[i] <= 2*n && dpY[i][j + vy[i]]) {
                dpY[i+1][j] = true;
            }
        }
    }
    
    if(dpX[mx][gx] && dpY[my][gy]) {
        out("Yes");
    }
    else {
        out("No");
    }

    re0;
}

Measured memory_bytes: 123776
#include<iostream>
using namespace std;
int main(){
    int A,B,V,W,T;
    cin>>A>>V>>B>>W>>T;
    bool isCaught=false;
    if(V<=W){
        isCaught=false;
    }else{
        double dist =abs(A-B);
        double ddist =abs(V-W);
        double dt =dist/ddist;
        if(dt<=T){isCaught=true;}
    }
    cout<<(isCaught? "YES":"NO");
}

Measured memory_bytes: 3576
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(b-a==c-b){
		cout<<"YES"<<endl;
	}
	
	else if(b-a!=c-b){
		cout<<"NO"<<endl;
	}
	
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <math.h>
#include <cmath>
#include <vector>

using namespace std;
#define ll long long

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

	vector<ll> x(1001);
	for (int i = 1; i <= N; i++) {
		int a = i;
		for (int j = 2; j <= a; j++) {
			while (a%j == 0) {
				x.at(j)++;
				a /= j;
			}
		}
	}

	long long ans = 1;
	long long mod = 1000000007;
	for (int i = 0; i<1001; i++) {
		ans *= (x.at(i) + 1);
		ans %= mod;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    char c;
    char s[21]={'\0'};
    int i = 0,j;
    c = getchar();
    while(c != '\n'){
        for(j=i;j>=0;j--){
            s[j+1] = s[j];
        }
        i++;
        s[0] = c;
        c = getchar();
    }
    printf("%s\n",s);
}

Measured memory_bytes: 912
#include <bits/stdc++.h>
using namespace std;
 
int main() {
        int N;
        int A;
        cin >> N;
        int MAX = 1000000;
        for(int i = 0; i < N; i++){
        int wattakaisu = 0;
        cin >> A;
        while(A % 2 == 0){
                A /= 2;
           wattakaisu += 1;
        }
        if(MAX > wattakaisu){
                 MAX = wattakaisu;
        }
    }
    cout << MAX << endl;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0};
const int dy[8] = {0, 1, 0, -1};

void solve() {
  int h, w; cin >> h >> w;
  vector<string> grid(h); rep(i, h) cin >> grid[i];
  vector<P> dots;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (grid[i][j] == '.') dots.push_back(make_pair(i, j));
    }
  }

  ll ans = 0;
  const int MAX = 20;
  bool visited[MAX][MAX] = {};
  for (int i = 0; i < dots.size(); i++) {
    int sy = dots[i].first;
    int sx = dots[i].second;
    for (int j = i + 1; j < dots.size(); j++) {
      int gy = dots[j].first;
      int gx = dots[j].second;

      queue<ll> qx, qy, qc;
      qx.push(sx);
      qy.push(sy);
      qc.push(0);
      visited[sy][sx] = true;

      while (!qx.empty()) {
        int x = qx.front(); qx.pop();
        int y = qy.front(); qy.pop();
        int c = qc.front(); qc.pop();

        if (x == gx && y == gy) {
          ans = max(ans, c);
          break;
        }

        for (int k = 0; k < 4; k++) {
          int nx = x + dx[k];
          int ny = y + dy[k];
          if (nx >= 0 && nx < w && ny >= 0 && ny < h && !visited[ny][nx] && grid[ny][nx] == '.') {
            visited[ny][nx] = true;
            qx.push(nx);
            qy.push(ny);
            qc.push(c + 1);
          }
        }
      }

      memset(visited, false, sizeof(visited));
    }
  }

  outl(ans);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 380
while(h,w=gets.split.map &:to_i)[0]>0
a=[]
b=[s=0]*w
h.times{|i|gets;a[i]=[]
w.times{|j|a[i]<<l=$_[j]<?.?0:(a[i][-1]||0)+1
m=b[j]+=l>0?1:0
l*m>s&&(1..m).each{|k|l>(t=a[i-k+1][j])&&l=t;l*m<s ?(break):s<l*k&&s=l*k}}}
p s
end

Measured memory_bytes: 8548
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

	return 0;
}

using namespace std;

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

void Main()
{
	inll n;
	vector<ll> a1, a2;

	ll max = 0;

	REP(i, n)
	{
		inll a1_;
		a1.push_back(a1_);
	}

	REP(i, n)
	{
		inll a2_;
		a2.push_back(a2_);
	}

	REP(i, n)
	{
		ll sum = 0;
		REP(j, i + 1)
		{
			sum += a1[j];
		}
		FOR(j, i, n)
		{
			sum += a2[j];
		}
		max = std::max(sum, max);
	}

	return OUT(max);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>

using namespace std;
typedef long long ll;

static const int mod = 1000000007;
static const int MAX_N = 21;
int DP[1 << MAX_N][MAX_N]; // メモ化テーブル
int N;
int a[MAX_N][MAX_N];
int rec(int S, int V);
int calc();

int main()
{
	cin >> N;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			cin >> a[i][j];
		}
	}
	
	std::fill(DP[0], DP[(1 << MAX_N)-1], -1);
	
	cout << calc() << endl;
	
	return 0;
}

int rec(int S, int V, int n){
	if(DP[S][V] >= 0){
		return DP[S][V];
	}
	
	if(!a[n][V]){
		DP[S][V] = 0;
		return 0;
	}
	else if(n == N-1){
		DP[S][V] = 1;
		return DP[S][V];
	}
	
	int sum = 0;
	int nextS = S | (1 << V);
	for(int i = 0; i < N; i++){
		if(i != V && !(S >> i & 1)){
			// なるべく関数呼び出しを少なくすると少し速くなる...
			sum += DP[nextS][i] >= 0 ? DP[nextS][i] : rec(nextS, i, n+1);
			sum %= mod;
		}
	}
	
	DP[S][V] = sum;
	return DP[S][V];
}

int calc(){
	int sum = 0;
	for(int i = 0; i < N; i++){
		sum += rec(0, i, 0);
		sum %= mod;
	}
	return sum;
}

Measured memory_bytes: 172288
#include <bits/stdc++.h>
#define assem99 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define endll '\n'
#define sz(a) (int)(a).size()
#define RWFile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
int dx[] = { 0, -1, 0, 1, -1, 1, -1, 1 };
int dy[] = { -1, 0, 1, 0, 1, -1, -1, 1 };
const int MOD = 1e8, N = 2e6 + 5, oo = 1e9;
const double pi = acos(-1);
using namespace std;

bool prime[N];
vector<int> primes;
int arr[N];
void sieve(int n) {
    memset(prime, 1, sizeof prime);
    for (int p = 2; p * p <= n; p++)
    {
        if(prime[p])
        {
            for(int i = p * p; i <= n; i += p) prime[i] = 0;
        }
    }
    for(int i = 2; i < n; i++) if(prime[i]) primes.push_back(i);
}

map<int, vector<int>> mp;
void getPrimes(int n, int i)
{
    while (n % 2 == 0)
    {
        mp[i].push_back(2);
        n /= 2;
    }
    for (int i = 3; i <= sqrt(n); i += 2)
    {
        while (n % i == 0)
        {
            mp[i].push_back(i);
            n /= i;
        }
    }
    if (n > 2) mp[i].push_back(n);
}
int mat[105][105];

int main()
{
    assem99
    int n, m; cin>>n>>m;
    int t; cin>>t;
    for(int i = 0; i < t; i++) cin>>arr[i];
    int id = 0;
    for(int i = 0; i< n; i++)
    {
        if(i % 2)
        {
            for(int j = m - 1; j >= 0; j--)
            {
                if(!arr[id]) id++;
                if(arr[id]) mat[i][j] = id + 1, arr[id]--;
            }
        }
        else
        {
            for(int j = 0; j < m; j++)
            {
                if(!arr[id]) id++;
                if(arr[id]) mat[i][j] = id + 1, arr[id]--;
            }
        }
    }
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < m; j++) cout<<mat[i][j]<<' ';
        cout<<endll;
    }

    return 0;
}

Measured memory_bytes: 3664
using System;

namespace AGc027A
{
    class Program
    {
        static void Main(string[] args)
        {
            var target = Console.ReadLine().Split(' ');
            int N = int.Parse(target[0]);
            int X = int.Parse(target[1]);
            int[] a = new int[N];
            target = Console.ReadLine().Split(' ');
            for(int i=0; i<N;i++){
                a[i] = int.Parse(target[i]);                         
            }
            Array.Sort(a);
            int count = 0; 
            while(count < N-1){
                if (X >= a[count])
                X -= a[count++];
                else break;
            }
            if(count == N-1 && X == a[N-1]) count++;
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13140
#include "bits/stdc++.h"
using namespace std;

#define OUT(x)  cerr << #x << " = " << x << endl;
#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define piii    pair<int, pair<int, int>>

int main() {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        vector<int> cnt(110, 0);
        for (int i = a; i < b; i ++) cnt[i] ++;
        for (int i = c; i < d; i ++) cnt[i] ++;
        int ans = 0;
        for (int i = 0; i < 110; i ++) ans += cnt[i] > 1;
        cout << ans << endl;
        return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
vector<int>g[100000];
int dp[100000][2];
void dfs(int s, int p){
    int ma = -1000000;
    for(int x:g[s]){
        if(x == p)continue;
        dfs(x,s);
        dp[s][0] += dp[x][1];
        ma = max(ma, dp[x][0] - dp[x][1]);
    }
    dp[s][1] = dp[s][0] + 1 + ma;
}
int main(){
    int n;
    cin >> n;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(0,-1);
    if(n%2==0 and dp[0][1] == n/2){
        cout << "Second" << endl;
    }else{
        cout << "First" << endl;
    }
}

Measured memory_bytes: 6656
#include"bits/stdc++.h"
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;

int main() {
	int x=0;
	cin >> x;
	ll cnt=0;
	REP(i, x) {
		if (i % 3 != 0 && i % 5 != 0)cnt+= i;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3660
import itertools
x = int(input())
num = [i**5 for i in range(3000)]
ans= list(itertools.combinations_with_replacement(num, 2))
for i in ans:
    if abs(i[0]-i[1]) == x:
        if i[0] < i[1]:
            print(int(i[1]**0.2),int(i[0]**0.2))
        else:
            print(int(i[0]**0.2),int(i[1]**0.2))
        break
    elif i[0]+i[1] == x:
        print(int(i[0]**0.2),int(i[1]**0.2)*-1)
        break


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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


int main() {
  int N;
  cin >> N;
  vector<ll> A(N);

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

  vector<ll> left(N + 1, 0);
  vector<ll> right(N + 1, 0);
  
  for(int i = 0; i < N; i++) {
    left[i + 1] = gcd(left[i], A[i]);
  }

  for(int i = N - 1; i >= 0; i--) {
    right[i] = gcd(right[i + 1], A[i]);
  }
  ll ans = -1;
  for(int i = 0; i < N; i++) {
    ll r = right[i + 1];
    ll l = left[i];
    if(ans < gcd(r, l)) ans = gcd(r, l); 
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
const int N=110;
int n,m,f[N][N][2];char c[N][N];
int main(){
	scanf("%d%d",&n,&m);
	memset(f,0x3f,sizeof(f));
	for(int i=1;i<=n;i++)scanf("%s",c[i]+1);f[0][1][0]=f[1][0][0]=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(c[i][j]=='.')f[i][j][0]=min(min(f[i-1][j][0],f[i-1][j][1]),min(f[i][j-1][0],f[i][j-1][1]));
			else f[i][j][1]=min(min(f[i-1][j][1],f[i][j-1][1]),min(f[i-1][j][0]+1,f[i][j-1][0]+1));
	cout<<min(f[n][m][0],f[n][m][1]);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int(i)=0;i<(n);i++)
const ll INF = 9223372036854775807;
#define MAX_V 100001
#define MAX_E 100000

//隣接リスト表現。
struct edge{
  ll to, cost;
};
typedef pair<int, int> P;//firstは最短距離、secondは頂点の番号

int V,E;                //頂点数、辺数
vector<edge> G[MAX_V];  //隣接リスト。各頂点にedgeがある分をつなげる。
ll d[MAX_V];            //頂点kからの最短距離

//隣接リストデータinput。
void input_graph(){
    int s,t,c;
    REP(i,E){
        cin>>s>>t>>c;s--;t--;
        G[s].push_back({t,c});
        G[t].push_back({s,c}); //無向グラフの場合
    }
}

void dijkstra(int s){
    // greater<P>を指定することでfirstが小さい順に取り出せる様にする
    priority_queue<P, vector<P>, greater<P>> que; //未確定頂点の内、最短距離のものがtopにくる
    fill(d, d+V, INF);
    d[s]=0;
    que.push(P(0,s));

    while(!que.empty()){
        P p=que.top();que.pop();
        int v=p.second;
        if(d[v]<p.first) continue;  //確定済み頂点に行かないようにしてる？
        REP(i,G[v].size()){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main(){
  cin>>V;E=V-1;
  input_graph();
  
  int q,k;cin>>q>>k;k--;
  dijkstra(k);
  
  REP(i,q){
    int x,y;cin>>x>>y;x--;y--;
    cout<<d[x]+d[y]<<endl;
  }
}

Measured memory_bytes: 9984
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <math.h>
#include <time.h>

typedef int32_t i32;
typedef int64_t i64;
typedef double f64;

void *const null=(void *)0;
i64 const llinf=4611686018427387903LL;
i64 const mod=1000000009LL;
f64 const pi=3.141592653589793;
f64 const rad=57.295779513082323;

#define CODE_

i32 judge(i64 *const a,i64 const n,i64 const k){
    i64 cnt=0LL;
    for(i64 i=0LL;i<n;++i){
        if(a[i]==k) ++cnt;
    }
    if(cnt==1LL) return 1;
    return 0;
}

i32 main(void){
    i64 n;
    scanf("%lli",&n);
    i64 **a=(i64 **)calloc(4LL,sizeof(i64 *));
    for(i64 i=0LL;i<4LL;++i) a[i]=(i64 *)calloc(n,sizeof(i64));
    for(i64 i=0LL;i<n;++i){
        for(i64 j=0LL;j<3LL;++j) scanf("%lli%*c",&a[j][i]);
    }
    for(i64 i=0LL;i<3LL;++i){
        for(i64 j=0LL;j<n;++j){
            if(judge(a[i],n,a[i][j])) a[3LL][j]+=a[i][j];
        }
    }
    for(i64 i=0LL;i<n;++i) printf("%lli\n",a[3LL][i]);
    return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <string.h>
#include <algorithm>
#include <set>
#include <vector>
#include <climits>
#include <map>
#include <queue>
#include <math.h>
#include <iomanip>

#define sqr(A) ((A) * (A))
#define F first
#define S second
#define MP make_pair
#define bsz  __builtin_popcount
#define all(A) A.begin(), A.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int PR = 727;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;

const int N = 1e5 + 20;
vector<pii> G[N];
int k, d[N];
set<pii> s;

void dijkstra(int src) {
	d[src] = 0;
	s.insert(MP(d[src], src));
	while (s.size()) {
		int v = s.begin()->S;
		s.erase(s.begin());
		for (auto e : G[v])
			if (d[e.F] > d[v] + e.S) {
				int u = e.F, w = e.S;
				s.erase(MP(d[u], u));
				d[u] = d[v] + w;
				s.insert(MP(d[u], u));
			}
	}
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	memset(d, 31, sizeof d);
	cin >> k;
	for (int i = 1; i < k; i++) {
		G[i].push_back(MP((i + 1) % k, 1));
		G[i].push_back(MP((10 * i) % k, 0));
	}
	dijkstra(1);
	cout << d[0] + 1 << endl;
}































Measured memory_bytes: 8320
N=int(input())

mini=float("inf")
for A in range(1,N):
  B=N-A
  sa=str(A)
  sb=str(B)
  sum_a=0
  sum_b=0
  for st in sa:
    sum_a += int(st)
  for st in sb:
    sum_b += int(st)
  mini= min(mini, sum_a+sum_b)  
  
print(mini)

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

using namespace std;

const int N = 1e6 + 5;

vector<int> g[N];

int d[N];
int vis[N];
bool ok[N];
int a[N], b[N];

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i)
    scanf("%d", d+i);
  for (int i = 0; i < m; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    --u, --v;
    a[i] = u;
    b[i] = v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  vector<int> nodes(n);
  for (int i = 0; i < n; ++i)
    nodes[i] = i;
  sort(nodes.begin(), nodes.end(), [](int l, int r) {
    return d[l] < d[r];
  });
  for (int v : nodes) {
    if (vis[v]) continue;
    queue<int> que;
    vis[v] = 1;
    que.push(v);
    while (!que.empty()) {
      int u = que.front();
      que.pop();
      for (int w : g[u]) {
        if (vis[w] || d[w] < d[u])
          continue;
        vis[w] = -vis[u];
        que.push(w);
      }
    }
  }
  for (int i = 0; i < m; ++i) {
    int u = a[i], v = b[i];
    if (vis[u] != vis[v]) {
      if (d[u] == max(d[u], d[v]))
        ok[u] = 1;
      if (d[v] == max(d[u], d[v]))
        ok[v] = 1;
    }
  }
  for (int i = 0; i < n; ++i) {
    if (!ok[i]) {
      puts("-1");
      return 0;
    }
  }
  for (int i = 0; i < n; ++i) {
    printf("%c", vis[i] > 0 ? 'B' : 'W');
  }
  printf("\n");
  for (int i = 0; i < m; ++i)
    printf("%d\n", max(d[a[i]], d[b[i]]));
  return 0;
}


Measured memory_bytes: 41216
#include<bits/stdc++.h>
using namespace std;
 
  string num,se;
 
 
int search(int x){
  int cnt=0;
  for(int i=0;i<num.size();i++){
    if(num[i]>='1' && num[i]<='9'){cnt++;return cnt;}
    else if(num[i]=='0')cnt++;
  }
}
 
 
int poi(){
  int f=0;
  if(num[0]>='1' && num[0]<='9')f=1;
  for(int i=0;i<(int)num.size();i++){
    if(f==1 && num[i]=='.')return i-1;
    else if(f==0 && num[i]=='.')return (-1*search(i)+1);
    else if(i==num.size()-1)return i;
  }
}
string renum;
 
void  renumber(){
 
   int f=0;
    for(int i=0;i<num.size();i++){
      if(num[i]=='.')continue;
      else if(f==0 && num[i]>='1' && num[i]<='9')renum=renum+num[i],f=1;
      else if(f==2)renum+=num[i];
      else if(f==1)renum=renum+'.'+num[i],f=2;
    }
}
 
int main(){
  int  n,jo10;
  cin>>n;
  string tan;
 
  for(int i=0;i<n;i++){
    jo10=0;
        string st;
    cin>>num>>st;
    if(st=="yotta") jo10=24,cin>>tan;
    else if(st=="zetta")jo10=21,cin>>tan;
    else if(st=="exa")jo10=18,cin>>tan;
    else if(st=="peta")jo10=15,cin>>tan;
    else if(st=="tera")jo10=12,cin>>tan;
    else if(st=="giga")jo10=9,cin>>tan;
    else if(st=="mega")jo10=6,cin>>tan;
    else if(st=="kilo")jo10=3,cin>>tan;
    else if(st=="hecto")jo10=2,cin>>tan;
    else if(st=="deca")jo10=1,cin>>tan;
    else if(st=="deci")jo10=-1,cin>>tan;
    else if(st=="centi")jo10=-2,cin>>tan;
    else if(st=="milli")jo10=-3,cin>>tan;
    else if(st=="micro")jo10=-6,cin>>tan;
    else if(st=="nano")jo10=-9,cin>>tan;
    else if(st=="pico")jo10=-12,cin>>tan;
    else if(st=="femto")jo10=-15,cin>>tan;
    else if(st=="ato")jo10=-18,cin>>tan;
    else if(st=="zepto")jo10=-21,cin>>tan;
    else if(st=="yocto")jo10=-24,cin>>tan;
    else tan=st;
    jo10+=poi();
    renumber();
    cout<<renum<<" * 10^"<<jo10<<" "<<tan<<endl;
   
    renum.clear();
  }
  return 0;
}

Measured memory_bytes: 1224
///******* In the name of Allah *******///

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int a;
    double aa,bb;
    cin>>a;
    aa = a;
    bb = 2 * 3.1416 * aa;
    printf("%0.2lf",bb);

    return 0;
}


Measured memory_bytes: 3764
#include <stdio.h>
#include<string.h>

int main()
{
    char s[1001];
    scanf("%s",s);
    char char_array[1001],str2[1001];
    char str[1001];
    strcpy(char_array,s);
    int t,i,a,b,k=0,l=0;
    char temp,p[1001];
    scanf("%d",&t);
    while(t--)
    {
        scanf("%s",str);
        if(strcmp(str,"replace")==0)
        {
            scanf("%d%d",&a,&b);
            scanf("%s",str2);
            for(i=a; i<=b; i++)
            {
                temp=char_array[i];
                char_array[i]=str2[k];
                str2[k]=temp;
                k++;
            }
            k=0;
        }
        else if(strcmp(str,"reverse")==0)
        {
            scanf("%d%d",&a,&b);
            while(a<b)
            {
                temp=char_array[a];
                char_array[a]=char_array[b];
                char_array[b]=temp;
                a++;
                b--;
            }
        }
        else if(strcmp(str,"print")==0)
        {
            scanf("%d%d",&a,&b);
            for(i=a; i<=b; i++)
            {
                p[l]=char_array[i];
                l++;
            }
            p[l]='\0';
            printf("%s\n",p);
            l=0;
        }
    }
}


Measured memory_bytes: 2100
def pgr(x, y, z):
    if x**2 + y**2 == z**2: return True
    else: return False
    
while 1:
    try:
        n = input()
        for i in range(n):
            a,b,c = map(int, raw_input().split())
            if (pgr(a,b,c) or pgr(b,c,a) or pgr(c,a,b)): print 'YES'
            else: print 'NO'
        break
    except EOFError:
        break

Measured memory_bytes: 4244
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    deque<int> d;
    rep(i,N){
        int p = lower_bound(d.begin(),d.end(),A[i])-d.begin();
        if(p == 0){
            d.push_front(A[i]);
        }
        else{
            d[p-1] = A[i];
        }
    }
    int ans = d.size();
    cout << ans << endl;
}


Measured memory_bytes: 1024
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		n: usize,
		s1: Chars,
		s2: Chars,
	}

	let mut index = 0usize;
	let mut ans: usize;
	let mut prev;
	// 最初
	if s1[index] == s2[index] {
		// 縦型
		ans = 3;
		index += 1;
		prev = 0;
	}
	else {
		// 横型
		ans = 6;
		index += 2;
		prev = 1;
	}
	loop {
		if index >= n {
			break;
		}
		if s1[index] == s2[index] {
			// 今回は縦型
			if prev == 0 {
				// 前は縦型
				ans = ans * 2 % 1000000007;
			}
			else {
				// 前は横型
				//ans = ans * 1 % 1000000007;
			}
			index += 1;
			prev = 0;
		}
		else {
			// 今回は横型
			if prev == 0 {
				// 前は縦型
				ans = ans * 2 % 1000000007;
			}
			else {
				// 前は横型
				ans = ans * 3 % 1000000007;
			}
			index += 2;
			prev = 1;
		}
	}
	println!("{}", ans);
}



Measured memory_bytes: 2148
#include<iostream>
#include<bitset>
#include<cstring>
using namespace std;
const int maxn = 1e5+5;

int main(){
	string s;
	cin >> s;
    bitset<maxn>bit (s);
    string s1,s2;
    for (int i = 1; i <= s.size(); i++) {
    	if (i%2) {
    		s1 += '0';
    		s2 += '1';
    	}else{
    		s1 += '1';
    		s2 += '0';
    	}
    }
    bitset<maxn>tar1 (s1);
    bitset<maxn>tar2 (s2);
    tar1 = tar1^bit;
    tar2 = tar2^bit;
    int a = tar1.count();
    int b = tar2.count();
    cout << min(a,b);
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int n; cin >> n;
	string s; cin >> s;
	int cnte[300010];
	int cntw[300010];
	cnte[0]=(s[0] =='E'?1:0);
	cntw[0]=(s[0] =='W'?1:0);
	for(int i=1;i<n;i++){
		if(s[i]=='E'){
			cnte[i]=cnte[i-1]+1;
			cntw[i]=cntw[i-1];

		}
		if(s[i]=='W'){
			cntw[i]=cntw[i-1]+1;
			cnte[i]=cnte[i-1];

		}
	}
	int ans =10000000000;
	ans=min(ans,cnte[n-1]-cnte[0]);
	ans=min(ans,cntw[n-2]);
	for(int i=1;i<n-1;i++){
		ans=min(ans,cntw[i-1]+cnte[n-1]-cnte[i]);
        
	}
	cout << ans << endl;
}

Measured memory_bytes: 3076
import sys
from itertools import accumulate
n,m,q = map(int,input().split())
ipt = sys.stdin.readlines()
rails = [[0]*n for _ in range(n)]
for line in ipt[:m]:
    l,r = map(int,line.split())
    rails[l-1][r-1] += 1
rails = [accumulate(s) for s in rails]
rails = [list(reversed(list(accumulate(reversed(s))))) for s in zip(*rails)]
buf = []
for  line in ipt[m:]:
    p,q = map(int,line.split())
    buf.append(rails[q-1][p-1])
print('\n'.join(map(str, buf)))

Measured memory_bytes: 37920
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{

	public static int min(int[] a)
	{
		int min = a[0];
		for (int i = 0; i < a.length; i++) {
			if(a[i]<min && a [i]!=-1)
			{	min=a[i];
				a[i]=-1;
				System.out.println(a[i]);
			}	
		}
		return min;	
	}
	
	
	public static void main(String[] args) throws IOException{
		// TODO Auto-generated method stub
		
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		
		int x,y,z;
		
		String s = reader.readLine();
		String[] inp = s.split(" ");
		
		x=Integer.parseInt(inp[0]);
		y=Integer.parseInt(inp[1]);
		z=Integer.parseInt(inp[2]);
		
		int[] arr = new int[3];
		arr[0]=x;arr[1]=y;arr[2]=z;
		
		int cost=0;
		
		int a  = Math.min(x,Math.min(y,z));
				
		if(a==x)
		{
			int b = Math.max(y,z);
			cost=cost+Math.abs(b-a);
			
			cost=cost+(Math.max(y,z)-b);
			
		}
		else if(a==y)
		{
			int b = Math.max(x,z);
			cost=cost+Math.abs(b-a);
			
			cost=cost+(Math.max(x,z)-b);
			
		}
		else if(a==z)
		{
			int b = Math.max(x,y);
			cost=cost+Math.abs(b-a);
			
			cost=cost+(Math.max(x,y)-b);
		}

		System.out.println(cost);
	}

}


Measured memory_bytes: 21204
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

char s[105], t[105];
bool cmp(char x, char y)
{
	return x > y;
}
int main()
{
	cin >> s;
	cin >> t;
	sort(s, strlen(s) + s);
	sort(t, strlen(t) + t, cmp);
	string str = s;
	string tt = t;
	if (str >= tt)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
int N,p;
int P[N];
int counter=0;
cin>>N;
for(int i=0;i<N;++i){
  cin>>p;
  P[i]=p;
}
for(int j=0;j<N;++j){
  if(P[j]!=(j+1)){
    counter+=1;
  }
}
if(counter<=2){
  cout<<"YES"<<"\n";
}
else{
  cout<<"NO"<<"\n";
}
return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    cnt = 0
    for i in range(0, n):
        d_1, d_2 = map(int, input().split())
        if d_1 == d_2:
            cnt += 1
        else :
            if cnt < 3 :
                cnt = 0

    if cnt >= 3:
        print("Yes")
    else :
        print("No")
main()

Measured memory_bytes: 9164
use std::io;

fn main () {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut iter = buf.split_whitespace();
	let h:i32 = match iter.next().unwrap().parse() {
		Ok(n) => n,
		Err(_) => panic!(""),
	};
	let a:i32 = match iter.next().unwrap().parse() {
		Ok(n) => n,
		Err(_) => panic!(""),
	};
	if h%a == 0 {
		println!("{}", h/a);
	}else{
		println!("{}", h/a + 1);
	}
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)

vi calc(string &S){
	vi V(S.size());
	int pre = 0;
	rp(now, 1, S.size()){
		if(S[pre] != S[now]){
			if(S[pre] == S[0]){
				int n = now - pre;
				int a = n/2;
				int b = n-a;
				V[now-1] += b;
				V[now] += a;
			}
			pre = now;
		}
	}
	return V;
}

int main(){
	string S; cin>>S;
	vi R = calc(S);
	reverse(all(S));
	vi L = calc(S);
	reverse(all(L));
	rp(i, 0, S.size()) cout<<L[i]+R[i]<<(i+1<S.size()?" ":"\n");
}

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

int GCD(int m,int n){
	if(n==0)return m;
	while(m%n!=0){
		m=m%n;;
		swap(m,n);
	}
	return n;
}

int main(){
	int m,n,gcd;
	
	//cout <<"最大公約数を知りたい二つの数を教えて下さい！\n";
	cin >> m >> n;

	gcd=GCD(m,n);

	//cout << m <<"と"<< n <<"の最大公約数は"<<gcd<<"です！\n";
	cout << gcd << endl;
}


Measured memory_bytes: 3080