akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
import cmath
import math
import copy
INF = float("inf")

EPS = 1e-9


def ctc(p1, r1, p2, r2):
    # 二つの円の共通接線の数
    # common tangent count?
    # common tangent of circle?
    # 2円の関係性は、
    # 同一(=INF), 離れている(=4)、外接(=3)、交わる(=2)、内接(=1)、内包(=0)がある
    # r1 <= r2として一般性を失わない
    if r2 < r1:
        p1, p2 = p2, p1
        r1, r2 = r2, r1

    d = abs(p1-p2)

    if p1 == p2 and d < EPS:    # 同一の円
        return INF
    elif (d - (r2+r1)) > EPS:   # 離れている
        return 4
    elif (d - (r2+r1)) > -EPS:  # 外接している
        return 3
    elif (d-(r2-r1)) > EPS:     # 交わっている
        return 2
    elif (d-(r2-r1)) > -EPS:    # 内接している
        return 1
    else:                       # 内包している
        return 0


def inner(p1, c1, p2, c2):
    coeff1 = c1/(c1+c2)
    coeff2 = c2/(c1+c2)
    return p1*coeff1+p2*coeff2


def intersection(p1, r1, p2, r2):
    status = ctc(p1, r1, p2, r2)
    d = abs(p1-p2)
    if not (1 <= status <= 3):
        return []
    elif status == 3:           # 外接
        return [inner(p1, r1, p2, r2)]
    elif status == 1:           # 内接
        return [p1 + r1*(p1-p2)/d]
    else:                       # 交わっている場合
        if r1 > r2:
            p1, p2 = p2, p1
            r1, r2 = r2, r1
        d = abs(p1-p2)
        cos = (r1**2+d**2-r2**2)/(2*r1*d)
        angle = math.acos(cos)
        phi = cmath.phase(p2-p1)
        return [
            p1 + cmath.rect(r1, phi+angle),
            p1 + cmath.rect(r1, phi-angle)
        ]


def circle_in(p, o, r1, allow_on_edge=True):
    if allow_on_edge:
        return abs(o-p)-r1 < EPS
    else:
        return abs(o-p)-r1 < -EPS


def solve(N: int, K: int, x: "List[int]", y: "List[int]", c: "List[int]"):

    # 時刻Tの時点でK枚以上の肉が焼ける熱源の配置はあるか
    comp = [complex(xx, yy) for xx, yy in zip(x, y)]

    left = 0
    right = 2000*max(c)
    while right - left > EPS:
        mid = (left + right)/2
        yakiniku = 0
        b = copy.copy(comp)
        for i in range(N):
            for j in range(i+1, N):
                b.extend(intersection(comp[i], mid/c[i], comp[j], mid/c[j]))

        for p in b:
            count = [circle_in(p, comp[k], mid/c[k])
                     for k in range(N)]
            yakiniku = max(yakiniku, sum(count))
        if yakiniku >= K:
            right = mid
        else:
            left = mid

    print(mid)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    c = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, K, x, y, c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 56540
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int> 
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >   
#define vpl vector< pair<ll,ll> >   
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod 1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double
#define all(c) (c).begin(),(c).end()
#define N 100001

int dp[100][N];
int n;
vi v(101);
vi wt(101);
int rec(int i,int w)
{
    if(w<0)
        return -inf;
    if(i == n)
        return 0;
    if(dp[i][w] == -1)
    {
        int ans = 0;
        ans = rec(i+1,w);
        ans = max(ans,v[i] + rec(i+1,w-wt[i]));
        dp[i][w] = ans;
        return ans;
    }
    else
        return dp[i][w];
}
int32_t main()
{                
    IOS;

    memset(dp,-1,sizeof(dp));
    cin>>n;
    int W;
    cin>>W;
    for(int i = 0;i  < n;i++)
    {
        cin>>wt[i]>>v[i];
    }
    cout<<rec(0,W);
    return 0;

}

Measured memory_bytes: 78336
#include<algorithm>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-8;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T& a, T b, bool equal = false){
    if(a < b || equal && a == b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b, bool equal = false){
    if(b < a || equal && a == b){
        a = b;
        return true;
    }
    return false;
}

