akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedInputStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    private static long slove(String p,long all){
        char m[]=p.toCharArray();
        for(int k=1;k<=p.length()/2;k++){
            for(int i=0;i<m.length;i++){
                if(i+2*k>=p.length())
                    break;
                else{
                    if(m[i]!=m[i+k]&&m[i+2*k]!=m[i+k]&&m[i]!=m[i+2*k]) {
                        all--;
                    }
                }
            }
        }
        return all;
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(new BufferedInputStream(System.in));
        int a=sc.nextInt();
        String p=sc.next();
        long countR=0;
        long countG=0;
        long countB=0;
        char m[]=p.toCharArray();
        for(int i=0;i<m.length;i++){
            if(m[i]=='R')
                countR++;
            if(m[i]=='G')
                countG++;
            if(m[i]=='B')
                countB++;
        }
        long all=countB*countG*countR;
        System.out.println(Main.slove(p,all));
    }
}


Measured memory_bytes: 35876
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll n;
  string s;
  cin>>s;
  n=s.size();
  vector<ll>v2(n,0);
  ll t=0;
  ll tmp=1;
  for(ll i=0;i<n-1;i++){
    if(s[i]=='R'&&s[i+1]=='L')v2[i]+=tmp/2+tmp%2,v2[i+1]+=tmp/2,t=i+1,tmp=1;
    if(s[i]=='L'&&s[i+1]=='L')tmp++;
    if(s[i]=='L'&&s[i+1]=='R')v2[t]+=tmp/2+tmp%2,v2[t-1]+=tmp/2,tmp=1;
    if(s[i]=='R'&&s[i+1]=='R')tmp++;
  }
  v2[t]+=tmp/2+tmp%2,v2[t-1]+=tmp/2,tmp=1;
  cout<<v2[0];
  for(ll i=1;i<n;i++){
    cout<<" "<<v2[i];
  }
  cout<<endl;
}


Measured memory_bytes: 1472
import bisect
a,b,c,d,e,f = map(int,input().split())
water = set()
sugar = set()
for i in range(301):
    for j in range(301):
        if 0 < (i*a + j*b)*100 <= f:
            water.add((i*a + j*b)*100)
