akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  for(int a=1;a<=9;a++)
  for(int b=1;b<=9;b++)
  {
    if(a*b==n)
    {
    puts("Yes");
    return 0;
    }
  }
  puts("No");
  return 0;
}


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

int main(){
    int A,B,Ty;
    cin >> A >> B ;
    Ty=A+B;
    if(Ty<24){
        cout << Ty <<endl;
    }
    else if(Ty>=24){
        cout << Ty -24 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const string yes = "Yes";
const string no = "No";

int main()
{
  int n; cin >> n;
  int m = 0;
  multiset<int> st;
  for (int i=0; i<pow(2,n); i++) {
    int tmp; cin >> tmp;
    st.insert(tmp);
    m = max(m, tmp);
  }

  vector<int> v;
  v.push_back(m);
  for (int i=0; i<n; i++) {
    sort(v.begin(),v.end());
    int len = v.size();
    for (int j=0; j<len; j++) {
      auto itr = st.lower_bound(v[j]);
      if (itr == st.begin()) {
        cout << "No" << endl;
        return 0;
      }
      itr--;
      v.push_back(*itr);
      st.erase(itr);
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 13692
//
//  0285.cpp
//  
//
//  Created by Minote Tomoki on 2015/06/01.
//
//

#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>


typedef struct _tree {
    std::string *val;
    struct _tree *left;
    struct _tree *right;
} node;

int offset=0;

node *state(int j,int i, int tj,int ty, std::string output) {
    node *r;
    
    r=(node*)malloc(sizeof(node));
    r->val = new std::string(output);
    r->left = NULL;
    r->right = NULL;
    
    if(j==tj && ty==i) return r;
    
    if( (i<=3 && j==5) || (i==5 && j<=3)) {
        return NULL;
    }
    else if( (i>4 && j>4) && (i-j)*(i-j) > 4) {
        return NULL;
    }
    
    if(j<tj) r->left = state(j+1,i,tj,ty,"A");
    if(i<ty) r->right = state(j,i+1,tj,ty,"B");
    return r;
}

void trace(node *r, std::string str) {
        str += *(r->val);
    
    if(r->left == NULL && r->right == NULL) {
        std::cout << str << std::endl;
    }
    
    if(r->left != NULL) trace(r->left,str);
    if(r->right != NULL) trace(r->right,str);

}

void freetree(node *n){
    if(n->left != NULL) freetree(n->left);
    if(n->right!= NULL) freetree(n->right);
    free(n);
}

int main(void) {
    int j;
    int y;
    
    std::string str;
    
    node *root=NULL;
    
    scanf("%d %d",&j,&y);
    if(j==0 && y==0) return 0;
    
    root=state(0,0,j,y,"");
    
    trace(root,str);
    
    freetree(root);

    return 0;
}

Measured memory_bytes: 1284
import java.util.Arrays;
import java.util.Scanner;

class Main{



	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		int N = sc.nextInt();
		int X = sc.nextInt();
		int[] x = new int[N];
		for(int i = 0;i < N;i++){
			x[i] = sc.nextInt();
		}
		if(N == 1){
			System.out.println(Math.abs(x[0]-X));
			return;
		}
		
		Arrays.sort(x);
		int[] dis = new int[N];
		for(int i = 0;i < N;i++){
			dis[i] =Math.abs(X - x[i]);
		}
		Arrays.sort(dis);
//		for(int i = 0;i < N ;i++){
//			System.out.println(dis[i]);
//		}
		int[] yakusuu = new int[N-1];
		for(int i = 0;i < N-1;i++){
			yakusuu[i] =(int)gcd(dis[i+1], dis[i]);
			dis[i+1] = yakusuu[i];
			}
		
		System.out.println(yakusuu[N-2]);
		
	}

	static long gcd(long a,long b){
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}



}




class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}



Measured memory_bytes: 50376
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,d,a;
    cin>>n>>d>>a;
    d*=2;
    int x[n],h[n];
    vector<pair<int,int>>p(n);
    for(int i=0;i<n;i++){
        cin>>x[i]>>h[i];
        p[i]={x[i],h[i]};
    }
    sort(p.begin(),p.end());
    for(int i=0;i<n;i++){
        x[i]=p[i].first;
        h[i]=p[i].second;
    }
    int dam[n+1]={},wa[n+1]={};
    long long X=0;
    for(int i=0;i<n;i++){
        h[i]=max(h[i]-wa[i],0);
        int att;
        if(h[i]>0)att=(h[i]-1)/a+1;
        else att=0;
        X+=att;
        dam[i]+=att*a;
        if(x[i]+d<x[n-1])dam[upper_bound(x,x+n,x[i]+d)-x]-=att*a;
        if(i)wa[i]=wa[i-1]+dam[i];
        else wa[i]=dam[i];
        wa[i+1]+=dam[i+1]+wa[i];
    }
    cout<<X<<endl;
    return 0;
}


Measured memory_bytes: 4992
import java.util.*;
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int sum = 0;
		int arry[]=new int[N+1];
		for(int i=1;i<=N;i++){
			arry[i]=sc.nextInt();
		}
		for(int i=1;i<=N-1;i++){
			for(int k=i+1;k<=N;k++){
				sum=sum+arry[i]*arry[k];
			}
		}
		System.out.println(sum);
    }
}

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