int dp1[301][301];
int dp2[301][301];

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

    int h, w;
    cin >> h >> w;

    vector<string> c(h);
    rep(i, h){
        cin >> c[i];
    }

    int ans = 0;
    rep(i, w - 1){
        rep(j, h + 1){
            if(j < h){
                dp1[j][0] = 0;
                if(j) dp1[0][j] = 0;
                rep(k, h - j){
                    dp1[j][0] += (c[k][i] == c[j + k][i + 1]);
                    if(j) dp1[0][j] += (c[j + k][i] == c[k][i + 1]);
                }
            }else{
                rep(k, h + 1){
                    dp1[j][k] = 0;
                    dp1[k][j] = 0;
                }
            }
        }
        rep(j, h){
            rep(k, h){
                dp1[j + 1][k + 1] = dp1[j][k] - (c[h - 1 - j][i] == c[h - 1 - k][i + 1]);
            }
        }

        rep(j, h + 1){
            rep(k, h + 1){
                dp2[j][k] = IINF;
            }
        }
        dp2[0][0] = 0;
        rep(j, h + 1){
            rep(k, h + 1){
                if(j < h){
                    chmin(dp2[j + 1][k], dp2[j][k] + dp1[j][k]);
                }
                if(k < h){
                    chmin(dp2[j][k + 1], dp2[j][k] + dp1[j][k]);
                }
            }
        }

        ans += dp2[h][h];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
X,Y,Z,K = gets.split.map(&:to_i)

A = gets.split.map(&:to_i).sort.reverse
B = gets.split.map(&:to_i).sort.reverse
C = gets.split.map(&:to_i).sort.reverse

s = []

for i in 0..X-1 do
  for j in 0..Y-1 do
    if (i+1)*(j+1) > K
      break
    end
    for k in 0..Z-1 do
      if (i+1)*(j+1)*(k+1) <= K
        s.push( A[i] + B[j] + C[k])
      else
        break
      end
    end
  end
end

s.sort!.reverse!

for i in 0..K-1 do
  puts s[i]
end


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

using namespace std;

int N;
set<pair<int, int> > PointInfo;
set<pair<int, int> >::iterator CurPos, NextPos, EndPos;

int solve() {
	int dx, dy, x1, y1, x2, y2, nextX1, nextY1, nextX2, nextY2, area;

	area = 0;
	EndPos = PointInfo.end();
	for (CurPos = PointInfo.begin(); CurPos != EndPos; ++CurPos) {
		NextPos = ++CurPos;
		--CurPos;
		while (NextPos != EndPos) {
			x1 = CurPos->first;
			y1 = CurPos->second;
			x2 = NextPos->first;
			y2 = NextPos->second;
			dx = x2 - x1;
			dy = abs(y2 - y1);

			nextX1 = x1 + dy;
			nextX2 = x2 + dy;
			nextY1 = y1 - dx;
			nextY2 = y2 - dx;
			if (PointInfo.count({ nextX1,nextY1 }) == 1 && PointInfo.count({ nextX2,nextY2 }) == 1) {
				area = max(area, dx*dx + dy*dy);
			}

			nextY1 = y1 + dx;
			nextY2 = y2 + dx;
			if (PointInfo.count({ nextX1,nextY1 }) == 1 && PointInfo.count({ nextX2,nextY2 }) == 1) {
				area = max(area, dx*dx + dy*dy);
			}
			++NextPos;
		}
	}

	return area;
}

int main() {
	int x, y;

	while (cin >> N, N) {
		PointInfo.clear();
		for (int i = 0; i < N; ++i) {
			cin >> x >> y;
			PointInfo.insert({ x,y });
		}
		cout << solve() << endl;
	}

	return 0;
}


Measured memory_bytes: 3176
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      ArrayList<Integer> one = nextIntArray();
      int X = one.get(0);
      int A = Math.abs(one.get(0) - one.get(1));
      int B = Math.abs(one.get(0) - one.get(2));
      if(A > B){
        myout("B");
      }else{
        myout("A");
      }
      
	}
	//Method addition frame start



	//Method addition frame end
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split('/');
            var z = s[0] + s[1] + s[2];
            if(int.Parse(z)>20190430)
            {
                Console.WriteLine("TBD");
            }
            else
            {
                Console.WriteLine("Heisei");
            }
            
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define All(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef double db;
typedef vector<int> VI;
typedef pair<int,int> PII;
const db PI=acos(-1.0);
const db eps=1e-6;
const ll mod=1e9+7;
const int inf=2147483647;
const int maxn=100005;
ll qpow(ll x,ll y) {ll ans=1,base=x; while(y){if(y&1)ans=(ans*base)%mod;base=(base*base)%mod;y>>=1;} return ans;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}

int n;
ll dp[2005][2005];
struct node{
	int id,val;
}a[2005];
bool cmp(node x1,node x2){
	return x1.val<x2.val;
}
int main(){
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",&a[i].val),a[i].id=i;
	sort(a+1,a+1+n,cmp);
	rep(i,1,n) dp[i][i]=1ll*a[1].val*abs(a[1].id-i);
	rep(len,2,n){
		for(int i=1,j=i+len-1;j<=n;i++,j=i+len-1){
			dp[i][j]=max(dp[i+1][j]+1ll*a[len].val*abs(a[len].id-i),dp[i][j-1]+1ll*a[len].val*abs(a[len].id-j));
		}
	}
	printf("%lld\n",dp[1][n]);
	return 0;
}

Measured memory_bytes: 26468
from itertools import permutations
import heapq

INF = float('inf')
n, m, R = list(map(int, input().split()))
r = list(map(int, input().split()))

cost = {}
for i in range(m):
    a, b, c = list(map(int, input().split()))
    if not a in cost.keys():
        cost[a] = [(b, c)]
    else:
        cost[a].append((b, c))
    if not b in cost.keys():
        cost[b] = [(a, c)]
    else:
        cost[b].append((a, c))
        
dist = [[INF]*(n+1) for _ in range(n+1)]
for st in r:
    d = [INF]*(n+1)
    d[st] = 0
    path = [(0, st)]
    heapq.heapify(path)
    while len(path) > 0:
        c, node = heapq.heappop(path)
        if d[node] < c:
            continue
        d[node] = c
        for node_next, c_next in cost[node]:
            if d[node_next] < INF:
                continue
            heapq.heappush(path, (d[node]+c_next, node_next))
    dist[st] = d
# for d in dist: print(d)

ans = INF
for p in permutations(r):
    ans_ = 0
    for i in range(R-1):
        ans_ += dist[p[i]][p[i+1]]
    ans = min(ans, ans_)
print(ans)


Measured memory_bytes: 9604
N = int(input())
counter =-1 
number = 0
for i in range(N):
    k = i+1
    now_counter = 0
    while(k % 2 == 0):
        now_counter += 1
        k /= 2
    if(now_counter > counter):
        number = i+1
        counter = now_counter
print(number)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

int main() {
	int n;
	scanf("%d", &n);
	ll mx=0, my=0;
	for(int i=0; i<n; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		ll rat;
		if(!i)
			rat=1;
		else {
			ll rx = (mx-1)/x+1, ry = (my-1)/y+1;
			rat = max(rx, ry);
		}
		mx = rat*x, my = rat*y;
	}
	printf("%lld\n", mx+my);
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int H,W,count = 0;
  cin >> H >> W;
  char a[55][55];
  for(int i = 1;i<=H;i++)
  {
    for(int k = 1;k<=W;k++)
    {
      cin >> a[i][k];
    }
  }
 for(int i = 1;i<=H;i++)
  {
    for(int k = 1;k<=W;k++)
    {
      if(a[i][k] == '#' && a[i-1][k] != '#' && a[i+1][k] != '#' && a[i][k-1] != '#' && a[i][k+1] != '#')
      {count++;}
    }
  }
  if(count == 0)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <iostream>

using namespace std;

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64; // 9e18
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

const double PI = 3.141592653589793238463;
const int MAXN = 1000500;
const int MAXVALUE = 1000000500;
const long double EPS = 1e-7;
const i64 INF = 1e18;
i64 mod = 1e9 + 7;


i64 T, n, m, k, q;
vector <i64> a;


i64 check(i64 x, i64 k, i64 n) {
    return (k + x / n);
}

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

    string s, t;
    cin >> s;
    cin >> t;
    bool fl = true;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] != t[i]) {
            fl = false;
            break;
        }
    }

    if (fl) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3032
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define mp make_pair
#define pb push_back
#define fir first
#define sec second
#define all(x) (x).begin(),(x).end()
#define rep(i, a, b, c) for(int i=(a); i<=(b); i+=(c))
#define rep(i,a,b) for (int i=(a); i<=(b); ++i)
#define rep_it(it,x) for (__typeof((x).begin()) it=(x).begin(); it!=(x).end(); it++)
#define debug(x) cout<< #x << " => " << (x) << endl
#define debug_pair(x) cout<<"\n{ "<<(x).fir<<" , "<<(x).sec<<" }\n"
#define debug_arr(x,n) cout<<#x<<":\n"; rep(i,0,n) cout<<#x<<"["<<(i)<<"] => "<<x[i]<<endl
#define ms(a, b) memset(a, b, sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
const int inf = 0x3f3f3f3f;
const double PI=acos(-1);
const double eps=1e-9;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b)*b; }
int qpow(int a, int b, int mod){int res=1, base=a%mod;while(b){if(b&1)res*=base;base*=base;b>>=1;}return res;}
ll qpow(ll a, ll b, ll mod){ll res=1, base=a%mod;while(b){if(b&1)res*=base;base*=base;b>>=1;}return res;}
void file_put() {
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
}
const int maxn = 105;

