akhauriyash/Code-Regression huggingface dataset:
using System;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		int[] p=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int[] a=new int[n],b=new int[n];
		for(int i=0;i<n;i++){b[p[i]-1]=(i+1)*1;}
		a[0]=1;
		b[0]--;
		int m=0;
		for(int i=1;i<n;i++){
			a[i]=a[i-1]+1;
			b[i]-=a[i-1]+1;
			if(b[i]>=b[i-1]){
				a[i]+=b[i]-b[i-1]+1;
				b[i]=b[i-1]-1;
			}
			m=Math.Min(m,b[i]);
		}
		for(int i=0;i<n;i++){b[i]-=m-1;}
		Console.WriteLine(String.Join(" ",a));
		Console.WriteLine(String.Join(" ",b));
	}
}

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

const int MAXN = 50001;

bool prime[MAXN] = {true, true};

int main()
{
  for (int i = 2; i * i < MAXN; i++){
    for (int j = i * i; j < MAXN; j += i){
      prime[j] = true;
    }
  }
  
  int n;
  while (scanf("%d", &n), n){
    int cnt = 0;
    for (int i = 2; i <= n / 2; i++){
      if (!prime[i] && !prime[n - i]){ // i + (n - i) = n
        cnt++;
      }
    }
    printf("%d\n", cnt);
  }

  return (0);
}

Measured memory_bytes: 1236
def main
  n = gets.chomp.to_i

  words = []
  n.times do
    w = gets.chomp
    if words.index(w)
      puts 'No'
      return
    end

    last_w = words[-1]
    if last_w && last_w[-1] != w[0]
      puts 'No'
      return
    end

    words << w
  end

  puts 'Yes'
end

if __FILE__ == $0
  main
end


Measured memory_bytes: 1788
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <sstream>
#include <iostream>
#include <time.h>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <string.h>
#include <bitset>
#define sf scanf
#define pf printf
#define lf double
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define ll long long
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
#define eps 1e-7
#define zero(x) (((x) > 0? (x):(-x)) < eps)
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <sstream>
#include <iostream>
#include <time.h>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <string.h>
#include <bitset>

using namespace std;
//https://codeforces.com/contest/1238/problems
//https://codeforces.com/contest/1238/submit

int main(){
    int n;
    cin >> n;
    string a;
    cin >> a;

for(int i = 0; i < a.length(); i ++){
    a[i] += n;
    if(a[i] > 'Z'){
        a[i] -= 'Z';
        a[i] += 'A';
        a[i] -= 1;
    }
}
    cout << a <<endl;



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m;i>n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl
#define Vecpr(K,L1,L2,N) vector<pair<L1,L2>> K(N)
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,R) vector<vector<L>> K(N, vector<L>(M,R))
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C=0,D=0,E=0,F=INF,G=INF,H=0,N,M,K,sum=0;
  cin >> N >> K;
  string S;
  cin >> S;
  rep(i,1,N)if(S[i]==S[i-1])sum++;
  sum+=2*K;
  if(sum>=N)sum=N-1;
  Out(sum);
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
main(){
    int a[4];
    cin>>a[0]>>a[1]>>a[2]>>a[3];
    sort(a,a+4);
    if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
   
}

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

using namespace std;