int solve(int x, int y, vector<set<int>>& vx, vector<set<int>>& vy, char d, vector<vector<char>> const& dd) {
    if(d == '>') {
        auto it = vy[y].upper_bound(x);
        if(it == vy[y].end()) {
            return 1;
        }
        int nx = (*it);
        char nd = dd[*it][y];
        vy[y].erase(it);
        vx[nx].erase(y);
        return solve(nx, y, vx, vy, nd, dd) + 1;
    } else if(d == '<') {
        auto it = vy[y].lower_bound(x);
        if(it == vy[y].begin()) {
            return 1;
        }
        int nx = *(--it);
        char nd = dd[nx][y];
        vy[y].erase(it);
        vx[nx].erase(y);
        return solve(nx, y, vx, vy, nd, dd) + 1;
    } else if(d == 'v') {
        auto it = vx[x].upper_bound(y);
        if(it == vx[x].end()) {
            return 1;
        }
        int ny = *it;
        char nd = dd[x][ny];
        vx[x].erase(ny);
        vy[ny].erase(x);
        return solve(x, ny, vx, vy, nd, dd) + 1;
    } else {
        auto it = vx[x].lower_bound(y);
        if(it == vx[x].begin()) {
            return 1;
        }
        int ny = *(--it);
        char nd = dd[x][ny];
        vx[x].erase(ny);
        vy[ny].erase(x);
        return solve(x, ny, vx, vy, nd, dd) + 1;
    }
}

int main() {
    int n;
    cin >> n;
    using data = tuple<int, int, char>;
    vector<int> x(n), y(n);
    vector<char> d(n);
    vector<int> xs, ys;
    for(int i=0; i<n; ++i) {
        cin >> x[i] >> y[i] >> d[i];
        xs.push_back(x[i]);
        ys.push_back(y[i]);
    }
    sort(xs.begin(), xs.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
    sort(ys.begin(), ys.end());
    ys.erase(unique(ys.begin(), ys.end()), ys.end());
    for(int i=0; i<n; ++i) {
        x[i] = lower_bound(xs.begin(), xs.end(), x[i]) - xs.begin();
        y[i] = lower_bound(ys.begin(), ys.end(), y[i]) - ys.begin();
    }
    vector<vector<char>> dd(xs.size(), vector<char>(ys.size()));
    for(int i=0; i<n; ++i) {
        dd[x[i]][y[i]] = d[i];
    }
    vector<set<int>> vx(xs.size());
    vector<set<int>> vy(ys.size());
    for(int i=0; i<n; ++i) {
        vx[x[i]].insert(y[i]);
        vy[y[i]].insert(x[i]);
    }
    int res = 0;
    for(int i=0; i<n; ++i) {
        auto vxx = vx;
        auto vyy = vy;
        vxx[x[i]].erase(y[i]);
        vyy[y[i]].erase(x[i]);
        res = max(res, solve(x[i], y[i], vxx, vyy, d[i], dd));
    }
    cout << res << endl;
}


Measured memory_bytes: 6376
#include<stdio.h>
#include<string.h>
int main(){
  int n,d=1,m,i;
  char s[300][20],c[20],w[][20]={"Opened by","Closed by","Unknown"};
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%s",s[i]);
  scanf("%d",&m);
  while(m--){
    scanf("%s",c);
    for(i=0;i<n&&strcmp(s[i],c);i++);
    printf("%s %s\n",i-n?w[d=1-d]:w[2],c);
  }
  return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N);
    vector<int> y(M);
    REP(i,N) cin >> x[i];
    REP(i,M) cin >> y[i];
    sort(x.begin(), x.end());
    sort(y.begin(),y.end());

    bool war = true;
    for(int i = X + 1; i <= Y; ++i){
        if(x[N-1] < i && i <= y[0]) war = false;
    }
    if(war) cout << "War" << endl;
    else cout<< "No War" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  int N = in();
  vector<string> S(N);
  int C=0;  // AB を内部にいくつ含むか
  vi typ = {0,0,0,0};  // *, *A, B*, B*A
  rep(i,N) cin >> S[i];
  rep(i,N){
    rep(j,S[i].size()-1){
      if(S[i][j]=='A' && S[i][j+1]=='B') C++;
    }
    if(S[i][0]=='B'){
      if(S[i][S[i].size()-1]=='A') typ[3]++;
      else typ[2]++;
    } else {
      if(S[i][S[i].size()-1]=='A') typ[1]++;
      else typ[0]++;
    }
  }

  dump(C, typ);

  // First, typ[3] is consumed
  if(typ[3]>0){
    C += typ[3]-1; typ[3] = 1;
  }
  C += min(typ[1],typ[2]);
  if(typ[3]==1 && (typ[1]>0 || typ[2]>0)) C++;
  cout << C << endl;

  return 0;
}


Measured memory_bytes: 768
N, K = map(int, input().split())
V = list(map(int, input().split()))
M = min(N, K)
ans = 0
for i in range(1, M+1):
    for a in range(i+1):
        L = sorted(V[:a] + V[N-(i-a):], reverse=True)
        for _ in range(K-i):
            if L and L[-1] < 0:
                L.pop()
            else:
                break
        ans = max(ans, sum(L))
print(ans)

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

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n),b(n),c(n),d(n);
	for(int i = 0;i<n;i++)cin >> a[i];

	b[0]= 1000;
	c[0] =b[0]/a[0];

	d[0] = b[0]%a[0];
	for(int i = 1;i<n;i++)
	{
		for(int j = 0;j<i;j++)
		{
			b[i] = max(b[i] ,b[j]);
			b[i] = max(b[i],c[j]*a[i]+d[j]);
		}
		c[i]=b[i]/a[i];
		d[i]=b[i]%a[i];
	}
	ll ans = 0;
	for(int i = 0;i<n;i++)ans = max(ans,b[i]);
	//for(int i = 0;i<n;i++)cout << a[i] << ' ' << b[i] << ' ' << c[i] << ' ' <<d[i] << endl;
	cout << ans << endl;
}