int n, m;
int num[maxn];
int main() {
//	file_put();
	int a, b, c , d, e, f;
	scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
	if(a>b) swap(a, b);
	if(c>d) swap(c, d);
	int cnt=0;
	int ans1=0, ans2=0;
	double MAX = -1;
	for(int i=0; ;++i){
		if(a*i*100>f) break;
		for(int j=0; ;++j){
			if(a*i*100+j*b*100>f) break;
			int p = a*i+j*b;
			p*=e;
			for(int k=0; ;++k){
				if(k*c+p/e*100 > f || k*c>p)  break; 
				for(int z=0; ;++z){
					if(p/e*100 + k*c+z*d > f || k*c+z*d>p) break; 
					if(1.0*(k*c+z*d)/p>MAX){
						MAX = 1.0*(k*c+z*d)/p;
						ans1=p/e*100+k*c+z*d;
						ans2=k*c+z*d;
					}
				}
			}
		}
	}
	cout << ans1 <<" "<<ans2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define print(a)                cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define SS                      stringstream
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

ll poww(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD) { return powm(a, m-2, m);}

int main()
{
	fastIO
	ll x;
	cin>>x;
	rep(i,x,inf,1)
	{
		ll flag=0;
		rep(j,2,sqrt(i),1)
		{
			if(i%j==0)
			{
				flag=1;
				break;
			}
		}
		if(flag==0)
			{
			cout<<i;
			break;
			}
	}
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi = vector<int>;
using vl= vector<ll>;
using vs=vector<string>;

ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a);}
ll max(ll a, ll b) {if (a > b) return a; else return b;}
ll min(ll a, ll b) {if (a < b) return a; else return b;}
ll power(ll a,ll b) {long long res = 1; while (b > 0) {if (b & 1)res = res * a;a = a * a;b >>= 1;} return res;}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int testcase=1;
    
    for(int p=0;p<testcase;p++){
        ll n=0;
        cin>>n;
        n=n%1000;
	if(n==0)
        cout<<n;
else
cout<<1000-n;
        
        }

    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define MOD 1000000007