int main() {
	int K,S;
	cin >> K>>S;

	int X, Y;

	int count = 0;

	for (X = 0; X <= K; ++X) {
		for (Y = 0;Y <= K; ++Y) {	
				if (S-K<=X+Y && X+Y <= S) {
					count = count + 1;
			}
		}
	}

cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i,m,n) for(long long i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

int main(){
	REP(i,1,10){
		REP(j,1,10){
			cout<<i<<"x"<<j<<"="<<i*j<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2988
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n, a, b; cin >> n >> a >> b;
	cout << min(a, b) << " " << max(0, b - (n - a)) << endl;
}

Measured memory_bytes: 3600
while True:
	sousa=input().split()
	sousa=[int(sousa[0]),int(sousa[1])]
	if sousa==[0,0]:break
	yama=[]
	for k in range(sousa[0]):yama.append(k+1)
	yama=yama[::-1]
	for r in range(sousa[1]):
		[p,c]=input().split()
		[p,c]=[int(p),int(c)]
		yama[:p+c-1]=yama[p-1:p+c-1]+yama[:p-1]
	print(yama[0])

Measured memory_bytes: 7524
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define mod 1000000007
#define pll pair<long long,long long>
using namespace std;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
bool prime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return true;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    vector<int>v;
    while(n>0){
        int x=n%26;
        v.pb(x);
        if(x==0)n=n-26;
        n=n/26;
    }
    for(int i=v.size()-1;i>=0;i--){
        if(v[i]==0)cout<<'z';
        else {
            char c=v[i]-1+'a';
            cout<<c;
        }
    }
    return 0;
}
    

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

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

int main() {

    int N;
    int t[110000], x[110000], y[110000];
    cin >> N;
    t[0] = x[0] = y[0] = 0;  // 初期状態
    for (int i = 0; i < N; ++i) cin >> t[i+1] >> x[i+1] >> y[i+1];  // 1-index にしておく

    bool can = true;
    for (int i = 0; i < N; ++i) {
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dt < dist) can = false;
        if (dist % 2 != dt % 2) can = false;  // dist と dt の偶奇は一致する必要あり！
    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	int A[100000];
	rep(i, N) cin >> A[i];
	sort(A, A + N);

	int saidai = A[N - 1];
	int saishou = A[0];

	int kotae1[100000], kotae2[100000];
	for (int i = 1; i < N - 1; i++) {
		if (A[i] < 0) {
			kotae1[i] = saidai;
			kotae2[i] = A[i];
			saidai -= A[i];
		}
		else {
			kotae1[i] = saishou;
			kotae2[i] = A[i];
			saishou -= A[i];
		}
	}
	kotae1[N - 1] = saidai;
	kotae2[N - 1] = saishou;

	co(saidai - saishou);
	rep1(i, N - 1) {
		cosp(kotae1[i]);
		co(kotae2[i]);
	}

	Would you please return 0;
}

Measured memory_bytes: 3072
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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


signed main(void) {
    int k,x;
    cin >> k >> x;
    if(500*k >= x){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<cctype>
using namespace std;
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;}
const long long INF = 1LL << 60;

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

Measured memory_bytes: 256
open Scanf
open Printf

let flip f x y = f y x

let rec range a b = if a >= b then [] else a :: range (a+1) b

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)

let rec for_iter a b f = if a >= b then [] else let x = f a in x :: for_iter (a+1) b f
let rec for_iter_ a b f = if a >= b then () else (f a; for_iter_ (a+1) b f)

let () =
  let [x; a; b] = read_ints 3 in
  printf "%s\n" @@ if (abs (x-a)) < (abs (x-b)) then "A" else "B"


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

int main(){
  int A,B,K;
  cin>>A>>B>>K;
  vector<int> vec;
  
  int minAB = min(A,B);
  
  for(int i=0;i<minAB;i++){
    if(A%(i+1)==0 && B%(i+1) ==0)
      vec.push_back(i+1);
  }
  
  reverse(vec.begin(),vec.end());
  cout<<vec.at(K-1)<<endl;
}

Measured memory_bytes: 256
from collections import deque
H, W = map(int, input().split())
CY, CX = map(lambda x: int(x)-1, input().split())
DY, DX = map(lambda x: int(x)-1, input().split())

gridgraph = [input() for _ in range(H)]
q = deque()
q.append([CY, CX])
# 更新されるなら追加
adjacent = [[1, 0], [0, 1], [-1, 0], [0, -1]]
INF = float("inf")
distant = [[INF]*W for _ in range(H)]
distant[CY][CX] = 0
while len(q):
    cy, cx = q.popleft()
    for dy, dx in adjacent:
        ny, nx = cy+dy, cx+dx
        if ny < 0 or ny >= H or nx < 0 or nx >= W:
            continue
        if gridgraph[ny][nx] == "." and distant[ny][nx] > distant[cy][cx]:
            distant[ny][nx] = distant[cy][cx]
            q.appendleft([ny, nx])
    for i in range(-2, 3, 1):
        for j in range(-2, 3, 1):
            target_y, target_x = cy+i, cx+j
            if target_y < 0 or target_y >= H or target_x < 0 or target_x >= W:
                continue
            if gridgraph[target_y][target_x] == "." and distant[target_y][target_x] > distant[cy][cx]+1:
                distant[target_y][target_x] = distant[cy][cx]+1
                q.append([target_y, target_x])
if distant[DY][DX] == INF:
    print(-1)
else:
    print(distant[DY][DX])


Measured memory_bytes: 115172
#define _CRT_SECURE_NO_WARNINGS

//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
int d[10][10];

int Min(int a, int b) {
	if (a < b)return a;
	return b;
}

void warshall_floyd(int n) { // nは頂点数
	for (int i = 0; i < n; i++)      // 経由する頂点
		for (int j = 0; j < n; j++)    // 開始頂点
			for (int k = 0; k < n; k++)  // 終端
				d[j][k] = Min(d[j][k], d[j][i] + d[i][k]);
}

int main() {
#ifdef DEBUG

#endif
	int INF = 99999999;
	int i, j;
	for (i = 0; i < 10; i++) {
		for (j = 0; j < 10; j++) {
			if (i == j) {
				d[i][j] = 0;
			}
			else {
				d[i][j] = INF;
			}
		}
	}

	int H, W;
	scanf("%d %d", &H, &W);

	int c[10][10];
	for (i = 0; i < 10; i++) {
		for (j = 0; j < 10; j++) {
			scanf("%d", &d[i][j]);
		}
	}

	warshall_floyd(10);
	/*
	printf("\n");
	for (i = 0; i < 10; i++) {
		for (j = 0; j < 10; j++) {
			printf("%d ", d[i][j]);
		}
		printf("\n");
	}
	/*/
	//*/
	int A;
	int ans = 0;
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			scanf("%d", &A);
			if (A == -1)continue;
			ans += d[A][1];
		}
	}
	printf("%d\n", ans);
}

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