for i in range(1500//d + 1):
    for j in range((1500 - (i*d))//c + 1):
        if i*d + j*c <= f//2 + 1:
            sugar.add(i*d + j*c)
sugar = sorted(list(sugar))
ans = [100*a, 0]
M = 0
for i in water:
    tmp = [i, sugar[bisect.bisect(sugar,min(f-i, i*e/100)) - 1]]
    if tmp[1]/sum(tmp) > ans[1]/ans[0]:
        ans = [sum(tmp), tmp[1]]
print(' '.join([str(i) for i in ans]))


Measured memory_bytes: 39792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

int main(){
  string N; cin >> N;
  int ans = 0;
  string num = "0123456789";
  rep(i,N.size()){
    rep(j,11){ if(N[i]==num[j]) ans += j;}
    ans %= 9; 
  }
  if(ans == 0)  cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3752
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
int main(void){
    int n,x;
    scanf("%d%d",&n,&x);
    int l[n],d[n+1],ans=1;
    d[0]=0;
    for(int i=0;n>i;++i)
    scanf("%d",&l[i]);
    for(int i=1;n+1>i;++i){
        d[i]=d[i-1]+l[i-1];
        if(d[i]<=x)
        ++ans;
    }
    printf("%d",ans);
    return 0;
}

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

int main() {
    int x;
    cin >> x;
    int coin500, coin5;
    coin500 = (int)(x / 500);
    coin5 = (int)((x % 500) / 5);
    ll ans;
    ans = (ll)(coin500*1000 + coin5*5);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[201],s=0,b;
	cin>>n;
	for(int i=1;i<=n*2;i++){
		
		cin>>a[i];
		
		if(i%2==0){
			if(a[i]==a[i-1])s++;
			else s=0;
		} 
		
		if(s==3){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
}

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

typedef long long ll;

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

ll mod = 1e9+7;

ll power(ll a, ll b){
	ll tmp = 1LL;
	while( b >= 1){
		if(b % 2){ tmp = (tmp * a) % mod;}
		a = (a * a) % mod;
		b /= 2;
	}
	return tmp % mod;
}

ll modinv(ll x){
	return power(x, mod-2);
}
	       	
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	bool isprime[1000007];
	memset(isprime, true, sizeof(isprime));
	isprime[0] = isprime[1] = false;
	for(int i=4; i<1000007; i+=2) isprime[i] = false;
	for(int i=3; i*i<1000007; i+=2){
		if(isprime[i]){
			for(int j = i*i; j<1000007; j+=(2*i))
				isprime[j] = false;
		}
	}
	vector<ll> primes;
	for(int i=2; i<1000007; i++)
		if(isprime[i]) primes.push_back(i*1LL);
	//cout << primes.size() << endl;
	int n; cin >> n;
	ll arr[n];
	ll lcm = 1LL;
	map<ll, ll> m;
	for(int i=0; i<n; i++){
		cin >> arr[i];
		map<ll, ll> tmp;
		ll se = arr[i];
		while(arr[i] >  1){
			for(auto x: primes){
				if(arr[i] % x == 0){
					while(arr[i] % x == 0){
						arr[i] /= x;
						tmp[x]++;
					}
				}
				if( x * x > se) break;

			}
			if(arr[i] != 1)
				tmp[arr[i]]++;
			arr[i] = 1;
		}
		arr[i] = se;
		//cout << arr[i] << " : ";
		for(auto x : tmp){
			//cout << x.first << " " << x.second << endl;
			m[x.first] = max(m[x.first], x.second);
		}
	}
	//ll mul = 1;
	for(auto x: m){
		//cout << x.first << " " << x.second << endl;
		lcm = (lcm * power(x.first, x.second)) % mod;
	}
	//cout << lcm << endl;
	ll ans = 0;
	for(int i=0; i<n; i++){
		ans = ans + (modinv(arr[i]) * lcm) % mod;
		ans %= mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 2548
from sys import stdin
input = stdin.readline


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


N, Q = map(int, input().split())
c = list(map(int, input().split()))

lr = []
for i in range(Q):
    l, r = map(int, input().split())
    lr.append([l, r, i])

lr.sort(key=lambda x: x[1])
# print("lr", lr)
rightest = [-1] * (N + 1)
current_q = 0
bit = Bit(N)
ans = [0] * Q

for i in range(N):
    if rightest[c[i]] != -1:
        bit.add(rightest[c[i]] + 1, -1)
    rightest[c[i]] = i
    bit.add(i + 1, 1)
    # print(bit.tree)

    while current_q < Q and lr[current_q][1] == i + 1:
        ans[lr[current_q][2]] = bit.sum(lr[current_q][1]) - bit.sum(lr[current_q][0] - 1)
        current_q += 1

for i in range(Q):
    print(ans[i])


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

int main() {
    int n; cin>>n;
    int acts[n][3], dp[n][4];

    memset(dp, -1, sizeof dp);
    for (int i=0; i<n; i++) cin>>acts[i][0]>>acts[i][1]>>acts[i][2];
    for (int i=0; i<3; i++) dp[n-1][i] = acts[n-1][i];

    for (int day=n-2; day>=0; day--) {
        for (int act=0; act<3; act++) {
            for (int next=0; next<3; next++) {
                if (act==next) continue;
                dp[day][act] = max(
                    dp[day][act],
                    acts[day][act] + dp[day+1][next]
                );
            }
        }
    }

    int ans = max({ dp[0][0], dp[0][1], dp[0][2] });
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;

int main(){
   
    string s1,s2,s3;
    int n;
    cin>>n>>s1>>s2>>s3;
    int ans=0;
            set<char> s;
    for(int i=0;i<n;i++){
        
        s.insert(s1[i]);
        s.insert(s2[i]);
        s.insert(s3[i]);
        
       
        ans+=s.size()-1;
        s.clear();
    }
    cout<<ans<<endl;
return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);

  rep(i, n) cin >> a[i];
  sort(a.rbegin(), a.rend());
  ll ans = 0;
  int t = n - 1;

  rep(i, n) {
    int lim = 2;
    if(i == 0) lim = 1;
    rep(j, lim) {
      if (t > 0) {
        ans += a[i];
        t--;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

int countDivisibles(int A, int B, int M) 
{  
	int counter = 0; 
	for (int i = A; i <= B; i++) 
		if (i % M == 0) 
			counter++; 

	return counter; 
} 


int main() 
{ 
	 int A, B, M;
	 cin >> A >> B >> M;
	cout << countDivisibles(A, B, M) << endl; 
	return 0; 
} 


Measured memory_bytes: 3592
//in progress
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fr(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define forn(i,n) for(int i =0; i < (int)(n); i++)
#define rfr(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define PI 3.14159265
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  //freopen("a.in", "r", stdin);
  //freopen("a.out", "w", stdout);
  int n,k;
  cin>>n>>k;
  int a[n+5];
  for(int i=0;i<n;i++)
  cin>>a[i];
  int fw[k+5];
  memset(fw,0,sizeof(fw));
  for(int i=0;i<=k+2;i++)
  {
    for(int j=0;j<n;j++)
    {
      if(i-a[j]>=0 && fw[i-a[j]]==0)
      {fw[i]=1;
      break;}
    }
  }
  if(fw[k]==0)
  cout<<"Second\n";
  else
  cout<<"First\n";
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#define fi first
#define se second
#define p_b push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define all(x) x.begin(),x.end()
#define sset ordered_set
#define sqr(x) (x)*(x)
#define pw(x) (1ll << x)

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
const ll MAXN = 1123456;
const ll N = 2e5;
mt19937_64 rnd(chrono::system_clock::now().time_since_epoch().count());

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename T> void vout(T s){cout << s << endl;exit(0);}


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

    ll n;
    cin >> n;

    cout << n * sqr(n) << "\n";


    return 0;
}


Measured memory_bytes: 256
n = int(input())
Items = {}
init = True


for i in range(n):
    s = str(input())
    if init:
        Items[s] = 0
    else:
        Keys = Items.keys()
        duplicate = False
        key = ""
        for j in range(len(Items)):
            if Keys[j] == s:
                duplicate = True
                break
            else:
                duplicate = False
        if duplicate:
            Items[key] += 1
        else:
            Items[s] = 0

print(len(Items))

Measured memory_bytes: 35072
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 入力
		int[] x = new int[5];
		boolean error = false;
		for (int i = 0; i < 5; i++) {
			x[i] = sc.nextInt();
			if (x[i] > 123 || x[i] < 1) {
				error = true;
			}
		}
		// 入力チェック
		if (error) {
			System.out.println("無効な入力値です");
			return;
		}
		
		// 答えを出力
		int count = 0;
		int max = 0;
		for (int i = 0; i < 5; i++) {
			count = count + x[i];
			if (10 - x[i] % 10 != 10){
				count = count + 10 - x[i] % 10;
				if (max <= 10 - x[i] % 10) {
					max = 10 - x[i] % 10;
				}
			}
		}
		count = count - max;
		System.out.println(count);
	}
}


Measured memory_bytes: 22608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		int a = scanner.nextInt();
		int b = scanner.nextInt();

		if(a<=8&&b<=8) {
			System.out.println("Yay!");
		}else {
			System.out.println(":(");
		}

	}

}


Measured memory_bytes: 22484
from collections import deque
sx,sy,tx,ty=map(int,input().split())
# sx,sy,tx,ty=-2,-2,1,1
result=deque()
A=B=C=D=0

#右に移動
for _ in range(sx,tx):
  result.append("R")
  A+=1

#上に移動
if sy!=ty:
  for _ in range(sy,ty):
    result.append("U")
    B+=1
#真横の点を指定されたとき
# else:
#   result.append("U")
#   B+=1

#左に1個移動して、上に移動した分-1だけ下にくだっていく
result.append("L")
for _ in range(B-1):
  result.append("D")
  C+=1

#右に移動した分-1だけ左に移動する
for _ in range(A-1):
  result.append("L")
  D+=1

#下に移動することでスタート地点に戻ってくる
result.append("D")

#下に１個移動し、A+1だけ右に移動
result.append("D")
for _ in range(A+1):
  result.append("R")

#B+1だけ上に移動
for _ in range(B+1):
  result.append("U")

#ゴールを通っててさらに上に
result.append("L")
result.append("U")

#左に2個移動して、Cだけ下がる
result.append("L")
result.append("L")
for _ in range(C):
  result.append("D")

#左にＤだけ移動
for _ in range(D):
  result.append("L")

#仕上げ
result.append("D")
result.append("D")
result.append("R")

print(*result,sep="")


Measured memory_bytes: 5236
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define sz(v) ((int)((v).size()))
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<
T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    
    double r;
    cin>>r;
    printf("%.12f",2.0*r*3.141592653589);
    return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
using namespace std;

int main(){ 
  long a,b,n,x=0,y=0,ans=100000,c=0;
  cin>>n>>a>>b;
  if(n==1){
    if(b==a) co(1);
    else co(0);
  }
  else{
    if(b>=a) co((n-2)*(b-a)+1);
    else co(0);
  }
  
  return 0;
}

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

using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

bool era[10000001]={false};


void makeERA(){
    for(int i=2;i<1000001;i++){
        if(era[i]!=true)continue;
        for(int j=2;i*j<=10000000;j++){
            era[i*j]=false;
        }

    }
    era[2]=true;
}




int main(){
    for(int i=0;i<10000001;i++)era[i]=true;
    era[0]=false;era[1]=false;
    makeERA();
    
    int n;
    while(cin>>n){
        if(n==0)break;
        
        if(n%2==0)n--;
        for(int i=n;i>=8;i-=2){
            if(era[i-8]&&era[i-6]&&!era[i-4]&&era[i-2]&&era[i]){
                cout<<i<<endl;
                goto next;
            }
        }
        next:;
    }
    
    
    return 0;
}

Measured memory_bytes: 10924
#include <iostream>
using namespace std;
 
int main() {
    int N ;
    cin >> N ;
   double num1=1;
   double base1=2;
   double num2=(N+1);
   double base2=2*N;
   if(N%2==0){
       cout<<num1/base1;
   }
   else{
       cout<<num2/base2;
   }
   return 0;
}

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

int main(){
    cin.sync_with_stdio(false);
    int n, k; cin >> n >> k;

    vector<int>v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    
    vector<int>cost(n, INT_MAX);
    cost[n-1] = 0;
    for(int i = n-2; i >= 0; i--){
        for(int j = i+1; j <= i+k && j < n; j++){
            cost[i] = min(cost[i], cost[j]+abs(v[j]-v[i]));
        }
    }

    cout<<cost[0]<<endl;
}


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

int main() {
  int64_t N, C;
  cin >> N;
  C = 0;
  
  for (int64_t i = 0; i < N; i++) {
    if ((i + 1) % 15 == 0) {
    }
    else if ((i + 1) % 3 == 0) {
    }
    else if ((i + 1) % 5 == 0) {
    }
    else {
      C = C + (i + 1);
    }
  }
  
  cout << C;
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
"""
Created on Fri Aug  7 01:25:53 2020

@author: saito
"""

# %% import phase
#from collections import deque

# %% define phase


# %% input phase
K = int(input())

# %% process phase
r = 0
answer = -1
h = []

for cnt in range(K):
    r = (10*r+7) % K
    if r == 0:
        answer = cnt + 1
        break

# %%output phase
print(answer)

Measured memory_bytes: 9184
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, H):
    ans = 0
    t = 0
    for i in range(1, len(H)):
        if H[i-1] >= H[i]:
            t += 1
        else:
            ans = max(ans, t)
            t = 0
    ans = max(ans, t)
    return ans


def main():
    N = read_int()
    H = read_int_n()
    print(slv(N, H))


if __name__ == '__main__':
    main()


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

int main(){
  int n;
  cin>>n;
  int a,b,c,d;
  int pnt[1000]={};

  for(int i=0;i<(n*(n-1)/2);i++){
cin>>a>>b>>c>>d;
 if(c>d) pnt[a]+=3;
 else if(d>c)pnt[b]+=3;
 else if(d==c) pnt[a]++,pnt[b]++;
  }
  int vic[1000];

  for(int i=1;i<=n;i++){
    int cnt=1;
    for(int j=1;j<=n;j++)if(pnt[i]<pnt[j])cnt++;
    vic[i]=cnt;
  }
  for(int i=1;i<=n;i++) cout<<vic[i]<<endl;


  return 0;
}

Measured memory_bytes: 1168
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

const int N=6010;
int a[N][N];
int main()
{
    int n, k, k2; cin>>n>>k;
    k2=k+k;
    for(int x, y; n--; ) {
        char c;
        cin>>x>>y>>c;
        if (c%2) x+=k;
        x%=k2, y%=k2;
        for(int i=0; i<4; ++i) {
            for(int j=0; j<4; ++j) {
                if (i%2!=j%2) continue;
                ++a[y+i*k][x+j*k];
                --a[y+i*k][x+j*k+k];
                --a[y+i*k+k][x+j*k];
                ++a[y+i*k+k][x+j*k+k];
            }
        }
    }
#define rep(i, a) for(int i=a; i<N; ++i)
    rep(i, 0) rep(j, 1) a[i][j]+=a[i][j-1];
    rep(i, 1) rep(j, 0) a[i][j]+=a[i-1][j];

    int res=0;
    rep(i, 0) rep(j, 0) res=max(res, a[i][j]);
    cout<<res<<endl;
}


Measured memory_bytes: 141312
import itertools
n,m,q = map(int,input().split())
inputList = []
for i in range(1,q+1):
    abcd = list(map(int,input().split()))
    inputList.append(abcd)
AList =  list(itertools.combinations_with_replacement(range(1,m+1), n))
PointList = []
for array in AList:
    point = 0
    for iList in inputList:
        if array[iList[1]-1] - array[iList[0]-1] == iList[2]:
            point = point + iList[3]
    PointList.append(point)
print(max(PointList))


Measured memory_bytes: 25116
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {k: isize,s: isize}
    let mut res = 0;
    for x in 0..=k {
        for y in 0..=k {
            let z = s - x - y;
            if 0 <= z && z <= k {
                res += 1;
            }
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll n,k;
  cin >> n >> k;
  vector<ll> vec(n);
  rep(i,n){
    cin >> vec[i];
  }
  rep(i,n-k){
    if(vec[k+i] > vec[i]){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}

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

int main() {
    int a1,a2,a3;
    cin >> a1 >> a2 >> a3;
    if((a1 == 7 && a2 == 5 && a3 == 5)||(a1 == 5 && a2 == 7 && a3 == 5)||(a1 == 5 && a2 == 5 && a3 == 7)){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
 
const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;
 
 
int n;
 
vector<vi> g;
int c[500005], lev[500005], memo[500005];
int naive[500005];
int level;
void dfs(int r){
	lev[r] = level++;
	FOR(v, g[r]){
		dfs(*v);
		c[r] += c[*v];
		naive[r] += naive[*v] + c[*v];
		if(naive[r] > (1 << 28)) naive[r] = 1 << 28;
	}
	--level;
}
 
int solve(int r){
	if(r == n-1) return 0;
	if(memo[r]) return memo[r];
	const int c1 = g[r][0];
	const int c2 = g[r][1];
	return memo[r] = min(naive[c1]+c[c1]+solve(c2)+1,
					 min(naive[c2]+c[c2]+solve(c1)+1,
						 solve(c1)+solve(c2)+lev[r]+2));
}
 
int main_(){
	ios::sync_with_stdio(false);
	while(cin >> n){
		g = vector<vi>(n);
		REP(i, n-1){
			int x, y;
			cin >> x >> y;x--;y--;
			g[i].push_back(x);
			g[i].push_back(y);
		}
		memset(c, 0, sizeof(c));
		c[n-1] = 1;
		naive[n-1] = 0;
		dfs(0);
		cout << solve(0) << endl;
	}
	return 0;
}

long long esp_org, esp_new;

main(){
    //  新しいスタック領域を確保する
    const int size = 28*1024*1024;
    void *p = malloc(size);
    esp_new = (long long)p + size - 1;

    //  スタックを置き換える
    __asm__("mov %rsp, esp_org");
    __asm__("mov esp_new, %rsp");
    
    //  メインの処理
    main_();
    //  スタックを元に戻す
   __asm__("mov esp_org, %rsp");

    return 0;
}

Measured memory_bytes: 60124
// C - Build Stairs

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


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

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

	string ans = "Yes";
	for (int i=N-1; i>=1; i--) {
		if (H[i-1] > H[i]) {
			H[i-1]--;
			if (H[i-1] > H[i]) {
				ans = "No";
				break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int N;
int A[100];

int main() {
  cin >> N;
  for (int i=0; i<N; i++) cin >> A[i];
  int m = 1145141919;
  for (int a=-100; a<=100; a++) {
    int c = 0;
    for (int i=0; i<N; i++) c += (A[i]-a)*(A[i]-a);
    m = min(c, m);
  }
  cout << m << "\n";
  return 0;
}


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 sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int n,m,q;
vector<int> a(51),b(51),c(51),d(51);
int dfs(int i,int j,vector<int>& A){
    if(i==n){
        int res=0;
        rep(k,q){
            if(A[b[k]]-A[a[k]]==c[k])res+=d[k];
        }
        return res;
    }
    
    int res=0;
    for(int k=j;k<=m;k++){
        auto nA=A;
        nA.push_back(k);
        int buf=dfs(i+1,k,nA);
        chmax(res,buf);
    }
    return res;
}
int main(void){
    cin>>n>>m>>q;
    rep(i,q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--;b[i]--;
    }
    vector<int> A;
    int res=dfs(0,1,A);
    cout<<res<<endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int a, b, x;
    cin >> a >> b >> x;
    double PI = acos(-1);
    double theta = 0.0;
    if (x * 2 >= a * a * b) { 
        theta = atan(2 * (a * a * b - x) * 1.0 / a / a / a);
    } else {
        theta = PI / 2 - atan(x * 2.0 / a / b / b);
    }

    cout << fixed << setprecision(7) << (180.0 / PI * theta) << endl;
    return 0;
};

Measured memory_bytes: 256
n, m = (int(x) for x in input().split())
p = [(i,0) for i in range(n)]

def check(i):
    j, d = p[i]
    if j != i:
        ii, dd = check(j)
        p[i] = (ii, d+dd)
    return p[i]

f = True
for _ in range(m):
    l, r, d = (int(x) for x in input().split())
    l-=1;r-=1
    li, ld = check(l)
    ri, rd = check(r)
    if li != ri:
        t = d+ld-rd
        if t >= 0:
            p[ri] = (li, t)
        else:
            p[li] = (ri, -t)
    else:
        if rd - ld != d:
            f = False
            break
print("Yes" if f else "No")


Measured memory_bytes: 16020
///B - Power Socket

#include<iostream>
using namespace std;
int main()
{
    int n,c;
    cin>>n>>c;
    int a=1,i,str=0;
    for(i=1; a<c; i++)
    {
        a= a+(n-1);
        str++;
    }
    cout<<str<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

string str;
int N; // 必要な数よりも大きい2^nよりも大きい数を入れるとよい
int BIT[600000];
int ind[300000] = {};

void add(int a, int w){
	
	// a番目の要素にwを足す O(log N)
	
	for(int x = a; x <= N; x += x & -x){
		BIT[x] += w;
	}
}

int sum(int a){
	
	// 1からaまでの要素の合計を返す O(log N)
	
	int ret = 0;
	for(int x = a; x > 0; x -= x & -x){
		ret += BIT[x];
	}
	return ret;
}

void init(){
	for(int i = 0; i < N; i++){
		BIT[i] = 0;
	}
}

long long int solve(){
	long long int ans = 0;
	for(int i = 0; i < str.size(); i++){
		ans += i - sum(ind[i]);
		add(ind[i], 1);
	}
	return ans;
}

int main(){
	
	cin >> str;
	
	N = 600000;
	
	int cnt[26] = {};
	vector<int> pos[26];
	
	for(int i = 0; i < str.size(); i++){
		cnt[str[i] - 'a']++;
	}
	
	int fl = 1;
	for(int i = 0; i < 26; i++){
		if(cnt[i] % 2 == 1){
			fl--;
		}
	}
	
	if(fl < 0){
		cout << "-1" << endl;
		return 0;
	}
	
	bool flag[26] = {};
	
	int ind_cur = 1;
	for(int i = 0; i < str.size(); i++){
		if(cnt[str[i] - 'a'] % 2 == 1 && pos[str[i] - 'a'].size() == cnt[str[i] - 'a'] / 2 && !flag[str[i] - 'a']){
			ind[i] = str.size() / 2 + 1;
			flag[str[i] - 'a'] = true;
		}else if(!flag[str[i] - 'a']){
			ind[i] = ind_cur;
			pos[str[i] - 'a'].push_back(ind_cur);
			ind_cur++;
			if(cnt[str[i] - 'a'] % 2 == 0 && pos[str[i] - 'a'].size() >= cnt[str[i] - 'a'] / 2){
				flag[str[i] - 'a'] = true;
			}
		}else{
			ind[i] = str.size() - pos[str[i] - 'a'][pos[str[i] - 'a'].size() - 1] + 1;
			pos[str[i] - 'a'].pop_back();
		}
	}
	
	cout << solve() << endl;
	
	return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,j,k=0;
    string ch;
    cin>>ch;
    n=ch.size();
    for(i=0;i<n;i++)
    {
        if(ch[i]=='h' && ch[i+1]=='i')
        {
            k++;
        }
    }
    if((k*2)==n)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
xy = []
X = []
Y = []
for i in range(n):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
    xy.append([x, y])
X.sort()
Y.sort()
ans = float("inf")
for i in range(n):
    for j in range(i + 1, n):
        for l in range(n):
            for m in range(l + 1, n):
                count = 0
                for o in range(n):
                    if X[i] <= xy[o][0] <= X[j] and Y[l] <= xy[o][1] <= Y[m]:
                        count += 1
                if count >= k:
                    ans = min(ans, (X[j] - X[i]) * (Y[m] - Y[l]))
print(ans)

Measured memory_bytes: 74600
#include<iostream>
using namespace std;
int main(int argc, char *argv[])
{
  for(;;) {
    string sstr;
    getline(cin, sstr);
    if(sstr == "#") break;
    const char *str = sstr.c_str();
    int cnt = 0;
    const int n = sstr.length();
    int nhs = 0, nts = 0, ntsp = 0;
    char hs[5][21], ts[5][21];
    for(int i = 0; i < 1 << n; i++) {
      char tmp[21], ans[21];
      ans[n] = 0;
      bool invalid = false;
      int ii = i;
      // bit reversal
      { register unsigned int x = i;
        x = (((x & 0xaaaaaaaa) >> 1) | ((x & 0x55555555) << 1));
        x = (((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2));
        x = (((x & 0xf0f0f0f0) >> 4) | ((x & 0x0f0f0f0f) << 4));
        x = (((x & 0xff00ff00) >> 8) | ((x & 0x00ff00ff) << 8));
        ii = ((x >> 16) | (x << 16));
        ii >>= (32-n);
      }
      for(int k = 0; k < n; k++, ii>>=1) {
        tmp[k] = str[k] + (ii&1); //(((ii & bb)) ? 1 : 0);
        ans[k] = tmp[k];
        if(tmp[k] > 'z') { invalid = true; break; }
      }
      if(invalid) continue;
      int hist[256];
      for(char c = 'b'; c <= 'z'; c++) {
        hist[c] = 0;
      }
      for(char *p = tmp; p != tmp + n; p++) {
        hist[*p]++;
      }
      for(char c = 'b'; c <= 'z'; c++) {
        if(hist[c] == 0) continue;
        for(char *p = tmp; p != tmp + n; p++) {
          if(*p == c) {
            (*p)--;
            break;
          }
        }
        // for(int k = 0; k < n; k++) {
        //   if(tmp[k] == c) {
        //     tmp[k]--;
        //     break;
        //   }
        // }
      }
      bool ok = true;
      for(int k = 0; k < n; k++) {
        if((str[k] != tmp[k])) { ok = false; break; }
      }
      if(ok) {
        cnt++;
        if(nhs<5) {
          for(int k = 0; k < n; k++) {
            hs[nhs][k] = ans[k];
          }
          hs[nhs][n] = 0;
          nhs++;
        } else {
          if(nts < 5) nts++;
          for(int k = 0; k < n; k++) {
            ts[ntsp][k] = ans[k];
          }
          ts[ntsp][n] = 0;
          ntsp = (ntsp + 1) % 5;
        }
      }
    }
    cout << cnt << endl;
    for(int i = 0; i < nhs; i++) {
      cout << hs[i] << endl;
    }
    for(int i = 0; i < nts; i++) {
      cout << ts[(ntsp - nts + i + 5) % 5] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3132
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;


int main(void)
{
	int N, t, pre_min, ans;
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	cin >> N;
	cin >> t;
	pre_min = t;
	ans = -(1 << 31);
	while (--N)
	{
		scanf("%d", &t);
		ans = max(ans, t - pre_min);
		pre_min = min(pre_min, t);
	}
	cout << ans << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3184
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 1000000007;
const int INF = 1000000000;
const double EPS = 1e-9;


int main() {

	cin.tie(0);

	int n, m;
	cin >> n >> m;
	
	vector<lint> x(n), y(m);
	FOR(i, 0, n) cin >> x[i];
	FOR(j, 0, m) cin >> y[j];

	lint sum_x = 0, sum_y = 0;

	FOR(i, 0, n) {
		sum_x += x[i] * (1 - n + 2 * i);
		sum_x %= MOD;
	}
	FOR(j, 0, m) {
		sum_y += y[j] * (1 - m + 2 * j);
		sum_y %= MOD;
	}

	cout << sum_x * sum_y % MOD;

	return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    map<int, vector<int>> Jobs;
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        if (a > M) continue;
        Jobs[a].push_back(b);
    }

    priority_queue<int> que;
    int64_t cnt = 0;
    for (int i = 1; i <= M; i++) {
        for (int r : Jobs[i]) {
            que.push(r);
        }
        if (!que.empty()) {
            int r = que.top();
            que.pop();
            cnt += r;
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 10880
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
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; }
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
const ll INF =1LL << 62;
int main(){

	ll n; cin >>n;
	ll ans=0;
	if(n==1){cout <<0 << endl;return 0;}
	if(n==2){cout << 0 << endl;return 0;}
	for(int i=1;i<sqrtl(n);i++){
		if(n%i==0)
          if(n/i!=i+1 &&n/i!=i-1)ans+=(n/i-1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int n, m;
  while (cin >> n >> m, n || m)
  {
    vector<int> a(n);
    for (auto &e : a)
      cin >> e;
    int ans = -1;
    for (int i = 0; i < n; ++i)
    {
      for (int j = i + 1; j < n; ++j)
      {
        if (i == j)
          continue;
        if (ans < a[i] + a[j] && a[i] + a[j] <= m)
          ans = a[i] + a[j];
      }
    }
    if (ans == -1)
      cout << "NONE" << endl;
    else
      cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3024
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        
        int progression[] = new int[n];
        
        int minPosition = 0;
        for(int i = 0; i < n; i++){
            progression[i] = sc.nextInt();
            if(progression[i] == 0){
                minPosition = i;
            }
        }

        int leftS = minPosition % (k - 1);
        int rightS = (n - minPosition - 1) % (k - 1);

        int left = 0;
        if(minPosition != 0){
            if(minPosition == k - 1){
                left = 1;
            }else{
                left = minPosition / (k - 1) + 1;
                left = leftS > 0 ? left + 1 : left;
            }
        }
        
        int right = 0;
        if(minPosition != n - 1){
            if(minPosition == n - k){
                right = 1;
            }else{
                right = (n - minPosition - 1) / (k - 1);
                right = rightS > 0 ? right + 1 : right;
            }
        }
        
        int count = right + left;
        if(rightS == 1 && leftS == 1){
            count--;
        }
        
        System.out.println(count);
        
    }
}



Measured memory_bytes: 49624
#include <iostream>
using namespace std;
int main(void){
    int T,J,S,Y,H;
    cin>>T>>J>>S>>Y>>H;
    
    if(T<40) T=40;
    if(J<40) J=40;
    if(S<40) S=40;
    if(Y<40) Y=40;
    if(H<40) H=40;
    
    cout<<(T+J+S+Y+H)/5<<endl;
}



Measured memory_bytes: 3088
c=[list(map(int,input().split())) for i in range(3)]
x=c[0][2]-c[0][1]
y=c[0][1]-c[0][0]
for i in range(1,3):
    if c[i][1]-c[i][0]!=y:
        print("No")
        break
    if c[i][2]-c[i][1]!=x:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 61896
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		int prevA = s;
 
		Set<Integer> prevFValues = new HashSet<>();
		prevFValues.add(s);
		for (int i=2; i<=1000000; i++) {
			int newA = f(prevA);
			if (prevFValues.contains(newA)) {
				System.out.println(i);
				return;
            }
			prevFValues.add(newA);
			prevA = newA;
		}
	}

	static int f(int n) {
		return (n % 2 == 0) ? (n / 2) : (3 * n + 1);
	}
}


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

int main(void) {
  char s[8001];
  int op[8000] = {}, x, y;
  int dx1_arr[16001] = {}, dy1_arr[16001] = {}, dx2_arr[16001] = {}, dy2_arr[16001] = {};
  int *dx1 = dx1_arr, *dy1 = dy1_arr, *dx2 = dx2_arr, *dy2 = dy2_arr, *tmp;
  int s_len, i, n, j;

  scanf("%s %d %d", s, &x, &y);
  s_len = strlen(s);
  for (i = n = 0; i < s_len; i++) {
    if (s[i] == 'F') op[n]++;
    else n++;
  }

  dx1[8000+op[0]] = dy1[8000] = 1;
  for (i = 1; i <= n; i++) {
    if (i % 2 == 0) {
      for (j = 0; j < 16001; j++) {
        if (dx1[j] == 1) {
          dx2[j-op[i]] = dx2[j+op[i]] = 1;
          dx1[j] = 0;
        }
      }
      tmp = dx1; dx1 = dx2; dx2 = tmp;

    } else {
      for (j = 0; j < 16001; j++) {
        if (dy1[j] == 1) {
          dy2[j-op[i]] = dy2[j+op[i]] = 1;
          dy1[j] = 0;
        }
      }
      tmp = dy1; dy1 = dy2; dy2 = tmp;
    }
  }

  if (dx1[8000+x] == 1 && dy1[8000+y] == 1) printf("Yes\n");
  else printf("No\n");

  return 0;
}


Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))
sum = 0
ans = 0
for i in range(n):
    if i % 2 == 0:
        if a[i] <= 0:
            ans += abs(a[i]) + 1
            sum += 1
        else:
            sum += a[i]
        if sum <= 0:
            ans += abs(sum) + 1
            sum = 1
    else:
        if a[i] >= 0:
            ans += abs(a[i]) + 1
            sum += -1
        else:
            sum += a[i]
        if sum >= 0:
            ans += abs(sum) + 1
            sum = -1
ans_odd = ans
sum = 0
ans = 0
for i in range(n):
    if i % 2 != 0:
        if a[i] <= 0:
            ans += abs(a[i]) + 1
            sum += 1
        else:
            sum += a[i]
        if sum <= 0:
            ans += abs(sum) + 1
            sum = 1
    else:
        if a[i] >= 0:
            ans += abs(a[i]) + 1
            sum += -1
        else:
            sum += a[i]
        if sum >= 0:
            ans += abs(sum) + 1
            sum = -1
ans = min(ans, ans_odd)
print(ans)

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

using namespace std;

int main()
{
    //system("chcp 65001");

    char b;
    cin >> b;

    if(b == 'A')
    {
        cout << "T";
    }
    else if(b == 'T')
    {
        cout << "A";
    }
    else if(b == 'C')
    {
        cout << "G";
    }
    else if(b == 'G')
    {
        cout << "C";
    }
    //cout << N;

    return 0;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin
 
ni = lambda:int(ns())
na = lambda:list(map(int,stdin.readline().split()))
ns = lambda:stdin.readline().rstrip()  # ignore trailing spaces

S = ns()
answer = 0
cur = S[0]

for s in S:
    if s != cur:
        answer += 1
        cur = s

print(answer)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

vector<ll> vec;

void go(ll val) {
	if (val > 3234566667ll) return;

	vec.push_back(val);
	for (int i = max(0ll, val % 10 - 1); i <= min(9ll, val % 10 + 1); ++i) {
		ll nxt = val * 10 + i;
		go(nxt);
	}
}
int main() {
	fastio;
	int K;
	cin >> K;

	for (int i = 1; i <= 9; ++i) go(i);
	sort(all(vec));

	cout << vec[K - 1];

	return 0;
}


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

using namespace std;

int main() {

    int N, M, C;
    cin >> N >> M >> C;

    int ans = 0;
    vector<int> B(M);
    for (int i = 0; i < M; ++i) {
        cin >> B[i];
    }

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

    for (int i = 0; i < N; ++i) {
        int sum = 0;
        for (int j = 0; j < M; ++j) {
            sum += B[j] * A[i][j];
        }
        if (sum > -C) {
            ans++;
        }
    }

    cout << ans << endl;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,k; cin>>n>>k;
  double ans=0;
  reps(i,n){
    ll now=i;
    double tmp=1.0/n;
    while(now<k) now*=2, tmp/=2;
    ans+=tmp;
  }
  coutd(ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
using namespace std;
int cnt[26];
string s;
main()
{
	cin>>s;
	for(char a:s)cnt[a-'a']++;
	priority_queue<long>P;
	long ans=0,c=0;
	for(int i=0;i<26;i++)if(cnt[i])
	{
		P.push(-cnt[i]);
		c++;
	}
	while(P.size()>1)
	{
		long now=P.top();P.pop();now+=P.top();P.pop();
		ans-=now;
		P.push(now);
	}
	cout<<ans-(c<2)*P.top()<<endl;
}



Measured memory_bytes: 3340
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
typedef unsigned long long l;
l p(l x,l n){
	if(!n)return 1;
	l r=p(x*x%M,n/2);
	if(n%2)r=r*x%M;
	return r;
}
int main(){
	l a,b;cin>>a>>b;cout<<p(a,b)<<endl;
}

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

using namespace std;

const double PI = M_PI;
int main()
{
	int n; cin >> n;
	int arr[n];
	memset(arr, 0, sizeof(arr));
	for(int i = 1; i < n; i++){
		int x; cin >> x;
		arr[--x]++;
	}
	for(int x : arr){
		cout << x << "\n";
	}
}


Measured memory_bytes: 4336
N,K=map(int,input().split())
A=list(map(int,input().split()))
A=[10*A[i] for i in range(N)]

def cond(n):
    cnt=0
    for i in range(N):
        q=(A[i]-1)//n
        cnt+=q

    return cnt<=K

start=0
end=10**10
while end-start>1:
    test=(end+start)//2
    if cond(test):
        end=test
    else:
        start=test

ans=end//10
if end%10>0:
    ans+=1

print(ans)


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

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

    int road[n] = {};
    int from , to;
    for(int i = 0; i < m; i++){
        cin >> from >> to;
        from--;
        to--;
        road[from]++;
        road[to]++;
    }

    for(int i = 0; i < n; i++){
        cout << road[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256