#define mp make_pair
#define ll long long
#define pb push_back
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug cout<<"Debugging.."<<endl
using namespace std;
int main()
{
	faster;

	int n;
	cin>>n;
	int arr[n][2];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i][0]>>arr[i][1];
	}
	int f=0;
	for(int i=0;i<n-2;i++)
	{
		if(arr[i][0]==arr[i][1])
		{
			if(arr[i+1][0]==arr[i+1][1] && arr[i+2][0]==arr[i+2][1])
			{
				cout<<"Yes";
				f=1;
				break;
			}
		}
	}
	if(f==0)
	cout<<"No";
	
}




Measured memory_bytes: 3612
#include<stdio.h>
 
int main() {
	long long n, m;
	scanf("%lld", &n);
	m = n % 1000;
	if (m != 0) {
		m = 1000 - m;
	}
	else {
		m = 0;
	}
	printf("%lld", m);
 
	return 0;
}


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

int N, X;
long long a, b, Ans;

inline int Rd() {
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	return x * f;
}

int main() {
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	cin >> N >> X;
	if(X >= 0) ++Ans;
	for(int i = 1; i <= N; ++i) {
		cin >> a;
		b += a;
		if(b <= X)
			++Ans;
	}
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
using ll = long long int;

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

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

int main() {

	ll N;
	cin >> N;
	ll ans = 0;
	ll cur = 1;

	for (size_t i = 0; i < N; i++)
	{
		ll value;
		cin >> value;

		if (value == cur) {
			cur++;
		}
		else {
			ans++;
		}
	}

	if (ans == N) {
		ans = -1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
 
class Program{
    static void Main(){
        int n = int.Parse(Console.ReadLine());
        AOJ.Point p1 = new AOJ.Point(0.0, 0.0);
        AOJ.Point p2 = new AOJ.Point(100.0, 0.0);
        Console.WriteLine(p1.ToString());
        AOJ.Koch.KochCurve(p1, p2, n);
        Console.WriteLine(p2.ToString());
    }
}

namespace AOJ
{
    class Koch{
        static double rad60 = Math.PI * 60.0 / 180.0;

        public static void KochCurve(Point p1, Point p2, int depth){
            Point s = p1 + (p2 - p1) / 3.0;
            Point t = p2 + (p1 - p2) / 3.0;
            double ux = (t - s).X * Math.Cos(rad60) - (t - s).Y * Math.Sin(rad60) + s.X;
            double uy = (t - s).X * Math.Sin(rad60) + (t - s).Y * Math.Cos(rad60) + s.Y;
            Point u = new Point(ux, uy);
            if(depth-- > 0){
                KochCurve(p1, s, depth);
                Console.WriteLine(s.ToString());
                KochCurve(s, u, depth);
                Console.WriteLine(u.ToString());
                KochCurve(u, t, depth);
                Console.WriteLine(t.ToString());
                KochCurve(t, p2, depth);
            }
        }
        
    }

    class Point{
        public double X {get; set;}
        public double Y {get; set;}

        public Point(double x, double y){
            this.X = x;
            this.Y = y;
        }
        
        public static Point operator + (Point p1, Point p2){
            return new Point(p1.X + p2.X, p1.Y + p2.Y);
        }
        public static Point operator - (Point p1, Point p2){
            return new Point(p1.X - p2.X, p1.Y - p2.Y);
        }
        public static Point operator / (Point p, double n){
            return new Point(p.X / n, p.Y / n);
        }
        public static Point operator * (Point p, double n){
            return new Point(p.X * n, p.Y * n);
        }

        public override string ToString(){
            return string.Format("{0:F8} {1:F8}", this.X, this.Y);
        }
    }
}

Measured memory_bytes: 9212
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int N = S.length();
    if (isPalin(S)
        && isPalin(S.substring(0, (N - 1) / 2))
        && isPalin(S.substring((N + 3) / 2 - 1))
    ) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }

  static boolean isPalin(String s) {
    int N = s.length();
    for (int i = 0; i < N / 2; i++) {
      if (s.charAt(i) != s.charAt(N - 1 - i)) {
        return false;
      }
    }
    return true;
  }
}


Measured memory_bytes: 23892
import math
n = int(input())
l = ["".join(sorted(input())) for i in range(n)]
l.sort()
c = 0
b = l[0]
ans = 0
for s in l[1:]:
    if s == b:
        c += 1
    else:
        ans += c * (c + 1) * 0.5
        c = 0
    b = s
ans += c * (c + 1) * 0.5
print(int(ans))

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

int main(){
    
    // 1. 入力情報取得.
    int N;
    scanf("%d", &N);
    double P[N + 1] = {};
    for(int i = 1; i <= N; i++) scanf("%lf", &P[i]);
    
    // 2. 表の個数が裏の個数を上回る確率を計算.
    // dp[i][j]: i枚目のコインまで確認して, 表の個数(j)となる確率を保存.
    double dp[N + 1][N + 1] = {};
    
    // 2-1. 1回目は, P[1], 1.0 - P[1] を設定.
    dp[1][1] = P[1];
    dp[1][0] = 1.0 - P[1];
    
    // 2-2. 2回目以降は, 前回の状態をもとに設定.
    // ex.
    // 2枚目まで確認して, 表が2枚 … 1枚目まで確認して, 表が1枚.
    // dp[2][2] = P[2] * dp[1][1];
    // 2枚目まで確認して, 表が1枚 … 1枚目まで確認して, 表が1枚 or 表が0枚.
    // dp[2][1] = (1 - P[2]) * dp[1][1] + P[2] * dp[1][0];
    // 2枚目まで確認して, 表が0枚 … 1枚目まで確認して, 表が0枚.
    // dp[2][0] = (1 - P[2]) * dp[1][0];
    // 
    for(int i = 2; i <= N; i++){
        for(int j = 0; j <= i; j++){
            if(j == 0)         dp[i][0] = (1 - P[i]) * dp[i - 1][0];
            if(i == j)         dp[i][i] = P[i] * dp[i - 1][i - 1];
            if(j > 0 && j < i) dp[i][j] = P[i] * dp[i - 1][j - 1] + (1 - P[i]) * dp[i - 1][j];
        }
    }
    // for(int i = 0; i <= N; i++){
    //     for(int j = 0; j <= i; j++){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    
    // 3. 後処理.
    double ans = 0.0;
    for(int j = (N + 1) / 2; j <= N; j++) ans += dp[N][j];
    printf("%.12f\n", ans);
    return 0;
    
}

Measured memory_bytes: 70528
fn main() {
    let _n = read::<usize>();
    let ts = read_vec::<u32>();
    let m = read::<u32>();
    let pxs = read_vec2::<usize>(m);

    let tssum = ts.iter().fold(0, |x, acc| x + acc);
    for px in pxs {
        println!("{}", tssum - ts[px[0] - 1] + px[1] as u32);
    }
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
/* Author : Harshit Jain a.k.a. iharshit009 */
#include <bits/stdc++.h>
#define vi               vector<int>
#define pb(x)            push_back(x)
#define all(x)           x.begin(), x.end()
#define sortall(x)       sort(all(x))
#define sortrev(x)       sort(all(x), greater<int>())
#define debug(x)         cout << '>' << #x << ':' << x << endl;
#define int              long long
#define ld               long double
#define endl 			 "\n";
#define mp 				 make_pair
#define pii 			 <int, int>
#define lb 				 lower_bound
#define ub				 upper_bound
#define len(a)           int((a).size())
#define prec(n)          fixed<<setprecision(n)
#define cnt(n)           __builtin_popcountll(n)
#define pi               pair<int, int>
const int mod = 1000000007;
using namespace std;
using namespace std::chrono;
// const int N = 1e5 + 5; 
// int n;
// int a[N];



int32_t main(){
auto start = high_resolution_clock::now(); // starting clock
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int t;
t = 1;
// cin >>t;
while(t--){
int n,x,t;
cin >> n >> x >> t;
// int per = x/t;
// int left = x%t;
if(n <=x){
	cout << t << endl;
}
else{
	int b = 0;
	if(n%x == 0){
		 b = n/x;
	}
	else{
		 b = n/x + 1;
	}
	cout << t*b << endl;
	// int per = n-x;

	// per*t
}
// debug(left)
// debug(per)
// cout << n/(per+left) << endl;









}
auto stop = high_resolution_clock::now(); // stop clock
auto duration = duration_cast<microseconds>(stop - start);  // printing duration
cerr << "Time taken by function: " << duration.count() << " milliseconds" << endl; 
return 0;
}

Measured memory_bytes: 3644
import java.util.*;
import java.lang.Math;

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

  		
      	int a = sc.nextInt();
      	int b = sc.nextInt();
      	int c = sc.nextInt();
      	int d = sc.nextInt();
      	boolean twin = false;
      	boolean awin = false;
      	String str = " ";
      
      	for(int i = 0;!twin && !awin;i++) {
			if(i % 2 == 0){
              c -= b;
              if(c <= 0) {
                twin = true;
              	str = "Yes";
              }
            } else {
              a -= d;
              if(a <= 0) {
                awin = true;
                str = "No";
              }
            }        
        }     	
      	
      	System.out.println(str);
        
	}
}


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

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

	ll sum = 0;
	for(int i = 1; i <= n; i++){
		if(i%5 == 0 || i%3 ==0) continue;
		else sum += i;
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>
#define rep(i, a, b) for (int(i) = (a); i < (b); i++)
using namespace std;

using ll = long long;

typedef pair<int, int> P;

const int INF = 100000000;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;

ll pow_mod(ll x, ll y, ll mod)
{
	ll ans=1;
	for(;y>0;y>>=1){
		if(y&1)(ans*=x)%=mod;
		(x*=x)%=mod;
	}
	return ans;
}

ll facto(ll a){
	if(a==1)
		return 1;
	else return a * facto(a - 1);
}

ll n, k;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	//問題文中の添え字が0-indexか1-indexか確認!
	cin >> n >> k;
	cout << (n - k + 1);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;
int main() {
    int n,m,c,r=0;
    cin >> n >> m >> c;
    vector<int> B(m);
    for(int i=0; i<m; i++){
        cin >> B[i];
    }
    vector<vector<int>> A(n,vector<int>(m));
    for(int j=0; j<n; j++){
        int sum=c;
        for(int i=0; i<m; i++){
            cin >> A[j][i];
            sum += A[j][i] * B[i];
        }
        if(sum > 0){
            r++;
        }
    }
    printf("%d\n",r);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(a==0){
        cout<<1;
    }
     if(b==0){
        cout<<2;
    }
     if(c==0){
        cout<<3;
    }
     if(d==0){
        cout<<4;
    }
     if(e==0){
        cout<<5;
    }
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
ll t,n,m,k;
ll dis[100005];
bool vis[100005];
vector<vector<ll>> ady;
void recc(ll v){
ll pa=0;
for(int i=0;i<ady[v].size();i++){
    if(dis[ady[v][i]]==false){
        recc(ady[v][i]);
        pa=max(pa,dis[ady[v][i]]+1);
    }else{
        pa=max(dis[ady[v][i]]+1,pa);
    }
}
dis[v]=pa;
}
int main(){
cin>>n>>m;
ady.resize(n+1);
for(int i=0;i<m;i++){
ll x,y;
cin>>x>>y;
ady[x].pb(y);
}

for(int i=1;i<=n;i++){
if(dis[i]==false){
    recc(i);
}
}
ll ans=0;
for(int i=1;i<=n;i++){
ans=max(ans,dis[i]);
//cout<<dis[i]<<endl;
}

cout<<ans<<endl;
}



Measured memory_bytes: 12176
N = int(input())
A = list(map(int, input().split()))
MOD = 1000000007

sum_all = 0
p = 1
for i in range(60):
    ones = 0
    zeros = 0

    x = 1 << i
    for a in A:
        if a & x:
            ones += 1
        else:
            zeros += 1

    sum_all += p * ones * zeros % MOD
    p *= 2 % MOD


print(sum_all % MOD)


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

int main(){

    int A, B;
    cin >> A >> B;

    if((A % 3 == 0) || (B % 3 == 0) || ((A + B) % 3 == 0)) cout << "Possible" << endl;
    else cout << "Impossible" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main() {
  string S;
  cin >> S;
  long long int max;
  long long int len;
  max = 0;

  for (long long int i = 0; i < S.size(); i++) {
    len = 0;
    
    for (long long int j = i; j < S.size(); j++) {
      string c = S.substr(j, 1);

      if (c == "A" || c == "C" || c == "G" || c == "T") {
        len++;
      }
      else {
        break;
      }
    }

    if (len > max)
      max = len;
  }

  cout << max << endl;

  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [0] * 100001
for i in range(n):
    l, r = map(int, input().split())
    for j in range(l, r + 1):
        a[j] = 1
ans = 0
for i in range(100001):
    if (a[i]):
        ans += 1
print(ans)


Measured memory_bytes: 3828
#include <iostream>
main(){for(int n,i,m,a[5000],j,s;std::cin>>n,n;std::cout<<m<<"\n"){for(i=0;i<n;i++)std::cin>>a[i];for(i=0,m=-1e9;i<n;i++)for(j=i,s=0;j<n;m=s>m?s:m,j++)s+=a[j];}}

Measured memory_bytes: 0
s = input()
l = len(s)
backet = [0] * 26
if l != 26:
  for i in s:
    backet[ord(i) - 97] = 1
  for i in range(26):
    if not backet[i]:
      print(s + chr(i + 97))
      break
else:
  if s == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
  else:
    d = []
    for i in s[::-1]:
      s = s[:-1]
      d.sort()
      for j in d:
        if j > ord(i)-97:
          print(s + chr(j+97))
          exit()
      d.append(ord(i)-97)


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

using namespace std;

const int INF = 1e9;

int main() {
  int n;
  cin >> n;
  vector<int> stones = vector<int> (n);
  vector<int> dp = vector<int> (n, INF);
  for (int i=0; i<n; ++i)
    cin >> stones[i];

  dp[0] = 0;
  auto cost = [&] (int i, int j) {return abs(stones[i] - stones[j]);};
  for (int i=1; i<n; ++i)
    dp[i] = min(dp[i-1] + cost(i, i-1), (i<2 ? INF : dp[i-2] + cost(i, i-2)));

  cout << dp[n-1] << "\n";
  return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
    return powmod(a, MOD-2);
}
ll f[10010], invf[10010];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
    invf[n]=inv(f[n]);
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
}
ll comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]%MOD*invf[x-y]%MOD;
}
int main()
{
	int n, m;
	cin>>n>>m;
	int p[5050];
	for(int i=0; i<n; i++){
		cin>>p[i]; p[i]--;
		if(i-2>=0 && p[i-2]>p[i-1] && p[i-1]>p[i]){
			cout<<0<<endl;
			return 0;
		}
	}
	p[n]=n+1, p[n+1]=n;
	n+=2;
	fac(n);
	vector<ll> dp(n+1);
	dp[0]=1;
	int pr=0;
	int cnt=0;
	for(int i=0; i<n-1; i++){
		if(p[i]<p[i+1]) continue;
		cnt++;
		vector<ll> tmp(n+1);
		int c1=0, c2=0, c=0;
		bool dame=0;
		if(pr>0 && (p[pr-2]>p[i] || p[pr-1]>p[i+1])){
			dame=1;
		}else{
			for(int j=pr; j<i; j++){
				if((pr==0 || p[pr-2]<p[j]) && p[j]<p[i+1]){
					c++;
					continue;
				}
				bool myon1=0, myon2=0;
				if(pr>0 && p[pr-1]<p[j] && p[j]<p[pr-2]) myon2=1;
				if(p[j]>p[i+1] && p[j]<p[i]) myon1=1;
				if(myon1 && myon2){
					dame=1;
					break;
				}else if(myon1) c1++;
				else c2++;
			}
			if(c1+c2+c<i-pr) dame=1;
		}
		if(!dame){
			for(int k=0; k<=n; k++){
				if(dp[k]==0) continue;
				for(int j=0; j<=c; j++){
					(tmp[k+c1+j+1]+=dp[k]*comb(c, j))%=MOD;
				}
			}
		}
		dame=0, c1=0, c2=0, c=0;
		if(pr>0 && p[pr-2]>p[i+1]) dame=1;
		else{
			for(int j=pr; j<i; j++){
				if((pr==0 || p[pr-2]<p[j]) && p[j]<p[i+1]) c++;
				else if(p[j]>p[i] || (pr>0 && p[j]<p[pr-1])){
					dame=1; break;
				}else c2++;
			}
			if(c+c2<i-pr) dame=1;
		}
		if(!dame){
			for(int k=0; k<=n; k++){
				if(dp[k]==0) continue;
				for(int j=0; j<=c; j++){
					(tmp[pr-k+c2+1+j]+=dp[k]*comb(c, j))%=MOD;
				}
			}
		}
		swap(dp, tmp);
		pr=i+2;
	}
	ll ans=0;
	for(int i=1; i<=n; i++){
		if(i-1<=m && n-i-1<=m) (ans+=dp[i])%=MOD;
	}
	(ans*=((MOD+1)/2))%=MOD;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P>> vec;
// vector<vector<int>> data(3, vector<int>(4));

int main() {
    ll N, K;
    cin >> N >> K;
    vector<vector<ll>> d(64, vector<ll>(N));
    rep(i, N) {
        cin >> d[0][i];
        d[0][i]--;
    }
    rep(i, 63) {
        rep(j, N) { d[i + 1][j] = d[i][d[i][j]]; }
    }

    ll now = 0;
    rep(i, 61) {
        if ((1LL << i) & K) now = d[i][now];
    }
    cout << now + 1 << endl;

    return 0;
}


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

using ll=long long;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

int div1(ll x){
  return x%1000000007;
}

main(){
  int a=in(),b=in(),t=in();
  cout << (t/a)*b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,t;cin >> s >> t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end());
	reverse(t.begin(),t.end());
	if(s>=t) cout << "No" << endl;
	else cout << "Yes" << endl;
}

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

using namespace std;

int main(void){
  
  int N, K, d, input, ans = 0;
  cin >> N >> K;
  vector<int> A(N, 0);
  for(int i=0;i<K;i++){
    cin >> d;
    for(int j=0; j<d; j++){
      cin >> input;
      A[input-1]++;
    }
  }
  for(int i=0; i<N; i++){
    if(A[i] == 0)ans++;
  }

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

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define INT_SIZE 32
#define me(x) memset(x,0,sizeof(x))
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
int main()
{
    int n,i;
    cin>>n;
    int a[n];
    map<int,int> mp,mp1;
    for(i=0;i<n;i++)
        cin>>a[i];
        int ans=0,ans1=0;
        vector<pair<int,int> > v,v1;
    for(i=0;i<n;i+=2)
    {
        mp[a[i]]++;
    }
    for(i=1;i<n;i+=2)
    {
        mp1[a[i]]++;
    }
    for(auto it=mp.begin();it!=mp.end();it++)
    {
        v.pb({it->ss,it->ff});
    }
    sort(v.rbegin(),v.rend());
    for(auto it=mp1.begin();it!=mp1.end();it++)
    {
        v1.pb({it->ss,it->ff});
    }
    sort(v1.rbegin(),v1.rend());
    if(v[0].ss==v1[0].ss)
    {
            ans=v[0].ff;
            if(v1.size()>1)
            {
                ans+=v1[1].ff;
            }
            ans1=v1[0].ff;
            if(v.size()>1)
            {
              ans1+=v[1].ff;
            }
        n-=max(ans,ans1);
    }
    else
    {
        n-=(v[0].ff+v1[0].ff);
    }
    cout<<n<<e;
}


Measured memory_bytes: 6648
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;

const int maxn = 10010;
int n;
int a[maxn];

int main()
{
	memset(a, 0, sizeof(a));
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}
	int num = 0;
	for (int i = 0; i < n; i++)
	{
		num += (a[i] - 1);
	}
	printf("%d", num);
	system("pause");
	return 0;

}

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

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

int main()
{
    int r,c;
    cin>>r>>c;

    string a[100],b[100];

    for(int i=0;i<r;i++) cin>>a[i],b[i]=a[i];

    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            //cout<<"i "<<i<<" j "<<j<<endl;
            char cnt='0';
            for(int k=0;k<8;k++){
                int ox=i+dx[k], oy=j+dy[k];
                //cout<<"ox "<<ox<<" oy "<<oy<<endl;
                if(a[i][j]=='.' && ox>=0 && ox<r && oy>=0 && oy<c){
                    if(a[ox][oy]=='#')
                        b[i][j]=cnt++;//cnt++;
                }
            }
            if(a[i][j]=='.')
                b[i][j]=cnt;

        }
    }


    for(int i=0;i<r;i++) cout<<b[i]<<endl;


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string S, substr;
	int ans;
	bool flag;
	bool is_ans = false;
	int count;
	cin >> S;

	while(!is_ans && S.size() > 0)
	{
		S.erase(S.end() - 1);
		for (int i = 0; i < S.size(); i++)
		{
			substr = S.substr(0, i + 1);
			count = 1;
			flag = true;
			for (int j = i + 1; j < S.size(); j += 1 + i)
			{
				if (S.substr(j, i + 1) == substr)
					count++;
				else
				{
					flag = false;
					break;
				}
			}

			if (flag && count % 2 == 0 && count != 0)
			{
				ans = S.size();
				is_ans = true;
				break;
			}
		}

	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int w, a, b; cin >> w >> a >> b;
  if(a + w < b) cout << b - (a + w) << endl;
  else if(b + w < a) cout << a - (b + w) << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 256