akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define reps(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) for(int i=0;i<a;i++)
typedef long long int ll;
using namespace std;
ll MOD = 1000000007;

const int MAX = 510000;

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int main(){
    ll N,M,K;
    cin>>N>>M>>K;
    long long int sum=0;
    for(ll k=1;k<N+1;k++){
        for(ll l=1;l<M+1;l++){
            sum = (sum %MOD) + (M*(((k-1)*k/2+(N-k)*(N-k+1)/2)% MOD)%MOD);
            sum = (sum % MOD) +  (N*(((l-1)*l/2+(M-l)*(M-l+1)/2)% MOD)%MOD);
            
        }
    }
    
    COMinit();
    long long aa = COM(N*M-2,K-2);
    
    sum = (aa%MOD) * (sum%MOD);
    
    sum = (sum % MOD) * modinv(2,MOD)%MOD;
    cout<<(sum % MOD);
    return 0;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n+1,0), b(m+1,0);
    ll ans = 0;
    ll x;
    for(int i=0;i<n;i++){
    	cin >> x;
    	a[i+1] = a[i] + x;
    }
    for(int i=0;i<m;i++){
    	cin >> x;
    	b[i+1] = b[i] + x;
    }
    for(int i=0;i<=n;i++){
    	if(a[i] > k) continue;
    	ll id = upper_bound(be(b), k - a[i]) - b.begin() - 1;
    	ans = max(ans, id + i);
    }
    cout << ans << endl;
    return 0;
}

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


int main(int argc, char *argv[]){
	string s;
	getline(cin,s);
	for (int i = 0; i < s.length(); ++i){
		if(s[i]<='z' && s[i]>='a')
			s[i]=s[i]-('a'-'A');
	}
	cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 1172
/*
	Name:
	Author: xiaruize
	Date:
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define ll long long
#define fir first
#define sz(a) int((a).size())
//#define int ll

int h,w,m,a[300005],b[300005],p1,p2;
set<pii> st;

signed main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j;
	cin>>h>>w>>m;
	vector<int> l,r;
	int x,y;
	for(i=1;i<=m;i++)
	{
		cin>>x>>y;
		st.insert(mk(x,y));
		a[x]++;
		b[y]++;
		if(a[x]>p1)
		{
			l.clear();
			p1=a[x];
		}
		if(a[x]==p1)
			l.pb(x);
		if(b[y]>p2)
		{
			r.clear();
			p2=b[y];
		}
		if(b[y]==p2)
			r.pb(y);
	}
	for(i=0;i<l.size();i++)
	{
		for(j=0;j<r.size();j++)
		{
			if(st.find(mk(l[i],r[j]))==st.end())
			{
				cout<<p1+p2<<endl;
				return 0;
			}
		}
	}
	cout<<p1+p2-1<<endl;
	return 0;
}


Measured memory_bytes: 21896
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<chrono>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X <<":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e14;
typedef std::pair<ll,ll> P;
struct edge{ int to,cost; };
#define VMAX 100000

ll N,M,K;
ll A,B,C,D,X,Y;
ll ans=0;
string G[100010];
string S,T,U;
ll F[100010];
bool ok=true;
std::queue<ll> Q;
ll Z[]={1,2,3,6,7,8,9,0};
int main(){
    cin>>N;
    ans=1;
    REP(i,N){
        ll a;
        cin>>a;
        if(a==0){cout<<0;return 0;}
        DEB(a)DEB(ans)DEB(log10(ans))DEB(double(log10(ans)+log10(a)))END
        if(double(log10(ans)+log10(a))>=(double)18&&ans*a!=1000000000000000000){
            DEB(log10(ans))DEB(log10(a))END
            ok=false;
        }
        
       if(ok) ans*=a;
       else ans=-1;
        
    }
    cout<<ans;
    
}

Measured memory_bytes: 7096
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		
		// 計算
		Permutation perm = new Permutation(n);
		
		// 出力
		for(String r : perm.list){
		    System.out.println(r);
		}
		//char result = 'a' + 3;
		//System.out.println(result);
	}
}

class Permutation {
    int n;
    ArrayList<String> list;
    long cnt = 0;
    
    public Permutation(int n){
        this.n = n;
        ArrayList<String> list = new ArrayList<String>();
        dfs("", 1, list);
        this.list = list;
    }
    
    private void dfs(String s, int max, ArrayList<String> list){
        this.cnt++;
        if(s.length() == n){
            list.add(s);
            return;
        }
        for(int i = 0; i < max; i++){
            char c = (char)('a' + i);
            //System.out.println("i:" + i + " now:" + now + " char:" + c);
            if(i == max-1){
                dfs(s + c, max+1, list);
            }else{
                dfs(s + c, max, list);
            }
        }
    }
}




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

/* void printv(stack<int> q){ */
/*   for(int i:q)cout<<i<<' '; */
/*   cout<<endl; */
/* } */

int main() {
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    string s;
    cin >> s;
    set<string> kind;
    kind.insert(s);
    for (int j = 1; j < int(s.size()); j++) {
      string first = s.substr(0, j);
      string second = s.substr(j);
      kind.insert(second + first);

      reverse(first.begin(), first.end());
      kind.insert(first + second);
      kind.insert(second + first);

      reverse(second.begin(), second.end());
      kind.insert(first + second);
      kind.insert(second + first);

      reverse(first.begin(), first.end());
      kind.insert(first + second);
      kind.insert(second + first);
    }
    cout << kind.size() << endl;
  }
}



