akhauriyash/Code-Regression huggingface dataset:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


s = input()
if s[0]==s[-1]:
    v = len(s) - 1
else:
    v = len(s)
if v%2==0:
    print("Second")
else:
    print("First")

Measured memory_bytes: 62336
#include <bits/stdc++.h>
using namespace std;
int main() 
{
    //ifstream cin("input.in");
    //ofstream cout("output.out");
    ios::sync_with_stdio(0);cin.tie(0);
    long n,a[100009],c=0;
    cin>>n;
    for(long i=1;i<=n;i++)
        cin>>a[i];
    for(long i=1;i<=n-1;i++)
        if(a[i]==i){
            c++;
            swap(a[i],a[i+1]);
        }
    if(a[n]==n){
        swap(a[n-1],a[n]);
        c++;
    }
    //for(long i=1;i<=n;i++)
    //    cout<<a[i]<<" ";
    //cout<<"\n";
    cout<<c;
    return 0;
}   

Measured memory_bytes: 1024
// by azidoazideazide(C2N14)
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<utility>
using namespace std;
using ll=long long;
#define pb push_back
#define fi first
#define se second

ll cnt[100005];

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n,q,tt,tsum=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>tt;
		cnt[tt]++;
		tsum+=tt;
	}
	cin>>q;
	while(q--){
		ll from, to;
		cin>>from>>to;
		if(cnt[from]){
			tsum+=(to-from)*cnt[from];
			cnt[to]+=cnt[from];
			cnt[from]=0;
		}
		cout<<tsum<<endl;
	}
}


Measured memory_bytes: 4420
#include<cstdio>
#define MAXN 100005
#define LL long long
int n;
LL a[MAXN],b[MAXN],sum,cnt;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		sum+=a[i];
	}
	LL tmp=1LL*n*(n+1)/2;
	if(sum%tmp)
	{
		printf("NO\n");
		return 0;
	}
	LL cnt=sum/tmp;
	b[n]=b[1]-a[n];
	b[n]=cnt-b[n];
	for(int i=1;i<n;i++)
	{
		b[i]=cnt-(a[i+1]-a[i]);
		if(b[i]<0||(b[i]%n))
		{
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
    return 0;
}

Measured memory_bytes: 3616
// PCK2016問題７　イワシロ・イッツァ
// 
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string T,B;
    int dp[1001][1001];
    cin >> T >> B;
    
    if(T[0]==B[0]){
        dp[0][0]=1;
    }
    else{
        dp[0][0]=0;
    }
    for(int j=1;j<T.size();j++){
       dp[0][j]=dp[0][j-1];
        if(T[j]==B[0]){
            dp[0][j]++;
        }
    }
    
    for(int i=1;i<B.size();i++){
        dp[i][0]=0;
        for(int j=1;j<T.size();j++){
            dp[i][j]=dp[i][j-1];
            if(B[i]==T[j]){
                dp[i][j]=(dp[i][j]+dp[i-1][j-1])%1000000007;
            }
        }
    }
    cout << dp[B.size()-1][T.size()-1] << endl;
}



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

char a[1005];
char b[1005];

