akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

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

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

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

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

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

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

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


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

ll 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;
	}
}

ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {

	ll k, q;
	cin >> k >> q;

	vector<ll> d(k);
	rep(i, k) cin >> d[i];

	repn(i, q) {
		ll n, x, m;
		cin >> n >> x >> m;

		vector<ll> e(k);
		rep(i, k) {
			e[i] = d[i] % m;
			if (e[i] == 0) { e[i] = m; }
		}

		vector<ll> sum(k + 1,0);
		repn(i, k) sum[i] = sum[i - 1] + e[i - 1];

		ll S = sum[k];

		ll last = x + S * ((n - 1) / k) + sum[(n - 1) % k];



		ll t = last / m - x / m;

		cout << n - 1 - t << endl;
	}
	
	system("PAUSE");

	

}


Measured memory_bytes: 632
#include<stdio.h>
int srx,sry;
int main()
{
    int i;
    for(i=1;i<=3;i++)
    {int t;
    scanf("%d",&t);
    if(t==5)
    srx++;
    else if(t==7)
    sry++;}
    if(srx==2&&sry==1)
    printf("YES\n");
    else
    printf("NO\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define con continue
#define ub upper_bound
#define lb lower_bound
#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

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

const int dx8[] = {-1, 0, 1, 0,1,1,-1,-1};
const int dy8[] = {0, -1, 0, 1,1,-1,1,-1};



void solve()
{
 string x ;
 cin >> x ;
 if(x.back()=='s') x+="es";
 else x+="s" ;
 cout <<x << endl;
}



int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
    solve();
}


Measured memory_bytes: 3656
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int main(void){
    int W,a,b;
    cin>>W>>a>>b;
    //被ってる場合
    if((a+W>=b&&a<b+W) || (a<=b+W&&b<a+W)){
        cout << 0 << endl;
        return 0;
    }
    cout << (b>a+W?(b-a-W):(a-b-W)) << endl;
}

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

#define INF 1000000000
using namespace::std;


long Lmax(long x, long y) {
	if (x > y)return x;
	return y;
}

int max(int x, int y) {
	if (x > y)return x;
	return y;
}

long Lmin(long x, long y) {
	if (x < y)return x;
	return y;
}


int min(int x, int y) {
	if (x < y)return x;
	return y;
}

int abs(int a) {
	if (a < 0) {
		return -a;
	}
	return a;
}
long long ans;
int N, M,F,K, W,L,sa,X[2000000], Y[2000000], Z[2000000],  k[3],B,C,n[2];
string s, t[100];
bool a, b, c;
int main() {
	cin >> k[0]>>k[1]>>k[2];
	cin >> K;
	ans = max(k[0], k[1]);
	ans = max(ans, k[2]);
	F += k[0] + k[1] + k[2];
	F = F - ans;

	for (int i = 0; i < K; i++) {
		ans = ans * 2;
	}
	cout <<  F+ans<< endl;
	return 0;
}




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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,d,x;

    cin >> n >> d >> x;

    ll a[n];
    ll sum = 0;
    ll ans = 0;

    rep(i,n)    
    {
        cin >> a[i];
        
        ll x = 1;
        while(x<=d)
        {
            ans++;
            x = x+a[i];
        }
    }

    ans = ans + x;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
#include <math.h>
using namespace std;
using ll = long long;
using ld = long double;
using namespace std::chrono; 
#define fo(i,z,n) for(int i = z;i<n;i++)
#define Fo(i,z,n) for(ll i = z;i<n;i++)
#define INT_BITS 32
#define mod 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> > 
#define pb push_back
#define f first
// #define s second
#define int long long
#define float long double
#define all(c) (c).begin(), (c).end()
#define endl '\n'


int32_t main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     cout.tie(0);
   	
    // int t;
     // cin >> t;

//      while(t--){

// }
  string s;
  cin >> s;
  string t;
  cin >> t;
  int n = t.length();
  int count = 0;
  fo(i,0,n){
  	if(s[i] != t[i])count++;
  }
cout << count << endl;

return 0;
}





Measured memory_bytes: 3864
#include<iostream>
using namespace std;
int main()
{
   int A,B;
   cin>>A>>B;
   if((A==1 && B==2)||(A==2 && B==1))
   {
       cout<<"3";
   }
   else if((A==1 && B==3)||(A==3 && B==1))
   {
       cout<<"2";
   }
    else if((A==2 && B==3)||(A==3 && B==2))
   {
       cout<<"1";
   }
}


Measured memory_bytes: 3492
p = Array.new(10) { (0..9).map { 0 } }
ds = [0, 1, 2, 4]

while (line = gets)
  x, y, size = line.chop.split(",").map{|s| s.to_i}

  d = ds[size]
  for i in (0..9)
    for j in (0..9)
      if (x - i) ** 2 + (y - j) ** 2 <= d
        p[i][j] += 1
      end
    end
  end
end

pf = p.flatten

count = pf.select{|k| k == 0}.length
max = pf.max

puts count, max

Measured memory_bytes: 6112
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

using R = double;

