akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	N := nextInt()
	T := make([]int, N)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		T[i], A[i] = nextInt(), nextInt()
	}

	t, a := 1, 1

	for i := 0; i < N; i++ {
		x := t / T[i]
		y := a / A[i]
		if t%T[i] != 0 {
			x++
		}

		if a%A[i] != 0 {
			y++
		}
		n := max(x, y)

		t = n * T[i]
		a = n * A[i]

	}

	fmt.Println(t + a)
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}


Measured memory_bytes: 640
s = input()
q = int(input())

for qi in range(q):
    command = input().split()

    a = int(command[1])
    b = int(command[2])

    if command[0] =='print':
        print(s[a:b +1])

    elif command[0] =='reverse':
        s = s[:a] + s[a:b +1][::-1]+ s[b + 1:]

    else:
        p = command[3]
        s = s[:a] + p + s[b+1:]

Measured memory_bytes: 7680
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define in insert
#define sz(x) ((in)(x).size())
using namespace std;
const int N = 123;
int n;
double a[N];

void read_file()
{
    freopen("text.in","r",stdin);
    freopen("text.out","w",stdout);
}

void solve()
{
    cin >> n;
    double ans = 0.0;
    double x;
    for (int i = 0; i < n; i++){
        cin >> x;
        ans += 1 / x;
    }
    printf("%.9f\n", 1/ans);
}

int main()
{
    solve();
    //cerr << printf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
    return (0);
}




Measured memory_bytes: 256
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
using namespace std; 
 
const int N = 2e5 + 100, OO = 1e9 + 100, M = 998244353, P = 6151, SQ = 120, lg = 22;
typedef pair <int, int> pii;

int32_t main() {
    use_fast;
	int h, w, n;
	cin >> h >> w >> n;
	if(w > h)
		swap(w, h);
	for(int i = 1; i <= w; i++) {
		n -= h;
		if(n <= 0)
			return cout << i << endl, 0;
	}
	cout << w << endl;
	return 0; 
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/	

Measured memory_bytes: 256
import math

N=int(input())
a=list(map(int, input().split()))
B=a[:]

for i in range(N-1,-1,-1):
    s = 0
    j = i
    j+=(i+1)
    while j < N:
        s+=B[j]
        j+=(i+1)
    m = s % 2
    B[i] = a[i] ^ m

ans = [i + 1 for i, x in enumerate(B) if x == 1]
l = len(ans)
print(l)
if (l > 0):
    print(*ans)


Measured memory_bytes: 14136
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    a, b, h, m = LI()
    d = h * 30 - m * 5.5
    if d > 180:
        d = 360 - d
    print(sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(2 * d * math.pi / 360)))
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 81456
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())

    print(N * 800 - N // 15 * 200)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61820
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int scoreA = 0, scoreB = 0;
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
            for (int i = 0; i < n; i++) {
                int cardA = sc.nextInt();
                int cardB = sc.nextInt();
                if (cardA > cardB) {
                    scoreA += cardA + cardB;
                } else if (cardA < cardB) {
                    scoreB += cardA + cardB;
                } else {
                    scoreA += cardA;
                    scoreB += cardB;
                }
            }
            System.out.println(scoreA + " " + scoreB);
        }
    }
}


Measured memory_bytes: 59960
#include<bits/stdc++.h>
 
using namespace std;
 
using   ll=long long;
using   ld=long double;
 
#define fast           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl           "\n"
#define long long      int 
#define pb             push_back
#define mp             make_pair
#define vll            vector<ll>
#define f              first
#define s              second
#define pll            pair<ll,ll>
#define ALL(v)         v.begin(),v.end()
#define ALLR(v)        v.rbegin(),v.rend()
#define Inf            LLONG_MAX
#define pii            3.14159265358979323 
#define md             1000000007

bool cmp(pll & a,pll & b)
{
    return (a.f>b.f || a.f==b.f && a.s<b.s);
}
 
struct Compare{ 
    bool operator()(ll const& a, ll const& b) 
    { 
        return a>b;
    } 
};

void solve()
{
    ll n,m,x,y,cur=0,ans=0,tot=0;
    
    cin>>n>>m;
    
    vector<pll> a(n);
    
    priority_queue<ll,vector<ll>,Compare> qq;
    
    for(int i=0;i<n;i++)
    {
        cin>>a[i].f>>a[i].s;
    }
    
    sort(ALL(a),cmp);
  
    for(int i=0;i<n;i++)
    {   
        if(a[i].f+cur<=m)
        {
            tot+=a[i].s;
            
            ans=max(ans,tot);
            
            qq.push(a[i].s);
            
            cur++;
        }
        else if(!qq.empty())
        {
            ll g=qq.top();
            
            qq.pop();
            
            tot-=g;
            cur--;
            cur=max(0LL,cur);
            i--;
        }
        //cout<<ans<<endl;
    }
    
    cout<<ans;
}
 