Measured memory_bytes: 3592
#include <stdio.h>

int from, battery, to;
int prob[16][16]; //残量iで, 地点jからbatteryへいける確率

int getProb(int lim, int start)
{
    int k;
    int ans;
    
    if (prob[lim][start] >= 0){
        return (prob[lim][start]);
    }
    
    if (start == battery && lim == 0){
        return (1);
    }
    if (lim == 0){
        return (0);
    }
    
    ans = 0.0;
    k = 4;
    
    if ((start + 1) % 3 && start + 1 != to){
        ans += getProb(lim - 1, start + 1);
        k--;
    }
    
    if (start % 3 && start - 1 != to){
        ans += getProb(lim - 1, start - 1);
        k--;
    }
    
    if (start + 3 < 9 && start + 3 != to){
        ans += getProb(lim - 1, start + 3);
        k--;
    }
    
    if (start - 3 >= 0 && start - 3 != to){
        ans += getProb(lim - 1, start - 3);
        k--;
    }
    
    ans += getProb(lim - 1, start) * k;
    
    return (prob[lim][start] = ans);
}

int main(void)
{
    int left;
    int i, j;
    char in[16];
    
    while (1){
        scanf(" %d", &left);
        if (left == 0){
            break;
        }
        scanf(" %c %c %c", in, in + 2, in + 4);
        from = in[0] - 'A';
        battery = in[2] - 'A';
        to = in[4] - 'A';
        
        for (i = 0; i < 16; i++){
            for (j = 0; j < 16; j++){
                prob[i][j] = -1;
            }
        }
        
        printf("%.8lf\n", getProb(left, from) * 1.0 / (1 << (left * 2)));
    }
    
    return (0);
}

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

int main(void){
    char s[202];
    char p[202];
    char z[404];    

    scanf("%s", &s);
    scanf("%s", &p);
    
    strcpy(z, s);//sの文字列をzにコピーする
    strcat(s, z);//sの後ろにzを連結する


    if (strstr(s, p) != NULL){//pがあるか探す
        printf("Yes\n");
    }
    else if(strstr(s, p) == NULL){
        printf("No\n");
    }

    return (0);
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
const int INF = 1e9;
const int MO = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#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 FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define rt return
#define ENDL cout<<endl
#define MAXE(a,b) a=max(a,b)
#define MINE(a,b) a=min(a,b)
#define s second
#define f first

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    CIN(A);CIN(B);
    if(B % A == 0){
        COUT(A+B);
    }else{
        COUT(B-A);
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();

		System.out.println(Math.max(Math.max(a + b, a - b), a * b));
	}
}


Measured memory_bytes: 22100
#include<stdio.h>
int main(void)
{
	int a,s,d[2000],f,g,h,i,j;
	scanf("%d %d",&a,&s);
	while(a!=0&&s!=0){
		for(i=1;i<=a;i++){
			scanf("%d",&d[i]);
		}
		for(i=1;i<=a;i++){
			for(j=i;j<=a;j++){
				if(d[i]<d[j]){
					f=d[i];
					d[i]=d[j];
					d[j]=f;
				}
			}
		}
		g=0;
		h=0;
		for(i=1;i<=a;i++){
			if(g==s-1){
				g=0;
				d[i]=0;
			}
			else if(g!=s-1){
				g++;
				h+=d[i];
			}
			//printf("%d %d\n",g,d[i]);
		}
		printf("%d\n",h);
	scanf("%d %d",&a,&s);
	}
	return 0;
}