int main(void){
    int n; cin >> n;
    vector<R> rs(n), xs(n);
    for(auto & e : rs) cin >> e;

    rep(i, n){
        R & x = xs[i] = rs[i];
        rep(j, i){
            R c = rs[j] + rs[i];
            R b = rs[j] - rs[i];

            R a = sqrt(c * c - b * b);
            chmax(x, xs[j] + a);
        }
    }

    R res = 0;
    rep(i, n){
        chmax(res, xs[i] + rs[i]);
    }

    cout.precision(20);
    cout << fixed << res << endl;

    return 0;
}

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

#define For(i, j, k) for(int i = j; i <= k; i++)
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;

const int Mod = 1e9 + 7;
const int N = 210;

void add(int &x, int y){
	x += y;
	if(x >= Mod) x -= Mod;
}

void mul(int &x, int y){
	x = (long long)(x) * y % Mod;
}

int Pow(int x, int e){
	int ret = 1;
	while(e){
		if(e & 1) ret = 1ll * ret * x % Mod;
		x = 1ll * x * x % Mod;
		e >>= 1;
	}
	return ret;
}

int gcd(int x, int y){
	return !y ? x : gcd(y, x % y);
}

int n, m, k;

int Polya(int x){
	int ret = 0;
	For(i, 1, x) add(ret, Pow(k, gcd(i, x)));
	mul(ret, Pow(x, Mod - 2));
	return ret;
}

int C[N][N];

vector<int> G[N];
int ans = 1;
int dfn[N], low[N];
bool link[N][N];

stack<pair<int, int> > st;

void calc(int a, int b){
	map<int, bool> M;
	int e = 0;
	auto s = st.top();
	do{
		++e;
		s = st.top(); st.pop();
		M[s.x] = 1, M[s.y] = 1;
	}while(s.x != a || s.y != b);

//	printf("%d -> %d: %d %llu\n", a, b, e, M.size());

	if(e <= int(M.size())) mul(ans, Polya(e));
	else mul(ans, C[e + k - 1][k - 1]);
	
}

void Tarjan(int o, int f){
	static int clk = 0;
	dfn[o] = low[o] = ++clk;

	for(int v : G[o]){
		if(v == f) continue;
		if(!dfn[v]){
			st.push(mp(o, v));
			Tarjan(v, o);
			if(low[v] >= dfn[o]) calc(o, v);
			low[o] = min(low[v], low[o]);
		}
		else if(dfn[v] < dfn[o]){
			st.push(mp(o, v));
			low[o] = min(low[o], dfn[v]);
		}
	}
}