signed main()
{
 
    fast;
 
    ll t;
    
    t=1;
    
    //cin>>t;
    
    while(t--)
    {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 2936
#include <iostream>
#include <bits/stdc++.h>
#define pb push_back
#define ob pop_back
#define xx first
#define yy second
#define dob double
#define rin(i,n,k) for(int i=0;i<n;i+=k)
#define int long long int
#define ss size()
using namespace std;
const int M=1e9+7,maxn=100010;
std::vector<int> adj[maxn];
std::vector<int> v1;
int ans,n,k,m,x,y,q,par[maxn],h[maxn],mach[maxn],sk[maxn],dp[maxn];
bool mark[maxn],bpart[maxn];
string s,s1,s2;
map <string ,int> mp;
bool markchaild[maxn];

int32_t main() {
    cin>>s;
    q=753;
    for(int i=2;i<s.ss;i++){
        ans=(s[i-2]-'0')*100;
        ans+=(s[i-1]-'0')*10;
        ans+=(s[i]-'0');
        //cout<<ans<<endl;
        ans=fabs(ans-753);
        if(ans<q)
            q=ans;
    }
    cout<<q;
    return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
 
vector<string> a,b,c,d;
string ans;
 
int main() {
  int n;
  cin >> n;
  for(int i = 1 ; i <= n ; ++i) {
    string s;
    cin >> s;
    int x = s[0],y = s[s.size()-1];
    if(x != 'B' && y != 'A') a.push_back(s);
    if(x != 'B' && y == 'A') b.push_back(s);
    if(x == 'B' && y != 'A') c.push_back(s);
    if(x == 'B' && y == 'A') d.push_back(s);
  }
  for(auto v : a) ans += v;
  if(b.size()) {
    ans += b[b.size()-1];
    b.pop_back();
  }
  for(auto v : d) ans += v;
  if(c.size()) {
    ans += c[c.size()-1];
    c.pop_back();
  }
  while(b.size() && c.size()) {
    ans += b[b.size()-1];
    b.pop_back();
    ans += c[c.size()-1];
    c.pop_back();
  }
  for(auto v : b) ans += v;
  for(auto v : c) ans += v;
  int tot = 0;
  for(int i = 0 ; i < ans.size()-1 ; ++i) 
    if(ans[i] == 'A' && ans[i+1] == 'B')
      ++tot;
  cout << tot << endl;
  return 0;
}

Measured memory_bytes: 896
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("-1"),0;
#define mod 1000000007
#define N 5055
//#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,k,f[N][N][2],ans;
inline void add(int &x,int k){
	x+=k;x-=(x>=mod)?mod:0;
}
signed main(){
	n=read();k=read();
	f[n+1][0][2]=1;
	D(i,n+1,2){
		D(j,n-1,0) add(f[i][j][1],f[i][j+1][1]);
		F(j,0,n){
			F(t,1,2){
				add(f[i-1][j+1][2],f[i][j][t]);
				add(f[i-1][j][1],f[i][j][t]);
			}
		}
	}
	ans=f[1][n-k][1];
	F(i,1,n-k-1) ans=ans*2%mod;
	wrn(ans);
	return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n;
  cin >> n;
  if(n==1||n==2){
    cout << 0 << endl;
    return 0;
  }
  vector<bool> a(n+3,true);
  a[0]=a[1]=false;
  vector<int> prime(n+3,-1);
  int now=0;
  for(int i=0;i<n+3;i++){
    if(a[i]==true){
      prime[now]=i;
      now++;
      for(int j=i*2;j<n+3;j+=i){
        a[j]=false;
      }
    }
  }
  int ans=0;
  for(int i=1;i<now;i++){
    if(prime[i-1]+2==prime[i]) ans++;
  }
  cout << ans*2 << endl;
  return 0;
}



Measured memory_bytes: 43116
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll 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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};

istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint comb(int a, int b) {
  if (a < b) return 0;
  if (b < 0 || a < 0) return 0;
  mint ret = 1;
  rep(i, b) {
    ret *= (a-i);
  }
  rep(i,b) ret /= (i+1); 
  return ret;
}

mint c[4005][4005];

mint comb2(int a, int b) {
  return c[a][b];
}

mint f2(int x, int y) {
  return comb(x+y-1, y-1);
}

mint f(int x, int y) {
  if (x < y) return 0;
  if (x == y) return 1;
  if (y < 1) return 0;
  return f2(x-y, y);
}


int main() {
  int n,k; cin >> n >> k; 
  for(int i=1; i<=k; i++) {
    mint ans = f(k, i);
    mint s = 0;
    s += f(n-k, i);
    s *= 2;
    s += f(n-k, i+1);
    s += f(n-k, i-1);
    ans *= s;
    printf("%lld\n", ans.x);
  }
  
  return 0;
}

Measured memory_bytes: 125568
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int a, b, c;
  cin >> a >> b >> c;
  if (a==b && b==c) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

using namespace std;

int main(){
    
    int a,b,c;
    cin>>a>>b>>c;
    
    if(a*b>c){
        cout<<c<<"\n";
    }
    else if(a*b==c){
        cout<<c<<"\n";
    }
    else{
        cout<<a*b<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}

struct MaxFlow{
	using D = int;
	const D inf = 1e9;
	struct edge{
		int to;
		D cap;
		int rev;
		int id;
		edge(int to,D cap,int rev):to(to),cap(cap),rev(rev),id(-1){}
		edge(int to,D cap,int rev,int id):to(to),cap(cap),rev(rev),id(id){}
	};

	int V;
	vector<vector<edge>> G;
	vector<int> level,iter;

	MaxFlow(int V):V(V){
		G = vector<vector<edge>>(V);
		level = vector<int>(V);
		iter = vector<int>(V);
	}

	void add_edge(int from, int to, D cap, int id = -1){
		edge e1(to,cap,(int)G[to].size(),id);
		edge e2(from,0,(int)G[from].size(),-1);
		G[from].push_back(e1);
		G[to].push_back(e2);
	}
	void bfs(int s){
		level = vector<int>(V,-1);

		queue<int> que;
		level[s]=0;
		que.push(s);
		while(!que.empty()){
			int v=que.front();
			que.pop();
			for(int i=0;i<(int)G[v].size();i++){
				edge &e=G[v][i];
				if(e.cap>0 && level[e.to]<0){
					level[e.to]=level[v]+1;
					que.push(e.to);
				}
			}
		}
	}
	D dfs(int v,int t,D f){
		if(v==t) return f;
		for(int &i=iter[v];i<(int)G[v].size();i++){
			edge &e=G[v][i];
			if(e.cap>0 && level[v]<level[e.to]){
				D d = dfs(e.to,t,min(f,e.cap));
				if(d>0){
					e.cap-=d;
					G[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}
	D max_flow(int s,int t){
		D flow=0;
		while(true){
			bfs(s);
			if(level[t]<0) return flow;
			iter = vector<int>(V,0);
			D f;
			while( (f=dfs(s,t,inf))>0 ) flow+=f;
		}
	}
};

int N;
const int MN = 100010;
int a[MN],b[MN],x[MN];
vector<int> bch[MN];

int main(){
	cin>>N;
	rep(i,N){
		cin>>a[i];
		if(a[i]!=-1) a[i]--;
		else a[i] = N;
		x[i]--;
		x[a[i]]++;
	}
	rep(i,N){
		cin>>b[i];
		if(b[i]!=-1) b[i]--;
		else b[i] = N;
		x[i]++;
		x[b[i]]--;
		bch[b[i]].pb(i);
	}

	rep(i,N) if(x[i]%2!=0){
		puts("IMPOSSIBLE");
		return 0;
	}

	int V = N+3;
	int S = N+1, T = N+2;

	MaxFlow MF(V);

	int F = 0;
	rep(v,N){
		if(x[v]>0){
			F += x[v]/2;
			MF.add_edge(S,v,x[v]/2);
		}else{
			MF.add_edge(v,T,-x[v]/2);
		}
	}
	rep(i,N){
		MF.add_edge(a[i],i,1,i);
		MF.add_edge(i,b[i],1,i+N);
	}
	int f = MF.max_flow(S,T);
	if(f != F){
		puts("IMPOSSIBLE");
		return 0;
	}
	puts("POSSIBLE");
	vector<int> bv(N,-1);
	rep(i,V) for(auto e : MF.G[i]){
		if(N<=e.id && e.id<N+N){
			if(e.cap==0) bv[e.id-N] = 1;
		}
	}
	rep(v,N){
		int ans = 0;
		ans += bv[v];
		for(int u: bch[v]) ans -= bv[u];
		cout<<ans<<" ";
	}
	puts("");
}


Measured memory_bytes: 24168
#include <iostream>
#include <string>
#include <malloc.h>
#include <stdlib.h>

using namespace std;

struct Node
{
	int key;
	Node *next, *prev;
};

Node *null;

Node* ListSearch(int key)
{
	Node* cur = null->next;

	while (cur != null && cur->key != key)
		cur = cur->next;

	return cur;
}

void Init()
{
	null = (Node*)malloc(sizeof(Node));

	null->next = null;
	null->prev = null;
}

void OutputList()
{
	Node* cur = null->next;

	int i = 0;
	while (true)
	{
		if (cur == null)
			break;

		if (i > 0)
			cout << " ";

		cout << cur->key;

		cur = cur->next;
		i++;
	}

	cout << endl;
}

void DeleteNode(Node* t)
{
	if (t == null)
		return;

	t->prev->next = t->next;
	t->next->prev = t->prev;

	free(t);
}

void DeleteFirst()
{
	DeleteNode(null->next);
}

void DeleteLast()
{
	DeleteNode(null->prev);
}

void DeleteKey(int key)
{
	DeleteNode(ListSearch(key));
}

void Insert(int key)
{
	Node* x = (Node*)malloc(sizeof(Node));

	x->key = key;

	x->next = null->next;

	null->next->prev = x;
	null->next = x;

	x->prev = null;
}

int main()
{
	int n;
	string com;

	cin >> n;

	Init();
	for (int i = 0;i < n;i++)
	{
		int key;
		cin >> com;

		if (com == "insert")
		{
			cin >> key;

			Insert(key);
		}
		else if (com == "delete")
		{
			cin >> key;

			DeleteKey(key);
		}
		else if (com == "deleteFirst")
			DeleteFirst();
		else if (com == "deleteLast")
			DeleteLast();
	}

	OutputList();

	return 0;
}

Measured memory_bytes: 34364
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
typedef long long ll;

int main(){
	int n,m;
	cin >> n >> m;
	vector<tuple<ll,ll>> v(n);
	rep(i,n){
		ll a,b;
		cin >> a >> b;
		v[i]=make_tuple(a,b);
	}

	sort(v.begin(),v.end());

	ll sum_money = 0;
	ll sum_num = 0;
	rep(i,n){
		if(sum_num + get<1>(v[i]) >= m){
			sum_money += (m-sum_num)*get<0>(v[i]);
			break;
		}else{
			sum_num += get<1>(v[i]);
			sum_money += get<0>(v[i])*get<1>(v[i]);
		}
	}
	cout << sum_money;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
int main()
{
    ll N;
    cin >> N;
    ll ans = 1;
    repd(i, 1, N + 1) {
        ans *= i;
        ans %= MOD;
    }

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

Measured memory_bytes: 384
N = gets.to_i
A = gets.chomp.split(" ").map(&:to_i)

wk = Hash.new{|h, k| h[k] = 0}
A.each_with_index{|a, i| wk[a-i] += 1}

puts A.each_with_index.inject(0){|r, (a, i)|
  r + wk[-a-i]
}


Measured memory_bytes: 52552
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int n; cin >> n;
    vector<int> w;
    rep(i,n){
        int a; cin >> a;
        w.push_back(a);
    } 
    
    int s1=0;
    int s2=0;
    int ans = 1e9;
    
    rep(i,n){
        for(int j=0; j<=i; j++) s1 = s1 + w[j];
        for(int j=i+1; j<n; j++) s2 = s2 + w[j];
        if(ans > abs(s1-s2)) ans = abs(s1-s2);
        s1 = 0; s2 = 0;
    }
    
    cout << ans << ln;
    return 0;
}

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

int count(int n){
    int cnt = 0;
    while(n%2==0){
        n/=2;
        cnt++;
    }
    return cnt;
}

int main(){
    int n;
    cin >> n;
    int max = 0;
    int ans = 1;
    
    for(int i=1;i<=n;i++){
        if(max<count(i)){
            max = count(i);
            ans = i;            
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

int t;
ll A, B, C, D;

ll gcd(ll x, ll y) {
	if (x < y) swap(x, y);
	return y ? gcd(y, x%y) : x;
}
int main() {
	cin.tie(NULL); cout.tie(NULL);
	ios::sync_with_stdio(false);

	cin >> t;

	while (t--) {
		cin >> A >> B >> C >> D;

		if (A - B < 0 || D - B < 0) {
			cout << "No\n"; 
		}
		else {
			if (A%B > C) {
				cout << "No\n"; continue;
			}
			ll GCD = gcd(B, D);
			ll n;

			if (A - C >= 0) {
				n = (A - C) / B;
				if ((A - (n + 1)*B) <= C) n++;
			}
			else n = 0;
			ll m = (C - (A - n*B)) / GCD;
			while (m*GCD + (A - n*B) <= C) m++;
			if (m*GCD + (A - n*B) - B < 0)
				 cout << "No\n";
			else cout << "Yes\n";
		}
	}
	
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = (int)(n)-1; i >=0; i--)

using ll = long long;

int main(){
  int N; cin>>N;
  vector<int> L(N); rep(i,N)cin>>L.at(i);
  sort(begin(L),end(L));
  int res = 0;
  for(int i = 0; i < N-1; i++){
    for(int j = i+1; j < N; j++){
      int s = L.at(i)+L.at(j);
      auto lb = lower_bound(begin(L),end(L),s);//iter
      int l = distance(begin(L),lb);
      res+=(l-j-1);
    }
  }
  cout<<res<<endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

/**
 * ランレングス圧縮
 */
vector<pair<char, ll>> RLE(const string &S) {
    ll cnt = 0;
    vector<pair<char, ll>> res;
    for (ll i = 0; i < (ll) S.size(); i++) {
        cnt++;
        if (i == (ll) S.size() - 1) {
            res.emplace_back(S[i], cnt);
            break;
        }
        if (S[i] != S[i + 1]) {
            res.emplace_back(S[i], cnt);
            cnt = 0;
        }
    }
    return res;
}

void Main() {
    ll N; cin >> N;
    string S; cin >> S;
    cout << RLE(S).size() << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 2500
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

int main() {
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if (e - a > k) {
		cout << ":(" << endl;
	}
	else {
		cout << "Yay!" << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define INF ((1LL<<62)-(1LL<<31))
#define min(p,q)((p)<(q)?(p):(q))
#define max(p,q)((p)>(q)?(p):(q))

ll cost[110][110];

//ワーシャルフロイド
//頂点数（と隣接行列）を引いて全点間最短距離を返す
//O(V^3)
ll dddd[110][110];
void waasharuhuroido(ll n){
	rep(i,0,n)rep(j,0,n)dddd[i][j]=cost[i][j];//辺が無いところはINFにする前処理が必要
	rep(k,0,n)rep(i,0,n)rep(j,0,n)dddd[i][j]=min(dddd[i][j],dddd[i][k]+dddd[k][j]);
}
	
ll a[110];
int main(){
	ll n,m,s,g,t,list;
	while(scanf("%lld%lld%lld%lld%lld%lld",&n,&t,&list,&m,&s,&g),n){
		rep(i,0,n)a[i]=0;
		rep(i,0,list){
			ll t;
			scanf("%lld",&t);
			a[t]=1;
		}
		a[s]=a[g]=1;

		rep(i,0,n)rep(j,0,n)cost[i][j]=i==j?0:INF;
		rep(i,0,m){
			ll x,y,c;
			scanf("%lld%lld%lld",&x,&y,&c);
			cost[x][y]=cost[y][x]=c;
		}

		waasharuhuroido(n);
		rep(i,0,n)rep(j,0,n){
			if(a[i]&&a[j]&&dddd[i][j]<=t)cost[i][j]=dddd[i][j];
			else cost[i][j]=INF;
		}
		waasharuhuroido(n);

		if(dddd[s][g]==INF)puts("Help!");
		else printf("%lld\n",dddd[s][g]+max(0,dddd[s][g]-t));
	}
}


Measured memory_bytes: 2028
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int r=nxt(),g=nxt(),b=nxt();
    int test=r*100+g*10+b;
    if(test%4==0)
        cout<<"YES\n";
    else
        cout<<"NO\n";
    
    return 0;   
}




 
 


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int l, r, d;
    cin >> l >> r >> d;
    cout << r / d - (l - 1) / d;
    cout << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
const int INF = 1 << 27;
const ll LLINF = (ll)1 << 60;
const ll MOD = 1e9+7;

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

const int MAXN = 110;
int w[MAXN], v[MAXN];
int main() {
  int N, W;
  scanf("%d %d", &N, &W);
  for (int i = 0; i < N; i++) {
    scanf("%d %d", &w[i], &v[i]);
  }

  vector<ll> dp(W + 1, 0);
  for (int i = 0; i < N; i++) {
    for (int sumW = W; sumW >= 0; sumW--) {
      if (sumW >= w[i]) {
        dp[sumW] = max(dp[sumW], v[i] +  dp[sumW - w[i]]);
      }
    }
  }

  printf("%lld\n", dp[W]);
}


Measured memory_bytes: 1024
N, M = map(int, input().split())
ab = [[] for i in range(M)]
ans = 0
for i in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    ab[i] = [a, b]

def cal(AB):
    matrix = [[] for i in range(N)]
    for a, b in AB:
        matrix[a].append(b)
        matrix[b].append(a)
    check = [0] * N
    check[0] = 1
    deque = [0]
    while deque:
        now = deque.pop()
        for i in matrix[now]:
            if check[i] == 0:
                deque.append(i)
                check[i] = 1
    if len(set(check)) == 1:
        return 0
    else:
        return 1

for i in range(M):
    AB = ab[:]
    del AB[i]
    ans += cal(AB)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int MOD = 998244353;
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}

void radd(int &x, int y)
{
	x=add(x,y);
}

int a[111111];
int dp[4555][4555];
int c[2];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	string s; cin>>s;
	int n=s.length();
	for(int i=0;i<n;i++) a[i]=s[i]-'0';
	dp[0][0]=1;
	for(int i=0;i<2*n;i++)
	{
		if(i<n)
		{
			c[0]+=a[i];
			c[1]+=2-a[i];
		}
		for(int j=0;j<=2*n;j++)
		{
			int v=dp[i][j];
			if(v==0) continue;
			int C[2]={c[0],c[1]};
			C[0]-=j;
			C[1]-=(i-j);
			//cerr<<i<<' '<<j<<' '<<v<<' '<<C[0]<<' '<<C[1]<<'\n';
			if(C[0]<0||C[1]<0) continue;
			//choose 1
			if(C[1]>0) radd(dp[i+1][j],v);
			//choose 0
			if(C[0]>0) radd(dp[i+1][j+1],v);
		}
	}
	int ans=0;
	for(int i=0;i<=2*n;i++) ans=add(ans,dp[2*n][i]);
	cout<<ans<<'\n';
}	


Measured memory_bytes: 70400
#include<stdio.h>
#include<stdlib.h>
#define BUFSIZE 1000000007
typedef long long ll;
int N, K;
ll rem = 0;
ll sum1, sum2 = 0;

ll Sum(ll num)
{
    if (num == N + 2)
        return 0;
    sum1 = num * (num - 1) / 2;
    sum2 = num * (2 * (N - num + 1) + (num - 1)) / 2;
    rem += sum2 - sum1 + 1;
    rem %= BUFSIZE;
    Sum(num + 1);
    return 0;
}

int main(void)
{
    scanf("%d", &N);
    scanf("%d", &K);
    Sum(K);
    printf("%lld", rem % BUFSIZE);
    return 0;
}


Measured memory_bytes: 4800
n = gets.to_i
a = gets.split.map(&:to_i)

cnt = 0
flg = true
while flg
  0.upto(n-1) do |i|
    if a[i].even?
      a[i] /= 2
    else
      flg = false
      break
    end
  end
  cnt += 1 if flg
end

puts cnt


Measured memory_bytes: 1788
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main() {
	
	int h, w;
	cin >> h >> w;
	REP(i, h) {
		string c;
		cin >> c;
		cout << c << endl << c << endl;
	}


	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <stack>
//#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int N;
    cin >> N;
    vector<pair<int, int>> tasks;
    int a, b;
    for (int i = 0; i < N; i++)
    {
        cin >> a >> b;
        tasks.emplace_back(b, a);
    }
    sort(tasks.begin(), tasks.end());
    int sum = 0;
    for (auto i : tasks)
    {
        sum += i.second;
        if (sum > i.first)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 5368
#include <bits/stdc++.h>
#define MAX_N 300000
#define MAX_M 100000
using namespace std;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n, m, tr[MAX_M+5]; struct seg {int l, r;} s[MAX_N+5];
bool cmp(const seg &a, const seg &b) {return a.r-a.l < b.r-b.l;}
void inc(int p) {for (; p <= m; p += (p&-p)) tr[p]++;}
void dec(int p) {for (; p <= m; p += (p&-p)) tr[p]--;}
int sum(int p) {int ret = 0; for (; p; p -= (p&-p)) ret += tr[p]; return ret;}
int main() {
	read(n), read(m);
	for (int i = 1; i <= n; i++)
		read(s[i].l), read(s[i].r);
	sort(s+1, s+n+1, cmp);
	for (int d = 1, p = 1; d <= m; d++) {
		while (p <= n && s[p].r-s[p].l < d)
			inc(s[p].l), dec(s[p].r+1), p++;
		int tot = 0;
		for (int i = d; i <= m; i += d)
			tot += sum(i);
		printf("%d\n", tot+n-p+1);
	}
	return 0;
}


Measured memory_bytes: 3712
char buf[1000];
i,len;

main(){
	gets(buf);
	gets(buf);
	if((len=strlen(buf))%2) return puts("No") && 0;
	
	for(i=0;i<len/2;i++) if(buf[i]!=buf[i+len/2]) return puts("No") && 0;
	puts("Yes");
}


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

int main(){
    int X, Y;
    cin >> X >> Y;
    if(2 * X <= Y && Y <= 4 * X && Y % 2 == 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3608
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // 入力
        MyScanner sc = new MyScanner(System.in);
        int N = sc.nextInt();
        int[][] abc = new int[N][3];
        for(int i = 0; i < N; i++) {
            int[] line = sc.nextIntArray();
            abc[i][0] = line[0];
            abc[i][1] = line[1];
            abc[i][2] = line[2];
        }
        // System.out.println(N);
        // for(int[] arr:abc) System.out.println(Arrays.toString(arr));
        // System.out.println();

        // 初期化
        int[][] dp = new int[N][3];  // 幸福度の総和の最大値
        // for(int[] arr:dp) System.out.println(Arrays.toString(arr));
        // System.out.println();

        // 主処理
        for(int i = 0; i < N; i++) {
            if(i == 0) {
                dp[0][0] = abc[0][0];
                dp[0][1] = abc[0][1];
                dp[0][2] = abc[0][2];
            } else {
                dp[i][0] = Math.max(dp[i][0], abc[i][0] + dp[i-1][1]);
                dp[i][0] = Math.max(dp[i][0], abc[i][0] + dp[i-1][2]);

                dp[i][1] = Math.max(dp[i][1], abc[i][1] + dp[i-1][0]);
                dp[i][1] = Math.max(dp[i][1], abc[i][1] + dp[i-1][2]);

                dp[i][2] = Math.max(dp[i][2], abc[i][2] + dp[i-1][0]);
                dp[i][2] = Math.max(dp[i][2], abc[i][2] + dp[i-1][1]);
            }
        }

        // 出力
        // for(int[] arr:dp) System.out.println(Arrays.toString(arr));
        System.out.println(Math.max(Math.max(dp[N-1][0],dp[N-1][1]),dp[N-1][2]));
    }

    static class MyScanner {
        BufferedReader br;
        MyScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }
        // 標準入力を文字列で取得
        public String nextString() throws IOException {
            return br.readLine();
        }
        // 標準入力を文字列の配列で取得
        public String[] nextStringArray() throws IOException {
            return nextString().split(" ");
        }
        // 標準入力を数値で取得
        public int nextInt() throws IOException {
            return Integer.parseInt(nextString());
        }
        // 標準入力を数値の配列で取得
        public int[] nextIntArray() throws IOException {
            String[] strArr = nextStringArray();
            int[] intArr = new int[strArr.length];
            for(int i = 0; i < strArr.length; i++) {
                intArr[i] = Integer.parseInt(strArr[i]);
            }
            return intArr;
        }
    }
}


Measured memory_bytes: 49036
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			String N = sc.next();
			String[] number = new String[3];
			for (int i = 0; i < 3; i++) {
				number[i] = String.valueOf(N.charAt(i));
			}
			String ans = "No";
			for (int i = 0; i < 3; i++) {
				if (number[i].equals("7")) {
					ans = "Yes";
					break;
				}
			}

			System.out.println(ans);
		} finally

		{
			sc.close();
		}
	}

}


Measured memory_bytes: 26996
#include"bits/stdc++.h"

#define rep(i, N) for(int i = 0;i < N;i++)
typedef long long ll;
const int mod = 1e9 + 7;

using namespace std;

int main(void) {
	int H1, M1, H2, M2, K; cin >> H1 >> M1 >> H2 >> M2 >> K;

	int m1 = H1 * 60 + M1;
	int m2 = H2 * 60 + M2;

	cout << m2 - m1 - K << endl;

	return 0;
}

Measured memory_bytes: 3592
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<math.h>
#include<list>
#include<complex>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define vvvll vector<vector<vector<ll>>>
#define vtype(type) vector<type>
#define vvtype(type) vector<vector<type>>
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,x) unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;
struct wall
{
	long long r; ll c;
	bool operator<(const wall& rhs) const {
		if (r != rhs.r) {
			return r < rhs.r;
		}
		else {
			return c < rhs.c;
		}
	}
};


ll const MOD = 1e9 + 7;


ll mod_p(ll x, ll y) {
	x %= MOD;
	y %= MOD;
	return (x + y + MOD) % MOD;
}

ll mod_m(ll x, ll y) {
	x %= MOD;
	y %= MOD;
	return x * y%MOD;
}

ll mod_pow(ll x, ll t) {
	x %= MOD;
	if (t == 0) {
		return 1;
	}
	else {
		ll v = mod_pow(x, t / 2);
		if (t % 2 == 0) {
			return v * v % MOD;
		}
		else {
			return v * v%MOD * x %MOD;
		}
	}
}

ll mod_inv(ll x) {
	return mod_pow(x, MOD - 2);
}


ll const MAX = 2e5 + 5;
struct ball {
	ll c; ll w;
};

vector<ball> b(MAX);
vll colmin(MAX, 1e10);
vll colnum(MAX, 0);
ll min_wei = 1e10;
ll min_i;
vll movable(MAX, 0);

int main() {
	ll n, x, y;
	cin >> n >> x >> y;
	REP(i, 1, n) {
		ll c, w;
		cin >> c >> w;
		b[i] = { c,w };
		//min_wei = min(min_wei, w);
		if (min_wei > w) {
			min_i = i;
			min_wei = w;
		}
		colmin[c] = min(colmin[c], w);
	}
	ll min_col = b[min_i].c;
	ll min_wei2 = 1e10;
	REP(i, 1, n) {
		if (b[i].w + colmin[b[i].c] <= x) {
			b[i].w = colmin[b[i].c];
		}
	}
	REP(i, 1, n) {
		if (b[i].c != min_col) {
			min_wei2 = min(min_wei2, b[i].w);
		}
	}

	ll ttl = 0;
	REP(i, 1, n) {
		if (b[i].c != min_col && b[i].w + min_wei <= y) {
			movable[i] = 1;
			colnum[b[i].c]++;
			ttl++;
		}
		if(b[i].c == min_col && b[i].w + min_wei2 <= y){
			movable[i] = 1;
			colnum[b[i].c]++;
			ttl++;
		}
	}
	ll ans = 1;
	REP(i, 1, ttl) {
		ans = mod_m(ans, i);
	}
	REP(i, 1, n) {
		ll tmp = 1;
		REP(j, 1, colnum[i]) {
			tmp = mod_m(tmp, j);
		}
		tmp = mod_inv(tmp);
		ans = mod_m(ans, tmp);
	}
	cout << ans << endl;
	/*
	REP(i, 1, n) {
		cout << colnum[i] << " ";
	}
	cout << endl;
	REP(i, 1, n) {
		cout << b[i].c << " ";
	}
	cout << endl;
	REP(i, 1, n) {
		cout << b[i].w << " ";
	}
	cout << endl;
	REP(i, 1, n) {
		cout << movable[i] << " ";
	}

	cout << endl;
	cout << endl << ttl << endl;
	*/
}

Measured memory_bytes: 10112
function Main(_input) {
    input = _input.split("\n");
    var str_K = input[0];
    var arr_secondLine = input[1].split(" ");
    var num_K = parseInt(str_K);
    var num_A = parseInt(arr_secondLine[0]);
    var num_B = parseInt(arr_secondLine[1]);
    var result = false;
    for( var i = num_A; i <= num_B; i++ ) {
        if(i % num_K == 0){
            result = true;
            break;
        }
    }
    console.log( result? "OK": "NG" );
    
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

using ull = unsigned long long;

template<typename T>
constexpr T GCD(T a, T b) {
    return (a % b ? GCD(b, a % b) : b);
}

template<typename T>
constexpr T LCM(T a, T b) {
    return a * b / GCD(a, b);
}

int main() {
    ull A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << (B - A + 1) + (B / LCM(C, D) - (A - 1) / LCM(C, D)) - (B / C - (A - 1) / C) -
            (B / D - (A - 1) / D) << endl;
    return 0;
}


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


typedef long long LLI;

bool isprime(int num){

  int div = 2;
  while(div <= sqrt(num)){

    if(num%div == 0) return false;

    div += 1;

  }

  return true;
}

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

  for(int i = N; i < 100004; i ++ ){
    if(isprime(i)) {
      cout << i << endl;
      break;
    }
  }

}





Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n,k = map(int,input().split())
s = list(input())

if s[k-1] == "A":
    s[k-1] = "a"
if s[k-1] == "B":
    s[k-1] = "b"
if s[k-1] == "C":
    s[k-1] = "c"

print("".join(s))


Measured memory_bytes: 3060
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;


public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        final int n=scanner.nextInt();
        int[][] graph=new int[n][n];
        for(int i=0;i<n;i++){
            int index=scanner.nextInt();
            int loopCount=scanner.nextInt();
            for(int j=0;j<loopCount;j++){
                graph[index-1][scanner.nextInt()-1]=1;
            }
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                System.out.print(graph[i][j]);
                if(j==n-1){
                    System.out.println();
                }else{
                    System.out.print(" ");
                }
            }
        }

    }
}


Measured memory_bytes: 34996
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	N, K int
)

func parse() {

	stdin := bufio.NewScanner(os.Stdin)
	stdin.Split(bufio.ScanWords)

	stdin.Scan()
	n, _ := strconv.Atoi(stdin.Text())
	N = n

	stdin.Scan()
	k, _ := strconv.Atoi(stdin.Text())
	K = k
}

func cubic(a int) int {
	return a * a * a
}

func calc() int {

	if K%2 == 0 {
		return cubic(N/K) + cubic((N+(K/2))/K)
	} else {
		return cubic(N / K)
	}
}

func main() {
	parse()
	fmt.Println(calc())
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  
  sort(a.begin(),a.end(),greater<int>());
  int m,l,k;
  m=a[0];
  a.erase(a.begin());
  sort(a.begin(),a.end());
  if(n==2)l=0;
  else {for(int i=1;i<n;i++){
    if(a[i]>m/2){
      l=a[i];
      k=a[i-1];
      break;
    } 
  }
       }
  if(m/2-k<l-m/2)l=k;
  cout << m << " " << l << endl;
}

Measured memory_bytes: 768