Measured memory_bytes: 3184
from sys import stdin, stdout

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def binom_tables(n, q):
	fact = [1 for _ in range(n + 1)]
	inv = [1 for _ in range(n + 1)]
	for i in range(1, n+1):
		fact[i] = (fact[i-1] * i) % q
		inv[i] = pow(fact[i], q-2, q)
	return fact, inv

def binom(n, k, q, F, I):
	return (F[n]*((I[k]*I[n-k])%q))%q

def main():
	MOD = 998244353
	n, m, k = rli()
	F, I = binom_tables(n, MOD)
	ans = 0
	for i in range(n-k, n+1):
		ans += (binom(n-1, i-1, MOD, F, I)*m*pow(m-1, i-1, MOD))%MOD
	print(ans % MOD)

if __name__ == "__main__":
	main()

Measured memory_bytes: 84472
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=10000000;


int main(){
    LL l,n;cin >> l >> n;
    vector<LL> x(n),t(n);
    for(int i=0;i<n;i++){
        cin >> x[i];
    }
    for(int i=0;i<n;i++){
        t[i]=l-x[n-1-i];
    }
    vector<LL> a(n+1,0),b(n+1,0);
    for(int i=0;i<n;i++){
        a[i+1]=a[i]+x[i];
        b[i+1]=b[i]+t[i];
    }
    LL ans=0;
    for(int i=0;i<n;i++){
        int res=n-i-1;
        int k=res/2;
        if(res%2==0){
            LL s=2*(a[k+i]-a[i]+b[k])+x[k+i];
            ans=max(ans,s);
            s=2*(b[k+i]-b[i]+a[k])+t[k+i];
            ans=max(ans,s);
        }
        else{
            LL s=2*(a[k+i+1]-a[i]+b[k])+t[k];
            ans=max(ans,s);
            s=2*(b[k+i+1]-b[i]+a[k])+x[k];
            ans=max(ans,s);
        }

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

Measured memory_bytes: 6528
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)
#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = (ll)1 << 62;

ll t[1001] = {};
ll a[1001] = {};
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%lli %lli", &t[i], &a[i]);
	}
	ll currentT = 1, currentA = 1;
	for (int i = 0; i < n; ++i) {
		ll multiT = (currentT - 1LL) / t[i] + 1LL;
		ll multiA = (currentA - 1LL) / a[i] + 1LL;
		ll multi = max(multiT, multiA);
		currentT = t[i] * multi;
		currentA = a[i] * multi;
		//printf("%d %lli %lli %lli %lli\n", i, multiT, multiA, currentT, currentA);
	}
	printf("%lli\n", currentT + currentA);
	return 0;
}

Measured memory_bytes: 256
/* C++標準ヘッダファイル */
/* 文字列ライブラリ */
#include <string>

/* コンテナライブラリ */
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <forward_list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>

/* アルゴリズムライブラリ */
#include <algorithm>

/* 数値演算ライブラリ */
#include <cmath>

/* 入出力ライブラリ */
#include <iostream>

/* std使用<-namespace */
using namespace std;

/* define, typedef */
#define rpt(i, n) for(ll i = 0; i < (n); i++)  // リピート
typedef long long ll;

/* main関数 */
int main(void) {
	vector<int> mul;
	mul.reserve(100);
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			mul.push_back(i * j);
		}
	}

	int n;
	cin >> n;

	if (count(mul.begin(), mul.end(), n) >= 1) cout << "Yes";
	else cout << "No";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int K;
  int A;
  int B;
  int sum = 0;
  cin>>K;
  cin>>A;
  cin>>B;
  for(int i = A;i >= A && i <= B;i++){
    if(i % K == 0){
      cout<<"OK"<<'\n';
      sum = 1;
      break;
    }
  }
  if(sum == 0){
    cout<<"NG"<<'\n';
  }
}

Measured memory_bytes: 3636
#define rep(i,n) REP(i,0,n)
#define REP(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;

const ll MAXN = (ll)3e3+10;
const ll DIV = (ll)1e9+7;
// ll dp[MAXN][MAXN];

ll dp[MAXN][MAXN];
vector<int> A;
ll Update(int l, int r) {
   if (dp[l][r] != -INF) return dp[l][r];
   if (l==r) dp[l][r] = A[l];
   else {
      chmax(dp[l][r],A[l]-Update(l+1,r));
      chmax(dp[l][r],A[r]-Update(l,r-1));
   }
   return dp[l][r];
}

int main(void) {
   int N;
   cin>>N;
   A.resize(N);
   rep(i,N) cin>>A[i];
   rep(i,MAXN) rep(j,MAXN) dp[i][j] = -INF;
   rep(i,N/2) Update(i,N-i);
   cout<<Update(0,N-1)<<endl;


   return 0;
}

Measured memory_bytes: 71168
#include <iostream>
#include <string>
#include <vector>

using namespace std;
int main() {
	int n;
	string s;

	cin >> n >> s;
	vector<int> ss;

	for (char c : s) {
		ss.push_back(c - '0');
	}

	int count = 0;

	for (int i = 0; i < 1000; i++) {
		vector<int> num;
		num.push_back(i / 100);
		num.push_back((i / 10) % 10);
		num.push_back(i % 10);
		int pos = 0;

		for(int j = 0; j < n; j++) {
			if (ss[j] == num[pos]) {
				pos++;
				if (pos == 3) {
					count++;
					break;
				}
			}
		}

	}

	cout << count << endl;

	return 0;
}

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