int main(){
	scanf("%d%d%d", &n, &m, &k);
	For(i, 1, m){
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].pb(v), G[v].pb(u);
		link[u][v] = link[v][u] = true;
	}

	For(i, 0, m + k){
		C[i][0] = 1;
		For(j, 1, i) C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % Mod;
	}

	For(i, 1, n) if(!dfn[i]) Tarjan(i, 0);
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 384
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int Y = sc.nextInt();
    String ans = "No";
    for (int i = 0; i <= X; i++) {
      if ((i*2 + (X-i)*4) == Y) {
        ans = "Yes";
        break;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 27044
#include <stdio.h>

int main(void){
    int s,sec,min,hour;

    scanf("%d", &s);

    sec = s%60;
    s = (s-sec)/60;
    min = s%60;
    s = (s-min)/60;
    hour = s%60;

    printf("%d:%d:%d\n",hour,min,sec);

    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 sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;

vector<ll> al;
vector<ll> p;

ll dfs(ll X,int L){
    if(L==0)return X;
    if(X==0 || X==1)return 0;
    if(X>=al.at(L))return p.at(L);
    if(X>al.at(L-1)+1)return p.at(L-1)+1+dfs(X-al.at(L-1)-2,L-1);
    return dfs(X-1,L-1);
}

int main() {
    ll N,X;
    cin>>N>>X;
    al.resize(N+1);
    al.at(0)=1;
    rep(i,N+1){
        if(i)al.at(i)=al.at(i-1)*2+3;
    }
    p.resize(N+1);
    p.at(0)=1;
    rep(i,N+1){
        if(i)p.at(i)=p.at(i-1)*2+1;
    }
    cout<<dfs(X,N)<<endl;;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main(){FIN
    vll a(3); REP(i,3) cin>>a[i];
    ll k;cin>>k;
    VSORTR(a);
    a[0] *= power(2,k);
    cout<<a[0]+a[1]+a[2]<<endl;
    

    return 0;
}


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

using namespace std;

typedef long long ll;

const ll p = 1e9 + 7;

int main() {
  int n, k; cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<vector<ll> > dp(n, vector<ll>(k + 1));
  for (int i = 0; i <= k; i++) dp[0][i] = (i <= a[0]) + (i > 0 ? dp[0][i - 1] : 0);
  for (int i = 1; i < n; i++) {
    for (int j = 0; j <= k; j++) {
      int l = max(0, j - a[i]), r = j;
      dp[i][j] = dp[i - 1][r] - (l > 0 ? dp[i - 1][l - 1] : 0);
      dp[i][j] += (j > 0 ? dp[i][j - 1] : 0);
      dp[i][j] %= p;
      dp[i][j] += p;
      dp[i][j] %= p;
    }
  }
  cout << ((dp[n - 1][k] - (k > 0 ? dp[n - 1][k - 1] : 0)) % p + p) % p << endl;
  return 0;
}


Measured memory_bytes: 79488
#include <iostream>
#include <algorithm>

using namespace std;


bool is_stopping;

int main() {
	int h, w;
	cin >> h >> w;

	char array[55][55];

	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> array[i][j];
		}
	}

	//真ん中を探索
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (array[i][j] == '#' && //真ん中が'#'
				array[i-1][j] == '.' && //一つ左が'.'
				array[i+1][j] == '.' && //一つ右が'.'
				array[i][j-1] == '.' && //一つ上が'.'
				array[i][j+1] == '.') { //一つ下が'.'
				is_stopping = true;
			}
		}
	}

	if (is_stopping) cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
sum_a = 0
result = 0
for i in range(n):
  sum_a += a[i]
for j in range(n):
  sum_a -= a[j]
  result += sum_a * a[j]
print(result % (10**9 + 7))

Measured memory_bytes: 31228
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc178
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            //// 文字列の入力
            //string s = Console.ReadLine();

            //// 整数の入力
            long n = long.Parse(Console.ReadLine());

            //// 文字列配列の入力
            //string[] inputStrArray = Console.ReadLine().Split(' ');

            // 整数配列の入力
            //var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            long result=1;
           
            if(n==1)result=0;

            
            


            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27236
import bisect as bs
def find(x):
    n = bs.bisect_left(S,x)
    if n != len(S) and x == S[n]: return True
    else: return False

n = int(input())
S = [int(i) for i in input().split()]
q = int(input())
T = [int(i) for i in input().split()]
ans = 0
for i in range(q):
    if find(T[i]): ans += 1
print(ans)


Measured memory_bytes: 16924
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int x;
    cin>>x;
    rep(i, 1000){
        for(int j = -1000;j<=1000;j++){
            if(pow(i, 5)-pow(j, 5) == x) {
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }
    return 0;
}

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

#define ll long long int
#define LD long double

const int N = 100010;

int inf = 1e9;
int mod = 1e9 + 7;

class wunionfind {
  public:
    int *id, *sz;
    wunionfind(int n = N) {
        id = new int[n + 1];
        sz = new int[n + 1];
        for(int i = 0; i <= n; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    int root(int idx) {
        int x = idx;
        while(x != id[x]) {
            id[x] = id[id[x]];
            x = id[x];
        }
        return x;
    }
    bool uni(int a, int b) {
        int x = root(a), y = root(b);
        if(sz[x] < sz[y]) {
            swap(x, y);
        }
        if (x != y) {
            id[y] = x;
            sz[x] += sz[y];
            sz[y] = 0;
            return false;
        }
        return true;
    }
    bool check(int a, int b) {
        return (root(a) == root(b));
    }
};


signed main()
{
    //freopen("IN.txt", "r", stdin);
    //freopen("OUT.txt", "w", stdout);

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

    int n, q;
    ll m;
    cin >> n >> m >> q;

    wunionfind W(n);

    vector<pair<int,int>> query;
    int cnt = n;

    for(int i = 0; i < q; i++) {
        int a, b, c; cin >> a >> b >> c;
        if(c == 0) {
            if(!W.uni(a, b)) {
                cnt--;
            }
        }
        else {
            query.push_back({a, b});
        }
    }


    if(m == n - 1) {
        if((int)query.size()) {
            cout << "No\n";
            return 0;
        }
        cout << "Yes\n";
        return 0;
    }

    for(auto it : query) {
        if(W.check(it.first, it.second)) {
            cout << "No\n";
            return 0;
        }
    }

    ll mini = n;
    ll maxi = n + 1LL * cnt * (cnt - 3) / 2;

    if(m <= maxi && m >= mini) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

int N, P, tmp;

int main()
{
    cin >> N >> P;
    lint e = 1, o = 0;
    REP(_, N)
    {
        cin >> tmp;
        if (tmp & 1) o = e = o + e;
        else e <<= 1, o <<= 1;
    }
    cout << (P ? o : e) << endl;
}


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

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

    for(int i = 0; i < (int)a.size(); ++i){
        char b = a[i];
    }

    cout << "2018/01/" << a.substr(8) << endl;

    return 0;

}

Measured memory_bytes: 256
using System;
    class Program
    {
        static void Main(string[] args)
        {
            
            // スペース区切りの整数の入力
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int K = int.Parse(input[1]);


            // 割ればええんちゃうの
            int amari = N % K;

            //人が多いときはダメなのかぁ
            if (amari > 1)
            {
                amari = 1;
            }
            

            //出力
            Console.WriteLine(amari.ToString());

            
        }
    }

Measured memory_bytes: 13140
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<vector>
#include<algorithm>
#include<string.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << x << endl;
using namespace std;

int main(){
    long long input;
    while(cin >> input, input){
        int ans = 0;
        while(input / 5){
            ans += input / 5;
            input /= 5;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
using namespace std;

int main(){
  int a,b,k;
  cin >> a >> b >> k;
  if(a<=k && k<=a+b) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
#include<string>
#define ll long long int
#define mod 1000000007
#define MAX 10000003
#define pb push_back
#define mp make_pair
#define mem(x,y) memset(x,y,sizeof(x))
#define lcm(a,b) (a*b)/__gcd(a,b)
#define set_bit_count(x) __builtin_popcount(x)
#define leading_zero_count(x) __builtin_clz(x)
#define tailing_zero_count(x) __builtin_ctz(x)
#define str_rev(str) reverse(str.begin(),str.end())
#define loop(i,x,y) for(ll i=x;i<y;i++)
#define rloop(i,x,y) for(ll i=x-1;i>=y;i--)
using namespace std;
vector<vector<ll> > vec2d;
vector<pair<ll, ll> > vec_pair;
// unordered_map<ll, ll> ump;
multiset<ll> node[200003];
map<ll, ll> omp;
ll pown(ll a, ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	return pown(a,b/2)*pown(a,b-b/2);
}
int main()
{
	int a,b;
	cin>>a>>b;
	if(a>9 or b>9)
		cout << -1 << endl;
	else
		cout << a*b << endl;
	return 0;
}

Measured memory_bytes: 9600
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>
#include <math.h>
#include<algorithm>
#include <map>
using namespace std;

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

	int n,x;
	cin >> n >> x ;

	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a,a+n);

	int count=0;
	for(int i = 0; i < n; i++){
		if(x>=a[i]){
			x -= a[i];
			count++;
		}
	}

	if(x!=0 && count==n){
		count -= 1;
	}

	if(count==-1){
		cout << 0 <<endl;
	}
	else{
		cout << count <<endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
using namespace std;
const int MOD = (int)1e9 + 7;

int n, x;
int solve(int a, int b)
{
  if(a % b == 0)
    return b * (a / b * 2 - 1);
  else
    return b * (a / b * 2) + solve(b, a % b);
}

signed main()
{
  cin >> n >> x;
  cout << n + solve(max(x, n - x), min(x, n - x)) << endl;
  return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    string s;cin >>s;
    ll n=s.size();
    string ans="";
    for (int i = 0; i < n; ++i) {
        if(s[i]=='?')ans+='D';
        else ans+=s[i];
    }
    cout <<ans <<endl;
    return 0;
}


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

int main(){
	int n;
	scanf("%d", &n);
	
	long long mn1 = 1LL << 50, mx1 = -1LL << 50, mn2 = 1LL << 50, mx2 = -1LL << 50;
	
	for(int i = 0; i < n; i++){
		long long x, y;
		scanf("%lld %lld", &x, &y);
		
		mn1 = min(mn1, x + y);
		mx1 = max(mx1, x + y);
		
		mn2 = min(mn2, x - y);
		mx2 = max(mx2, x - y);
	}
	
	printf("%lld\n", max(mx1 - mn1, mx2 - mn2));
	
	return 0;
}


Measured memory_bytes: 3816
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
  int n, w;
  cin >> n >> w;
  array<vector<long long>, 4> items, ps;
  long long min_w;
  for (int i = 0; i < n; i++) {
    int w, v;
    cin >> w >> v;
    if (i == 0) min_w = w;
    items[w - min_w].push_back(v);
  }
  for (int i = 0; i < 4; i++) {
    sort(rbegin(items[i]), rend(items[i]));
    ps[i].push_back(0);
    partial_sum(begin(items[i]), end(items[i]), back_inserter(ps[i]));
  }
  array<int, 4> is;
  long long max_value = 0;
#define L(i) for (is[i] = 0; is[i] < ps[i].size(); is[i]++)
  L(0) L(1) L(2) L(3) {
    long long weight = 0;
    for (int i = 0; i < 4; i++)
      weight += is[i] * (min_w + i);
    if (weight > w) break;
    long long value = 0;
    for (int i = 0; i < 4; i++)
      value += ps[i][is[i]];
    max_value = max(value, max_value);
  }
  cout << max_value << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

const int MAX_N = 501;
const int MAX_V = 2000;
// 赤と青のカード
int b[MAX_N],r[MAX_N];
// 頂点数
int V;
// グラフ
vector<int> G[MAX_V];
// マッチングのペア
int match[MAX_V];
// すでに調べたかどうか
bool used[MAX_V];

// aとbの最大公約数を返す(ユークリッドの互除法)
int gcd(int a, int b){
    return (b>0)? gcd( b , a%b ) : a ;
}

// 辺の追加.
void add_edge(int u, int v){
	G[u].push_back(v);
	G[v].push_back(u);
}

// 増加path を DFSで探す.
bool dfs(int v){
	used[v] = true;
	for(int i=0 ; i < G[v].size() ; i++ ){
		int u = G[v][i];
		int w = match[u];
		if( w < 0 || !used[w] && dfs(w) ){
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}

// 二部グラフの最大マッチングを求める.
int solve(){
	int res = 0;
	for(int v=0 ; v < V ; v++ ){
		if( match[v] < 0 ){
			// 初期化
			for(int i=0 ; i < V ; i++ ){
				used[i] = false;
			}
			if( dfs(v) ){
				res++;
			}
		}
	}
	return res;
}

// 初期化
void init(){
	for(int i=0 ; i < MAX_V ; i++ ){
		G[i].clear();
		match[i] = -1;
	}
}

int main(){
	int m, n;
	while( cin >> m >> n , m || n ){
		// 初期化
		V = n + m;
		init();
		
		// 入力
		for(int i=0 ; i < m ; i++ ){
			cin >> b[i];
		}
		for(int i=0 ; i < n ; i++ ){
			cin >> r[i];
		}
		
		// ペアを探して辺を追加しておく
		for(int i=0 ; i < m ; i++ ){
			for(int j=0 ; j < n ; j++ ){
				if( gcd(b[i], r[j]) >= 2 ){
					int u = i;
					int v = j + m;
					add_edge(u,v);
				}
			}
		}
		int ans = solve();
		cout << ans << endl;
	}
}

Measured memory_bytes: 3080
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define MO(a) AS_MOD(a,mod)
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)
#define MIN(V, T) V=min(V,T)

#define PrintArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;
#define PrintPairs(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i].fi <<"," << cont[__i].se<<")";} cout<<endl;
#define Print(v) cout<<v<<endl;
#define PDBG() cout<<"Line:"<<__LINE__<<endl;
#define PrintArray2D(cont, fh, th, fw, tw) for(int __i=fh;__i<th;++__i){for(int __j=fw;__j<tw;++__j) {cout<<cont[__i][__j]<<" ";} cout<<endl;}cout<<endl;
#define Resize2D(cont,H,W,V) cont.resize(H);for(int i=0;i<H;++i)cont[i].resize(W,V);
#define Resize3D(cont,H,W,D,V) cont.resize(H);for(int i=0;i<H;++i)cont[i].resize(W);for(int i=0;i<H;++i)for(int j=0;j<W;++j)cont[i][j].resize(D,V);
/*
 * ***_bound(6)
 * 5 6 6 6 6 6 7 7 7
 *   ^lower    ^upper
 * void reverse(c.begin(), c.end())
 *
 * graph
 * seg tree
 * dp
 * brute force
 * priority_queue<int,vector<int>, greater<int>> Q;
 */
struct Comparator{
    int operator()(int l, int r) const {
        return r<l;
    }
};
/*
struct PairComp{
    int operator()(P l, P r) const {
        return l.fi==r.fi?l.se<r.se:l.fi<r.fi;
    }
};*/
struct Vec;
//set<int, Comparator> S;




// solution below
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PP;
int main() {
    cout.precision(15);
    cout << fixed;
    int a;
    cin >> a;
    cout<<a+a*a+a*a*a<<endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mk make_pair
#define pb push_back
int main()
{
ios_base ::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int n;cin>>n;int h[n+1];h[0]=0;
for(int i=1;i<=n;i++)
{
    cin>>h[i];
}
ll dp[n+1];
dp[0]=0;dp[1]=0;dp[2]=dp[1]+abs(h[2]-h[1]);
for(ll i=3;i<=n;i++)
{
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
}
cout<<dp[n];
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
typedef long long ll;
#define endl '\n'
using namespace std;
const int MOD = 1000000007, MAX = 2000000007, MAXN = 2005;
pair<ll,int> p[MAXN];
ll dp[MAXN][MAXN];

ll solve(int n)
{
    for(int i=0; i<n; i++)
        dp[i][i] = p[0].first*(abs(i-p[0].second));
    for(int k=1; k<n; k++)
    {
        for(int i=0; i+k<n; i++)
        {
            dp[i][i+k] = max(dp[i][i+k-1] + p[k].first*abs(i+k-p[k].second),dp[i+1][i+k] + p[k].first*abs(i-p[k].second));
        }
    }
    return dp[0][n-1];
}

bool compare(const pair<ll,int>&a, const pair<ll,int>&b)
{
    if(a.first == b.first)
        return a.second > b.second;
    return a.first < b.first;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>p[i].first;
        p[i].second = i;
    }
    sort(p,p+n,compare);
    cout<<solve(n);
	return 0;
}

Measured memory_bytes: 26300
#include <iostream>
using namespace std;
int main()
{
int n,e=0,o=0;
float rt;
cin>>n;
for(int i=n;i>0;i--){
    if(i%2==0){
       e++;
    }
    else if(i%2==1){
        o++;
    }
}
rt=1.0*o/n;
cout<<rt;
return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

vector<ll> find_fac(ll x) {
    vector<ll> ans;
    for(ll i = 1; i*i <= x; i++) {
        if (x % i == 0) {
            ans.push_back(i);
            if (i*i != x)
                ans.push_back(x/i);
        }
    }
    sort(ans.begin(), ans.end());
    return ans;
}
bool can_use(vector<ll> arr, ll x, ll quota) {
    vector<ll> rem;
    for(ll val: arr) {
        if (val % x > 0)
            rem.push_back(val%x);
    }
    sort(rem.begin(), rem.end());
    int l = 0, r = rem.size()-1;
    while (l <= r) {
        ll m = min(rem[l], x-rem[r]);
        quota -= m;
        rem[l] -= m;
        rem[r] += m;
        if (rem[l] % x == 0)
            l++;
        if (rem[r] % x == 0)
            r--;
    }
    return quota >= 0;
}
int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> arr(n, 0);
    for(auto& val: arr)
        cin >> val;
    ll acc = accumulate(arr.begin(), arr.end(), 0LL);
    auto cand = find_fac(acc);
    ll ans = 1;
    for(ll val: cand) {
        if (can_use(arr, val, k)) {
            ans = val;
        }
    }
    cout << ans << endl;
    return 0;
}




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

int main(){
    int n;cin>>n;
    int P[n+1],DP[n][n];
    rep(i,n){
        scanf("%d %d",&P[i],&P[i+1]);
    }
    rep(i,n){
        DP[i][i]=0;
    }
    for(int i=1;i<n;i++){
        for(int j=0;j+i<n;j++){
            int minc=Infinity;
            for(int k=j;k<j+i;k++){
                minc=min(minc,DP[j][k]+DP[k+1][j+i]+P[j]*P[k+1]*P[j+i+1]);
            }
            DP[j][j+i]=minc;
        }
    }
    cout<<DP[0][n-1]<<endl;
}


Measured memory_bytes: 3240
X = gets.to_i

x = X % 100

c5 = x / 5
x5 = x % 5

c4 = x5 / 4
x4 = x5 % 4

c3 = x4 / 3
x3 = x4 % 3

c2 = x3 / 2
x2 = x3 % 2

c1 = x2 / 1
x1 = x2 % 1

puts ((c5 + c4 + c4 + c2 + c1) <= X / 100) ? 1 : 0

Measured memory_bytes: 14332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )
#define SORT(x) sort(x.begin(), x.end())

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


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

    int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
    int ans = 0;
    if (A + B > C * 2) {
        ans += C * min(X, Y) * 2;
        if (X > Y) ans += (X - Y) * A;
        else ans += (Y - X) * B;
    } 
    else ans += A * X + B * Y;
    ans = min(ans, C * max(X, Y) * 2);

    COUT(ans);
}

Measured memory_bytes: 256
///cREATED bY BERNARB.01
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef priority_queue<int,vector<int>,greater<int>> pqil;
typedef priority_queue<int> pqig;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef priority_queue<pii> pqiig;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<int, int> mii;
#define mid ((l+r)/2)
#define PB push_back
#define PP pop_back
#define PF push_front
#define DF pop_front
#define F first
#define S second
#define MP make_pair
#define C continue
#define B break
#define R return
#define sz(v) (int)(v).size()
#define len(s) (int)(s).length()
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define clr(arr, x) memset((arr), (x), sizeof (arr))
#define loop(n) for(int i=0; i<(n); i++)
#define lop(a, n) for(int i=(a); i<(n); i++)
#define jloop(n) for(ll j=0; j<(n); j++)
#define kloop(n) for(ll k=0; k<(n); k++)
#define rloop(n) for(ll i=(n)-1; i>=0; i--)
#define sgm(y) (((y)*((y)+1))/2)
const ll INF = 2e17+423;
const ll mod = 1e9+7; //998244353;
const ld pi = acos(-1.0);
const ld cmpf = 1e-9;
//__int128_t
//      -ASCII-
//a -> z | A -> Z | 0 -> 9
//97 122 | 65  90 | 48  57
#define endl '\n'
ll po(ll,ll);















int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s, t;
  cin >> s >> t ;
  cout << t+s << endl;
  R 0;
}
/*

*/




























































ll po(ll x, ll n){
  if(n==0) R 1;
  ll y = po(x, n/2);
  y = ((y)*(y));
  if(n%2) y = (y*(x));
  R y;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a) memset(a, 0, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define sz(x) (int)x.size()

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 2000100;

int main(){
        _ios;
        int n;
        cin>>n;
        string s;
        cin>>s;
        int res = 0;
        rep(i,n-2){
            if(s[i]=='A' and s[i+1]=='B' and s[i+2]=='C')res++;
        }
        cout<<res<<endl;




return 0;
}







Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        int N = sc.nextInt();
        int[] D = new int[N];
        for (int i = 0; i < N; i++)
            D[i] = sc.nextInt();
        int[] count = new int[N];
        long ans = 1;
        boolean isPrevZero = false;

        for (int i = 0; i < N; i++)
            count[D[i]]++;

        if (D[0] != 0 || count[0] != 1) {
            System.out.println(0);
            return;
        }

        for (int i = 1; i < N; i++) {
            for (int j = 0; j < count[i]; j++) {
                ans *= count[i - 1];
                ans %= 998244353;
            }
        }

        System.out.println(ans % 998244353);

    }
}

Measured memory_bytes: 51560
n, m, q = gets.chomp.split.map &:to_i
st = Array.new(n+1){Array.new(n+1,0)}
dt = Array.new(n+1){Array.new(n+1,0)}
at = Array.new(n+1){Array.new(n+1,0)}
m.times do
  d = gets.chomp.split.map &:to_i
  dt[d[0]][d[1]] += 1
end
(0..n).each do |i|
  (i..n).each do |j|
    st[i][j] = 0
    st[i][j] += st[i][j-1] if(j>0)
    st[i][j] += dt[i][j]
  end
end
(0..n).each do |i|
  (0..n).reverse_each do |j|
    at[j][i] = 0
    at[j][i] += at[j+1][i] if(j<n)
    at[j][i] += st[j][i]
  end
end
h = {}
q.times do |i|
  d = gets.chomp.split.map &:to_i
  ans = 0
  p at[d[0]][d[1]] 
end

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


void solve(long long N, long long L){
    long long ans = 0;
    if(L <= 0){
        if( L + N -1 >= 0){
            for(int i = 0;i < N;i++){
                ans += L;
                L++;
            }
        }else{
            for(int i = 0;i < N-1;i++){
                ans += L;
                L++;
            }
        }
    }else{
        L++;
        for(int i = 0;i < N-1;i++){
            ans += L;
            L++;
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long L;
    scanf("%lld",&L);
    solve(N, L);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string s[1001];
bool  cmp(string s1, string s2){
     return (s1 + s2) < (s2 + s1)? true : false;
}
int main(){
	int n,m,count=0,i,j;
	cin>>n>>m;
	
	for( i=0;i<n;i++){
		cin>>s[i];
		count++;
	}
	sort(s,s+n,cmp);
	for(i=0;i<n;i++){
		cout<<s[i];
	}
	cout<<endl; 
	return 0;
}  

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

const int MOD = 1e9 + 7;
const int MAXN = 1005;
int dp[MAXN][MAXN];

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

	int H, W;
	cin >> H >> W;
	vector<string> grid(H);
	for (int i = 0; i < H; ++i) cin >> grid[i];


	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (i == 0 && j == 0) {
				dp[i][j] = 1;
				continue;
			}
			if (grid[i][j] == '#') {
				dp[i][j] = -1;
				continue;
			}

			if (i > 0 && dp[i-1][j] > 0) dp[i][j] = (dp[i][j] + dp[i-1][j]) % MOD;
			if (j > 0 && dp[i][j-1] > 0) dp[i][j] = (dp[i][j] + dp[i][j-1]) % MOD;
		}
	}

	cout << dp[H-1][W-1] << endl;
}


Measured memory_bytes: 5248
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder.DP
{
    class EDPC_L
    {
        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            var dp = new long[n + 1, n + 1];

            for (int i = n - 1; i >= 0; i--)
            {
                for (int j = i + 1; j <= n; j++)
                {
                    if ((n - (j - i)) % 2 == 0)
                        dp[i, j] = Math.Max(dp[i + 1, j] + a[i], dp[i, j - 1] + a[j - 1]);
                    else
                        dp[i, j] = Math.Min(dp[i + 1, j] - a[i], dp[i, j - 1] - a[j - 1]);
                }
            }
            Console.WriteLine(dp[0, n]);
        }
    }
}


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

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

  if (a>9 || a<1)
    {
      cout << "-1" << endl;
    }
  else if(b>9 || b<1)
    {
      cout << "-1" << endl;
    }
  else
    {
      cout << a*b << endl;
    }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), k = sc.nextInt();
		long ans = 0;
		sc.close();
		if (k != 0) {
			for (int i = k + 1; i <= n; ++i) {
				long tmpr = n % (long) i;
				long tmp = n / (long) i;
				ans += tmp * (long) (i - k);
				if (tmpr >= k)
					ans += tmpr - (long) k + 1;
			}
		} else
			ans = (long) n * (long) n;
		System.out.println(ans);
	}

}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int A, B; cin >> A >> B;
    if (A%3 == 0 or B%3 == 0 or (A+B)%3 == 0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
def f l,m
$h[l+[m]]||=m<2?l.inject(:+):(1..l.size-m+1).map{|i|[l[0,i].inject(:+),f(l[i..-1],m-1)].max}.min
end
while(m,n=gets.split.map &:to_i)[0]>0
w=(1..n).map{gets.to_i}
$h={}
p m<n ?f(w,m):w.max
end

Measured memory_bytes: 6160
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
using namespace std;

int main() {
	int dis1, rad1,dis2=0,rad2=0;
	double x = 0, y = 0,PI= 3.141592653589793;
	scanf("%d , %d", &dis1, &rad1);
	y += dis1; rad2 = rad1;
	while (scanf("%d , %d",&dis1,&rad1)) {
		if (dis1 != 0) {
			x += dis1*sin(rad2*PI/180);
			y += dis1*cos(rad2*PI/180);
			rad2 += rad1;
		}
		else {
			cout << int(x) << endl;
			cout << int(y) << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3500
#include<iostream>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdio>
typedef long long LL;
using namespace std;
LL a[200005];
int main()
{
	ios::sync_with_stdio(false);
	LL T,cnt = 1;
	int flag = 0;
	cin >> T;
	for (int i = 0;i < T;i++)
	{
		cin >> a[i];
		if (a[i] == 0)
			flag = 2;
	}
	
	if (flag == 2)
	{
		cout << 0 << endl;
		return 0;
	}
	LL sum=1000000000000000000;
	for (int i = 0;i < T-1;i++)
	{
		if(sum/a[i]<a[i+1]){
			flag=1;
			break;
		}
		cnt*=a[i];
		sum/=a[i];
	}
	if (flag == 1)
		cout << -1 << endl;
	else
		cout << cnt*a[T-1] << endl;
	return 0;
}

Measured memory_bytes: 4440
# https://atcoder.jp/contests/abc161/tasks/abc161_e

N, K, C = map(int, input().split())
S = input()

left = []
i = 0
while K > len(left):
    while True:
        if S[i] == 'o':
            left.append(i)
            i += C + 1
            break
        i += 1

right = []
i = N - 1
while K > len(right):
    while True:
        if S[i] == 'o':
            right.append(i)
            i -= (C + 1)
            break
        i -= 1

right.reverse()

ans = 0
for i in range(K):
    if left[i] == right[i]:
        print(left[i] + 1)


Measured memory_bytes: 58104
n = int(input())
b = list(map(int, input().split()))
a = []

for i in range(n):
    if i == 0:
        a.append(b[0])
    elif 0 < i <= n-2 :
        a.append(min(b[i], b[i-1]))
    else :
        a.append(b[-1])


print(sum(a))

Measured memory_bytes: 3060
def make_text():
    temp = []
    while True:
        row = input().split()
        if row == ['END_OF_TEXT']:
            break
        temp.append(list(map(lambda x: x.lower(), row)))
    return temp

def find_word(word,text):
    num = 0
    for row in text:
        for t in row:
            if t == word:
                num += 1

    return num

if __name__ == '__main__':
    w = input()
    t = make_text()
    num = find_word(w,t)
    print(num)


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

int main() {
  string s;
  cin >> s;
  int ans = 100000;
  for (int i = 0; i < s.size() - 2; i++) {
    
    int a = stoi(s.substr(i,3));;
    ans = min(ans, abs(753 - a));
  }
  cout << ans << endl;

}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#include <cstdlib>

using namespace std ;
using ll = long long;

const ll INF = numeric_limits<ll>::max()/2;
const ll SIZE = 100010;

int main(){

    int N,K;
    ll h[100010];
    ll dp[2000000];
    cin >> N >> K;
    
    for(int i=0; i<N; ++i){
        cin >> h[i];
    }
    for(int i=0; i<2000000; ++i){
        dp[i] = INF;
    }

    dp[0] = 0;

for(int i=0; i<N; ++i){
    for(int j=1; j<=K; ++j){
        dp[i+j] = min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
    }
}
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll mod = 100000007;

int main() {
    ll X;
    cin >> X;
    for (int i = -1000;i < 1000;i++){
        for (int j = -1000;j < 1000;j++){
            if (pow(i,5) - pow(j,5) == X){
                cout << i << ' ' << j << endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 4028
#include <stdio.h>

int main(void){
	int v[4][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};  /* d をベクトル化するための配列 */
	int N, n, d;
	int x[200-1], y[200-1];
	int i, j, xmax, xmin, ymax, ymin;

	while (scanf("%d", &N) == 1){
		if (N < 1 || N >= 200){
			break;
		}

		/* 正方形を並べる */
		x[0] = 0;
		y[0] = 0;
		for (i = 1; i < N; i++){
			scanf("%d %d", &n, &d);
			x[i] = x[n] + v[d][0];
			y[i] = y[n] + v[d][1];
		}

		/* 最も左、下、右、上にある正方形の座標を調べる */
		xmax = x[0];
		xmin = x[0];
		ymax = y[0];
		ymin = y[0];
		for (i = 1; i < N; i++){
			if (x[i] < xmin){
				xmin = x[i];
			}else if (x[i] > xmax){
				xmax = x[i];
			}
			if (y[i] < ymin){
				ymin = y[i];
			}else if (y[i] > ymax){
				ymax = y[i];
			}
		}

		/* 必要な箱の大きさを出力する */
		/* xmax, xmin の絶対値はそれぞれ、座標平面の正の部分、負の部分の大きさを表す */
		/* ゆえに 箱の大きさは xmax - xmin + 1 */
		printf("%d %d\n", xmax - xmin + 1, ymax - ymin + 1);
	}

    return 0;
}

Measured memory_bytes: 604
N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
x.append(X)
y.append(Y)
x.sort()
y.sort()
if x[N] < y[0]:
    print("No War")
else:
    print("War")

Measured memory_bytes: 38512