Measured memory_bytes: 1036
local t = {}
for i = 1, 7 do t[i] = io.read("*n") end
local ret = t[2] + 2 * (t[1] // 2 + t[4] // 2 + t[5] // 2)
local a = t[1] % 2 + t[4] % 2 + t[5] % 2
if a == 3 then
  ret = ret + 3
elseif a == 2 then
  if 0 < t[1] and 0 < t[4] and 0 < t[5] then
    ret = ret + 1
  end
end
print(ret)


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

int main(int argc,char *argv[]){
  long int N,X;
  cin >> N >> X;
  long int ans = N;
  N = N-X;
  while(N%X != 0){
    long int next = N % X;
    ans += (N-next)*2;
    N = X;
    X = next;
  }
  ans += (N*2-X);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys

input = lambda: sys.stdin.readline().rstrip()

s = deque(list(input()))
q = int(input())

rev_cnt = 0
for i in range(q):
    query = input().split()
    if query[0] == '2':
        if (query[1] == '1' and rev_cnt % 2 == 0) or ((query[1] == '2' and rev_cnt % 2 == 1)):
            s.appendleft(query[2])
        else:
            s.append(query[2])
    else:
        rev_cnt += 1

if rev_cnt % 2 == 1:
    print(''.join([s[len(s) - i - 1] for i in range(len(s))]))
else:
    print(''.join([c for c in s]))


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define PI 3.14159265358979323846
ll A,B,X;
ll i, j, k;
double ans;

int main(){
    scanf("%lld%lld%lld",&A,&B,&X);
    if(X<=A*A*B/2){
        printf("%.12lf", atan((1.0 * A * B * B) / (2.0 * X)) * 180 / PI);
    }else{
        X = A * A * B - X;
        printf("%.12lf", 90-atan((1.0 * A * A * A) / (2.0 * X)) * 180 / PI);
    }
    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin >> n >> k;
    ll a[n];
    for(ll i = 0;i < n;i++){
    	cin >> a[i];
    }
    ll dp[n];
    dp[0] = 0;
    for(ll i = 1;i < n;i++){
    	dp[i] = INT_MAX;
    	for(ll j = max((ll)0,i-k);j < i;j++){
    		dp[i] = min(dp[i],abs(a[i]-a[j])+dp[j]);
    	}
    }
    cout << dp[n-1] << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int inf = 999999999;
const double pi = acos(-1);

#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define mod(i) (i%(ll)(1e9 + 7))


int main(){
	ll n,x,y;
	cin >> n ;
	cin >> x >> y;
	rep(i,1,n){
		ll a,b;
		cin >> a >> b;
		if(a == b){
			ll t = max(x,y);
			x = t;
			y = t;
		}else{
			ll t = max((x+a-1)/a,(y+b-1)/b);
			x = a * t;
			y = b * t;
		}
	}
	
	cout << x + y << endl;
	return 0;
}

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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    int x = 0;
    while (N != 0) {
        x++;
        N /= K;
    }
    cout << x << endl;
}

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

typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<int> l(n);
    int i;
    for(i = 0;i < n;++i){
        cin >> l.at(i);
    }
    sort(l.begin(),l.end());
    int j;
    ll ans = 0;
    for(i = 0;i < n-2;++i){
        for(j = i+1;j < n-1;++j){
            int temp = l.at(i) + l.at(j);
            int index = lower_bound(l.begin(),l.end(),temp) - l.begin();
            ans += index - 1 - j;
        }
    }
    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++)

int main()
{
    long long a, b, c;
    cin >> a >> b >> c;
    long long tmp = c - a - b;
    if(tmp <= 0)
    {
        cout << "No" << endl;
        return 0;
    }

    if((4 * a * b) < (tmp * tmp))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, T t){return v2<T>(r, vector<T>(c, t));}

int n, q;
void solve(){
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    cin >> q;
    vector<pair<int , int>> b(q);
    for(int i = 0; i < q; i++) cin >> b[i].first >> b[i].second;

    unordered_map<int, int> m;
    ll sum = 0;
    for(int i = 0; i < n; i++){
        sum += a[i];
        m[a[i]]++;
    }

    for(int i = 0; i < q; i++){
        sum += (b[i].second - b[i].first) * m[b[i].first];
        m[b[i].second] += m[b[i].first];
        m[b[i].first] = 0;

        cout << sum << '\n';
    }
}

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


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


// HOW TO DO 
// sort 
// if a+ b > c ans ++ 
int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; ++i) cin >> vec[i];
    sort(vec.begin(), vec.end());

    int ans = 0;

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < i; ++j) {
            for (int k = 0; k < j; ++k) {
                if (vec[k] != vec[j] and vec[i] != vec[j] and
                    vec[k] + vec[j] > vec[i]) {
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<int>a(M);
  vector<int>b(M);
  vector<int>ans(N);
  
  for(int i=0;i<M;i++){
    cin>>a.at(i)>>b.at(i);
    for(int j=0;j<N;j++){
      if(a.at(i)==j+1){
        ans.at(j)++;
  }
    }
    for(int k=0;k<N;k++){
      if(b.at(i)==k+1){
        ans.at(k)++;
      }
    }
  }
  

for(int i=0;i<N;i++){
  cout<<ans.at(i)<<endl;
}
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]

use procon::*;
use std::cmp::{max, min};
use std::collections::*;
use std::ops::*;
use std::*;

pub fn main() {
    let N = read_line().parse::<usize>().unwrap();
    let P = (0..N)
        .map(|_| read_line().parse::<usize>().unwrap() - 1)
        .collect::<Vec<_>>();

    let mut len = vec![1; N];
    let mut done = vec![false; N];
    for p in P {
        len[p] = if p >= 1 && done[p - 1] {
            len[p - 1] + 1
        } else {
            1
        };
        done[p] = true;
    }
    let m = len.iter().cloned().max().unwrap();

    println!("{}", N - m);

    return;
}

pub mod procon {
    use std;
    use std::collections::*;
    use std::io;
    use std::mem;
    use std::str::FromStr;

    pub fn read_line() -> String {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        buf.trim_right().to_owned()
    }

    pub fn read_words<T>() -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        buf.split_whitespace()
            .map(|word| T::from_str(word).unwrap())
            .collect()
    }

    pub fn read_vec(len: usize) -> Vec<String> {
        let mut vec = Vec::new();
        while vec.len() < len {
            let line = read_line();
            for word in line.split_whitespace() {
                vec.push(word.to_owned());
            }
        }
        assert!(vec.len() == len);
        vec
    }
}


Measured memory_bytes: 8444
#include <string>
#include <vector>
#include <algorithm>
#include<iostream>
#include <stdio.h>
using namespace std;


int main()
{    
    long long N, K;
    cin >> N >> K;
    long long A[N];
    for (long long i = 0; i < N; ++i) {
        cin >> A[i];
    }
    
    long long P=0;
    long long L[N*2]={0};
    long long D[N*2]={0};
    long long c=0;
    long long R=0;

    long long ans=0;

    while(1){
        c+=1;
        P=A[P]-1;
        L[c]=P;
        if (D[P]>0){
            R=D[P];
            break;
        }
        D[P]=c;
        if (P==0){break;}
    }
    if (K<R){
        ans=L[K]+1;
    }else {
    K-=R;
    K%=(c-R);
    ans=L[R+K]+1;
    }
    cout << ans << endl;
    
    return 0;

}

Measured memory_bytes: 11364
#include<iostream>
#include<cmath>

using namespace std;

bool isPrime(int x){
	if(x < 2)
		return false;
	if(x == 2)
		return true;
	if(x % 2 == 0)
		return false;
	double s = sqrt(x);
	for(int i=3;i <=s;i+=2){
		if(x % i == 0)return false;
	}
	return true;

}

int main(){
	int n,e;
	int count = 0;
	cin >> n;
	for(int i = 0;i<n;i++){
		cin >>e;
		if(isPrime(e)) count++;
	}
	cout << count << endl;
	
	return 0;
}

Measured memory_bytes: 3048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] read = br.readLine().split("");
		int count = 0;
		for(int i = 0; i < 4; i++) {
			if(read[i].equals("2")) {
				count++;
			}
		}
		System.out.println(count);
	}
}

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