using ll = long long;

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

	ll cnt1 = 0,cnt2 = 0;
	for(ll i=0;i<3;i++){
		if(s[i]=='A'){
			cnt1++;
		}
		else{
			cnt2++;
		}
	}

	if(cnt1 == 0 || cnt2 == 0){
		cout << "No\n";
	}
	else{
		cout << "Yes\n";
	}
}

Measured memory_bytes: 256
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

dd={'R':0, 'G':1, 'B':2}



def other_c(a,b):
	if a in 'RG' and b in 'RG':
		return 'B'
	elif a in 'GB' and b in 'GB':
		return 'R'
	else:
		return 'G'

def main():
	n = int(input())
	s = list(input())
	zn=[0]*n
	cc=[zn[:], zn[:], zn[:]]
	cc[dd[s[-1]]][-1]=1
	for i in range(n-2,-1,-1):
		c=dd[s[i]]
		for ci in range(3):
			cc[ci][i]+=cc[ci][i+1]+(c==ci)
	#print(cc)
	count=0
	for i in range(n-2):
		ci=s[i]
		for j in range(i+1, n-1):
			if s[j]==ci:
				continue
			other = other_c(ci, s[j])
			ol=dd[other]
			add = cc[ol][j+1]
			if j + (j-i) < n and s[j+(j-i)]==other:
				add -= 1
			count+=add
	print(count)
			
			
	
		
		
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 68972
#!/usr/bin/env python
# -*- coding: utf-8 -*-

x=int(input())

n2 = x // 11
# print(n2)

y = x - n2 * 11
# print(y)

n = 0
z = 6
while y > 0:
    y -= z
    if z == 6:
        z = 5
    else:
        z = 6
    n += 1
# print(n)
print(n2 * 2 + n)


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

int n;
pair<int,int> poi[57];

double f(double x, double y, int v)
{
	x-=poi[v].first;
	y-=poi[v].second;
	return x*x+y*y;
}

double knowxy(double x, double y)
{
	double ret=0;
	for (int i=1; i<=n; i++)
		ret=max(ret, f(x, y, i));
	return ret;
}

double knowx(double x)
{
	double bsa=-1000;
	double bsb=1000;
	for (int h=0; h<100; h++)
	{
		double bs1=(2*bsa+bsb)/3;
		double bs2=(bsa+2*bsb)/3;
		if (knowxy(x, bs1)<knowxy(x, bs2))
			bsb=bs2;
		else
			bsa=bs1;
	}
	return knowxy(x, bsa);
}

