akhauriyash/Code-Regression huggingface dataset:
k, a, b = map(int, input().split())


if b - a < 2:
    print(k + 1)
else:
    t = k - a + 1
    if t >= 2 and t % 2 == 0:
        ans = (b - a) * (t // 2) + a
    else:
        ans = (b - a) * (t // 2) + a + 1
    print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
#define inf 1000000000
int main(){
    int n;
    cin >> n;
    int x[n];
    rep(i,n) cin >> x[i];
    int ans = inf;
    rep(i,101){
        int temp = 0;
        rep(j,n){
            temp += (x[j]-i)*(x[j]-i);
        }
        ans = min(ans,temp);
    }
    cout << ans << endl;

    return 0;    
}

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

string s;
bool a[4];

int main(){
    bool flag=true;

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin>>s;
    for (int i=0; i<s.size(); i++){
        if (s[i]=='N') a[0]=true;
        if (s[i]=='S') a[1]=true;
        if (s[i]=='W') a[2]=true;
        if (s[i]=='E') a[3]=true;
    }

    if ((!a[0]&&a[1])||(a[0]&&!a[1])) flag=false;
    if ((!a[2]&&a[3])||(a[2]&&!a[3])) flag=false;

    if (flag) cout<<"Yes";
    else cout<<"No";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.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;}
const ll INF = 1LL << 60;

int main() {
    int a, b; cin >> a >> b;
    if(a != 1  && b != 1) cout << 1 << endl;
    if(a != 2  && b != 2) cout << 2 << endl;
    if(a != 3  && b != 3) cout << 3 << endl;
}

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


#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
using ll = long long;

/*
  小さい順: sort(v.begin(), v.end());
  逆順: reverse(v.begin(), v.end());
  vector<pair<ll, ll> > p; ＃ソートした場合、１つ目でソート
  tie(b, a) = p.at(i); #pairを分割
  tasks.emplace_back(b, a)  ＃配列tasksの最後に(b,a)を追加
    string -> int : stoi(S);
  int -> string : to_string(N);
  Sのn文字以降をm文字取り出す : S.substr(n,m)

  int: -2,147,483,648 ～ 2,147,483,647 (2×10^9)
  ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 (9×10^18)

*/

//126~
//126-e

int main() {

    ll N, count=0, ans=0;
    string S;
    cin >> N;
    if(N==0) cout << 1 << endl;
    else cout << 0 << endl;

}



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

bool d(int a[],int n,int key)
{
	for(int i=0;i<n;i++)
	if(a[i]==key) return true;
	return false;
}
int main()
{
	int a;
	cin>>a;
	int _a[a];
	for(int i=0;i<a;i++) cin>>_a[i];
	int b;
	cin>>b;
	int _b[b];
	for(int i=0;i<b;i++) cin>>_b[i];
	
	int count=0;
	for(int i=0;i<b;i++)
	{
		if(d(_a,a,_b[i])) count++;
	}
	printf("%d\n",count);
	return 0;
}


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

int main(){
	int n;
	cin >> n;
	if(n==1||n==2){
		cout << 2 << endl;
		return 0;
	}
	while(true){
		int count=0;
		rep(i,sqrt(n)+1){
			if(n%i==0)count++;
		}
		if(count==0){
			cout << n << endl;
			break;
		}
		n++;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int m,n;
int main()
{
	scanf("%d%d",&m,&n);
	if(m==n)
	{
		printf("Draw");
		return 0;
	}
	if(m==1&&n==13)
	{
		printf("Alice");
		return 0;
	}
	if(m==13&&n==1)
	{
		printf("Bob");
		return 0;
	}
	if(m>n) 
	  printf("Alice");
	if(n>m)
	  printf("Bob");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <random>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using Pt = pair<int, int>;

int main()
{
	int X;
	cin >> X;
	if (X <= 599)
		cout << 8 << endl;
	else if (X <= 799)
		cout << 7 << endl;
	else if (X <= 999)
		cout << 6 << endl;
	else if (X <= 1199)
		cout << 5 << endl;
	else if (X <= 1399)
		cout << 4 << endl;
	else if (X <= 1599)
		cout << 3 << endl;
	else if (X <= 1799)
		cout << 2 << endl;
	else
		cout << 1 << endl;


	return 0;
}

Measured memory_bytes: 3668
import std.stdio;
import std.conv;
import std.string;
import std.algorithm;

void main()
{
    auto n = map!(to!int)(readln.strip.split);

    while(n[0]!=-1 || n[1] != -1 || n[2] != -1) {
        string grade;
        int m=n[0],f=n[1],r=n[2],score=0;

        score = m+f;
        if(m==-1 || f ==-1)
        {
            grade = "F";
        }
        else if(score >= 80)
        {
            grade = "A";
        }
        else if(score < 80 && score >= 65)
        {
            grade = "B";
        }
        else if(score < 65 && score >= 50)
        {
            grade = "C";
        }
        else if(score < 50 && score >= 30)
        {
            if(r>=50)
                grade = "C";
            else
                grade = "D";
        }
        else
            grade = "F";

        writeln(grade);
        n = map!(to!int)(readln.strip.split);
    }
}

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

typedef long long LL;

LL calc( int n ) {
    LL res = 1;
    for ( int i = 1; i <= n; ++ i ) {
        res *= i;
    }
    return res;
}

LL solve( string s ) {
    int n = s.size();
    int cnt[26] = {0};
    for ( int i = 0; i < n; ++ i ) {
        cnt[s[i]-'a'] ++;
    }
    if ( n % 2 == 1 ) {
        int cnt2 = 0;
        for ( int i = 0; i < 26; ++ i ) {
            if ( cnt[i] % 2 == 1 ) cnt2 ++;
        }
        if ( cnt2 > 1 ) return 0;
    } else {
        for ( int i = 0; i < 26; ++ i ) {
            if ( cnt[i] % 2 == 1 ) return 0;
        }
    }
    LL a = calc(n/2), b = 1;
    for ( int i = 0; i < 26; ++ i ) {
        if ( cnt[i] > 0 ) b *= calc( cnt[i] / 2 );
    }
    return a / b;
}

int main() {
    string line;
    while ( cin >> line ) {
        cout << solve( line ) << endl;
    }
    return 0;
}

Measured memory_bytes: 0
def func(a,b,c,d,s):
    if a+b+c+d==7:
        s[1],s[3],s[5]="+","+","+"
    elif a+b+c-d==7:
        s[1],s[3],s[5]="+","+","-"
    elif a+b-c+d==7:
        s[1],s[3],s[5]="+","-","+"
    elif a+b-c-d==7:
        s[1],s[3],s[5]="+","-","-"
    elif a-b+c+d==7:
        s[1],s[3],s[5]="-","+","+"
    elif a-b+c-d==7:
        s[1],s[3],s[5]="-","+","-"
    elif a-b-c+d==7:
        s[1],s[3],s[5]="-","-","+"
    elif a-b-c-d==7:
        s[1],s[3],s[5]="-","-","-"

x=str(input())
ans=''

a=int(x[0])
b=int(x[1])
c=int(x[2])
d=int(x[3])

s=[a,"",b,"",c,"",d]

func(a,b,c,d,s)

for x in s:
    ans+=str(x)

print(ans+"=7")

Measured memory_bytes: 3064
lst = ['#', "."]
lst *= 150



while True:
    h, w = [int(i) for i in input().split(' ')]
    if h == 0 and w == 0:
        exit()
    for j in range(h):
        if j % 2 == 0:
            print(*lst[:w], sep='')
        else:
            print(*lst[:-w-1:-1], sep='')
    print()


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

int main(void){
	int n,k,x,y,ans=0;
	cin >> n >> k >> x >> y;
	
	for(int i=1;i<n+1;i++){
		if(i<=k) ans+=x; else ans +=y;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#[macro_use]extern crate text_io;

fn main(){
    let n:i32 = read!();
    let m:i32 = read!();
    let mut a:Vec<i32> = Vec::with_capacity((m-1) as usize);

    for _ in 1..=m {
        a.push(read!());
    }

    let mut hwsum = 0;
    for i in a.iter() {
        hwsum += *i;
    }
    println!("{}",if hwsum > n {-1} else {n - hwsum});
}

Measured memory_bytes: 2164
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,n-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,n-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll sum = 0;
    rep(i,n) sum ^= a[i];
    rep(i,n) cout << (sum^a[i]) << endl;

    // cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 4840
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
*/public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
static class TaskD   {
public void solve(int testNumber, Scanner in, PrintWriter out) {
        int N = in.nextInt();
        int M = in.nextInt();
        int[] factor = factor(M);
        out.println(M/factor[binary_search(N, factor)]);
    }

public   static int[] factor(long n) {
        int[] ret = new int[(int)Math.sqrt(n) + 6];
        int pos = 0;
        for(int i = 1; i*i <= n; i++){
            if(n%i==0) ret[pos++] = i;
        }
        int max = pos;
        if(ret[max-1] == Math.sqrt(n)) max-=1;
        for(int i = max-1; i >= 0; i--){
            ret[pos++] = (int)(n/ret[i]);
        }
        return Arrays.copyOf(ret, pos);
    }

boolean isOK(int index, int key, int[] a) {
        if (a[index] >= key) return true;
        else return false;
    }

int binary_search(int key, int[] a) {
        int ng = -1;
        int ok = (int)a.length - 1;
        if(!isOK(ok, key, a)){
            return 1 << 29;
        }
        while (Math.abs(ok - ng) > 1) {
            int mid = (ok + ng) / 2;

            if (isOK(mid, key, a)) ok = mid;
            else ng = mid;
        }
        return ok;
    }

}
}



Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 
 
int32_t main()
{
    fast;
    string s, t;
    int c = 0;
    cin >> s >> t;
    For(i, 0, s.size()) {
        if(t[i] != s[i]) c++;
    }
    cout << c;
    
    
    
    return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll A[200005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    ll N;
    cin >> N;
    for(int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    if(N % 2 == 0)
    {
        for(int i = N-1; i > 0; i -= 2)
        {
            cout << A[i] << " ";
        }
        for(int i = 0; i < N; i += 2)
        {
            cout << A[i] << " ";
        }
    }
    else
    {
        for(int i = N-1; i >= 0; i -= 2)
        {
            cout << A[i] << " ";
        }
        for(int i = 1; i < N; i += 2)
        {
            cout << A[i] << " ";
        }
    }
    return 0;
}


Measured memory_bytes: 3712
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

size_t H, W;
auto a = make_v(0_im, 35, 35);

auto dp = make_v(-1_im, 35, 35, 1225);

intmax_t rec(int y, int x, intmax_t dist) {
    if (dist < 0) return INF;
    if (y == 0 && x == 0) return 0;
    if (~dp[y][x][dist]) return dp[y][x][dist];

    intmax_t ret = INF;
    for (size_t i = 0; i < 4; ++i) {
        int ny = y + dy[i];
        int nx = x + dx[i];
        if (inside(ny, nx, H, W)) {
            chmin(ret, rec(ny, nx, dist - 1) + ((dist - 1) * 2 + 1) * a[y][x]);
        }
    }

    return dp[y][x][dist] = ret;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> H >> W;

    for (size_t i = 0; i < H; ++i) {
        for (size_t j = 0; j < W; ++j) {
            cin >> a[i][j];
        }
    }

    intmax_t res = INF;
    for (intmax_t d = 1; d <= H * W; ++d) {
        chmin(res, rec(H - 1, W - 1, d));
    }

    cout << res << "\n";

    return 0;
}



Measured memory_bytes: 14972
while True:
    x = input()
    list = x.split()
    list_i = [int(s) for s in list]
    [H, W] = list_i
    #Hが縦の数、Wが横の数

    #終了条件を指定
    if H == 0 and W == 0:
        break

    
    #2行ずつ処理していくので2で割った数字（切捨て）を出しておく
    tate = H // 2
    yoko = W // 2
    
    #Hの奇数、偶数、Wの奇数、偶数で4パターン作る。
    
    #####H＝偶数、W＝偶数の場合
    if H % 2 == 0 and W % 2 == 0:
    
        for a in range(tate):
            #1行目の処理
            for b in range(yoko - 1):
                print("#.", end="")
            print("#.")
            b = 0
        
            #2行目の処理
            for b in range(yoko - 1):
                print(".#", end="")
            print(".#")
            b = 0
        a = 0
    
    #####H＝偶数、W＝奇数の場合
    elif H % 2 == 0 and not W % 2 == 0:
    
        for a in range(tate):
            #1行目の処理
            for b in range(yoko):
                print("#.", end="")
            print("#")
            b = 0
        
            #2行目の処理
            for b in range(yoko):
                print(".#", end="")
            print(".")
            b = 0
        a = 0
        
    #####H＝奇数、W＝偶数の場合
    elif not H % 2 == 0 and W % 2 == 0:

        for a in range(tate):
            #1行目の処理
            for b in range(yoko - 1):
                print("#.", end="")
            print("#.")
            b = 0
        
            #2行目の処理
            for b in range(yoko - 1):
                print(".#", end="")
            print(".#")
            b = 0
        
        #最終行の処理
        for b in range(yoko - 1):
            print("#.", end="")
        print("#.")
        b = 0
        
        a = 0
    
    
    
    #####H＝奇数、W＝奇数の場合
    elif not H % 2 == 0 and  not W % 2 == 0:

        for a in range(tate):
            #1行目の処理
            for b in range(yoko):
                print("#.", end="")
            print("#")
            b = 0
        
            #2行目の処理
            for b in range(yoko):
                print(".#", end="")
            print(".")
            b = 0
        
        #最終行の処理
        for b in range(yoko):
            print("#.", end="")
        print("#")
        b = 0
        a = 0
    
    print()



Measured memory_bytes: 6400
#include <stdio.h>

int main(void){
	int i, x, n;
	scanf("%d", &n);
	for(i = 3; i <= n; i++){
		x = i;
		if(i % 3 == 0){
			printf(" %d", x);
			continue;
		}
		while(x > 0){
			if(x % 10 == 3){
				printf(" %d", i);
				break;
			}
			x /= 10;
		}
	}
	printf("\n");
	return 0;
}

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

const ll MAXN = 10000;

ll N, ans=0, tmp1=0, tmp2=0, tmp3=0;
string A[MAXN];

signed main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];
    for(int i=0;i<N;i++) {
        for(int j=0;j<A[i].size()-1;j++) {
            if(A[i][j]=='A'&&A[i][j+1]=='B') {
                A[i][j] = 'C';
                A[i][j+1]= 'C';
                ans++;
            }
        }
        if(A[i][0]=='B') tmp1++;
        if(A[i][A[i].size()-1]=='A') tmp2++;
        if(A[i][0]=='B'&&A[i][A[i].size()-1]=='A') tmp3++;
    }
    if(tmp2<tmp1) ans+=tmp2;
    else ans+=tmp1;
    if(tmp3!=0&&tmp1==tmp3&&tmp2==tmp3) ans--;
    cout << ans << endl;
    return 0;
}

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

int main(){
    int X;
    cin >> X;
    while(true){
        bool flag = true;
        for(int i = 2; i <= sqrt(X); ++i){
            if(X % i == 0){
                flag = false;
                break;
            }
        }
        if(flag){
            cout << X << endl;
            break;
        }
        ++X;
    }
    return 0;
}

Measured memory_bytes: 3644
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define d long double
#define pii pair<int,int>
#define pb push_back
#define pf push_front
#define cases int t;cin>>t;while(t--)
#define N 100003
#define M 103
#define inf LLONG_MAX
//int mod=1e9+7;
//int mod=998244353;

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int n;
    cin>>n;
    int ans=0,ma=0,i,x;
    for(i=1;i<=n;++i)
    {
        cin>>x;
        ma=max(ma,x);
        if(x==ma)
        {
            ++ans;
        }
    }
    cout<<ans;



    return 0;
}


Measured memory_bytes: 256
n,c = map(int,input().split())
sushi = [[0,0]]
for i in range(n):
    x,v = map(int,input().split())
    sushi.append([x,v])

###はじめ反時計回りに回る場合
score = [0 for i in range(n+1)] #時計回りでk番目までの寿司が食べられる時、最大摂取カロリーを記録する
start = 0
noteat = 0
for i in range(1,n+1):
    temp = 0
    if score[i-1] - (sushi[i][0] - start) + sushi[i][1] + noteat > score[i-1]: #寿司を食べた場合
        temp = score[i-1] - (sushi[i][0] - start) + sushi[i][1] + noteat
        noteat = 0
        start = sushi[i][0]
    else:
        noteat += sushi[i][1]
        temp = score[i-1]
    score[i] = temp



ans = score[n]
leftscore = 0
dist = 0
for i in range(1,n): #i個は反時計回りに食べてから時計回りに戻る
    leftscore += sushi[-i][1]
    if i == 1:
        dist += c - sushi[-i][0]
    else:
        dist += sushi[-i+1][0] - sushi[-i][0]
    if leftscore - 2*dist + score[n-i] > ans:
        ans = leftscore - 2*dist + score[n-i]


#######

#######はじめ時計回りに回る場合
reverse = [0 for i in range(n+1)]
start = c
noteat = 0
for i in range(1,n+1):
    temp = 0
    if sushi[-i][1] - (start - sushi[-i][0]) + reverse[i-1] + noteat > reverse[i-1]: #寿司を食べた場合
        temp = sushi[-i][1] - (start - sushi[-i][0]) + reverse[i-1] + noteat
        noteat = 0
        start = sushi[-i][0]
    else:
        noteat += sushi[-i][1]
        temp = reverse[i-1]
    reverse[i] = temp



ans2 = reverse[n]
rightscore = 0
dist = 0
for i in range(1,n): #i個時計回りに食べてから戻る
    rightscore += sushi[i][1]
    dist += sushi[i][0] - sushi[i-1][0]
    if rightscore - 2*dist + reverse[n-i] > ans2:
        ans2 = rightscore - 2*dist + reverse[n-i]

print(max(ans,ans2))

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

int64_t h;

int64_t dp(int64_t i) {
    if (i == 0 || i == 1) {
        return 1;
    }
    return 1 + 2 * dp(i / 2);
}

void solve() {
    cout << dp(h) << endl;
}

int main() {
    cin >> h;    
    solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits> 



int main()
{
    long N,X,Y;
    std::cin >> N >> X >> Y;
    X-=1;
    Y-=1;
    long result[2001]={};
    long point=X+(Y-X)/2;
    for(long i=0; i<N; i++){
        for(long j=i+1; j<N; j++){
            if(i<=X){
                if(j<=point){
                    result[j-i]++;
                }else{
                    result[abs(X-i)+1+abs(j-Y)]++;
                }
            }else{
                long num=std::min(abs(j-i),abs(i-X)+1+abs(j-Y));
                result[num]++;
            }
        }
    }

    for(long i=1; i<N; i++){
        std::cout << result[i] << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;

const long long MOD = 1000000007;

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

	int n;
	cin >> n;
	int a = 1, b = 1;
	
	int checker[8] = {0};
	rep(i, n) {
		int p;
		cin >> p;
		checker[p - 1] = 1;
		int t = 1;
		REP(j, 2, n - i) {
			t *= j;
		}

		int s = 0;
		rep(j, p-1) {
			if (checker[j] == 0)++s;
		}

		a += t * s;
	}
	
	rep(i, 8) {
		checker[i] = 0;
	}

	rep(i, n) {
		int p;
		cin >> p;
		checker[p - 1] = 1;
		int t = 1;
		REP(j, 2, n - i) {
			t *= j;
		}

		int s = 0;
		rep(j, p - 1) {
			if (checker[j] == 0) ++s;
		}

		b += t * s;
	}

	cout << abs(a - b) << "\n";

	return 0;
}


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

int main(){  	
	std::string S;
	std::string T;
	std::cin >> S >> T;
  	int min = T.size();
  	int pass = S.size() - T.size();
  	for(int j=0;j <= pass;j++){
      int count = 0;
      for(int i = 0; i < T.size(); i++){
          if(T.at(i) != S.at(j + i)){
              count++;
          }
      }
      if(count < min){
      	min = count;
      }
    }
  	std::cout << min << std::endl;
	return 0;
}

Measured memory_bytes: 3652
import java.util.*;
public class Main {
	public static int cnt(int x) {
		int ret=0;
		while (x>0) {
			++ret;
			x-=x&-x;
		}
		return ret;
	}
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int[] dp=new int[1<<n];
		int[][] a=new int[n][n];
		int mod=1000000007;
		for (int i=0;i<n;++i)
			for (int j=0;j<n;++j)
				a[i][j]=in.nextInt();
		dp[0]=1;
		for (int i=0,v=0;i<(1<<n)-1;++i,v=cnt(i)) if (dp[i]>0)
			for (int u=0;u<n;++u) if ((i>>u&1)==0&&a[u][v]>0)
				dp[i^(1<<u)]=(dp[i^(1<<u)]+dp[i])%mod;
		System.out.println(dp[(1<<n)-1]);
	}
}

Measured memory_bytes: 30164
#include<stdio.h>
int main()
{
	int x[3000],y[3000],i=0,j=0,h;
	for (;;)
	{
		scanf("%d %d", &x[i], &y[i]);
		if (x[i] == 0 && y[i] == 0)
		{
			break;
		}
		if (x[i] <= y[i])
		{
			printf("%d %d\n", x[i], y[i]);
		}
		else
		{
			printf("%d %d\n", y[i], x[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 2604
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
#include <set>

const int INF = (1 << 28);

using namespace std;

typedef pair<unsigned char, int> pci;
typedef pair<double, pci> C;       // ??????????????£?????¬?????????????????´???

double d[256][31];                 // ?????£?????¬????????¶?????????????????´???

int main(void) {
    int n, m, p, a, b;

    while (cin >> n >> m >> p >> a >> b, n+m+p+a+b) {
        for (int i = 0; i < 256; i++) {
            for (int j = 0; j < 31; j++) {
                d[i][j] = INF;
            }
        }

        vector<int> t(n);       // ??¬???
        for (int i = 0; i < n; i++) {
            cin >> t[i];
        }
        vector<vector<int>> city(m+1, vector<int>(m+1)); // ????????¨?????????????????????????????£????????????
        for (int i = 0; i <= m; i++) {
            for (int j = 0; j <= m; j++) {
                city[i][j] = INF;
            }
        }
        int x, y, z;
        for (int i = 0; i < p; i++) {
            cin >> x >> y >> z;
            city[x][y] = z;
            city[y][x] = z;
        }

        priority_queue<C, vector<C>, greater<C> > que;
        que.push(C(0, pci(0, a)));
        d[0][a] = 0;
        while (!que.empty()) {
            C c = que.top(); que.pop();
            int cn = c.second.second;      // ???????????????
            unsigned char ticket = c.second.first;  // ?????£???????????¬???
            // ?????£????????????????????°?????°??????
            int cnt = 0;
            for (int i = 0; i < 8; i++) {
                cnt += (ticket >> i) & 1;
            }
            if (cnt == n) continue;
            if (d[ticket][cn] < c.first) continue;

            for (int i = 1; i <= m; i++) {
                if (city[cn][i] != INF) {
                    for (int j = 0; j < n; j++) {
                        // j???????????¬???????????£??????????????£??????
                        if (!((ticket >> j) & 1)) {
                            double time = c.first + (city[cn][i] / (double)t[j]);
                            unsigned tmp = ticket | (1 << j);
                            if (d[tmp][i] > time) {
                                d[tmp][i] = time;
                                que.push(C(time, pci(tmp, i)));
                            }
                        }
                    }
                }
            }
        }

        double ans = INF;
        for (int i = 0; i < 256; i++) {
            ans = min(ans, d[i][b]);
        }

        if (ans != INF) {
            printf("%.5f\n", ans);
        } else {
            puts("Impossible");
        }
    }


    return 0;
}

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

const int MAXN = 200000+10;
vector<int> G[MAXN];
bool possible[MAXN];
int main()
{
    int N,M;
    scanf("%d%d",&N,&M);
    for(int i = 0 ; i < M ; i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        G[a].push_back(b);
    }
    for(int i = 0 ; i < G[1].size(); i++)
    {
        int t = G[1][i];
        possible[t] = true;
        for(int j = 0 ; j < G[t].size();j++)
        {
            possible[G[t][j]] = true;
        }
    }
    if(possible[N])
    {
        printf("POSSIBLE\n");
    }
    else{
        printf("IMPOSSIBLE\n");
    }
    return 0;
}


Measured memory_bytes: 8696
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <climits>

#define PI 3.14159265359

using namespace std;
using ll = long long;
using pint = pair<int, int>;

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

	vector<int> L(M);
	vector<int> R(M);

	for (int i = 0; i < M; ++i) {
		cin >> L[i] >> R[i];
	}

	int maxNo = 100000;
	int minNo = 0;

	for (int i = 0; i < M; ++i) {
		minNo = max(minNo, L[i]);
		maxNo = min(maxNo, R[i]);
	}

	int ans = maxNo - minNo;
	if (ans < 0) {
		cout << 0 << endl;
	}
	else {
		cout << (maxNo - minNo) + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 4036
var i,j,k,l,m,n,q,w,x,y,t:longint;
    st,ed,first,next,d,v,color,fw,c:array[1..200000] of longint;
    b:array[1..200000]of boolean;
procedure ad(p,o:longint);
begin
    t:=t+1;  ed[t]:=o; next[t]:=first[p];first[p]:=t;
end;
procedure dfs(p,o,cl:longint);
var i,j:longint;
begin
    if fw[p]>=o then exit;
    i:=first[p]; fw[p]:=o;  b[p]:=true;
    if color[p]=0 then color[p]:=cl;
    while (i>=1) do begin
        if b[ed[i]]=false then
               dfs(ed[i],o-1,cl);
        i:=next[i];
    end;
   b[p]:=false;
end;
begin
    readln(n,m);
    for i:=1 to m do first[i]:=-1;
    fillchar(fw,sizeof(fw),255);
    for i:=1 to m do begin readln(x,y); ad(x,y);ad(y,x); end;
    readln(q);
    for i:=1 to q do readln(v[i],d[i],c[i]);
    for i:=q downto 1 do begin dfs(v[i],d[i],c[i]); end;
    for i:=1 to n do writeln(color[i]);
end.

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

struct ConvexHullTrick {
    struct Line {
        long long a, b;
        long long get(long long x) { return a * x + b; }
    };
    deque<Line> que;
    bool check(Line a, Line b, Line c) {
        return (b.b - c.b) * (b.a - a.a) <= (a.b - b.b) * (c.a - b.a);
    }
    void add(long long a, long long b) {
        Line l{a, b};
        while(que.size() > 1 && check(que[que.size() - 2], que.back(), l))
            que.pop_back();
        que.push_back(l);
    }
    long long query(long long x) {
        if(que.empty()) return INT64_MAX;
        while(que.size() > 1 && que[0].get(x) >= que[1].get(x))
            que.pop_front();
        return que[0].get(x);
    }
};

int N;
long long C;
long long h[200009];

ConvexHullTrick cht;

long long dp[200009];

int main() {
    cin >> N >> C;
    for(int i = 0; i < N; i++)
        cin >> h[i];

    cht.add(-2 * h[0], h[0] * h[0]);
    for(int i = 1; i < N; i++) {
        dp[i] = cht.query(h[i]) + h[i] * h[i] + C;
        cht.add(-2 * h[i], dp[i] + h[i] * h[i]);
    }

    cout << dp[N - 1] << endl;

    return 0;
}

Measured memory_bytes: 5632
N = int(input())
L = list(map(int,input().split()))
ans = 0
for i in range(N):
    j = i+1
    for j in range(N):
        k = j+1
        for k in range(N):
            if L[i] != L[j] and L[i] != L[k] and L[j] != L[k]:
                if L[i]<L[j]+L[k] and L[j]<L[i]+L[k] and L[k]<L[i]+L[j]:
                    ans += 1
            k += 1
        j += 1
    i += 1
print(ans//6)

Measured memory_bytes: 9104
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<vector<int> > vvi;
#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define frpn(x) freopen(#x ".in","r",stdin);freopen(#x ".out","w",stdout);
#define all(a) a.begin(), a.end()
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)(n); ++i)
#define forab(i, a, b) for(int i=(int)(a); i<=(int)(b); ++i)
#define fornd(i, n) for(int i=(int)(n); i>=0; --i)

const int INF = (int)1e6+5;
const int NAX = (int)50+5;
const int MOD = (int)1e9+7;

template <class T>
inline void rem(T &n){
   n = (-MOD <= n && n <= MOD) ? n : n%MOD ;
  if(n < 0) n += MOD; 
} 
int a[NAX];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n; cin >> n;
    forn(i, n){
      cin >> a[i];
      --a[i];
    }
    int c = 0, f = 0;
    forn(i, n){
      if(a[a[i]] == i && a[i] != i)
        ++c;
      if(a[i] == i)
         ++f;
      
    }
    if((c == 2 && f == n-2) || c == 0 && f == n)
      cout << "YES\n";
    else
      cout << "NO\n";
    return 0;
  }


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

int main() {
int n;
cin >> n;
vector<int> w(n);
vector<int> a;
rep(i,n) cin >> w.at(i);

for(int t = 1; t <= n; t++){
  int sum1 = 0,sum2 = 0;
  for(int i = 1; i <= n; i++){
    if(i <= t) sum1 += w.at(i-1);
    else sum2 += w.at(i-1);
  }
  a.push_back(abs(sum2-sum1));
}
sort(a.begin(),a.end());
cout << a.at(0) << endl;
}
  


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  pair<int,int> p[M];
  for(int i=0;i<M;i++){
    cin >> p[i].first >> p[i].second;
    p[i].first--;
    p[i].second--;
  }

  sort(p,p+M);

  int cnt = 0;
  int mx = 1000000007;
  for(int i=0;i<M;i++){
    int s = p[i].first;
    int t = p[i].second;
    if(s>=mx){
      cnt++;
      mx = t;
    }
    mx = min(mx, t);
  }

  cout << cnt + 1 << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repi(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
typedef long long ll;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  ll ans=0;
  string prev="",now="";
  for(char c:s){
    now+=c;
    if(prev!=now){
      ans++;
      prev=now;
      now="";
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int x;
    cin >> x;
    
    if(x < 600){
        cout << 8;
    }
    else if(x < 800){
        cout << 7;
    }
    else if(x < 1000){
        cout << 6;
    }
    else if(x < 1200){
        cout << 5;
    }
    else if(x < 1400){
        cout << 4;
    }
    else if(x < 1600){
        cout << 3;
    }
    else if(x < 1800){
        cout << 2;
    }
    else{
        cout << 1;
    }
    
    return 0;
}


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

int main(){
    long long N,D,x,y,sum =0;
    cin >> N >> D;
    D *= D;
    for(long long i = 0;i < N ;i++){
        cin >> x >> y;
        if(D >= x*x+y*y)
            sum++;
    }
    cout << sum <<endl;
}

Measured memory_bytes: 3496
N = int(input())
h = list(map(int, input().split()))

dp = [N * 10 ** 4] * N
dp[0] = 0
for i in range(1, N):
	dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]))
	if i > 1:
		dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]))

print(dp[-1])

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

for h in range(1, 3501):
    for n in range(1, 3501):
        if 4*h*n != N*(n+h):
            x = N*h*n
            y = 4*h*n - N*(n+h)
            w = x // y
            if x % y == 0 and 1 <= w <= 3500:
                print(h, n, w)
                exit()



Measured memory_bytes: 41308
n=int(input())
l=list(map(int,input().split()))
mi=10**9
mi_lst=[]
cnt=0
for i in range(n):
  if l[i]<mi:
    mi_lst.append(l[i])
    mi=min(mi,l[i])
    cnt+=1
  else:mi_lst.append(l[-1])
print(cnt)

Measured memory_bytes: 24744
#include <stdio.h>
#include <vector>
using namespace std;

int main(void)
{
	int n, m;	//??????A????????°???????????????b???????´???°
	scanf("%d %d", &n, &m);
	
	typedef vector<int> Row;
	vector<Row> matrixA(100,Row(100));
	vector<Row> matrixB(m,Row(1));
	
	
	for(int i = 0; i < n; i++){	//?????????
		for(int j = 0; j < m; j++){
			 matrixA[i][j] = 0;
		}
	}
	
	for(int i = 0; i < n; i++){	
		for(int j = 0; j < m; j++){
			scanf("%d", &matrixA[i][j]);
		}
	}
	for(int i = 0; i < m; i++){	
		for(int j = 0; j < 1; j++){	
			scanf("%d", &matrixB[i][j]);
		}
	}
	for(int i = 0; i < n; i++){	
		int c;
		int sum = 0;
		for(int j = 0; j < m; j++){
			c = matrixA[i][j] * matrixB[j][0];
			sum += c;
		}
		printf("%d\n", sum);
	}
}

Measured memory_bytes: 2812
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
using namespace std;

int main(){
  long long A,B,C;
  long long X,Y;
  cin >> A >> B >> C >> X >> Y;
  long long twoC = 2 * C;

  long long result = 0;
  if(A + B < twoC){
    result = A * X + B * Y; // Cが要らないケース
  }else{
    result = twoC * min(X, Y);
    if(X > Y){
      result += min(A, twoC) * (X - Y);
    }else{
      result += min(B, twoC) * (Y - X);
    }
  }

  cout << result << "\n";

  return 0;
}


Measured memory_bytes: 256
/**
  * @brief atcoder
  * @author yao
  */
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <utility>
#include <algorithm>
#include <functional>
#include <climits>
#define ft first
#define sd second
#ifdef DBG
#   define dbg_pri(x...) fprintf(stderr,x)
#else
#   define dbg_pri(x...) 0
#   define NDEBUG
#endif //DBG
#include <cassert>

typedef unsigned int uint;
typedef long long int lli;
typedef unsigned long long int ulli;

#define N 32
#define MAX 1e18

int x[N], y[N], p[N];
std::pair<int,int> a[N];
int na;
std::pair<int,int> b[N];
int nb;
lli rp[N], rn[N];
lli rx[N], ry[N];
lli ans[N];
lli dp[N][N];

void solve_b(lli *res)
{
    std::sort(b,b+nb);
    dbg_pri("poi 2:");
    for(int i=0;i<nb;++i)dbg_pri(" (%d,%d)", b[i].ft, b[i].sd);
    dbg_pri("\n");
    for(int i=1;i<=nb;++i)
    {
        dp[i][0] = dp[i-1][0] + (lli)b[i-1].ft*b[i-1].sd;
        for(int j=1;j<=i;++j)
        {
            dp[i][j] = dp[i-1][j-1];
            int s=i-1, l=0, r=b[s].sd;
            lli val = 0;
            for(int k=i-2;k>=0;--k)
            {
                l += b[k].sd;
                val += (lli)(b[s].ft-b[k].ft) * b[k].sd;
                while(s>k && r < l)
                {
                    val -= (lli)(l-r) * (b[s].ft-b[s-1].ft);
                    --s, l-=b[s].sd, r+=b[s].sd;
                }
                dp[i][j] = std::min(dp[i][j],dp[k][j-1] + val);
            }
        }
    }
    std::fill(res,res+N,0);
    for(int i=0;i<=nb;++i) res[i] = dp[nb][i];
    dbg_pri("poi 1:");
    for(int i=0;i<=nb;++i) dbg_pri(" %lld", res[i]);
    dbg_pri("\n");
}
void solve(lli *res)
{
    nb = 0;
    for(int i=0;i<na;++i)if(a[i].ft > 0)
        b[nb++] = a[i];
    solve_b(rp);
    nb = 0;
    for(int i=0;i<na;++i)if(a[i].ft < 0)
        b[nb++] = {-a[i].ft,a[i].sd};
    solve_b(rn);
    std::fill(res,res+N,MAX);
    for(int i=0;i<=na;++i)for(int j=0;j<=na;++j)
        res[i+j] = std::min(res[i+j], rp[i]+rn[j]);
    dbg_pri("poi 3:");
    for(int i=0;i<=na;++i) dbg_pri(" %lld", res[i]);
    dbg_pri("\n");
}

int main()
{
    int n;
    scanf("%d", &n);
    std::fill(ans,ans+N,MAX);
    for(int i=0;i<n;++i)
        scanf("%d%d%d", &x[i], &y[i], &p[i]);
    for(int i=0;i<1<<n;++i)
    {
        na = 0;
        for(int j=0;j<n;++j)if(i&1<<j) a[na++] = {x[j], p[j]};
        solve(rx);
        na = 0;
        for(int j=0;j<n;++j)if(!(i&1<<j)) a[na++] = {y[j], p[j]};
        solve(ry);
        for(int i=0;i<=n;++i)for(int j=0;j<=n;++j)
            ans[i+j] = std::min(ans[i+j], rx[i]+ry[j]);
    }
    for(int i=0;i<=n;++i)printf("%lld\n", ans[i]);
    return 0;
}


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

using namespace std;
using ll = long long;

template<class T>
class SegTree{
	int n;                       //葉の数
	vector<T> data;              //格納するデータ
	T def;                       //単位元
	function<T(T, T)> operation; //区間クエリで使う処理
	function<T(T, T)> update;    //点更新で使う処理

	//区間[a, b)の総和
	T _query(int a, int b, int k, int l, int r){
		if(r <= a || b <= l)return def;
		if(a <= l && r <= b)return data[k];
		T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2);
		T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r);
		return operation(c1, c2);
	}
public:
	
	//_n : 要素数, _def : 単位元, _operation : クエリ関数, _update : 更新関数
	SegTree(int _n, T _def, function<T(T,T)> _operation, function<T(T,T)> _update) : def(_def), operation(_operation), update(_update){
			n = 1;
			while(n < _n)n *= 2;
			data = vector<T> (2 * n - 1, def);
	}

	//[a, b)の区間クエリを実行
   T query(int a, int b){
		return _query(a, b, 0, 0, n);
	}

	void change(int i, T x){
		i += n - 1;
		data[i] = update(data[i], x);
		while(i  > 0){
			i = (i - 1) / 2;
			data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
		}
	}

	T operator[] (int i){
		return data[i + n - 1];
	}
};

int main()
{
	int n, q;
	string s;
	cin >> n >> s >> q;
	vector<int> ans;
	vector<SegTree<int>> seg(26, SegTree<int>(n, 0, [](int a, int b){return a + b;}, [](int a, int b){return b;}));

	for(int i = 0; i < n; i++) {
		seg[s[i] - 'a'].change(i, 1);
	}

	while(q--) {
		int f; cin >> f;
		if(f == 1) {
			int i; char c;
			cin >> i >> c; i--;
			for(int k = 0; k < 26; k++)seg[k].change(i, 0);
			seg[c - 'a'].change(i, 1);
		}else{
			int l, r, cnt = 0;
			cin >> l >> r; l--;
			for(int i = 0; i < 26; i++){
				cnt += (seg[i].query(l, r) != 0);
			}
			ans.push_back(cnt);
		}
	}

	for(auto i : ans)cout << i << endl;

}

Measured memory_bytes: 111620
n = int(input())
for i in range(n):
    hit_cou = 0
    out_cou = 0
    poi = 0
    while True:     
        eve = input()
        if eve == "HIT":
            if hit_cou == 3:
                poi += 1
            else:
            
                hit_cou += 1
        elif eve == "OUT":
            if out_cou == 2:
                print(poi)
                break
            else:
                out_cou += 1
        elif eve == "HOMERUN":
            poi += hit_cou + 1
            hit_cou = 0

Measured memory_bytes: 7540
//１オリジンでやった方がええかもね

#include<stdio.h>
#define N 101

main(){
  int n,i,j,u,k,v,A[N][N];
   
  for(i=0;i<N;i++){ //行列を０で初期化
    for(j=0;j<N;j++){
      A[i][j]=0;
    }
  }
 
  scanf("%d",&n);
   
  for(i=0;i<n;i++){ //n回ループ回す
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){ //ｋ回回してu列目(i列目)のv1行目を１にする
      scanf("%d",&v);
      A[i][v-1]= 1;
    }
  }
   
  for(i=0;i<n;i++){ //誰がね、誰がfor文回しても同じや同じや思って、やっと出力できるようになったんです
    for(j=0;j<n;j++){
      printf("%d", A[i][j]);
      if(j<n-1)printf(" ");
    }
    printf("\n");
  }

   
  return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
 
using namespace std;
 
int D[1005][1005];
 
int main() {
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;
    
    const int MOD = (int)1e9 + 7;
    
    char ch;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            cin >> ch;
            if (ch == '.') {
                if (i == 1 && j == 1) D[i][j] = 1;
                else D[i][j] = (D[i-1][j] + D[i][j-1]) % MOD;
            }
        }
    }
    
    cout << D[n][m];
    
    return 0;
}

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

int main() {
  ll x;
  cin >> x;
  ll sum=0;
  ll ans=0;
  rep(i,1000000){
    sum +=i;
    if(sum>=x){
      ans =i;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,a,b;
    cin>>n>>a>>b;
    long long ans =(n/(a+b))*a;
    n=n%(a+b);
    if(n>a)
    ans+=a;
    else
    ans+=n;
    cout<<ans<<endl;
    
    
    
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <set>
#include <cstdlib>
#include <ctime>

using namespace std;
typedef long long ll;

const int maxn = 100 + 10;

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    long long x, y;
    cin >> x >> y;
    int ans = 0;
    while(x<=y) ans++, x<<=1;
    cout << ans<< endl;
    return 0;
}

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

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

        int n = stoi(str);

        int count = 0; 
        while(n>0){
            count += n%10;
            n /=10;
        }

        cout << count << endl;
        return 0;
    }




Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    H=LI()
    now = H[0]-1
    for h in H:
        if now>h:
            print("No")
            return
        if now == h:
            continue
        now = max(h-1,now)
    print("Yes")
if __name__ == '__main__':
    main()

Measured memory_bytes: 17420
# coding: utf-8


def main():
    n = int(input())
    t = list(map(int, input().split()))
    m = int(input())
    time = []
    for i in range(m):
        time.append(list(map(int, input().split())))

    for i in range(m):
        result = 0
        for j in range(n):
            if time[i][0]-1 == j:
                result += time[i][1]
            else:
                result += t[j]
        print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
def calc(X):
    A = 1
    B = 1
    if X == 0:
        return A,B
    else:
        l_bound = 1
        h_bound = 200
        for i in range(l_bound,h_bound):
            for j in range(0,i+1):
                if i ** 5 - j ** 5 == X:
                    A = i
                    B = j
                    return A,B
                if i ** 5 + j ** 5 == X:
                    A = i
                    B = -j
                    return A,B
def resolve():
    X = int(input())
    A,B = calc(X)  
    print(str(A) + " " + str(B))
resolve()

Measured memory_bytes: 9040
#include<iostream>
#include<vector>
#include<string>
#include<cstdlib>
#include<sstream>
#include<queue>
#include<cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
#define INF 2147483647
#define lli long long int

using namespace std;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

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

	for (int i = 0; i < q; i++){
		int ans = 0;
		string n; cin >> n;
		//cout << " n = " << n << endl;
		while(1){
			int max = 0;
			if (n.size() == 1){
				cout << ans << endl;
				break;
			}else{
				for (int i = 0; i < n.size() - 1; i++){
					string str1 = n.substr(0,i+1);
					string str2 = n.substr(i+1,n.size()-i);
					//cout << "str1 = "  << str1 << endl;
					//cout << "str2 = "  << str2 << endl;
					int right = stoi(str1);
					int left = stoi(str2);
					if (max < right * left){
						max = right * left;
					}
				}
				ans++;
			}
			n = to_string(max);
		}
	}
	return 0;
}

Measured memory_bytes: 3240
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,k;
    while(cin>>n>>k)
    {
        long long l=n-k;
        long long s=0;
        for(int i=1;i<=l;i++)
        {
            long long r=n/(k+i);
            s+=r*i;
            if(n%(k+i)>=k)
                s+=n%(k+i)-k+1;
        }
        if(k==0)
            s-=n;
        cout<<s<<endl;
    }
    return 0;
}


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

int arr[223456];

int main() {
	// freopen("input.in", "r", stdin);
	// freopen("output.o", "w", stdout);
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &arr[i]);
	if (n % 2 == 1) {
		printf("%d ", arr[n]);
		for (int i = n - 2; i >= 1; i -= 2) printf("%d ", arr[i]);
		for (int i = 2; i <= n - 1; i += 2) printf("%d ", arr[i]);
	} else {
		printf("%d ", arr[n]);
		for (int i = n - 2; i >= 2; i -= 2) printf("%d ", arr[i]);
		for (int i = 1; i <= n - 1; i += 2) printf("%d ", arr[i]);
	}
}


Measured memory_bytes: 2944