typedef long long ll;
#define nl "\n"
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pp pop_back
#define bs binary_search
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define sll stack<ll>
#define qll queue<ll>
#define vll vector<ll>
#define vpll vector<pll>
#define vc vector <char>
#define vvll vector<vector<ll>>
#define all(x) x.begin(),x.end()
#define loop(i,s,n) for(ll i=s;i<n;i++)
#define test ll t; cin>>t; while(t--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
ll mod = 1000000007;  double pi = 3.1415926535;

set<ll> S;
unordered_map<ll, ll> M;

void printPrimeFactors(ll n)
{
	while (n % 2 == 0) {
		S.insert(2);
		M[2]++;
		n = n / 2;
	}
	for (ll i = 3; i <= sqrt(n); i = i + 2)
	{
		while (n % i == 0)
		{
			S.insert(i);
			M[i]++;
			n = n / i;
		}
	}
	if (n > 2)
	{
		S.insert(n);
		M[n]++;
	}
}

void solve()
{
	ll n;	cin >> n;
	printPrimeFactors(n);
	ll cnt = 0;
	for (ll x : S)
	{
		ll c = 1;
		while (M[x] > 0)
		{
			M[x] -= c;
			c++;
			cnt++;
		}
		if (M[x] < 0)	cnt--;
	}
	cout << cnt << nl;
}

int main() {
	fast_io;
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif

	solve();
	return 0;
}



Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main(void){
    int n,tmp,max=0,cash=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>tmp;
        if(max<tmp)max=tmp;
        cash+=tmp;
    }
    cash-=max/2;

    cout<<cash<<endl;

    return 0;
}

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

int main(){
    string s;
    cin >> s ;
    int count = 0;
    for (int i = 0; i < 3; i++) {
        if (s.at(i) == 'o') {
            count++;
        }
    }
    cout << 700 + count * 100 << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		for(;;){
			int m = s.nextInt();
			int f = s.nextInt();
			int r = s.nextInt();
			if(m == -1 && f == -1 && r == -1)
				break;
			int sum = m + f;
			if(m == -1 || f == -1)
				System.out.println("F");
			else if(sum >= 80)
				System.out.println("A");
			else if(sum >= 65 && sum <= 80)
				System.out.println("B");
			else if(sum >= 50 && sum < 65)
				System.out.println("C");
			else if(sum >= 30 && sum < 50){
				if(r >= 50)
					System.out.println("C");
				else
					System.out.println("D");
			}
			else if(sum < 30)
				System.out.println("F");
			}
		}
		
		}

Measured memory_bytes: 25924
#include<stdio.h>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<utility>
#include<stack>
#include<algorithm>
#include<string>
#include<string.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;

const int N = 1e6;
int prf[N + 5];

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n; cin >> n;
    int ans = 0;
    while(n--){
        int x; cin >> x;
        if(x & 1)ans++;
    }

    if(ans & 1)cout << "NO" << endl;
    else cout << "YES" << endl;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
idx_h = None
idx_w = None
for i in range(h):
    words = list(map(str, input().split()))
    for j in range(w):
        if words[j] == 'snuke':
            idx_h = i
            idx_w = j
        else:
            pass
ans = str(chr(97 + idx_w).upper()) + str(idx_h+1)
print(ans)


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