int main(){
  int a, b;
  cin >> a >> b;
  if((a+b)%2){
    cout << (a+b)/2 + 1 << endl;
  } else {
    cout << (a+b)/2 << endl;
  }
}


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

int main(int argc, const char * argv[]) {
    int A,B;
    cin >> A;
    cin >> B;
    if (A > 9 || B > 9) {
        cout << "-1" << endl;
        return 0;
    }
    cout << A*B;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
//		new A().doIt();
//		new B().doIt();
//		new C().doIt();
		new D().doIt();
	}
	class A{
		void doIt() {
			int N = sc.nextInt();
			int sum = 0;
			for(int i = 1;i <= N;i++) {
				sum = sum + i;
			}
			System.out.println(sum);
		}
	}
	class B{
		void doIt() {
			String str = sc.next();
			char ctr[] = str.toCharArray();
			ArrayList<Character> array = new ArrayList<Character>();
			for(int i = 0;i < str.length();i++) {
				if(ctr[i] == 'B') {
					if(array.size() > 0)array.remove(array.size() - 1);
				}else array.add(ctr[i]);
			}
			for(int i = 0;i < array.size();i++)System.out.print(array.get(i));
			System.out.println();
		}
	}
	class C{
		void doIt(){
			int N = sc.nextInt();
			int a[] = new int[N];
			for(int i = 0;i < N;i++)a[i] = sc.nextInt();
			
			int ans = Integer.MAX_VALUE;
			
			for(int i = -100;i <= 100;i++)ans = Math.min(ans, Distance(i,N,a));
			
			System.out.println(ans);
		}
		int Distance(int Pos,int N,int a[]) {
			int sum = 0;
			for(int i = 0;i < N;i++)sum += (Pos - a[i]) * (Pos - a[i]);
			return sum;
		}
	}
	class D{
		void doIt() {
			String str = sc.next();
			char ctr[] = str.toCharArray();
			Check(ctr,str.length());
		}
		void Check(char ctr[],int length) {
			int s = -1;
			int e = -1;
			if(length == 2) {
				if(ctr[0] == ctr[1]) {
					s = 1;e = 2;
				}
			}else {
				for(int i = 0;i < length - 2;i++) {
					if(ctr[i] == ctr[i+1]) {
						s = i+1;e = i+2;
					}
					else if(ctr[i] == ctr[i+2]) {
						s = i+1;e = i+3;
					}
					else if(ctr[i+1] == ctr[i+2]) {
						s = i+2;e = i+3;
					}
				}
			}
			System.out.println(s+" "+e);
			return;
		}
	}
}


Measured memory_bytes: 25660
from heapq import*
n,h=map(int,input().split())
katanas=[]
for _ in range(n):
  a,b=map(int,input().split())
  heappush(katanas,(-a,0))
  heappush(katanas,(-b,1))
  
ans=0
t=0
for i in range(10**9):
  tmp,idx=heappop(katanas)
  if idx==1:
    # bが出てくる
    # たかだかn回
    h=h-(-tmp)
    t+=1
    if h<=0:
      print(t)
      exit()
  else:
    # aが出てくる
    # 目一杯ふる
    t+=(h+(-tmp)-1)//(-tmp)
    print(t)
    exit()
  
    