int main()
{
	scanf("%d", &n);
	for (int i=1; i<=n; i++)
		scanf("%d%d", &poi[i].first, &poi[i].second);
	double bsa=-1000;
	double bsb=1000;
	for (int h=0; h<100; h++)
	{
		double bs1=(2*bsa+bsb)/3;
		double bs2=(bsa+2*bsb)/3;
		if (knowx(bs1)<knowx(bs2))
			bsb=bs2;
		else
			bsa=bs1;
	}
	printf("%.9lf\n", sqrt(knowx(bsa)));
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main() {
  int num1, num2, num3;
  int ans;
  int count=0;
  std::cin >> num1 >> num2 >> num3 >> ans;
  for (int i=0; i < num1+1; i++) {
    for (int j=0; j < num2+1; j++) {
      for (int k=0; k < num3+1; k++) {
        if (500*i+100*j+50*k == ans) {
          count++;
        }
      }
    }
  }
  std::cout << count << std::endl;
}


Measured memory_bytes: 256
//IN THE NAME OF GOD;
//Test By Dev-C++5.11
#include<bits/stdc++.h>
#define ll  long long
#define isc ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ld long double
#define ss string
#define ww while
#define vl vector<ll>
#define pb push_back
#define in insert
#define vec vector
#define itr iterator
#define gt goto
#define rep(i,n,j) for(ll i=n;i<j;i++)
#define tep(i,n,j) for(ll i=n;i>=j;i--)
#define co(n) cout << n ;
#define pll pair<ll,ll>
#define bft bool f=true
#define bff bool f=false 
using namespace std;


ll kmm(ll a, ll b) {
	return(a*b) / __gcd(a, b);
}

const ll mod = 1e9 + 7;
const ll MAXN = 2e5+5;
ll modpower(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return modpower((x*x)%mod,n/2);
    else
        return (x*modpower((x*x)%mod,(n-1)/2))%mod;

}

void solve(){
	ss s,t,a,b;
	cin >> s >> t;a=s,b=t;
	if(s==t)
		cout << "Yes";
	else{
		bft;
		sort(s.begin(),s.end());
		sort(t.begin(),t.end());
		rep(i,0,s.size() && f){
			if(s[i]!=t[i])
				f=false;
		}
		if(!f)
			cout << "No";
		else{
			for(ll i=a.size()-1;i>0 && f;i--){
				ss k=a.substr(i);
				s=a;
				s.erase(i);
				k+=s;
				if(k==b)
					f=false;
			}
			if(f)
				cout << "No";
			else
				cout << "Yes";
		}
	}
}

int main() {
	isc;
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
const int mod = 1e9 + 7;
const int ni = 5e8 + 4;
int n, k, a[2222];
LL ctl(LL fs, LL x){
    //printf("ed + fs=%lld ed/fs=%lld\n", ed + fs, ed / fs);
    LL ed = x * fs % mod;
    fs %= mod;
    ed %= mod;
    return (fs + ed) * x % mod * ni % mod;
}
int main(){
    cin>>n>>k;
    for(int i = 1;i <= n; i++){
        scanf("%d", &a[i]);
    }
    LL ans = 0;
    for(int i = 1;i <= n; i++){
        LL cnt = 0;
        for(int j = i + 1;j <= n; j++){
            if(a[j] < a[i])cnt++;
        }
        if(cnt == 0)continue;
        //printf("cnt=%lld k*cnt=%lld ctl=%lld\n", cnt, k * cnt, ctl(cnt, k * cnt));
        ans += ctl(cnt, k);
   //     printf("i=%d ctl=%lld\n", i, ctl(cnt, k * cnt));
        ans %= mod;
    }
    if(k != 1){
        for(int i = 1;i <= n; i++){
            LL cnt = 0;
            for(int j = i - 1;j >= 1; j--){
                if(a[i] > a[j]){
                    cnt++;
                }
            }
            if(!cnt) continue;
            //printf("i=%d ctl=%lld\n", i, ctl(cnt, (k - 1) * cnt));
            ans += ctl(cnt, k - 1);
            ans %= mod;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define vec2 vector<vector<lli>> 
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define FRE freopen("explicit.in","r",stdin);freopen("explicit.out","w",stdout)
#define pll pair <lli,lli>
#define vll vector <lli>
#define vpll vector <pll>
#define f first
#define s second
#define pb push_back
#define priq priority_queue
#define unm unordered_map
#define pf push_front
#define minii LLONG_MAX
#define all(x) x.begin(), x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define ld long double
#define eb emplace_back
const long double pi = 3.1415926535898;
const lli mod=1e9+7;
//const lli mod=100000000;
using namespace std;
lli lcm (lli a, lli b) {return ((a*b)/__gcd(a,b));}
lli modpower (lli a,lli b)
{
    if(b==0) return 1;
    lli c=modpower(a,b/2)%mod;
    if (b%2) return (((a*c)%mod)*c)%mod;
    else return (c*c)%mod;
}
lli power (lli a,lli b)
{
    if(b==0) return 1;
    lli c=power(a,b/2);
    if (b%2) return (a*c*c);
    else return c*c;
}
bool prime (lli k)
{
    if (k==1||k==0) return 0;
    bool flag=1;
    lli a=sqrt(k);
    for (int i=2;i<=a;i++)
    {
        if (k%i==0)
        {flag=0;break;}
    }
    return flag;
}
lli sieve (int n)
{
    bool qrr[n+1];
    for (int i=0;i<=n;i++)
    qrr[i]=1;qrr[0]=0;qrr[1]=0;
    for (int i=2;i*i<=n;i++)
    {
        if (qrr[i]==1)
        {
            for (int j=2*i;j<=n;j+=i)
            {qrr[j]=0;}
        }
    }
    return 0;
}
int main()
{
    fio;
    lli n,k,d;
    cin>>n>>k>>d;
    lli a,b;
    if (n>=0)
    {a=n/d,b;
    a++;
    if (a<k)
    {
        k-=a;
        n-=(a*d);
        //cout<<a<<"\n";
        b=n+d;
        if (k%2)
        cout<<abs(b);
        else
        cout<<abs(n);
    }
    else
    {
        n-=(k*d);
        cout<<abs(n);
    }}
    else
    {a=abs(n)/d,b;
    a++;
    if (a<k)
    {
        k-=a;
        n+=(a*d);
        //cout<<a<<"\n";
        b=n-d;
        if (k%2)
        cout<<abs(b);
        else
        cout<<abs(n);
    }
    else
    {
        n+=(k*d);
        cout<<abs(n);
    }}
    return 0;
}


Measured memory_bytes: 3656
#include<iostream>

using namespace std;


int main(){
  int a,l,b1[10],b2[10],num,max,min,lop4=0,lop5=0;
  int bk[10][10],bkn[10],i[20];

  cin>>a;
  cin>>l;
  while(a!=0 || l!=0){

    for(int lop=0;lop<10;lop++){
      b1[lop]=0;
      b2[lop]=0;
      bkn[lop]=0;
      i[lop]=-1;
      for(int lop2=0;lop2<10;lop2++){
        bk[lop][lop2]=-1;
      }
    }
    for(int lop=10;lop<20;lop++){
      i[lop]=-1;
    }
    lop4=1;
    i[0]=a;
    while(1){
      for(int lop=l;lop>0;lop--){
        if(a==0){
          bk[0][bkn[0]]=0;
          bkn[0]++;
        }else{
          num=a%10;
          a/=10;
          bk[num][bkn[num]]=num;
          bkn[num]++;
        }
      }
      /*for(int lop=0;lop<10;lop++){
        cout<<bkn[lop]<<endl;
      }
      for(int lop=0;lop<10;lop++){
        for(int lop2=0;lop2<10;lop2++){
          cout<<bk[lop][lop2]<<' ';
        }
        cout<<'\n';
      }*/
      max=0;min=0;
      for(int lop=9;lop>=0;lop--){
        num=0;
        while(bk[lop][num]!=-1){
          max+=lop;
          max*=10;
          num++;
        }
      }
      max/=10;
      for(int lop=1;lop<10;lop++){
        num=0;
        while(bk[lop][num]!=-1){
          min+=lop;
          min*=10;
          num++;
        }
      }
      min/=10;
      a=max-min;
      i[lop4]=a;
      lop5=0;
      while(i[lop5]!=-1){
        if(i[lop5]==i[lop4] && lop5!=lop4){
          cout<<lop5<<' '<<a<<' '<<lop4-lop5<<endl;
          break;
        }
        lop5++;
      }
      if(i[lop5]==i[lop4] && lop5!=lop4){
        break;
      }
      lop4++;
      max=0;
      min=0;
      for(int lop=0;lop<10;lop++){
        b1[lop]=0;
        b2[lop]=0;
        bkn[lop]=0;
        for(int lop2=0;lop2<10;lop2++){
          bk[lop][lop2]=-1;
        }
      }
    }




    cin>>a;
    cin>>l;
  }

  return 0;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

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

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

int main(){
    int n;
    cin >> n;
    vi l(n);
    rep(i, n) cin >> l[i];
    RSORT(l);
    int sum = 0;
    rep1(i, n-1) sum += l[i];
    if (l[0] < sum) cout << YES << endl;
    else cout << NO << endl;
    return 0;
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    bool isExist = 0;
    for (int i = 0; i < b; i++) {
        if ((i * a) % b == c) isExist = 1;
    }

    if (isExist) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define ll long long 

int main()
{
    ll n;
    cin>>n;
    ll arr[n];
    ll dp[n];
    for(ll i=0;i<n;i++){
        cin>>arr[i];
    }
    dp[n-1]=arr[n-1];
    for(ll i=n-2;i>=0;i--){
        dp[i]=(dp[i+1]+arr[i])%1000000007;
    }
    ll ans=0;
    for(int i=0;i<n-1;i++){
        ans+=((arr[i]*dp[i+1])%1000000007);
        ans=ans%1000000007;
    }
    
    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 6648
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;

map<int, int> mp;
vector<string> v(10010, "");
int main() {
	int N, M; cin >> N >> M;
	int p[]={1, 2, 5, 5, 4, 5, 6, 3, 7, 6};
	for(int i=0; i<M; ++i){
	    int A; cin >> A;
	    mp[p[A]]=max(mp[p[A]], A);
	}
	v[0]="0";
	for(int i=0; i<=N; ++i){
	    if(v[i].size()>0){
	        for(auto itr=mp.begin(); itr!=mp.end(); ++itr){
	            char c=itr->second+'0';
	            string T=c+v[i];
	            if(v[i+itr->first].size()<1) v[i+itr->first]=T;
	            if(T.size()>v[i+itr->first].size()) v[i+itr->first]=T;
	            if(T.size()==v[i+itr->first].size()){
	                if(T[0]>v[i+itr->first][0]) v[i+itr->first]=T;
	            }
	        }
	    }
	}
	v[N].pop_back();
	cout << v[N] << endl;
	return 0;
}


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

int a, b, l8, r8, l10, r10, l, r;

int main(){
    cin >> a >> b;
    l8 = 25*a;
    r8 = 25*(a+1);
    l10 = 20*b;
    r10 = 20*(b+1);
    if (r8 <= l10 || r10 <= l8){
        cout << -1;
    }
    else{
        l = max(l8, l10);
        r = min(r8, r10);
        if (l == r) cout << -1;
        else if (l % 2 == 0) cout << (l/2);
        else if (l/2 == r/2) cout << -1;
        else cout << (l/2+1);
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#define ll long long

using namespace std;

int main(){

    string S;
    cin >> S;
    for(int i = 0;i < S.size();i++){
        if(i % 2 == 0){
            if(S[i] != 'R' && S[i] != 'U' && S[i] != 'D'){
                cout << "No" << endl;
                return 0;
            }
        } 
        else{
            if(S[i] != 'L' && S[i] != 'U' && S[i] != 'D'){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = stdIn.nextInt();
		
		if (a == b) {
			System.out.println(c);
		} else if (b == c) {
			System.out.println(a);
		} else {
			System.out.println(b);
		}
	}
}

Measured memory_bytes: 21716
def gcd(n,m):#n,mは正の整数、最大公約数　許容は？
    if n==0:
        return m
    elif m==0:
        return n
    elif n>m:
        n=n%m
        return gcd(n,m)
    else:
        m=m%n
        return gcd(n,m)
def lcm(n,m):
    return n*m//gcd(n,m)


def longlcm(A):
    import copy
    if len(A)==2:
        return A[0]*A[1]//gcd(A[0],A[1])
    else:
        x=A[0]
        for i in range(1,len(A)):
            x=lcm(x,A[i])
        return x

N=int(input())
T=[0]*N
for i in range(0,N):
    T[i]=int(input())

print(longlcm(T))

Measured memory_bytes: 3444
#include<stdio.h>

int main(){
    int a,b;
    scanf("%d %d", &a, &b);
    if(a>0 && 10>a){
        if(b>0 && 10>b){
            printf("%d", a*b);
        }else{
            printf("-1");
        }
    }else{
        printf("-1");
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};


int main(void){
    int A,B;
    cin >> A >> B;
    string S;
    cin >> S;
    bool l = 1;
    for(int i = 0; i < A; i++){
        if(S[i] - '0' < 0 || S[i] - '9' > 0){
            l = 0;
        }
    }
    for(int i = A; i < A + 1; i++){
        if(S[i] != '-'){
            l = 0;
        }
    }
    for(int i = A + 1; i < A + B + 1; i++){
        if(S[i] - '0' < 0 || S[i] - '9' > 0){
            l = 0;
        }
    }
    
    l ? cout << "Yes" << endl: cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define FD(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define pii pair<int,int>
#define reset(x,y) memset(x, y,sizeof(x))
#define MIN(x,y) if (x > (y)) x = (y)
#define MAX(x,y) if (x < (y)) x = (y)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define EL putchar('\n');
#define mod 1e9+7
#define oo 1000006
int f[3005][3005];
string s,t;
stack<char>st;
main()
{
    cin>>s>>t;
    for(int i=1;i<=s.size();i++)
    {
    	for(int j=1;j<=t.size();j++)
    	{
    		if(s[i-1]==t[j-1]) f[i][j]=max(f[i-1][j-1]+1,max(f[i-1][j],f[i][j-1]));
    		else f[i][j]=max(f[i-1][j],f[i][j-1]);
		}
	}
	int i=s.length();
	int j=t.length();
	while(i>=1&&j>=1)
	{
		if(s[i-1]==t[j-1])
		{
			if(f[i][j]==f[i-1][j-1]+1)
			{
				st.push(s[i-1]);
				i--;
				j--;
			}
			else{
                if(f[i][j]==f[i-1][j])i-=1;
                else j-=1;
			}
		}
		else
		{
			if(f[i][j]==f[i-1][j])i-=1;
			else j-=1;
		}
	}
	while(!st.empty())
	{
		cout<<st.top();
		st.pop();
	}
}


Measured memory_bytes: 35456
#include<cstdio>
using namespace std;
int w,h,cnt,a[50][50];
void func(int,int);

int main(void)
{
	int i,j;
	while(1)	{
		scanf("%d %d",&w,&h);
		if(w==0 && h==0)	break;
		for(i=0;i<h;i++)	{
			for(j=0;j<w;j++)	{
				scanf("%d",&a[i][j]);
			}
		}
		cnt=0;
		for(i=0;i<h;i++)	{
			for(j=0;j<w;j++)	{
				if(a[i][j]==1)	{
					cnt++;
					a[i][j]=0;
					func(i,j);
				}
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}
void func(int y,int x)
{
	int i,j,xx,yy;
	for(i=-1;i<=1;i++)	{
		for(j=-1;j<=1;j++)	{
			if(y+i>=0 && y+i<h && x+j>=0 && x+j<w && a[y+i][x+j]==1)	{
				a[y+i][x+j]=0;
				func(y+i,x+j);
			}
		}
	}
}


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

using namespace std;

int main (void)
{
	int n;
	double a[100];
	cin >> n;

	double co = 0.0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		co += a[i];
	}

	double p = 0.0;
	p = co / (double)n;

	int k = 0;
	double kk = 10000;
	for (int i = 0; i < n; i++)
	{
		if (kk > fabs(a[i] - p))
		{
			k = 0;
			k = i;
			kk = 0;
			kk = fabs(a[i] - p);
		}
	}

	cout << k << endl;
	return 0;
}


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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int X;

int main()
{
	scanf("%d",&X);

	int sum = 0;
	for(int i = 1;;i++){
		sum += i;
		if(sum >= X){
			printf("%d\n",i);
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;
    string ans = "Yes";
    for (int i = 0; i < s.size(); ++i) {
        if (i % 2) {
            if (s[i] == 'R') ans = "No";
        } else {
            if (s[i] == 'L') ans = "No";
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
  int n, y;
  cin >> n >> y;
  vector<int> v = {10000, 5000, 1000};
  bool flag = false;
  for (int i = 0; i <= n; i++)
  {
  	for(int j = 0; j <= n; j++)
    {
      	if (n - i - j < 0) break;
		if (v[0] * i + v[1] * j + v[2] * (n - i - j) == y)
        {
          cout << i << " " << j << " " << n-i-j << endl;
          flag = true;
          break;
        }
    }
    if(flag) break;
  }
  if(!flag) cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
from sys import stdin


def main():
    w = next_int()
    h = next_int()
    n = next_int()

    x = 0
    y = 0

    for i in range(n):
        xi, yi, a = map(int, input().split())
        if a == 1:
            x = max(x, xi)
        if a == 2:
            w = min(w, xi)
        if a == 3:
            y = max(y, yi)
        if a == 4:
            h = min(h, yi)

    print(max(0, (w - x)) * max(0, (h - y)))


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

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

int main(){
    string s,t;
    cin >> s >> t;
    int n = s.size();
    for(int i = 0; i < n; i++){
        s = s.substr(1,n-1) + s[0];
        if(s == t){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let r = read::<usize>();
    let g = read::<usize>();
    let b = read::<usize>();
    println!(
        "{}",
        if (r * 100 + g * 10 + b) % 4 == 0 {
            "YES"
        } else {
            "NO"
        }
    );
}


Measured memory_bytes: 4352
n = int(input())
s = input()
alphabet = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]

ans = [0]*len(s)
for i in range(len(s)):
    S = s[i]
    key = (alphabet.index(S))
    ans[i] = alphabet[(key+n)%26]
print("".join(ans))

Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <boost/math/common_factor.hpp>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
#define INF 1e9+7
#define PI 3.141592653
using namespace std;

ll f(ll a,ll b , ll x){
    if(a%x==0)
        return (b/x)-(a/x)+1;
    else 
        return (b/x)-(a/x);
}

int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll lcm=boost::math::lcm(c,d);
    ll ans=(b-a+1)+f(a,b,lcm)-f(a,b,c)-f(a,b,d);
    cout<<ans;
}


Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(10000)
def resolve():
    N = int(input())
    TXY = [list(map(int, input().split(" "))) for i in range(N)]
    current = [0, 0, 0]
    for txy in TXY:
        tdiff = txy[0] - current[0]
        xdiff = abs(txy[1] - current[1])
        ydiff = abs(txy[2] - current[2])
        if tdiff < (xdiff + ydiff) or (tdiff % 2) != ((xdiff+ydiff) % 2):
            print("No")
            return
        current[0], current[1], current[2] = txy[0], txy[1], txy[2]
    print("Yes")
    


if '__main__' == __name__:
    resolve()

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

using namespace std;

class Inverse {
private:
  long long mod;
	vector<long long> inv;
  
public:
  Inverse() {}
  
	Inverse(long long mod, long long n = 1000000) : mod(mod) {
    inv = vector<long long>(n, 1);
    for (int i = 2; i < n; ++i) inv[i] = inv[mod % i] * (mod - mod / i) % mod;
  }
  
	long long operator()(long long a) const {
		if (a < (int)inv.size()) return inv[a];
		long long b = mod, x = 1, y = 0;
		while (b) {
			long long t = a / b;
			swap(a -= t * b, b);
			swap(x -= t * y, y);
		}
		return (x %= mod) < 0 ? x + mod : x;
	}
};

class Arithmetic {
public:
  virtual Arithmetic operator+=(const Arithmetic& a) {return a;};
  virtual Arithmetic operator-=(const Arithmetic& a) {return a;};
  virtual Arithmetic operator*=(const Arithmetic& a) {return a;};
  virtual Arithmetic operator/=(const Arithmetic& a) {return a;};
  
  Arithmetic operator+(const Arithmetic& r) const {
    Arithmetic res = *this;
    res += r;
    return res;
  }
  
  Arithmetic operator-(const Arithmetic& r) const {
    Arithmetic res = *this;
    res -= r;
    return res;
  }
  
  Arithmetic operator*(const Arithmetic& r) const {
    Arithmetic res = *this;
    res *= r;
    return res;
  }
  
  Arithmetic operator/(const Arithmetic& r) const {
    Arithmetic res = *this;
    res /= r;
    return res;
  }
};

class Mint : public Arithmetic {
private:
  static long long mod;
  static Inverse inverse;
  long long val;
	
public:
	Mint() {}

	Mint(const long long& val) {
    this->val = val % mod;
    if (this->val < 0) this->val += mod;
  }

  static void setMod(const long long& m) {
    mod = m;
    inverse = Inverse(m);
  }
	
	Mint operator+=(const Mint& m) {
		val += m.val;
		if (val >= mod) val -= mod;
		return *this;
	}
  
	Mint operator-=(const Mint& m) {
		val -= m.val;
		if (val < 0) val += mod;
		return *this;
	}
  
	Mint operator*=(const Mint& m) {
		val *= m.val;
		val %= mod;
		return *this;
	}
  
	Mint operator/=(const Mint& m) {
		val *= inverse(m.val);
		val %= mod;
		return *this;
	}
	
	Mint operator++() {return val += 1;}
	
	operator long long() {
		return val;
	}
};

Mint pow(const Mint& m, long long n) {
  if (n == 0) {
    return 1;
  } else if (n < 0) {
    return pow(m, -n);
  }
  Mint mm = pow(m, n / 2);
  mm *= mm;
  if (n % 2) mm *= m;
  return mm;
}

long long Mint::mod = 1000000007;
Inverse Mint::inverse(1000000007);

ostream& operator<<(ostream& os, Mint a) {
	os << (long long)a;
	return os;
}

istream& operator>>(istream& is, Mint& a) {
	long long n;
	is >> n;
	a = n;
	return is;
}

int main() {
  Mint m;
  int n;
  cin >> m >> n;
  cout << pow(m, n) << endl;
}

Measured memory_bytes: 8980
#include<bits/stdc++.h>
using namespace std;
int x,y;
int main(){
	scanf("%d%d",&x,&y);
	if (y==0&&x>0)printf("%d\n",x+1);
	else if (y==0&&x<0)printf("%d\n",-x);
	else if (x==0&&y>0)printf("%d\n",y);
	else if (x==0&&y<0)printf("%d\n",-y+1);
	else if (x<0&&y<0&&x<y)printf("%d\n",y-x);
	else if (x>0&&y>0&&x<y)printf("%d\n",y-x);
	else if (x<0&&y<0&&x>y)printf("%d\n",x-y+2);
	else if (x>0&&y>0&&x>y)printf("%d\n",x-y+2);
	else if (x<0&&y>0&&abs(x)>=abs(y))printf("%d\n",-y-x+1);
	else if (x<0&&y>0&&abs(x)<=abs(y))printf("%d\n",y+x+1);
	else if (x>0&&y<0&&abs(x)<=abs(y))printf("%d\n",-y-x+1);
	else printf("%d\n",y+x+1);
} 

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

//height 違う
public class Main{
    static int count =0;
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        str = br.readLine();
        
        String[] tmp = str.split("\\s");
        int[] num = new int[3];
        num[0] = Integer.parseInt(tmp[0]);
        num[1] = Integer.parseInt(tmp[1]);
        num[2] = Integer.parseInt(tmp[2]);
        run(num[0],num[1],num[2]);

    }
    public static void run(int a,int b,int c){
        if(a< b && b < c){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


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

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(N+1);
	ll ans = 0;
	ll left= 0;
	for(int i=0;i<N;i++)cin >> A[i];
	for(int i=0;i<N;i++){
		ans += A[i]/2;
		if(A[i+1])A[i+1]+=A[i]%2;
	}
	cout << ans << endl;
}

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

vector<int> v[100005];
int a[100005];

int dfs(int n  , int p)
{
    a[n] = 0;

    for(int it : v[n])
    {
        if(it==p)
            continue;
        dfs(it , n);
        a[n] ^= a[it]+1;
    }
}

int main()
{
    int n;

    cin >> n;

    for(int i = 1 ; i<n ; i++)
    {
        int x , y;
        cin >> x >> y;

        v[x].push_back(y);
        v[y].push_back(x);
    }

    dfs(1 , 0);

    if(a[1]==0)
    {
        cout << "Bob";
        return 0;
    }
    else
    cout << "Alice";
    return 0;
}


Measured memory_bytes: 12288
fun main(args: Array<String>) {
    val n = readLine()!!
    val list = readLine()!!.split(" ").map(String::toInt).toMutableList()
    var num = 0
    var breakFrag = false
    while(true) {
        num += 1
        for((index, value) in list.withIndex()) {
            if(value % 2 == 0) {
                list[index] = value / 2
            } else if(value % 2 != 0) {
                breakFrag = true
                num -= 1
                break
            }
        }
        if(breakFrag) {
            break
        }
    }
    print(num)
}

Measured memory_bytes: 36008
n,k=[int(x) for x in input().rstrip().split()]
v=[int(x) for x in input().rstrip().split()]
vr=v[::-1]
ans=0
mi=min(n,k)

for i in range(mi+1):
  for j in range(mi-i+1):
    minus=0
    now=v[:i]+vr[:j]
    d=k-(len(now))
    now.sort()
    md=min(d,len(now))
    for s in range(md):
      if 0<=now[s]:
        break
      minus+=now[s]

    ans=max(ans,sum(now)-minus)
print(ans)

Measured memory_bytes: 9216
package main
import "fmt"
func main() {
  var b string
  fmt.Scan(&b)
  if b=="A"{
    fmt.Println("T")
  }else if b=="T"{
    fmt.Println("A")
  }else if b=="C"{
    fmt.Println("G")
  }else{
    fmt.Println("C")
  }        
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 1e18

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

    ll ans = 0;
    repr(i, 1, n){
        ll tmp = n/i;
        ans += i * tmp * (tmp+1)/2;
    }

    cout << ans << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 3560
N,M = map(int,input().split())
Mod = 10**9+7

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

def nCr(n, r, mod=10**9+7):
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod

tup = factorize(M)
snum = 0
ans = 1
for t in tup:
    ans *= nCr(t[1]+N-1,t[1])

print(ans%Mod)


Measured memory_bytes: 3064
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X = INT()

if 400 <= X < 600:
    print(8)
elif 600 <= X < 800:
    print(7)
elif 800 <= X < 1000:
    print(6)
elif 1000 <= X < 1200:
    print(5)
elif 1200 <= X < 1400:
    print(4)
elif 1400 <= X < 1600:
    print(3)
elif 1600 <= X < 1800:
    print(2)
elif 1800 <= X < 2000:
    print(1)


Measured memory_bytes: 10044
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall

n = int(readline())
f = []
A = []
chk = []
for i in range(n):
  ar = list(map(int,readline().split()))
  f.append(ar)
  for j,ai in enumerate(ar):
    if i == j:
      continue
    A.append((i,j,ai))
  
INF = 10**9+1
g = [[INF] * n for _ in range(n)]
for a,b,c in A:
    g[a][b] = c
    g[b][a] = c

g = csr_matrix(g)
d = floyd_warshall(csgraph=g)

t = f == d
if t.all():
  ans = 0
  for i in range(n):
    d[i,i] = INF

  for i in range(n):
    for j in range(i+1,n):
      opt = np.min(d[i] + d[j])
      if opt > d[i,j]:
        ans += d[i,j]
        
  print(int(ans))
else:
  print(-1)

Measured memory_bytes: 52092
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <tuple>
#define INF 100000000
#define MOD 1000000007
using namespace std;
int main(void){
  int N,Q;
  cin>>N>>Q;
  char str[N+1];
  cin>>str;
  int l[Q],r[Q];
  for(int i=0;i<Q;i++){
      cin>>l[i]>>r[i];
  }
  int count[N+1];
  fill(count,count+N+1,0);
  for(int i=1;i<N;i++){
    if(str[i]=='C'&&str[i-1]=='A'){count[i+1]++;}
  }
  for(int i=1;i<=N;i++){
      count[i]+=count[i-1];
  }
  for(int i=0;i<Q;i++){
      cout<<count[r[i]]-count[l[i]]<<endl;
  }
  return 0;
}


Measured memory_bytes: 2048
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=2e5+100;
ll d[mm];
int main()
{
   ll n,m,i,j,t,a,b,c,p,k,kk; 
	string s;
	cin>>s;
	ll sum=0;
	for(i=0;i<s.size();i++)
	{
		sum+=(s[i]-'0');
	}
	if(sum%9) printf("No\n");
	else printf("Yes\n");
} 

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

int main() {

    int sum = 0, min_rem = 10;
    for (int i = 0; i < 5; i++) {
        int t;
        cin >> t;
        int rem = t % 10;

        if (rem != 0) {
            sum += t + (10 - rem);
            min_rem = min(min_rem, rem);
        } else {
            sum += t;
        }
    }

    int res = sum - (10 - min_rem);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	int h, w, m;
	cin >> h >> w >> m;
	vector<int> a(h), b(w);
	set<P> st;
	rep(i, m) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		a[u]++; b[v]++;
		st.insert({ u,v });
	}
	int ma = *max_element(all(a));
	int mb = *max_element(all(b));
	vector<int> va, vb;
	rep(i, h) if (a[i] == ma) va.pb(i);
	rep(i, w) if (b[i] == mb) vb.pb(i);
	for (int i : va) {
		for (int j : vb) {
			if (!st.count({ i, j })) {
				cout << ma + mb << '\n';
				return 0;
			}
		}
	}
	cout << ma + mb - 1 << '\n';
}

Measured memory_bytes: 28400