int main()
{
	scanf("%s%s",a+1,b+1);
	int len1 = strlen(a+1),len2 = strlen(b+1);
	int ans = len2;

	int n = len1-len2+1;
	for(int i = 1;i<=n;++i){
		int sum = 0;
		for(int j = 1;j<=len2;++j){
			if(a[i+j-1] == b[j]) sum++;
		}
		if(len2-sum<ans) ans = len2-sum;
	}
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << 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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

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

int main(){

  ll n,k;cin>>n>>k;

  if(n<k)out(1);
  else if(n==k)out(0);
  else {
    if(k==1)out(0);
    else out(n-k);
  }

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;


int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  double res = 0;
  while (n--) {
    double x; cin >> x;
    string u; cin >> u;
    if (u == "JPY") {
      res += x;
    } else {
      res += 380000 * x;
    }
  }
  cout << fixed << setprecision(15) << res << '\n';
}

Measured memory_bytes: 256
//In the name of He
#include <bits/stdc++.h>
#define pb push_back
#define X first
#define Y second
const bool DEBUG = false;
#define cerr if(DEBUG)cerr
#define bit(num,i) ((num>>i)&1)

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const long long maxn = 3e5 + 5 + 1;
const long long INF = 4e18 ;
const long long M = 1e9 + 7;
const int lg = 21;

#pragma GCC Optimize("Ofast")

ll x,y;

int main(){
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> x >> y;
    if ( (x/y)*y == x ){
        return cout << "-1", 0;
    }
    for(ll i = 2*x; i <= 1e18; i += x){
        if ( (i/y)*y != i ){
            return cout << i, 0;
        }
    }
    cout << "-1";
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
#pyrival orz
import os
import sys
from io import BytesIO, IOBase

"""
    for _ in range(int(input())):
    n,m=map(int,input().split())
    n=int(input())
    a = [int(x) for x in input().split()]
"""

def main():
    from functools import lru_cache

    @lru_cache(None)
    def solve(n):
        if n==0:
            return 0
        c=bin(n).count('1')
        return 1+solve(n%c)
    n=int(input())
    s=input()

    ct=s.count('1')

    mod=1
    if ct>1:
        mod*=ct-1
    mod*=ct+1

    p,g=1,0
    for x in s:
        g*=2
        if x=='1':
            g+=1
        g%=mod

    s=s[::-1]
    ans=[0]*len(s)
    for i,x in enumerate(s):
        p%=mod
        if x=='1':
            if ct==1:
                p*=2
                continue
            else:
                ans[i]=1+solve((g-p)%(ct-1))
        else:
            ans[i]=1+solve((g+p)%(ct+1))
        p*=2
    ans=ans[::-1]
    for x in ans:
        print(x)
# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 76680
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include<complex>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> pr;
typedef complex<double> com;


int main(){
	int n,m,sum=0;
	cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	cin >>m;
	vector<pr> b(m);
	rep(i, m) {
		cin >> b[i].first >> b[i].second;
	}
	rep(i, m) {
		cout << sum - a[b[i].first - 1] + b[i].second << endl;
	}
	return 0;
}
//Ctrl+Aを使わない

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int N, C; cin >> N >> C;
    vvi D(C, vi(C));
    REP(i, C)
        REP(j, C) cin >> D[i][j];
    vvi A(N, vi(N));
    REP(i, N){
        REP(j, N) {
            int a;  cin >> a;
            a--;
            A[i][j] = a;
        }
    }

    vvi sum(3, vi(C,0));
    REP(i,C) {
        REP(x,N){
            REP(y,N) {
                int p = (x + y) % 3;
                sum[p][i] += D[A[x][y]][i];
            }
        }
    }

    int ans = INF;
    REP(i,C) {        
        REP(j,C){
            if (j == i) continue;
            REP(k,C) {
                if (k == i || k == j) continue;

                ans = min(ans, sum[0][i] + sum[1][j] + sum[2][k]);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

string add_string ( string s, string add_s, int add_times ) {
    if ( add_times == 0 ) return s;
    return add_string(s, add_s, add_times-1) + add_s;
}

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    string ans;
    ans = add_string(ans, "R", (tx-sx));
    ans = add_string(ans, "U", (ty-sy));
    ans = add_string(ans, "L", (tx-sx));
    ans = add_string(ans, "D", (ty-sy));

    ans = add_string(ans, "D", 1);
    ans = add_string(ans, "R", (tx-sx+1));
    ans = add_string(ans, "U", (ty-sy+1));
    ans = add_string(ans, "L", 1);
    ans = add_string(ans, "U", 1);
    ans = add_string(ans, "L", (tx-sx+1));
    ans = add_string(ans, "D", (ty-sy+1));
    ans = add_string(ans, "R", 1);

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

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        string s;
        cin >> s;
        string t = s;
        reverse(all(t));
        Int cnt = 0;
        for (int i = 0; i < s.size(); ++i) {
            if (s[i] != t[i]) cnt++;
        }
        Int ans = cnt / 2;
        cout << ans << endl;

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[]
for i in range(n):
  a.append(str(input()))

a=sorted(a)
b=[]
c=[]

tmp="."
count=0

for i in range(n):
  if tmp != a[i]:
    b.append(tmp)
    c.append(count)
    tmp=a[i]
    count=1
  else:
    count += 1
 
b.append(tmp)
c.append(count)
k=sorted(c)[-1]
for i in range(len(b)):
  if c[i]==k:
    print(b[i])


Measured memory_bytes: 99160
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <cassert>
using namespace std;

int main(){
    long long N;
    cin >> N;
    long long ans = N*(N-1)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);
  static ArrayList<ArrayList<Integer>> g = new ArrayList<>();
  static int[] dist, color, visited;
  static int visitedCount = 0;

  public static void main(String[] args) {
    int N = sc.nextInt();
    int M = sc.nextInt();
    dist = new int[N];
    color = new int[N];
    visited = new int[N];
    for (int i = 0; i < N; i++) {
      g.add(new ArrayList<Integer>());
      dist[i] = -1;
    }
    for (int i = 0; i < M; i++) {
      int A = Integer.parseInt(sc.next()) - 1;
      int B = Integer.parseInt(sc.next()) - 1;
      g.get(A).add(B);
      g.get(B).add(A);
    }
    int Q = sc.nextInt();
    int[] V = new int[Q];
    int[] D = new int[Q];
    int[] C = new int[Q];
    for (int i = 0; i < Q; i++) {
      V[i] = Integer.parseInt(sc.next()) - 1;
      D[i] = Integer.parseInt(sc.next());
      C[i] = Integer.parseInt(sc.next());
    }
    for (int i = Q - 1; i >= 0; i--) {
      update(V[i], C[i], D[i]);
    }
    PrintWriter writer = new PrintWriter(System.out);
    for (int i = 0; i < N; i++) {
      writer.println(color[i]);
    }
    writer.flush();
  }

  static void update(int v, int c, int d) {
    visitedCount++;
    ArrayList<Integer> cur = new ArrayList<>();
    cur.add(v);
    while (d >= 0) {
      ArrayList<Integer> next = new ArrayList<>();
      for (int i = 0; i < cur.size(); i++) {
        int p = cur.get(i);
        if (dist[p] >= d) continue;
        dist[p] = d;
        if (color[p] == 0) color[p] = c;
        for (int n : g.get(p)) {
          if (visited[n] == visitedCount) continue;
          visited[n] = visitedCount;
          next.add(n);
        }
      }
      --d;
      cur = next;
    }
  }

}


Measured memory_bytes: 107848
N = int(input())
L = [int(i) for i in input().split()]
l = sorted(L)
#print(l)
while len(l) > 1:
  for i in range(1,len(l)):
    l[i] = l[i] % l[0]
  while 0 in l:
    l.remove(0)
  l.sort()
print(l[0])

Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
//#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
vector<int>w;
int n;
vector<int>b;
vector<vector<int>>e;
void _bdfs(int v){
    rep(i,e[v].size()){
        int next=e[v][i];
        if(b[next]==INF&&next!=n-1){
            b[next]=b[v]+1;
            _bdfs(next);
        }
    }
}
void _wdfs(int v){
    rep(i,e[v].size()){
        int next=e[v][i];
        if(w[next]==INF&&next!=0){
            w[next]=w[v]+1;
            _wdfs(next);
        }
    }
}
signed main(){
    cin>>n;
    vector<vector<int>>edge(n,vector<int>());
    rep(i,n-1){
        pii t; cin>>t.first>>t.second;
        --t.first,--t.second;
        edge[t.first].push_back(t.second);
        edge[t.second].push_back(t.first);
    }
    e=edge;
    vector<int>_b(n,INF); _b[0]=0;
    vector<int>_w(n,INF);_w[n-1]=0;
    b=_b; w=_w;
    _bdfs(0);
    _wdfs(n-1);
    int wcnt=0;int bcnt=0;
    rep(i,n)if(b[i]<=w[i])bcnt++; else wcnt++;
    if(bcnt>wcnt)cout<<"Fennec"<<endl;
    else cout<<"Snuke"<<endl;
}


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

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

    int flag = 0;
    if(s[2]==s[3]&&s[4]==s[5]){
        flag++;
    }
    if(flag == 1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }


}

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

string s, t;
int q;
int a, b, c, d;
int cntS[100001];
int cntT[100001];

signed main() {
	cin >> s >> t;
	cin >> q;
	
	for (int i = 1; i <= s.length(); i++) {
		if (s[i - 1] == 'A') {
			cntS[i] = cntS[i - 1] + 1;
		}
		else {
			cntS[i] = cntS[i - 1] + 2;
		}
	}
	for (int i = 1; i <= t.length(); i++) {
		if (t[i - 1] == 'A') {
			cntT[i] = cntT[i - 1] + 1;
		}
		else {
			cntT[i] = cntT[i - 1] + 2;
		}
	}
	
	for (int i = 0; i < q; i++) {
		cin >> a >> b >> c >> d;
		a--; c--;
		
		if ((cntS[b] - cntS[a]) % 3 == (cntT[d] - cntT[c]) % 3) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1664
#include<algorithm>
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main()
{
	pair<int,long>a[100001];
	long n,m,ans;
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>a[i].first>>a[i].second;
	sort(a,a+n);
	for(int i=0;m>0;i++)
	{
		ans+=a[i].first*min(m,a[i].second);
		m-=a[i].second;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
	int s[100][100]={}, d[100]={},e[100]={}, a, b, i, j;
	scanf("%d %d", &a, &b);
	for(i=0;i<a;i++){
		for(j=0;j<b;j++){
			scanf("%d", &s[i][j]);
		}
	}
	for(i=0;i<b;i++){
		scanf("%d", &d[i]);
	}
	for(i=0;i<a;i++){
		for(j=0;j<b;j++){
			e[i]=e[i]+s[i][j]*d[j];
		}
		printf("%d\n", e[i]);
	}
}


Measured memory_bytes: 2124
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL n,m;
    cin >> n >> m;

    LL x = 2;
    vector<LL> a;
    LL tmp = m;
    while(m > 1 && x*x <= tmp){
        if(m%x == 0){
            a.push_back(x);
            m/= x;
            x--;
        }
        x++;
    }
    if(m > 1){
        a.push_back(m);
    }
    m = tmp;

    vector<vector<bool>> dp(a.size()+1,vector<bool>(n,false));
    dp[0][1] = true;

    LL divisor = 1333333333333;

    for(LL i = 0; i < a.size(); i++){
        for(LL j = 0; j < n; j++){
            dp[i+1][j] = dp[i][j] || dp[i+1][j];
            if(dp[i][j]){
                if(j*a[i] >= n){
                    divisor = min(divisor,j*a[i]);
                }else{
                    dp[i+1][j*a[i]] = true;
                }
            }
        }
    }

    if(n == 1){
        divisor = 1;
    }

    cout << m/divisor << endl;
    
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

long dp[60][110][2510] = { 0 };

void solve() {
  long n, k;
  cin >> n >> k;

  // a: 段目
  // b: 未確定頂点
  // c: 確定済み奇妙さ

  dp[0][0][0] = 1;

  for (long a = 0; a < n; a++) {
    for (long b = 0; b <= n * 2; b++) {
      for (long c = 0; c <= n * n; c++) {
        // 両確定（同じ値）
        if (c+b < 2510) {
          dp[a+1][b][c+b] += dp[a][b][c];
          dp[a+1][b][c+b] %= MOD;
        }
        // 両確定（既存の未確定頂点と結ぶ）
        if (b-2 >= 0 and c+b-2 < 2510) {
          dp[a+1][b-2][c+b-2] += dp[a][b][c] * (b/2) * (b/2);
          dp[a+1][b-2][c+b-2] %= MOD;
        }
        // 両未確定
        if (b+2 < 110 and c+b+2 < 2510) {
          dp[a+1][b+2][c+b+2] += dp[a][b][c];
          dp[a+1][b+2][c+b+2] %= MOD;
        }
        // 片側確定
        if (c+b < 2510) {
          dp[a+1][b][c+b] += dp[a][b][c] * b;
          dp[a+1][b][c+b] %= MOD;
        }
      }
    }
  }
  cout << dp[n][0][k] << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 108800
#include<iostream>

using namespace std;

int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	if (0<= (x-r) && (x+r) <= W && 0<= (y-r) && (y+r) <= H) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}

	return 0;
}

Measured memory_bytes: 3096
#include<stdio.h>
int main(void)
{
	int a,s,d[9],f,g,h,i,j,z;
	scanf("%d",&a);
	while(a!=0){
		for(i=1;i<=8;i++){
			d[i]=0;
		}
		g=0;
		h=0;
		scanf("%d",&s);
		g=10;
		for(i=1;i<=8;i++){
			d[i]=s%g;
			s=s/10;

		}
		for(i=1;i<=8;i++){
			for(j=i+1;j<=8;j++){
				if(d[i]<d[j]){
					f=d[i];
					d[i]=d[j];
					d[j]=f;
				}
			}
		}
		z=1;
		for(i=8;i>=1;i--){
			h=d[i]*z+h;
			z*=10;
		}
		z=1;
		for(i=1;i<=8;i++){
			g=d[i]*z+g;
			if(i==1){
				g=g-10;
			}
			z*=10;
	//		printf("%d = %d\n",i,g);

		}
	//	printf("g = %d h = %d\n",g,h);
	printf("%d\n",h-g);
	a--;
	}
	return 0;
}

Measured memory_bytes: 1028
n=int(input())
a=list(map(int,input().split()))

p=[]
for i in range(n):
    p.append(a[i]-1)
    p.append(a[i])
    p.append(a[i]+1)

from collections import Counter

c=Counter(p).most_common()

m = list(c)[0][0]

ans=0

for i in range(n):
    if abs(a[i]-m)<=1:
        ans+=1

print(ans)


Measured memory_bytes: 35024
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
#define int long long

signed main() {
  int n;
  cin >> n;
  int d[n];
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    d[a - 1] = i;
  }
  set<int> s;
  s.insert(-1);
  s.insert(n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    auto itr = s.lower_bound(d[i]);
    int r = *itr;
    itr--;
    int l = *itr;
    ans += (r - d[i]) * (d[i] - l) * (i + 1);
    s.insert(d[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11136
// abc046_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int a, b, c;
    cin >> a >> b >> c;
    
    set<int> st;
    st.insert(a);
    st.insert(b);
    st.insert(c);
    int ans = st.size();
    print(ans);

    return 0;
}


Measured memory_bytes: 256
N, L = map(int, input().split())

apples = [L + i - 1 for i in range(1, N + 1)]

minabs = abs(apples[0])
minabsidx = 0
for i, a in enumerate(apples):
    if abs(a) < minabs:
        minabs = abs(a)
        minabsidx = i

print(sum(apples) - apples[minabsidx])


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



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

    int n;
    cin >> n;

    n <<= 1;

    vector< int > tab(n);
    
    for (int& i : tab)
        cin >> i;

    sort(begin(tab), end(tab));

    int res = 0;

    for (int i = 0; i < tab.size(); i += 2) 
        res += tab[i];

    cout << res << '\n';
}


Measured memory_bytes: 256
N, M, Q = gets.split.map(&:to_i)
X = []
Q.times do
  X << gets.split.map(&:to_i)
end

ans = 0
(1..M).to_a.repeated_combination(N).each do |y|
  tmp = X.map{|a, b, c, d| y[b - 1] - y[a - 1] == c ? d : 0}.sum
  ans = tmp if tmp > ans
end
puts ans

Measured memory_bytes: 15572
#include <iostream>

using namespace std;

//https://atcoder.jp/contests/abc001/submissions/5701454

int main(){
    int n;
    cin >> n;
    int s[n];
    for(int i = 0; i < n; ++i)
    {
        cin >> s[i];
    }

    //単調 >0: 増加, <0: 減少, 0:未決定 
    int tan = 0;
    int cnt = 1;

    for(int i = 0; i < n-1; ++i)
    {
        if(tan == 0)
        {
            if(s[i] < s[i+1])tan = 1;
            if(s[i] > s[i+1])tan = -1;
        }
        else if(tan > 0)
        {
            if(s[i] > s[i+1])
            {
                tan = 0;
                ++cnt;
            }
        }
        else if(tan < 0)
        {
            if(s[i] < s[i+1])
            {
                tan = 0;
                ++cnt;
            }
        }
    }

    





    cout << cnt << endl;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

import sys, math, random
import numpy as np

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column
# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']
# S.replace('ABC','X') # "testABCABC" -> "testXX"
# S=numpp.assaray(S)=="#"
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LLS(): return [list(sys.stdin.readline().rstrip()) for _ in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()



def main():
    N, K = list(map(int,input().split()))
    if K==1:
        print(0)
    else:
        print((N-(K-1))-1)
    
    
if __name__ == "__main__":
    main()

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

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

using namespace std;


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


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

	int a, b;
	cin >> a >> b;
	int c;
	cin >> c;
	if (a + b >= c)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	cout << endl;

}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
#include<random>

//by Skeef79

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>
#define what_is(x) cout<<#x<<" is "<<x<<en;

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];
}

void solve()
{
	string s;
	cin >> s;
	set<char>st;
	for (auto to : s)
		st.insert(to);
	if (st.count('A') && st.count('B'))
		cout << "Yes";
	else
		cout << "No";
}

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

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	int tst = 1;
	//cin >> tst;
	while (tst--)
		solve();

}

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

int main()
{
        double N, M;
        double sum = 0;
        cin >> N >> M;
        vector<double> A(N);

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

        int count = 0;

        for(int i = 0; i < N; i++)
        {
                if(A[i] >= sum / (4 * M) )
                {
                        count++;
                }
        }

        if(count >= M)
        {
                cout << "Yes" << endl;
        }
        else
        {
                cout << "No" << endl;
        }

        return 0;
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
int main(){
  int a,b;cin>>a>>b;
  cout<<(a-1)*(b-1)<<endl;
  return 0;
}


Measured memory_bytes: 768
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, A: "List[int]"):
    f = (sum(A[::2]) - sum(A[1::2])) // 2

    fs = [f]
    for a in A[:-1]:
        fs.append(a - fs[-1])

    ret = ' '.join([str(2 * f) for f in fs])
    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    result = solve(N, A)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 29316
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{

	public static void main(String[] args) throws Exception{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		while(true){

			String[] line = br.readLine().split(" ");
			int x = Integer.parseInt(line[0]);
			int y = Integer.parseInt(line[1]);

			if(x == 0 && y == 0){
				break;
			}

			if(x <= y){
				sb.append(x + " " + y + "\n");
			}else{
				sb.append(y + " " + x + "\n");
			}

		}

		System.out.print(sb);

	}
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cerr << #x << " " << x << endl
#define _ << " " <<
#define debug(...) fprintf(stderr, __VA_ARGS__)
typedef long long ll;
typedef std::pair<int, int> pii;
#define X first
#define Y second
#define double long double
typedef double db;
using namespace std;

const int MaxN = 200100;
const int Mod = 1e9 + 7;

int N;
int b[MaxN];
vector<int> V;
vector<int> ans;

void solve() {
  FOR(i, 1, N+1) {
    if (V[i] > i) {
      cout << -1 << endl;
      exit(0);
    }
  }

  FOR(tt, 1, N + 1) {
    int ind = -1, val = 10000;
    FOR(i, 1, (int)V.size()) {
      if (i - V[i] <= val) {
	val = i - V[i];
	ind = i;
      }
    }

    ans.push_back(ind);
    V.erase(V.begin() + ind);
  }

  
  ans.push_back(0);
  reverse(ans.begin(), ans.end());

  FOR(i, 1, N+1) { cout << ans[i] << endl;}
}

void load() {
  cin >> N;
  V.push_back(0);
  REP(i, N) { cin >> b[i + 1]; V.push_back(b[i+1]); }
}

void check() {
  assert((int)ans.size() == N+1);
  vector<int> a;
  a.push_back(0);
  
  FOR(i, 1, N + 1) {
    assert(ans[i] <= i);
    a.insert(a.begin() + ans[i], ans[i]);
  }

  FOR(i, 1, N+1) assert(a[i] == b[i]);
}

int main() {
  ios_base::sync_with_stdio(false);
  load();	
  solve();
  check();
  return 0;
}




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

using namespace std;

int main()
{
	int k,a,b;
	cin>>k>>a>>b;
	
	int mod=k-a%k;
	if (a+mod<=b || a%k==0)
		cout<<"OK"<<endl;
	else
		cout<<"NG"<<endl;
}	

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

int main(){
    char b;
    cin >> b;
    
    char ans = (b == 'A')? 'T' : (b == 'T')? 'A' : (b == 'C')? 'G' : 'C';
    cout << ans << endl;
    return 0;
}

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

int main() {
  string x , y , z ;
  cin >> x >> y >> z ; 
  
 char X = x[0] - 32 ;
 char Y = y[0] - 32 ;
 char Z = z[0] - 32 ;
  
  cout << X << Y << Z << endl;
}



Measured memory_bytes: 256
// I can

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const ll maxn=1000001,mod=1e9+7;

ll xxor(ll b){
ll hehe=b%4;
if(hehe==0) hehe=b;
else if(hehe==1) hehe=1;
else if(hehe==2) hehe=b+1;
else  hehe=0;
return hehe;
}

int main(){
sync

ll a,b;
cin>>a>>b;
ll ans=xxor(a-1)^xxor(b);
cout<<ans;

return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

int main() {
    ll n, t;
    cin >> n >> t;
    ll mincost = 10000;
    ll res = -1;
    for (ll i = 0; i < n; ++i) {
        ll c, u;
        cin >> c >> u;
        if (u <= t) {
            if (c <= mincost) {
                res = i;
                mincost = c;
            }
        }
    }
    if (mincost <= 1000) {
        cout << mincost << endl;
    } else {
        cout << "TLE" << endl;
    }
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

const int maxn = 105;
const int m = 1e9+7;

LL dp[maxn][270];
int cnt;
map<string,int> mp;
vector<string> vs;
set<int> bad;

bool is_bad(string s){
    string ss = s.substr(1,3);
    string ss2 = s.substr(0,3);
    if(ss == "ACG" || ss == "AGC" || ss == "CAG") return true;
    if(ss2 == "ACG" || ss2 == "AGC" || ss2 == "CAG") return true;
    if(s[0] == 'A' && s[1] == 'C' && s[3] == 'G') return true;
    if(s[0] == 'A' && s[2] == 'C' && s[3] == 'G') return true;
    return false;
}

void init(int d,string s){
    if(d == 4){
        vs.push_back(s);
        if(is_bad(s)){
            bad.insert(cnt);
        }
        dp[0][cnt] = 1;
        mp[s] = cnt++;
        return;
    }
    init(d+1,s+"A");
    init(d+1,s+"C");
    init(d+1,s+"G");
    init(d+1,s+"T");
}

int get_id(string s){
    return mp[s.substr(1,4)];
}

int main()
{
    cnt = 0;
    init(0,"");
    _for(i,1,98){
        _for(j,0,256){
            string s = vs[j];
            if(is_bad(s)) {
                dp[i][j] = (dp[i-1][j]*4 + dp[i][j])%m;
                continue;
            }

            int a = get_id(s+"A");
            int b = get_id(s+"C");
            int c = get_id(s+"G");
            int d = get_id(s+"T");
            dp[i][a] = (dp[i-1][j] + dp[i][a])%m;
            dp[i][b] = (dp[i-1][j] + dp[i][b])%m;
            dp[i][c] = (dp[i-1][j] + dp[i][c])%m;
            dp[i][d] = (dp[i-1][j] + dp[i][d])%m;
        }
    }

    int N;scanf("%d",&N);
    //cout << cnt << endl;
    if(N == 3){
        cout << 61 <<endl;
        return 0;
    }

    LL ans = 0;

    _for(j,0,256){
        string s = vs[j];
        if(is_bad(s)){
            ans = (ans + dp[N-4][j])%m;
            //cout << s << endl;
        }
    }

    LL d = 1;
    _for(i,0,N){
        d *= 4;
        d %= m;
    }
    cout << (d - ans + m)%m << endl;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int gcd(int a,int b)
{
	if(a%b==0)return b;
	else return gcd(b,a%b);
} 
int main()
{
	int gcd(int a,int b);
	long long A,B,t1,t2,t3,ans,C,D,g;
	while(~scanf("%lld%lld%lld%lld",&A,&B,&C,&D))
	{
		t1=B/C-(A-1)/C;
		t2=B/D-(A-1)/D;
		g=C*D/gcd(C,D);
		t3=B/g-(A-1)/g;
		printf("%lld\n",B-A+1-(t1+t2-t3));
	}
}

Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <cassert>

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

using namespace std;

int f(int x) {
    if(x == 0) {
        return 0;
    }
    return f(x % __builtin_popcount(x)) + 1; 
}


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

    int popcount_orig = 0;
    rep(i, N) {
        if(S[i] == '1')
            popcount_orig++;
    }

    auto pc0 = popcount_orig + 1;
    auto pc1 = popcount_orig - 1;

    int r0 = 0;
    int r1 = 0;
    rep(i, N) {
        int b = S[i] - '0';
        r0 = (r0*2) % pc0;
        if(pc1 != 0)
            r1 = (r1*2) % pc1;
        r0 += b;
        r1 += b;
    }
    vector<int> pow0(N);
    vector<int> pow1(N);
    int p0 = 1;
    int p1 = 1;
    for(int i=N-1; i>=0; --i) {
        pow0[i] = p0;
        pow1[i] = p1;
        p0 *= 2;
        p0 %= pc0;
        p1 *= 2;
        if(pc1 != 0)
            p1 %= pc1;
    }

    rep(i, N) {
        int b = S[i] - '0';
        if(b == 1) {
            if(pc1 > 0)
                cout << f((r1 - pow1[i] + pc1) % pc1) + 1<< endl;
            else
                cout << 0 << endl;
        } else {
            cout << f((r0 + pow0[i]) % pc0) + 1 << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 4676
import java.util.Scanner;
 
public class Main {
	public static void main (String args[]) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		System.out.println((n * (n-1))/ 2 + (m * (m-1))/ 2);
	}
}

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

int main(){
    int a, b;
    
    for(int i = 0 ; i < 3000 ; i++){
        cin >> a >> b;
        if(a < b){
            cout << a << " " << b << endl; 
        }
        else if((a == 0) && (b == 0)){
            break;
        }
        else if(a >= b){
            cout << b << " " << a << endl;
        }
    }
    
    return 0;
    
}


Measured memory_bytes: 3092
using System;
using System.Linq;

namespace B_001_60
{
    internal class Program
    {
        private static void Main(string[] args)
        {

            new Logic_C().Start();
         
        }

        public class Logic_C
        {
            public void Start()
            {
                var str1 = Console.ReadLine().Split(' ');
                var str2 = Console.ReadLine().Split(' ');

                var N = Convert.ToInt32(str1[0]);
                var T = Convert.ToInt32(str1[1]);
                var t = str2;

                var time = 0;

                for (int i = 0; i < str2.Length - 1; i++)
                {
                    time += Math.Min(T, Convert.ToInt32(t[i + 1]) - Convert.ToInt32(t[i]));
                }
                time += T;
                Console.WriteLine(time);
            }
        }
}
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a > c){
    cout << "NO" << endl;
  }
  else if (a+b>=c){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
const lli mod = 1e9+7;

lli n, m;

lli modfact(lli x){
	if(x == 0) return 1;
	return (x*modfact(x-1)%mod)%mod;
}

int main(void){
	cin >> n >> m;
	lli ans;
	if(n == m){
		ans = (2*modfact(n)*modfact(m))%mod;
	}else if(n == m-1 || n == m+1){
		ans = (modfact(n)*modfact(m))%mod;
	}else{
		ans = 0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5132
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//解説AC
int main(){
  int K; cin >> K;
  vector<ll> A(K);
  for(int i = 0; i < K; i++){ cin >> A[i];}
  
  ll L = 2; ll R = 2;
  
  for(int i = K-1; i >= 0; i--){
    L = (( L + A[i] - 1)/A[i])*A[i]; R = (R/A[i])*A[i] + ( A[i] - 1);
    if( L > R){ cout << -1 << endl; return 0;}
  }
  
  cout << L << " " << R << endl; return 0;}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,i,j,len;

    string s;

    cin>>s;

    len = s.size();

    int l = len/2,cnt = 0;
   l--;
   j = len-1;
   for(i=0;i<=l;i++)
   {
       if(s[i]!=s[j])cnt++;
        j--;
   }

   cout<<cnt<<endl;
}



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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

int main(void){
    int n;
    cin >> n;
    cout << (n+1)/2 << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
import itertools

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
P = tuple(LI())
Q = tuple(LI())

li = list(itertools.permutations(range(1,N+1)))

p_index = li.index(P)
q_index = li.index(Q)
print(abs(p_index-q_index))


Measured memory_bytes: 13920
#include <stdio.h>
int main()
{
	int n,i;
	long long l[87];
	scanf("%d",&n);
	l[0]=2;
	l[1]=1;
	for(i=2;i<=n;i++)
	{
		l[i]=l[i-2]+l[i-1];
	}
	printf("%lld",l[n]);
	return 0;
}

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

int main() {
    int d, n;
    cin >> d >> n;

    int ans = 0;
    if(n == 100) {
        n++;
    }
    for(int i = 1; i <= n; i++) {
        if(d == 0) {
            ans++;
        }

        if(d == 1) {
            ans = 100 * i;
        }

        if(d == 2) {
            ans = 10000 * i;
        }
    }

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


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

int main() {
  int count,i;
  string number;
  cin >> number;
  for(i=0;i<(int)number.size()-2;i++){
    if(number[i] == number[i+1] && number[i+1] == number[i+2]){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256