Measured memory_bytes: 94460
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    string a,b,c;
    cin >> a >> b >> c;
    if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0])
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int, int> pii;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int a, b, c; cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << ' ' << b << ' ' << c << '\n';

}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string>
using namespace std;
int main() {
	int n,m;
	while (cin >> n >> m&&n != 0 && m != 0) {
		int a[100], m2 = m;
		fill(a, a + m, 0);
		for (int i = 0; i < n; i++) {
			int b;
			for (int j = 0; j < m; j++) {
				cin >> b;
				if (b == 1)
					a[j]++;
			}
		}
		bool b[100];
		string s = "";
		fill(b, b + m, true);
		while (m2 != 0) {
			int m3 = 0,j=0;
			for (int i = m - 1; i >= 0; i--) {
				if (m3 <= a[i] && b[i]) {
					j = i;
					m3 = a[i];
				}
			}
			b[j] = false;
			if (m2 == m) s += to_string(j + 1);
			else {
				s += " ";
				s += to_string(j + 1);
			}
			m2--;
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 3212
package main

import "fmt"

func main() {
	// Code for B - Card Game for Three (ABC Edit)
	var Sa, Sb, Sc string
	fmt.Scanf("%s\n%s\n%s", &Sa, &Sb, &Sc)

	var flag string = string('a')
	for {
		if flag == string('a') {
			if len(Sa) == 0 {
				fmt.Println("A")
				break
			}
			flag = Sa[0:1]
			Sa = Sa[1:len(Sa)]
		} else if flag == string('b') {
			if len(Sb) == 0 {
				fmt.Println("B")
				break
			}
			flag = Sb[0:1]
			Sb = Sb[1:len(Sb)]
		} else {
			if len(Sc) == 0 {
				fmt.Println("C")
				break
			}
			flag = Sc[0:1]
			Sc = Sc[1:len(Sc)]
		}
	}
}


Measured memory_bytes: 1840
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int a, b, c;
	cin >> a >> b >> c;

	if (a <= c && c <= b) {
		out("Yes");
	}
	else {
		out("No");
	}

	return 0;
}

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

int main() {
  long long a, b ,x, ans = 0;
  cin >> a >> b >> x;
  
  if(a == 0){
    ans += b/x + 1;
  }else ans += b/x - (a-1)/x;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll n,c;
    cin >> n;
    ll dp[n+1];
    ll mxps[200005];
    ll i;
    for(i=0;i<200005;i++){
      mxps[i]=0;
    }
    dp[0]=1;
    for(i=1;i<=n;i++){
      cin >> c;
      if(mxps[c]==0|mxps[c]==i-1){
        dp[i]=dp[i-1];
      }else{
        dp[i]=(dp[i-1]+dp[mxps[c]])%1000000007;
      }
      mxps[c]=i;
    }
    cout << dp[n];
    return 0;
}


Measured memory_bytes: 3328
N, M = list(map(int, input().split()))
dp = [0] * (N+1)
for _ in range(M):
    a = int(input())
    dp[a] = -1

dp[0] = 1
dp[1] += 1
for i in range(2, N+1):
    if dp[i] == -1:
        dp[i] = 0
    else:
        dp[i] = (dp[i-1] + dp[i-2]) % 1000000007
print(dp[N])


Measured memory_bytes: 6900
// same integers
#include <stdio.h>

/*int find_num(int target, int ub, int kishutsu[MAXSIZE]){
    for(int i = 0; i < ub; i++){
        if(kishutsu[i] == target) return 1;
    }
    return 0;
}*/

int* max(int a[3]){
    if(a[0] >= a[1] && a[0] >= a[2]) return &a[0];
    else if(a[1] >= a[0] && a[1] >= a[2]) return &a[1];
    else return &a[2];
}

int find_even(int ar[3]){
    int num = 0;
    for(int i = 0; i < 3; i++){
        if(ar[i] % 2 == 0) num++;
    }
    return num;
}

int main(void){
    int a[3];
    scanf("%d %d %d", &a[0], &a[1], &a[2]);
    
    int *target;
    target = max(a);
    //printf("target = %d\n", *target);
    int num_even = find_even(a);
    //printf("num_even = %d\n", num_even);
    int ans;
    if(num_even == 3 || num_even == 0){
        ans = ((*target) * 3 - a[0] - a[1] - a[2]) / 2;
    }else{
        if((*target) % 2 != num_even % 2){
            //printf("max and num_even are not the same\n");
            ans = (*target - a[0]) / 2 + (*target - a[1]) / 2 + (*target - a[2]) / 2 + 1;
        }else{
            //printf("max and num_even are the same\n");
            for(int i = 0; i < 3; i++){
                if(a[i] != (*target) && a[i] % 2 == 0){
                    a[i]++;
                    break;
                }
            }
            (*target)++;
            ans = 1 + ((*target) * 3 - a[0] - a[1] - a[2]) / 2;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;

int main(void){
  long long N,M;
  cin >> N >> M;
  long long sum = 0;
  vector<int> v;
  for(int i=0;i<M;i++){
    int tmp;
    cin >> tmp;
    v.push_back(tmp);
    sum = sum +tmp;
  }
  if(sum > N){
    cout << -1 << endl;
    return 0;
  }
  cout << N-sum << endl;
  return 0;
} 


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

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0

now = -2
for i in range(len(A)):
    ans += B[A[i]-1]
    if now+1 == A[i]-1:
        ans += C[A[i]-2]
    now = A[i]-1

print(ans)


Measured memory_bytes: 3064
import sys
read=sys.stdin.read

n,*a=map(int,read().split())
def output(x,y):
  #a[y]+=a[x]
  print('{} {}'.format(x+1,y+1))
mx=max(a)
mxi=a.index(mx)
mn=min(a)
mni=a.index(mn)

print(2*n-1)
if abs(mx)>=abs(mn) and mx>=0:
  for i in range(n):
    if mxi!=i:
      output(mxi,i)
  output(mxi,mxi)
  for i in range(1,n):
    output(i-1,i)
elif abs(mx)<abs(mn) and mn<0:
  for i in range(n):
    if mni!=i:
      output(mni,i)
  output(mni,mni)
  for i in range(n-1,0,-1):
    output(i,i-1)

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

int main()
{
	string s;
	while (cin >> s)
	{
		int vis[3] = { 0 };
		int len = s.length();
		for (int i = 0; i < len; ++i)
		{
			if (s[i] == 'a')  vis[0] = 1;
			else if (s[i] == 'b') vis[1] = 1;
			else if (s[i] == 'c') vis[2] = 1;
		}
		int sum = vis[0] + vis[1] + vis[2];
		if (sum == 3) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    int k, n; cin >> k >> n;
    vector<int> a(n); rep(i, n) cin >> a[i];
    int ans = a[0] + k - a[n-1];
    rep(i, n-1) chmax(ans, a[i+1] - a[i]);
    cout << k - ans << endl;
}

Measured memory_bytes: 1024
def main():
    n, m = map(int, input().split())

    a = []
    for _ in range(n):
        r = [int(s) for s in input().split()][1:]
        a.append(r)
    
    print(solve(m, a))

def solve(m, a):
    s = set(range(1, m + 1))

    for i in range(len(a)):
        s = s & set(a[i])
    
    return len(s)

main()


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

using namespace std;
int main()
{
	int N, c, D1, D2;
	string ans;
	N = 0;
	ans = "No";
	cin >> N;
	c = 0; D1 = 0; D2 = 0;
	for (int i = 0; i < N; i++) {
		cin >> D1 >> D2;
		if (D1 == D2) {
			c += 1;
		}
		else {
			c = 0;
		}
		if (c == 3) {
			ans = "Yes";
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3588
from collections import defaultdict
from itertools import product
 
H,W,K = map(int,input().split())
S = [input() for i in range(H)]
 
C = [[int(S[i][k]) for i in range(H)] for k in range(W)]
answer = H*W #出力がこれを超えることはない
for X in product([False,True],repeat = H-1):
  M = [[0]]
  ans = sum(X)
  if ans > answer:#初期値がanswerよりも大きかったら考える必要がない
    continue
  for i,x in enumerate(X):#配列Mの作成
    if x:
      M.append([])
    M[-1].append(i+1)
  D = [0]*len(M)
  for c in C:
    for k,m in enumerate(M):
      D[k] += sum(c[i] for i in m)#k番目の要素に足していく
      #Dにどんどん代入することによってどの列まで足すことができるか算出することができる
    if any(d>K for d in D):#一つでもKを超えていたら
      ans += 1
      if ans >answer:
        break
      D = [sum(c[i] for i in m) for m in M]#超えた行について再び調査
      if any(d>K for d in D):
        ans = answer + 1
        #デフォルトanswerの結果より高い値にしてこの結果が出力にならないように設定する
        break
  answer = min(answer,ans)#あるXに対してanswerを算出(更新)
print(answer)

Measured memory_bytes: 3564
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
typedef long long ll;

ll calcDebt(ll debt)
{
    double buff;
    buff = (double) debt;
    buff = buff * 1.05;
    buff = ceil(buff / 1000) * 1000;
    return (ll) buff;
}

int main()
{
    int n;
    ll debt = 100000;
    cin >> n;
    for(int c = 0; c < n; c++)
        debt = calcDebt(debt);
    cout << debt << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e3+5;

int n;
int a[N][N],t[N],p[N];
queue<int>q[2];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	for(int j=1;j<n;++j)
	scanf("%d",&a[i][j]);
	for(int i=1;i<=n;++i)q[0].push(i);
	int now=1,nex=0;
	for(int day=1,tot=n*(n-1)/2;day<=n*(n-1)/2;++day){
		swap(now,nex);
		while(!q[now].empty()){
			int x=q[now].front();q[now].pop();
			int y=a[x][++t[x]];
			if(p[y]==x){
				tot--;
				q[nex].push(x);
				q[nex].push(y);
				p[x]=p[y]=0;
			}
			else p[x]=y;
		}
		if(!tot){
			cout<<day<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
} 

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

using namespace std;

using ll = long long;

const int N = 2e5 + 5;

ll arr[N];
ll psum[N];
int n;

ll get_psum(int l, int r) { return psum[r - 1] - psum[l - 1]; }

void shift_1(int &p1, int &p2, int &p3) {
  while (p1 + 1 < p2 && abs(get_psum(0, p1) - get_psum(p1, p2)) >=
                            abs(get_psum(0, p1 + 1) - get_psum(p1 + 1, p2))) {
    ++p1;
  }
  (void)p3;
}

void shift_3(int &p1, int &p2, int &p3) {
  while (p3 + 1 < n && abs(get_psum(p2, p3) - get_psum(p3, n)) >=
                           abs(get_psum(p2, p3 + 1) - get_psum(p3 + 1, n))) {
    ++p3;
  }
  (void)p1;
}

bool shift_2(int &p1, int &p2, int &p3) {
  if (p2 < p3 - 1) {
    ++p2;
    return true;
  } else if (p3 < n - 1) {
    ++p3;
    ++p2;
    return true;
  }
  return false;
  (void)p1;
}

int solve() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int d;
    scanf("%d", &d);
    arr[i] = d;
  }
  partial_sum(arr, arr + n, psum);
  int p1 = 1, p2 = 2, p3 = 3;
  ll min_seg = -1e14;
  ll max_seg = 1e14;
  do {
    shift_3(p1, p2, p3);
    shift_1(p1, p2, p3);
    ll cur_min_seg = min(get_psum(0, p1), min(get_psum(p1, p2),
                                       min(get_psum(p2, p3), get_psum(p3, n))));
    ll cur_max_seg = max(get_psum(0, p1), max(get_psum(p1, p2),
                                       max(get_psum(p2, p3), get_psum(p3, n))));
    if (cur_max_seg - cur_min_seg < max_seg - min_seg) {
        max_seg = cur_max_seg;
        min_seg = cur_min_seg;
    }
  } while (shift_2(p1, p2, p3));
  cout << max_seg - min_seg << endl;

  return 0;
}

int main() {
#ifdef LOCALHOST
  freopen("input", "r", stdin);
#endif
  while (solve())
    ;

  return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <unordered_map>
#include <cmath>
using namespace std;
#define ll long long
ll x,sol,a,val,i,rez,rez2;
unordered_map <ll,ll> m;
int main()
{
    cin>>x;
    if (x==0)
        cout<<0<<" "<<0;
    else
    {
        for (i=1;i<=3500;++i)
            m[i*i*i*i*i]=i;
        while (!sol)
        {
            val=1;
            for (i=1; i<=5; ++i)
                val=val*a;
            rez=val-x;
            rez2=abs(val-x);
            if (m[rez2])
            {
                sol=1;
                cout<<a<<" ";
                if (rez<0) cout<<-m[rez2]<<"\n";
                else cout<<m[rez2]<<"\n";
                break;
            }
            a++;
        }
    }
}


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

int main(){
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    rep(i,H){
        cin >> S[i];
    }

    char c;
    for(int j=0; j<H; j++){
        for(int k=0; k<W; k++){
            c = S[j][k];
            if(c == '#'){continue;}

            int val = 0;
            for(int d_j: {-1, 0, 1}){
                for(int d_k: {-1, 0, 1}){
                    if(d_j == 0 && d_k == 0)continue;

                    int x = k + d_k;
                    int y = j + d_j;

                    if( x >= 0 && x < W && y >=0 && y < H ){
                        val += (S[y][x] == '#')? 1 : 0;
                    }
                }
            }
            S[j][k] = val + '0';
        }
    }

    for(int j=0; j<H; j++){
        for(int k=0; k<W-1; k++){
            cout << S[j][k];
        }
        cout << S[j][W-1] << endl;;
    }
}

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

#define Rushia_mywife ios::sync_with_stdio(0);cin.tie(0);
#define rep(i,head,n) for(int i=(head);i<n;i++)
#define F first
#define S second
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define all(x) (x).begin(),(x).end()
#define SZ(x) (int)(x).size()
#define mem(x,i) memset((x),(i),sizeof((x)))
#define odd(x) ((x)&1)
#define LG(x) (int)log2((x))

using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<long long,long long>;
using ld = long double;

mt19937 mt_rand(time(0));
const int mod = 1000000007;
const int hnum = 998244353;
const ld PI = acos(-1);

#define int long long
int qpow(int x,int powcnt,int tomod){
	int res = 1;
	for(;powcnt;powcnt>>=1,x=(x*x)%tomod)
		if(1&powcnt)res = (res*x)%tomod;
	return (res%tomod);
}
int gcd(int aaa,int bbb){
	return (bbb==0 ? aaa : gcd(bbb,aaa%bbb));
}
int lcm(int aaa,int bbb){
	return (aaa/gcd(aaa,bbb))*bbb;
}
int C(int x){
	return x*(x-1)/2;
}
// --------------------------------------**
const int N = 2e5+10;

int seg[N<<2];
int dp[N];
int a[N],b[N];

void update(int l,int r,int pos,int del,int idx){
	if(l==r){
		seg[idx] += del;
		return;
	}
	int mid = (l+r)>>1;
	if(pos<=mid)
		update(l,mid,pos,del,idx<<1);
	else
		update(mid+1,r,pos,del,idx<<1|1);
	seg[idx] = (seg[idx<<1]+seg[idx<<1|1])%hnum;
}
int query(int l,int r,int ql,int qr,int idx){
	if(l==ql&&r==qr)
		return seg[idx];
	int mid = (l+r)>>1;
	if(qr<=mid)
		return query(l,mid,ql,qr,idx<<1);
	else if(ql>mid)
		return query(mid+1,r,ql,qr,idx<<1|1);
	return (query(l,mid,ql,mid,idx<<1)+query(mid+1,r,mid+1,qr,idx<<1|1))%hnum;
}

int n,k;

void solve(){
	cin >> n >> k;
	rep(i,0,k)
		cin >> a[i] >> b[i];
	dp[1] = 1;
	update(1,n,1,1,1);
	rep(i,2,n+1){
		rep(j,0,k){
			if(a[j]>=i)
				continue;
			//cout << a[j] << ',' << b[j] << ' ';
			dp[i] = (dp[i]+query(1,n,max(1LL,i-b[j]),i-a[j],1))%hnum;
			//cout << dp[i] << ' ';
		}
		update(1,n,i,dp[i],1);
		//cout << dp[i] << '\n';
	}
	//cout << '\n';
	cout << dp[n] << '\n';
	//cout << dp[4] << '\n';
}

signed main(){
    Rushia_mywife
    //int t; cin >> t;
    //while(t--)
    solve();
}


Measured memory_bytes: 9308
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define xrep(i, a, b) for (int i = int(a); i < int(b); ++i)
int main() {
    double R;
    cin >> R;
    double pi = acos(-1);
    cout << 2.0 * pi * R << endl;
    return 0;
}

Measured memory_bytes: 3808
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		for(int i=1;i<=10000;i++) {
			if(1<=x && x<=10000) {
				System.out.println("Case "+i+": "+ x);
			} else if(x == 0) {
				break;
			}
			x = sc.nextInt();
		}
	}
}

Measured memory_bytes: 42520
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
from collections import Counter

def flatten_2dim(array):
    return [item for sublist in array for item in sublist]

n,x,y = map(int,input().split())

# l = [[0,1,0,0,0],[1,0,1,1,0],[0,1,0,1,0],[0,1,1,0,1],[0,0,0,1,0]]

l = [[0]*n for i in range(n)]
for i in range(n-1):
    l[i][i+1] = 1
    l[i+1][i] = 1 
l[x-1][y-1] = 1
l[y-1][x-1] = 1
# l.append([x,y])

a = np.array(l)
ans = shortest_path(a,method ="D")
ans_counter = Counter(flatten_2dim(ans))
# values = ans_counter.values()
# print(l)
# print(ans)
for i in range(1,n):
    print(int(ans_counter[i]/2))

# print(ans_counter[1])
# print(values)

Measured memory_bytes: 309276
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int a, b;
  cin >> a >> b;

  int ans = max({a + b, a - b, a * b});
  cout << ans << endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 2e9;

int main()
{
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if (abs(a - b) > 1e18)
    {
        cout << "unfair" << endl;
    }
    else if (k % 2 == 0)
    {
        cout << a - b << endl;
    }
    else
    {
        cout << b - a << endl;
    }
}

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

int main() {
   string S, T;
   cin >> S >> T;
   
   for (int i = 0; i < S.size(); i++) {
      string S2 = "";
      for (int j = 0; j < S.size(); j++) {
         int tmp = (i + j)%S.size();
         S2 = S2 + S[tmp];
      }
      if (T == S2) {
         cout << "Yes" << endl;
         return 0;
      }
   }
   cout << "No" << endl;
   return 0;
}


Measured memory_bytes: 256