int main() {
  string a,b;cin>>a>>b;
  int n=stoi(a+b);
  for(int i=1;i<1000;i++){
    int ans=i*i;
    if(ans==n){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

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

int main()
{
   double v;
   while( cin >> v )
   {
      double t = v / 9.8;
      double y = 4.9 * t * t;

      double temp = ((y + 5) / 5);
      int intemp = (int)temp;
      double dotemp = temp - intemp;
      if( 1 > dotemp && dotemp > 0 ) ++intemp;
      cout << intemp << endl;
   }
}

Measured memory_bytes: 3212
import numpy as np
N = int(input())
row = [input().split() for i in range(N)]
f = np.vectorize(int)
t = f(row)
Flag = 0

time = t[0][0]
x = t[0][1]
y = t[0][2]
dis = abs(x) + abs(y)
if dis % 2 == time % 2 and dis <= time:
    for i in range(1,N):
        time = t[i][0] - t[i-1][0]
        x = t[i][1] - t[i-1][1]
        y = t[i][2] - t[i-1][2]
        dis = abs(x) + abs(y)
        if dis % 2 == time % 2 and dis <= time:
            continue
        else:
            Flag = 1
            break
else:
    Flag = 1

if Flag == 0:
    print("Yes")
else:
    print("No")




Measured memory_bytes: 59276
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;
using static Utils;
class Program
{


    void Solve()
    {
        var N = io.Int;
        var A = new int[N];
        REP(N, i => A[i] = io.Int);
        var order =
            A
                .Indexed()
                .OrderBy(x => x.Val)
                .Select(x => x.Idx + 1);
        WriteLine(String.Join(" ", order));
       
    }


    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Program().Stream();
    private void Stream()
    {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }

}

class SimpleIO
{
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] { ' ', '"', ',' };
    StreamWriter sw = new StreamWriter(OpenStandardOutput())
    {
#if DEBUG
        AutoFlush = true
#else
        AutoFlush = false
#endif
    };
    public SimpleIO()
    {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }
    string Next()
    {
        if (_bufferCnt < _nextBuffer.Length) return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while (st == string.Empty) st = ReadLine();
        _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}
static class Utils
{
    public static T id<T>(T x) => x;
    public static void FOR(int a, int b, Action<int> f) => FOR(a, b, 1, f);
    public static void FOR(int a, int b, int n, Action<int> f)
    {
        for (int i = a; i < b; i += n) f(i);
    }
    public static void REP(int a, Action<int> f) => FOR(0, a, f);
    public class IndexedItem<T>
    {
        public int Idx;
        public T Val;
        public IndexedItem(int idx, T val)
        {
            Idx = idx;
            Val = val;
        }
    }
    public static IEnumerable<IndexedItem<T>> Indexed<T>(this IEnumerable<T> xs) => xs.Select((x, i) => new IndexedItem<T>(i, x));
}

Measured memory_bytes: 33624
//
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    A[0] = 0;
    for (int i = 1; i < N; ++i)
    {
        int atemp;
        cin >> atemp;
        --atemp;
        A[i] = atemp;
    }
    vector<int> results(N, 0);
    for (int i = 1; i < N; ++i)
    {
        ++results[A[i]];
    }
    for (int i = 0; i < N; ++i)
    {
        cout << results[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 4840
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
	 Scanner sc = new Scanner(System.in);
	 int n = sc.nextInt();
	 int height = 0 ;
	  int count = 0 ;
	  for(int i = 0 ; i< n ; i++){
	      int h ; 
	     h =  sc.nextInt();
	      if(height<=h){
	             height = h ;
	              count++;
	          
	      }
	      
	      
	  }
	 System.out.println(count);
	 
	 
	 
	 
	 
	//	System.out.println("Hello World");
	}
}


Measured memory_bytes: 22484
// today's dinosaur code is brought to you by: the letter t
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstring>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<(int)(n);i++)
#define per(i,a,n) for (int i=(n)-1;i>=(int)(a);i--)
template<typename T> ostream& operator<<(ostream& s, vector<T> t) {rep(i, 0, t.size()) s << (i ? " " : "") << t[i]; return s;}
template<typename T> istream& operator>>(istream& s, vector<T> &t) {rep(i, 0, t.size()) s >> t[i]; return s;}
template<typename T, typename U> ostream& operator<<(ostream& s, pair<T, U> t) {s << "(" << t.first << "," << t.second << ")"; return s;}
template<typename T, typename U> istream& operator>>(istream& s, pair<T, U> &t) {s >> t.first >> t.second; return s;}
typedef long long ll;


int main() {
    ios_base::sync_with_stdio(false);
    ll a, b, c;
    cin >> a >> b >> c;
    
    
    rep(i, 0, 10000000) {
        if (a % 2 || b % 2 || c % 2) {
            cout << i << endl;
            return 0;
        }
        ll aa = (b + c) / 2;
        ll bb = (a + c) / 2;
        ll cc = (a + b) / 2;
        a = aa;
        b = bb;
        c = cc;
    }
    cout << -1 << endl;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    li n;
    cin >> n;
    li res = 0;
    repp(i, 1, n + 1) {
        res += (i * (n / i) * (1 + n / i)) / 2;
    }
    cout << res << endl;


    return 0;
}

Measured memory_bytes: 3588
import math

N,D = map(int,input().split())
x = []
count = 0

for i in range(N):
    x.append(list(map(int,input().split())))

for i in range(N):
    for j in range(i+1,N):
        Distance = 0
        for k in range(D):
            Distance += (x[i][k] - x[j][k])**2
        
        if math.sqrt(Distance) == int(math.sqrt(Distance)):
            count += 1
            
print(count)


Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll n,k;
  cin >> n >> k;
  ll cnt=0;
  vl a(n);
  while(cnt<k){
    ll x;
    cin >> x;
    cnt++;
    rep(i,x){
      ll z;
      cin >> z;
      z--;
      a[z]++;
    }
  }
  ll ans=0;
  rep(i,n){
    if(a[i]==0){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

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

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

	vll A(N + 1);
	repn(i, N) cin >> A[i];

	ll s = 0;
	repn(i, N) s += A[i];

	map<ll, ll> mp;
	repn(i, N) mp[A[i]]++;
	
	ll Q;
	cin >> Q;
	repn(i, Q) {
		ll b, c;
		cin >> b >> c;
		ll cnt = mp[b];
		mp[b] = 0;
		mp[c] += cnt;
		s += (c - b) * cnt;
		cout << s << endl;
	}
}


Measured memory_bytes: 9956
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
int main() {
    int n, r;
    cin >> n >> r;
    int ans = 0;
    if(n >= 10) ans = r;
    else{
        ans = r + (10 - n) * 100;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

fun main(args:Array<String>){

    val cin = Scanner(System.`in`)
    val result = mutableListOf<Int>()

    while(true){
	    val n = cin.nextInt()
	    val x = cin.nextInt()

	    if(n + x == 0) break

	    result.add(calc(n, x))
    }

    for(i in result.indices) println(result[i])
}

fun calc(n:Int, x:Int):Int{

    var t:Int = 0

    for(i in 1..n-2){
	    for(j in i+1..n-1){
	        for(k in j+1..n){
		        if(i + j + k == x) t++
	        }
	    }
    }
    return t
}




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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
#define INF 1e8
typedef long long ll;
typedef long double ld;

int main() {
    int n, m;
    cin >> n >> m;
    int ans = 1;
    for(int i = 1; i*i <= m; i++){
        if(m % i != 0) continue;
        int fact = m / i;
        if((ll)n*i <= m) ans = max(ans, i);
        if((ll)n*fact <= m) ans = max(ans, fact);
    }
    cout << ans << endl;
}



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

public class Main
{

  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;
    String         in_str;

    int in_N;

    int cnt;
    int ans;

    try
    {
      in_stream = new BufferedReader(new InputStreamReader(System.in));

      /*----------------
       * 引数
       *----------------*/
      in_str = new String(in_stream.readLine());
      in_N   = Integer.parseInt(in_str);


      /*----------------
       * 計算
       *----------------*/
      ans = 0;
      for(cnt=1; cnt<=in_N; cnt+=2)
      {
        if(8 == getFactorNum(cnt))
        {
          ans++;
        }
      }

      System.out.println("" + ans);
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }

  public static int getFactorNum
  (
    int num
  )
  {
    int ret;
    int cnt;


    ret = 0;
    for(cnt=1; cnt<=num; cnt++)
    {
      if(num % cnt == 0)
      {
        ret++;
      }
    }

    return ret;
  }
}


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

// 素因数分解
map< long long, int > prime_factor(long long n) {
  map< long long, int > ret;
  for(long long i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

long long getGDC(long long A, long long B){
  long long R;
  if (B > A) {
    R = A;
    A = B;
    B = R;
  }
 	
  R = A % B;
  while(R!=0){
    A = B;
    B = R;
    R = A % B;
  }
  return B;
}

int main() {
  ll A, B;
  cin >> A >> B;
  
  // 最大公約数
  ll v = getGDC(A,B);
  //cout << v << endl;
  // 素因数分解
  int cnt = 0;
  for(auto p : prime_factor(v)) {
    if(p.second) cnt++;      
  }
  
  cout << cnt+1 << endl;
  	return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

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

	cout << ((n % 500 <= a) ? "Yes" : "No") << endl;
	return (0);
}


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

vector<int> riffle(vector<int>card,int c)
{
  vector<int>A,B,C;
  A.insert(A.begin(),card.begin()+card.size()/2,card.end());
  B.insert(B.begin(),card.begin(),card.begin()+card.size()/2);
  while(C.size()<card.size()){
    for(int i=0;i<c;i++){
      if(A.empty())break;
      C.push_back(A.front());
      A.erase(A.begin());
    }
    for(int i=0;i<c;i++){
      if(B.empty())break;
      C.push_back(B.front());
      B.erase(B.begin());
    }
  }
  return C;
}

int main()
{
  int n,r,c;
  vector<int>card;
  while(cin>>n>>r){
    card.resize(n);
    for(int i=0;i<n;i++)card[i]=i;
    for(int i=0;i<r;i++){
      cin>>c;
      card=riffle(card,c);
    }
    cout<<card[n-1]<<endl;
  }
}

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

int main(){
  int n;
  cin >> n;
  vector<std::string> data(n);
  for(int i = 0; i < n; i++){
    std::string s;
    cin >> s;
    sort(s.begin(), s.end());
    data.at(i) = s;
  }
  sort(data.begin(), data.end());
  int64_t answer = 0;
  int64_t count = 0;
  for(int i = 0; i < n - 1; i++){
    if(data.at(i) == data.at(i + 1)){
      count++;
    }
    else{
      answer += count * (count + 1) / 2;
      count = 0;
    }
  }
  answer += count * (count + 1) / 2;
  cout << answer << endl;
}



Measured memory_bytes: 5760
#include <iostream>
#include <list>

using namespace std;

int main(void) {
	int n,r;
	while (cin >> n >> r, n) {
		list<int> hana;
		for (int i = 0; i < n; ++i) {
			hana.push_back(i+1);
		}
		
		int p,c,count;
		for (int i = 0; i < r; ++i) {
			cin >> p >> c;
			count = 1;
			for (list<int>::iterator itr = hana.begin(); itr != hana.end();) {
				if (count > n-(p-1)-c && count < n-(p-2)) {
					hana.push_back(*itr);
					itr = hana.erase(itr);
				}
				else {
					++itr;
				}
				++count;
			}
		}
		count = 1;
		for (list<int>::iterator itr = hana.begin(); itr != hana.end(); ++itr) {
			if (count == n) {
				cout << *itr << endl;
			}
			++count;
		}
	}

	return 0;
}

Measured memory_bytes: 3000
import bisect
N,M,Q=map(int,input().split())
LR=[[0]*(N+1) for _ in range(N)]
for i in range(M):
  l,r=map(int,input().split())
  LR[l-1][r]+=1
for i in range(N):
  for j in range(1,N+1):
    LR[i][j]+=LR[i][j-1]
  
for _ in range(Q):
  ans=0
  p,q=map(int,input().split())
  for i in range(p-1,q):
    ans+=LR[i][q]-LR[i][p-1]
  print(ans)

Measured memory_bytes: 53208
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
const int MOD=1e+9+7;
int dp[101][8];
int main(){ _;
  int h,w,k;cin>>h>>w>>k;
  k--;
  dp[0][0]=1;
  for(int r=0;r<h;r++){
    int end=1<<(w-1);
    for(int bits=0;bits<end;bits++){
      if((bits&0b11     )==0b11      ||
	 (bits&0b110    )==0b110     ||
	 (bits&0b1100   )==0b1100    ||
	 (bits&0b11000  )==0b11000   ||
	 (bits&0b110000 )==0b110000  ||
	 (bits&0b1100000)==0b1100000)
	continue;
      for(int i=0;i<w;i++){
	if(bits&(1<<i)){
	  dp[r+1][i]+=dp[r][i+1];
	}else if(i>0&&(bits&(1<<(i-1)))){
	  dp[r+1][i]+=dp[r][i-1];
	}else{
	  dp[r+1][i]+=dp[r][i];
	}
	dp[r+1][i]%=MOD;
      }
    }
  }
  // REP(i,h+1){
  //   REP(j,w){
  //     cout<<dp[i][j]<<",";
  //   }
  //   cout<<endl;
  // }
  cout<<dp[h][k]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i =0;i<(int)(n);i++)
typedef pair<int,int> P;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n){
        cin >> v[i];
    }
    int res = 0;
    rep(i,n){
        while(v[i]%2==0){
            v[i]/=2;
            res++;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#define R register
#define IN inline
#define gc getchar()
#define W while
#define ll long long
#define MX 300050
#define mod 1000000007
template <class T>
IN void in(T &x)
{
    x = 0; R char c = gc;
    W (!isdigit(c)) c = gc;
    W (isdigit(c))
    x = (x << 1) + (x << 3) + c - 48, c = gc;
}
short go[8][2] = {{2, 1}, {4, 3}, {6, 5}, {3, 3}, {7, 1}, {2, 1}, {2, 2}, {4, 4}};//打表转移
ll dp[MX][8];
char buf[MX];
int len;
int main(void)
{
    scanf("%s", buf + 1);
    len = std::strlen(buf + 1);
    dp[0][0] = 1; 
    R int j;
    for (R int i = 0; i < len; ++i)
    {
        for (j = 0; j <= 7; ++j)
        {
            if(buf[i + 1] != '0') dp[i + 1][go[j][1]] += dp[i][j], dp[i + 1][go[j][1]] %= mod;
            if(buf[i + 1] != '1') dp[i + 1][go[j][0]] += dp[i][j], dp[i + 1][go[j][0]] %= mod;
        }
    }
    printf("%d\n", (dp[len][1] + dp[len][3]) % mod);
}


Measured memory_bytes: 19200
#!/usr/bin/env python3
import sys
from fractions import gcd

def solve(N: int, M: int, a: "List[int]"):
    koubaisu = a[0]
    for i in range(1, N):

        koubaisu = koubaisu * a[i] // gcd(koubaisu, a[i])

    for i in a:
        if koubaisu // i % 2 == 0:
            print(0)
            exit()

    print(M // koubaisu - M // (2*koubaisu))


    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    M = int(next(tokens))  # type: int
    a = [int(next(tokens)) // 2 for _ in range(N)]  # type: "List[int]"
    solve(N, M, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 85788
#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>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#define int long long
using namespace std;
const long long maxn = 1000100, mod = 1e9 + 7, maxa = 3e6 + 100, maxb = 23, base = 737, base2 = 3079, mod2 = 242121643;
const long long inf = 2e18 + 13;
long long max(long long x, long long y){return (x > y ? x : y);}
long long min(long long x, long long y){return (x < y ? x : y);}


int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long n, m;
    cin >> n;
    long long ans = 0, tmp = 0;
    while(1)
    {
        if(tmp >= n){break ;}
        ans++;
        tmp += ans;
    }
    cout << ans << endl;
    return 0;
}












Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i += 2){
        int cnt = 0;
        for(int j = 1; j <= n; j++){
            if(i%j == 0) cnt++;
        }
        if(cnt == 8) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	long long int n, m, a = 1, b = 1;
	cin >> n >> m;

	if(abs(n-m) >= 2)
		cout << 0 << endl;
	else if(n == m){
		for(int i = n; i > 1; i--){
			a *= i;
			a %= 1000000007;
		}
		b = a;

		cout << (a * b * 2) % 1000000007 << endl;
	}
	else{
		for(int i = n; i > 1; i--){
			a *= i;
			a %= 1000000007;
		}
		for(int i = m; i > 1; i--){
			b *= i;
			b %= 1000000007;
		}
		cout << (a * b) % 1000000007 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 5010
#define INF 1e9
#define F first
#define S second
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
  
int N,K;
pii taxi[MAX];
vector<int> G[MAX];
int cost[MAX][MAX];
 
int dijkstra(){
  priority_queue<piii,vector<piii>,greater<piii> > Q;
  Q.push(piii(pii(0,0),0));
  fill(cost[0],cost[0]+MAX*MAX,INF);
  cost[0][0] = 0;
 
  while(!Q.empty()){
    piii p = Q.top(); Q.pop();
    int v = p.F.S, r = p.S;
    if(cost[v][r] < p.F.F) continue;
    if(v == N-1){
      return cost[v][r];
    }
    if(r > 0){
      for(int i = 0 ; i < (int)G[v].size() ; i++){
        int to = G[v][i];
        if(cost[v][r] < cost[to][r-1]){
          cost[to][r-1] = cost[v][r];
          Q.push(piii(pii(cost[to][r-1],to),r-1));
        }
      }
    }
    pii t = taxi[v];
    for(int i = 0 ; i < (int)G[v].size() ; i++){
      int to = G[v][i];
      if(cost[v][r] + t.F < cost[to][t.S-1]){
        cost[to][t.S-1] = cost[v][r] + t.F;
        Q.push(piii(pii(cost[to][t.S-1],to),t.S-1));
      }
    }
  }
   
  return *min_element(cost[N-1],cost[N-1]+N);
}
 
int main(){
  int C,R,A,B;
  cin >> N >> K;
  for(int i = 0 ; i < N ; i++){
    cin >> C >> R;
    taxi[i] = pii(C,R);
  }
  for(int i = 0 ; i < K ; i++){
    cin >> A >> B; A--; B--;
    G[A].push_back(B);
    G[B].push_back(A);
  }
  cout << dijkstra() << endl;
  return 0;
}

Measured memory_bytes: 99800
#include <iostream>
using std::cin;
using std::cout;

void shell_sort(unsigned a[], unsigned n){
  const unsigned gaps[] = {1,8,23,77,281,1073,4193,16577,65921,262913,1050113};
  // pow(4,i)+3*pow(2,i-1)+1 (prefixed with 1)

  unsigned gap_num = 11, count = 0;
  while(gaps[--gap_num] > n);

  for(int i = gap_num+1; i; i--){
    unsigned gap = gaps[i-1];
    for(unsigned j = gap; j < n; j++){
      unsigned v = a[j];
      int k = j - gap;
      while(k >= 0 && a[k] > v){
        a[k+gap] = a[k];
        k -= gap;
        count++;
      }
      a[k+gap] = v;
    }
  }

  cout << (gap_num+1) << '\n';

  for(; gap_num; gap_num--) cout << gaps[gap_num] << ' ';
  cout << gaps[0] << '\n';

  cout << count << '\n';
}

int main(){
  std::ios::sync_with_stdio(false);
  unsigned n,i;
  cin >> n;
  auto a = new unsigned[n];
  for(i = 0; i < n; i++) cin >> a[i];
  shell_sort(a,n);
  for(i = 0; i < n; i++) cout << a[i] << '\n';
  delete[](a);
}

Measured memory_bytes: 4888
#nの約数を列挙する関数
import math
def n_div(n):
    div_list = []
    import math
    for i in range(1, math.ceil(math.sqrt(n))+1):
        if n % i ==0:
            div_list.append(i)
            if i*i ==n:
                continue
            div_list.append(n//i)
    div_list.sort()
    return div_list

n = int(input())
lr = n_div(n)
#print(lr)
if len(lr) % 2==0:
    a = len(lr)/2
    a = int(a)
    ans = lr[a]+lr[a-1]-2
else:
    a = math.floor(len(lr)/2)
    #print(a)
    ans = lr[a]*2  -2
    
print(ans)

Measured memory_bytes: 9160
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n; cin >> n;
    double jpy = 0, btc = 0;
    rep(i, n){
        double x; string u; cin >> x >> u;
        (u == "JPY") ? jpy += x : btc += x;
    }
    cout << jpy + (btc * 380000.0) << endl;
}

Measured memory_bytes: 256
#include <stdio.h> 

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

	scanf("%d %d %d %d %d",&W, &H, &x, &y, &r);

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

	else
	{
	printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 584
mod = 1000000007
H, W, K = map(int, input().split())

# 平行な縦線がx本あるとき、横線の引き方はfib[x]通り
fib = [1, 1, 2, 3, 5, 8, 13, 21, 34]

dp = [[0] * (W + 1) for j in range(H + 1)]
dp[0][0] = 1
dp[0][1] = 1

for h in range(1, H + 1):
    for w in range(1, W + 1):
        dp[h][w] = dp[h - 1][w] * fib[w - 1] * fib[W - w]
        if w > 1:
            dp[h][w] += dp[h - 1][w - 1] * fib[w - 2] * fib[W - w]
        if w < W:
            dp[h][w] += dp[h - 1][w + 1] * fib[w - 1] * fib[W - w - 1]
        dp[h][w] %= mod

print(dp[H][K])

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"regexp"
)

func main() {
	var re = regexp.MustCompile(`(?s)^(hi)*$`)
	var str string
	fmt.Scanf("%s", &str)
	match := re.MatchString(str)
	if match {
		fmt.Print("Yes")
	} else {
		fmt.Print("No")
	}
}


Measured memory_bytes: 640