akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

template <typename T>
std::vector<T> enum_div(T n) {
    std::vector<T> ret;
    for (T i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

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

    int N;
    cin >> N;
    vector<int> C(N), S(N), F(N);
    REP(i, N - 1) {
        cin >> C[i] >> S[i] >> F[i];
    }

    REP(i, N) {
        int t = 0;
        FOR(j, i, N - 1) {
            if (t <= S[j]) {
                t = S[j] + C[j];
            } else {
                t = round_up(t, F[j]) * F[j] + C[j];
            }
        }
        cout << t << endl;
    }
    return 0;
}


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


int main(){
	int label[7];
	cin >> label[1] >> label[2] >> label[3] >> label[4] >> label[5] >> label[6];
	int n;
	cin >> n;
	for(int i = 0;i < n;i++){
		int a = 0,b = 0,ans;
		cin >> a >> b;
		for(int j = 1;j <= 6;j++){
			if(label[j] == a) a = j;
			else if(label[j] == b) b = j;
		}
		if(a == 1){
			if(b == 2)ans = 3;
			else if(b == 3)ans = 5;
			else if(b == 5)ans = 4;
			else if(b == 4)ans = 2;
		}
		else if(a == 2){
			if(b == 1)ans = 4;
			else if(b == 4)ans = 6;
			else if(b == 6)ans = 3;
			else if(b == 3)ans = 1;
		}
		else if(a == 3){
			if(b == 1)ans = 2;
			else if(b == 2)ans = 6;
			else if(b == 6)ans = 5;
			else if(b == 5)ans = 1;
		}
		else if(a == 4){
			if(b == 1)ans = 5;
			else if(b == 5)ans = 6;
			else if(b == 6)ans = 2;
			else if(b == 2)ans = 1;
		}
		else if(a == 5){
			if(b == 1)ans = 3;
			else if(b == 3)ans = 6;
			else if(b == 6)ans = 4;
			else if(b == 4)ans = 1;
		}
		else if(a == 6){
			if(b == 2)ans = 4;
			else if(b == 4)ans = 5;
			else if(b == 5)ans = 3;
			else if(b == 3)ans = 2;
		}
		cout << label[ans] << "\n";
	}
	
	return 0;
}

Measured memory_bytes: 3076
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		
		Scanner n=new Scanner(System.in);
		
		int start = n.nextInt();
		int end = n.nextInt();
		int num = n.nextInt();
		int cnt = 0;
		
		for (int a = start;a<=end;a++){
			
			if ((num % a) == 0){
				cnt=cnt+1;
			}
		}
		System.out.println(cnt);
	}

}

Measured memory_bytes: 17328
#include <iostream>

using namespace std;

int main(){
    int h, w;
    while (cin >> h >> w) {
        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++)
                cout << '#';
            cout << endl;
        }
        if (h) cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3096
s=input()
k=int(input())
l=list(s)

for i in range(len(s)):
  f=(-ord(s[i])+ord("z")+1)%26
  if f<=k:
    l[i]="a"
    k-=f

k=k%26
a=ord(l[-1])+k 
if a> ord("z"):a-=26
l[-1]=chr(a)
print("".join(l))

Measured memory_bytes: 10180
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long n,rem,i,cnt=0,sum=0;
    cin>>n;
    for(i=1;i<=n;i++){
        if(i%15!=0 && i%3!=0 && i%5!=0){
            sum+=i;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3640
#define NDEBUG
//
#include <algorithm>
#include <cassert>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <utility>
#include <vector>

int main(void) {
  int N, M;
  std::cin >> N >> M;
  std::multimap<int, int> map;
  for (int i = 0; i < M; i++) {
    int a, b;
    std::cin >> a >> b;
    assert(0 < a && a < b && b <= N);
    map.emplace(a, b);
    map.emplace(b, a);
  }
  std::vector<bool> visited(N);
  visited.resize(N);
  int ans = 0;
  std::fill(visited.begin(), visited.end(), false);

  std::function<void(int)> dfs = [&](int v) {
    if (std::all_of(visited.begin(), visited.end(), [](bool a) { return a; })) {
      ans += 1;
      return;
    }
    auto it = map.find(v);
    assert(it != map.end());
    do {
      auto v2 = it->second;
      if (visited.at(v2 - 1))
        continue;
      visited.at(v2 - 1) = true;
      dfs(v2);
      visited.at(v2 - 1) = false;
    } while ((++it)->first == v);
  };
  visited.at(0) = true;
  dfs(1);
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env ruby
# require 'pry'

# N
# a_1 b_1
# ...
# a_N b_N
# ↑を[[a_1,..a_N],[b_1,..b_N]]にする
# N = gets.to_i
# a, b = N.times.map{gets.split.map(&:to_i)}.transpose

s = gets.chomp.split('')
acgt = ['A','C','G','T']
count = 0
s.length.times do |i|
  sum = 0
  (s.length-i).times do |j|
    if acgt.include?(s[i+j])
      sum += 1
    else
      break
    end
  end
  count = sum if sum > count
end

puts count

Measured memory_bytes: 14332
n = int(input())
a = list(map(int, input().split()))

# hoge % 3 の最大値は2(3で割ったあまりなので,,)
# hoge % 3, hoge % 4, hoge % 5ならそれぞれ2,3,4が最大なのでその和の9が最大となるんじゃないかと

ans = sum(a) - len(a)
print(ans)

# 証明?
# m = a1*a2...anとした時に m mod ai = 0,
# (m-1) mod ai = ai - 1
# このmが明らかに存在するので、上のやり方で良いとわかる

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

int main() {
    vector<string> v(3);
    for (int i = 0; i < 3; i++) cin >> v[i];

    int next = 0;
    while (true) {
        string s = v[next];
        if (s.size() == 0) {
            printf("%c", 'A' + next); //next == 0, 1, 2のとき、出力はA,B,Cになる
            return 0;
        }
        v[next] = s.substr(1, s.size() - 1);
        next = s[0] - 'a'; // s[0] == 'a'だったらnext == 0.同じくs[0] == 'b', s[0] == 'c'だったらnext == 1 or 2.
    }
}

Measured memory_bytes: 256
using System;
using System.Linq;
using static System.Console;
class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(ReadLine());
        string[] strA = ReadLine().Split(' ');
        string[] strB = ReadLine().Split(' ');
        int[] A = strA.Select(int.Parse).ToArray();
        int[] B = strB.Select(int.Parse).ToArray();
        int tmp;
        long ans = 0L;
        for(int i = 0; i < N; i++)
        {
            tmp = 0;
            if (A[i] >= B[i])
            {
                ans += B[i];
            }
            else
            {
                ans += A[i];
                tmp = B[i] - A[i];
                if(A[i + 1] >= tmp)
                {
                    ans += tmp;
                    A[i + 1] -= tmp;
                }
                else
                {
                    ans += A[i + 1];
                    A[i + 1] = 0;
                }
            }
        }
        WriteLine(ans);
    }
}

Measured memory_bytes: 33324
#include<stdio.h>
int main(){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(x-r>=0 && x+r<=W && y-r>=0 && y+r<=H){
	printf("Yes\n");
	}
	if(x-r<0||x+r>W||y-r<0||y+r>H){
	printf("No\n");
	}
	return 0;
}
     

Measured memory_bytes: 584
n,k = map(int,input().split())
a = list(map(int,input().split()))

s = sum(i for i in a if i > 0)

ans = 0
psum = 0
asum = 0
for i in range(n-k+1):
    if i == 0:
        for j in range(k):
            if a[j]>0:
                psum += a[j]
            asum += a[j]
    else:
        if a[i-1] > 0:
            psum -= a[i-1]
        asum -= a[i-1]
        if a[i+k-1] > 0:
            psum += a[i+k-1]
        asum += a[i+k-1]
    ans = max(ans, s - psum +[0,asum][asum>0])
print(ans)

Measured memory_bytes: 14844
import math
n,d = map(int,input().split())
x = [list(map(int,input().split())) for i in range(n)]
norm = 0
ans = 0
for i in range(n - 1):
  for j in range(i+1,n):
    # if i >= j:
    #   continue
    #print(x[i][j])
    for k in range(d):
      #print(abs(x[i][k]-x[j][k])**2)
      norm += abs(x[i][k]-x[j][k])**2
      if k == (d - 1):
        p = math.sqrt(norm)
        #print(str(x[i][k])+"と"+str(x[j][k]))
        #print(p)
        norm = 0
        if p.is_integer():
          ans += 1
print(ans)

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

using namespace std;

int main() {
  string a, b;
  cin >> a >> b;
  int ans = 0;
  for(int i = 0; i < (int)a.size(); ++i) {
    ans += a[i] != b[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3864
#include<iostream>
#include<vector>
#include<algorithm>

int main(){
  int N;
  std::cin >> N;
  std::vector<long long> A(N);
  for(int i = 0; i < N; i++) std::cin >> A.at(i);
  std::sort(A.begin(), A.end());
  int ans = 0;
  int count = 1;
  for(int i = 0; i < N - 1; i++){
    if(A.at(i) == A.at(i + 1)){
      count++;
      continue;
    }else{
    if(count % 2 != 0) ans++;
    count = 1;
    }
  }
  if(N == 1) ans = 1;
  else{
    if(count % 2 != 0) ans++;
  }
  std::cout << ans << std::endl;
}

Measured memory_bytes: 1024
/*
 * 0154.cpp
 *
 *  Created on: 2011/07/27
 *      Author: isa
 */

#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int main(void){
	int m,g,tmp;

	while(cin >> m && m){
		int c[m],n[m],dp[8][1001];

		for(int i=0;i<m;i++){
			cin >> c[i] >> n[i];
		}
		memset(dp,0,sizeof(dp));
		dp[0][0] = 1;
		for(int i=0;i<m;i++){
			for(int j=0;j<=1000;j++){
				for(int k=0;k<=n[i];k++){
					if(j+k*c[i] > 1000) break;
					dp[i+1][j+k*c[i]] += dp[i][j];
				}
			}
		}
		cin >> g;
		for(int i=0;i<g;i++){
			cin >> tmp;
			cout << dp[m][tmp] << endl;
		}
	}
}

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

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

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<Edge>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}


bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}

bool palin(string S){//回文判定
  int n = S.size();
  bool flag = true;
  if(n%2 == 0){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  else if(n%2 == 1){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}
void dfs(string S,int N,vector<string> &v){
  if(S.size() == N) return;
  if(S.size() == N-1){
    v.push_back(S+'A');
    v.push_back(S+'B');
    v.push_back(S+'C');
    v.push_back(S+'x');
  }
  dfs(S+'A',N,v);
  dfs(S+'B',N,v);
  dfs(S+'C',N,v);
  dfs(S+'x',N,v);
}


int main(){
  int N,A,B,C;
  cin >> N >> A >> B >> C;
  vector<int> l(N);
  rep(i,N){
    cin >> l[i];
  }
  vector<string> v;
  dfs("",N,v);
  int ans = 10000000;
  vector<string> v2;
  /*rep(i,v.size()){
    cout << v[i] << endl;
  }*/
  
  
  rep(i,v.size()){
    int cA = 0;//Aに使う竹の数
    int cB = 0;
    int cC = 0;
    int sumA = 0;//Aに使う竹の和
    int sumB = 0;
    int sumC = 0;
    int mp = 0;
    rep(j,v[j].size()){
      if(v[i][j] == 'A') {
        cA++;
        sumA += l[j];
      }
      if(v[i][j] == 'B'){ 
        cB++;
        sumB += l[j];
      }
      if(v[i][j] == 'C'){
        cC++;
        sumC += l[j];
      }
    }
    if(cA >= 1 && cB >= 1 && cC >= 1){
      mp = 10*(cA-1) + abs(A-sumA) + 10*(cB-1) + abs(B-sumB) + 10*(cC-1) + abs(C-sumC);
      ans = min(ans,mp);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3832
#include<queue>
#include<cstdio>
#include<algorithm>

#define	mp	make_pair
#define	pb	push_back

using namespace std;

typedef	pair<int,int>	pii;

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

int main(){
	for(int w,h;scanf("%d%d",&w,&h),w;){
		char tile[20][21];
		vector<pii> obj(1);
		for(int i=0;i<h;i++){
			scanf("%s",tile[i]);
			for(int j=0;j<w;j++){
				if(tile[i][j]=='o')	obj[0]=mp(i,j);
				if(tile[i][j]=='*')	obj.pb(mp(i,j));
			}
		}

		int m=obj.size(),adj[11][11];

		for(int k=0;k<m;k++){
			int tmp[20][20];
			for(int i=0;i<h;i++)for(int j=0;j<w;j++)	tmp[i][j]=1<<25;
			tmp[obj[k].first][obj[k].second]=0;

			queue< pair<int,pii> > qu;	qu.push(mp(0,obj[k]));
			while(!qu.empty()){
				pair<int,pii> a=qu.front();	qu.pop();
				int d=a.first,x=a.second.second,y=a.second.first;
				for(int i=0;i<4;i++){
					int xx=x+dx[i],yy=y+dy[i];
					if(0<=xx && xx<w && 0<=yy && yy<h && tile[yy][xx]!='x'){
						if(d+1<tmp[yy][xx]){
							qu.push(mp(d+1,mp(yy,xx)));
							tmp[yy][xx]=d+1;
						}
					}
				}
			}

			for(int i=0;i<m;i++)	adj[k][i]=tmp[obj[i].first][obj[i].second];
		}

		int ans=1<<25;
		int route[10]={1,2,3,4,5,6,7,8,9,10};
		do{
			int dis=adj[0][route[0]];
			for(int i=0;i<m-2;i++)	dis+=adj[route[i]][route[i+1]];
			ans=min(ans,dis);
		}while(next_permutation(route,route+m-1));
		printf("%d\n",ans>=(1<<25)?-1:ans);
	}

	return 0;
}

Measured memory_bytes: 828
#include <iostream>

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

    if (a < b && b < c) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1156
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int n,m;
    cin>>n>>m;
    vi a(m);
    int s=0;
    FOR(i,0,m){
        cin>>a[i];
        s+=a[i];
    }
    if(s>n){
        cout<<-1<<endl;
    }else{
        cout<<n-s<<endl;
    }

}


Measured memory_bytes: 3668
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

LL n,k;
VL a;

bool isOK(LL mid){
    LL cut = 0;
    REP(i,n){
        cut += (a[i]+mid-1)/mid -1;
    }
    if(cut<=k){
        return true;
    }
    else{
        return false;
    }
}

void Main()
{
    cin>>n>>k;

    a.resize(n);
    REP(i,n){
        cin>>a[i];
    }

    LL ng = 0;
    LL ok = INF ;

    while (abs(ok - ng) > 1) {
        LL mid = (ok + ng) / 2;

        if (isOK(mid)) ok = mid;
        else ng = mid;
    }
    cout<<ok<<endl;

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 4784
#include <iostream>
#include <vector>
#include <map>
#include <numeric>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x.at(i); }


int main() {

    CIN(int, N);
    CINS(int, A, N);

    vector<int> gcd_l(N, 0);
    vector<int> gcd_r(N, 0);
    vector<int> gcd_(N, 0);

    gcd_l[0] = A[0];
    gcd_r[0] = A[N-1];

    for (int i = 1; i < N; i++) {
        gcd_l[i] = gcd(gcd_l[i - 1], A[i-1]);
        gcd_r[i] = gcd(gcd_r[i - 1], A[N-i]);
    }

    gcd_[0] = gcd_r[N-1];
    gcd_[N - 1] = gcd_l[N-1];

    for (int i = 1; i < N - 1; i++) {
        gcd_[i] = gcd(gcd_l[i], gcd_r[N-1-i]);
    }

    int max = 0;

    for (int i = 0; i < N; i++) {
        if (max < gcd_[i]) {
            max = gcd_[i];
        }
    }

    cout << max;
    return 0;
}

Measured memory_bytes: 1792
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll nCm(ll n, ll m){
    if (m == 0 || m == n)
        return (1);
    else if (m == 1)
        return (n);
    return (nCm(n - 1, m) + nCm(n - 1, m - 1));
}

//-----------------------ここから-----------

int main(void){
    int x, y, z;
    cin >> x >> y >> z;

    cout << (x - z) / (y + z) << endl;
}

Measured memory_bytes: 256
N,M = map(int, input().split())
a = [int(i) for i in input().split()]
c = [[int(i) for i in input().split()] for j in range(M)]

a.sort()
c2=sorted(c,key=lambda x:(-int(x[1])))

d = []
for i in range(M):
    for j in range(c2[i][0]):
        d.append(c2[i][1])
        if len(d) == N:
            break
    else:
        continue
    break

i = 0
while a[i] < d[i]:
    a[i] = d[i]
    i += 1
    if i == N or i == len(d):
        break

print(sum(a))


Measured memory_bytes: 30968
from sys import stdin
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
prime_list=[i for i in range(2,100000) if is_prime(i)]
oppai=[0]*100000
oppai[1]=0
before=1
for num in prime_list:
    if (num+1)//2 in prime_list:
        oppai[before:num - 2] = [oppai[before]] * (num-1 - before)
        oppai[num-1]=oppai[before]+1
    else:oppai[before:num-1]=[oppai[before]]*(num-before)
    before=num-1
oppai[99991:99999]=[oppai[99990]]*8
N=list(map(int,stdin.readline().strip().split()))[0]
for _ in range(N):
    count = 0
    a,b=list(map(int,stdin.readline().strip().split()))
    if a==b:
        bb = (oppai[b - 1])
        aa = (oppai[a - 2])
        count = bb - aa
        print(count)
    else:
        if a>=2:
            bb = oppai[b - 1]
            aa = oppai[a - 2]
            count = bb - aa
            print(count)
        else:
            bb = oppai[b - 1]
            count = bb
            print(count)





Measured memory_bytes: 5352
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

ll solve(ll H) {
    if(H == 0) return 0;
    if(H == 1) return 1;
    return 2 * solve(H / 2) + 1;
}

int main() {
    ll H; cin >> H;
    cout << solve(H) << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Console;

namespace CPLib
{
    class Atria
    {
        static void Main(string[] args)
        {
            string s = ReadLine();
            WriteLine(s[0]+""+s[1]+s[2]);
        }
    }
}


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

#define mainspring cout<<"mainspring\n";
#define barrel cout<<"barrel\n";
#define escapement cout<<"escapement\n";

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second
#define tik(i,a,b) for(int i = a; i < b; i++)
#define tok(i,a,b) for(int i = a; i >= b; i--)
#define error(args...) {string _s = #args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}

typedef long long ll;
typedef unsigned long long ull;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " ";
    err(++it, args...);
}

ll pow(ll x, ll y) {
	if(y == 0)
	return 1;
	ll temp = pow(x, y/2);
	temp = (temp*temp);
	if(y%2 == 1)
		temp *= x;
	return temp;
}

const int MAXN = 2E5 + 100;
int dp[MAXN];

int main() {
	int n, k, c;
	cin >> n >> k >> c;
	string s;
	cin >> s;
	dp[0] = (s[0] == 'o');
	set<int> bad;
	for(int i = 1; i < n; i++) {
		if(s[i] == 'o') {
			dp[i] = dp[i - 1];
			if(i - c - 1 >= 0)
				dp[i] = max(dp[i], dp[i - c - 1] + 1);
			else
				dp[i] = max(dp[i], 1);
		}
		else {
			dp[i] = dp[i - 1];
		}
		// if(s[i] == 'o' && dp[i] == dp[i - 1]) {
		// 	if(dp[i] == ((i - c - 1 >= 0 ? dp[i - c - 1] : 0) + 1)) {
		// 		error(dp[i]);
		// 		bad.insert(dp[i]);
		// 	}
		// }
	}
	// for(int i = 0; i < n; i++)
	// 	cout << dp[i] << ' ';
	// cout << '\n' << endl;
	// int pos = n - 1;
	// vi res;
	// while(true) {
	// 	if(dp[pos] == dp[pos - 1]) {
	// 		pos--;
	// 		continue;
	// 	}
	// 	else {
	// 		res.pb(pos + 1);
	// 		if(dp[pos] == 1)
	// 			break;
	// 		pos -= c + 1;
	// 	}
	// }
	// for(int i = 0; i < n; i++) {
	// 	if(bad.find(dp[i]) == bad.end() && (i == 0 || dp[i] != dp[i - 1]))
	// 		cout << i + 1 << '\n';
	// }
	if(dp[n - 1] > k)
		return 0;
	vector<set<int>> v(k + 1);
	for(int i = 0; i < n; i++) {
		if(s[i] == 'x')
			continue;
		v[dp[i]].insert(i + 1);
	}
	for(int i = k - 1; i >= 1; i--) {
		set<int> tmp;
		for(int x : v[i]) {
			if(v[i + 1].upper_bound(x + c) != v[i + 1].end())
				tmp.insert(x);
		}
		v[i] = tmp;
	}
	for(auto s : v) {
		if(sz(s) == 1) {
			cout << *s.begin() << '\n';
		}
	}
}

Measured memory_bytes: 21252
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
int main() {
	int x = 0;
	int N;	cin >> N;
	string S;	cin >> S;
	vector<int> num(N + 1);
	num[0] = 0;
	for (int i = 0; i < N; ++i) {
		if (S[i] == 'I') {
			++x;
		}
		if (S[i] == 'D') {
			--x;
		}
		num[i + 1] = x;
	}
	cout << *max_element(num.begin(), num.end()) << endl;
	cin >> x;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)			(a).begin(),(a).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF				2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<ll, ll>	P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int N, Y;
	cin >> N >> Y;
	Y /= 1000;

	for (int n1000 = 0; n1000 <= N; n1000++) {
		for (int n5000 = 0; n5000 <= N; n5000++) {
			int n10000 = N - n5000 - n1000;
			int yCalc = n10000 * 10 + 5 * n5000 + n1000;
			if (0 <= n10000){
				if (yCalc == Y) {
					cout << n10000 << " " << n5000 << " " << n1000 << endl;
					return 0;
				}
			}
		}
	}

	cout << "-1 -1 -1" << endl;
	return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(void)
{
  int A,B,K,a,b;
  scanf("%d",&A);
  scanf("%d",&B);
  a=A+B;
  b=a;
  a=a/2;
  a=a*2;
  if(a==b)
  {
     K=(A+B)/2;
     printf("%d\n",K);
  }
  else printf("IMPOSSIBLE");
  return 0;
}

Measured memory_bytes: 128
n, m = gets.split.map(&:to_i)

graph = Hash.new { |h, k| h[k] = [] }
m.times do
  a, b = gets.split.map(&:to_i)
  graph[a].push(b)
  graph[b].push(a)
end

dist = Array.new(n + 1, -1)
dist[1] = 0

que = []
que.push(1)

ans = Array.new(n + 1, -1)

until que.empty?
  v = que.shift

  graph[v].each do |nv|
    next if dist[nv] != -1

    dist[nv] = dist[v] + 1
    que.push(nv)
    ans[nv] = v
  end
end

puts "Yes"
puts ans[2, n - 1]


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()


int main(){
    ll N;
    cin>>N;
    map<ll,ll> mp;
    rep(i,N){
        ll a;
        cin>>a;
        mp[a]++;
    }
    ll M1=0,M2=0;
    for(auto x:mp){
        if(x.second>=4){
            M1=M2=x.first;
        }else if(x.second>=2){
            M2=M1;
            M1=x.first;
        }
    }
    cout<<M1*M2<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int n,m;
priority_queue<pair<int,pair<int,int>>>pq;
vector<int>adj[100002];
int dist[100002];
int prv[100002];
int main()
{
	memset(dist,-1,sizeof(dist));
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	pq.push({0,{1,1}});
	while(pq.size())
	{
		int cur = pq.top().second.first;
		int p = pq.top().second.second;
		int cost = -pq.top().first;
		pq.pop();
		if(dist[cur]!=-1)continue;
		dist[cur] = cost;
		prv[cur] = p;
		for(int next:adj[cur])
		{
			if(dist[next]!=-1)continue;
			pq.push({-(cost+1),{next,cur}});
		}
	}
	for(int i=2;i<=n;i++)
	{
		if(dist[i]==-1)
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes\n";
	for(int i=2;i<=n;i++)cout<<prv[i]<<'\n';
}

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

const int maxn = 100009;
int a, n, cnt2, cnt4;

int main(){
	scanf("%d", &n);
	for (int i=1; i<=n; i++){
		scanf("%d", &a);
		if (a%4 == 0) cnt4++;
		else if (a%2 == 0) cnt2++;
	}
	if (!cnt2 && cnt4*2+1 >= n || cnt2 && 2*cnt4 + cnt2 >= n) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			long[] a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
			long[] b = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

			long[] d = new long[n];
			for (int i = 0; i < n; i++) {
				d[i] = a[i] - b[i];
			}

			Array.Sort(d);
			long msum = d.Where(x => x < 0).Sum() * -1;
			long psum = d.Where(x => x > 0).Sum();
			if (msum > psum) {
				Console.WriteLine(-1);
				return;
			}

			int mcount = d.Where(x => x < 0).Count();
			if (mcount == 0) {
				Console.WriteLine(0);
				return;
			}

			long sum = 0;
			for (int i = n - 1; i >= 0; --i) {
				if (d[i] <= 0) {
					Console.WriteLine(-1);
					return;
				}

				sum += d[i];
				if (sum >= msum) {
					int temp = n - i;
					Console.WriteLine(mcount + temp);
					return;
				}
			}

			Console.WriteLine(-1);
		}
	}
}

Measured memory_bytes: 32224
#include<stdio.h>
int main(void){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(x+r<=W&&y+r<=H&&x-r>=0&&y-r>=0){
		printf("Yes\n");
	}else if(x+r>=W||y+r>=H||x-r<0||y-r<0){
		printf("No\n");
	}
	return 0;
	
}

Measured memory_bytes: 584
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
 
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
 

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

#define MOD 998244353

ll dp[3001][3001];

int main(){
    std::ios::sync_with_stdio(false);
    int n, s;
    cin >> n >> s;
    int a[n] = {};
    for(int i=0;i<n;++i)
    {
      cin >> a[i];
    }
    dp[0][0] = 1;
    for(int i=0;i<n;++i)
    {
      for(int j=0;j<=s;++j)
      {
        int add = 0;
        if(j - a[i] >= 0)
        {
          add = dp[i][j -a[i]];
        } 
        dp[i+1][j] = (dp[i][j] * 2 + add) % MOD;
      }
    }
    cout << dp[n][s] << endl;
}

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

#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << " ";
#define endl "\n"
#define MOD (int) 1e9+7
#define inf (int) (1e18)

void solve(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    if(s.size()<=n){
        cout<<s<<endl;
    } else {
        cout<<s.substr(0,n)<<"..."<<endl;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int t=1;
    // cin >> t;
    for(long int tt=1;tt<=t;tt++){
        solve();
    }
    return 0;
}

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

string f(char c, int a, int b, int *pnum, int *pnumb){
  if(c == 'c') return "No";
  if(c == 'a'){
    if(*pnum < a + b){
      *pnum += 1;
      return "Yes";
    }else{
      return "No";
    }
  }
  if(c == 'b'){
    if(*pnum < a + b && *pnumb <= b){
      *pnum += 1;
      *pnumb += 1;
      return "Yes";
    }else{
      return "No";
    }
  }
  return "No";
}

int main(void){
  int n, a, b;
  string s;
  cin >> n >> a >> b >> s;
  int *pnum, *pnumb;
  int num, numb;
  pnum = &num;
  pnumb = &numb;
  *pnum = 0;
  *pnumb = 1;
  for(int i = 0; i < n; i++) cout << f(s[i], a, b, pnum, pnumb) << endl;
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

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

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
}

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

int main(){
	int N,C;
	cin >> N >> C;
	int D[C][C];
	int c[C][3];
	for(int i=0;i<C;i++){
		for(int j=0;j<C;j++){
			int d;
			cin >> d;
			D[i][j]=d;
		}
	}
	for(int i=0;i<C;i++)for(int j=0;j<3;j++)c[i][j]=0;
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			int d;
			cin >> d;
			c[d-1][(i+j)%3]++;
		}
	}
	
	int ans=999999999;
	
	for(int c1=0;c1<C;c1++){
		int dif1=0;
		for(int cc=0;cc<C;cc++)dif1+=D[cc][c1]*c[cc][1];
		for(int c2=0;c2<C;c2++){
			if(c2==c1)continue;
			int dif2=0;
			for(int cc=0;cc<C;cc++)dif2+=D[cc][c2]*c[cc][2];
			for(int c3=0;c3<C;c3++){
				if(c3==c1 || c3==c2)continue;
				int dif3=0;
				for(int cc=0;cc<C;cc++)dif3+=D[cc][c3]*c[cc][0];
				ans=min(ans,dif1+dif2+dif3);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

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

}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**3
eps = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []
    while True:
        n,p = LI()
        mp = p
        if n == 0:
            break
        a = [0] * n
        i = 0
        while True:
            if p == 0:
                p = a[i]
                a[i] = 0
            else:
                a[i] += 1
                p -= 1
                if a[i] == mp:
                    break
            i = (i+1) % n
        rr.append(i)

    return '\n'.join(map(str, rr))


print(main())




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

int main(){
	ll n,m;
	cin>>n>>m;
	
	for(int i=0;i<m;i++){
		ll tp;
		cin>>tp;
		n=n-tp;
	}
	
	if(n<0) cout<<-1<<endl;
	else cout<<n<<endl;
	
}

Measured memory_bytes: 3636
N = int(input())
L = list(map(int,input().split()))
L.sort()
count = 0
for i in range(N):
    for j in range(i,N):
         for k in range(j,N):
            a = L[i]
            b = L[j]
            c = L[k]
            if(a != b and b != c and c != a):
                if (a + b > c and a + c > b and b + c > a):
                    count += 1
print(count)

Measured memory_bytes: 9180
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef complex<double> Point;

typedef map<int, pair<int, long long> > mipill;

int main()
{
	int w, h;
	while(scanf("%d%d", &h, &w), w){
		vector<vector<bool> > memo(h, vector<bool>(w, false));
		vector<string> field(h);
		rep(i, h){
			char str[128];
			scanf("%s", str);
			field[i] = string(str);
		}

		int y = 0, x = 0;
		while(field[y][x] != '.' && !memo[y][x]){
			memo[y][x] = true;
			if(field[y][x] == '>')
				++x;
			else if(field[y][x] == 'v')
				++y;
			else if(field[y][x] == '^')
				--y;
			else
				--x;
		}

		if(field[y][x] == '.')
			printf("%d %d\n", x, y);
		else
			puts("LOOP");
	}

	return 0;
}

Measured memory_bytes: 0
input = gets.split().map{|a| a.to_i}

a = input[0]
b = input[1]
c = input[2]
d = input[3]

if b <= c || d <= a
  puts 0
elsif a < c && b < d
  puts b-c
elsif c < a && d < b
  puts d-a
elsif a <= c && b >= d
  puts d-c
elsif c <= a && d >= b
  puts b-a
else
  puts b-a
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
long long int dp[100005][105],vmax=0;
long long int sol(long long int j,long long int i,long long int w[],long long int v[],long long int n)
{
    if(j<=0)return 0;
    if(i==n)return 10000000009;
    if(dp[j][i]!=-1)return dp[j][i];
    dp[j][i]=min(sol(j,i+1,w,v,n),
                w[i]+sol(j-v[i],i+1,w,v,n));
    return dp[j][i];
}
long long int wt(long long int w[],long long int v[],long long int n,long long int c)
{
    for(long long int j=vmax;j>=0;j--)
    {
        if(sol(j,0,w,v,n)<=c)return j;
    }
}
int main()
{
    memset(dp,-1,sizeof(dp));
    long long int n,c;
    cin>>n>>c;
    long long int w[n],v[n];
    for(int i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
        vmax+=v[i];
    }
    cout<<wt(w,v,n,c);
}

Measured memory_bytes: 82304
# Aizu Problem 0075: BMI
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


for line in sys.stdin:
    line = line.split(',')
    s = line[0]
    w = float(line[1])
    h = float(line[2])
    bmi = w / h**2
    if bmi >= 25:
        print(s)

Measured memory_bytes: 7488
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

int main() {
    string s;
    cin >> s;
    int k; cin >> k;
    if (s.size() == 1) {
        cout << k / 2 << endl;
    }
    else if (s[0] == s[s.size() -1]) {
        int a = 0, b = 0;
        REP(i, s.size()) {
            if (s[0] != s[i]) {
                break;
            }
            if (i == s.size() - 1) {
                cout << (ll)s.size() * k / 2 << endl;
                return 0;
            }
            a++;
        }
        REP(i, s.size()) {
            if (s[s.size() - 1] != s[s.size() - 1 - i]) {
                break;
            }
            b++;
        }
        ll cnt = 0;
        REP(i, s.size() - 1) {
            if (s[i] == s[i + 1]) {
                i++;
                cnt++;
            }
        }
        cout << cnt * k - ll(a / 2 + b / 2 - (a + b) / 2) * (k-1) << endl;
    }
    else {
        ll cnt = 0;
        REP(i, s.size() - 1) {
            if (s[i] == s[i + 1]) {
                i++;
                cnt++;
            }
        }
        cout << cnt * k << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from collections import deque

H, W = map(int, input().split())

S = [['#'] * (W + 2)]
for _ in range(H):
    tmp = ['#'] + list(input()) + ['#']
    S.append(tmp)
S.append(['#'] * (W + 2))
#迷路の周りを全て壁で覆うことでどの場所からでも四方に探索できるようにした

move = [[1, 0], [-1, 0], [0, 1], [0, -1]]#上下左右どこかに1マス移動する

ans = 0
# スタート位置を変えながら全探索
for X in range(1, H + 1):
    for Y in range(1, W + 1):
        if S[X][Y] == '#':
            continue
#if ~ continue分はtrueなら下の操作を行うことなく次の番号に移るという意味
        check = [[-1] * (W + 2) for _ in range(H + 2)]
        check[X][Y] = 0
#cheakには壁には-1、道にはそこまでの距離、未探索地には0を入れる
        que = deque()
        que.append([X, Y])
        while que:
            tmp = que.popleft()
            x = tmp[0]
            y = tmp[1]
            flag = True
            for dx, dy in move:
                nx = x + dx
                ny = y + dy
                if S[nx][ny] == '.' and check[nx][ny] == -1:#次の移動場所が"道"かつ"未探索"ならqueに突っ込む
                    que.append([nx, ny])
                    check[nx][ny] = check[x][y] + 1 #cheakにそこまでの距離を代入
                    flag = False
#flagの使い方が上手、真似したい
            if flag:#ある一点のスタート地点からの探索がすべて終わってから、その中の
                ans = max(ans, check[x][y])


print (ans)


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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String n = br.readLine();
        String[] str = n.split(" ");
        
        int W = Integer.parseInt(str[0]);
        int H = Integer.parseInt(str[1]);
        int x = Integer.parseInt(str[2]);
        int y = Integer.parseInt(str[3]);
        int r = Integer.parseInt(str[4]);
        
        if(((x-r<0)||(x+r>W))||((y-r<0)||(y+r>H))){
        	System.out.println("No");
        }else{
        	System.out.println("Yes");
        }
        
        
	}
}

Measured memory_bytes: 24396
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, i=0, sum=0;
  cin >> N;

  while(i < N){
    int start,end;
    cin >> start >> end;

    sum += end - start +1;

    i++;
  }
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int p,q,r;
int min;
int main(){
	scanf("%d %d %d", &p, &q, &r);
	min = p + q;
	if(min >= q + r) min =q+r;
	if(min >= p + r) min = r + p;
	printf("%d\n", min);
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){
	int i,n,num,min=1000001,max=-1000001;
	long sum=0;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&num);
		sum+=num;
		if(num<min){
			min=num;
		}
		if(num>max){
			max=num;
		}
	}
	
	printf("%d %d %ld\n",min,max,sum);
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <string.h>
#define LEN 100005

typedef struct pp {
  char name[100];
  int t;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x) {
  Q[tail] = x;
  tail = (tail + 1) % LEN;
}

P dequeue() {
  P x = Q[head];
  head = (head + 1) % LEN;
  return x;
}

int min(int a, int b) { return a < b ? a : b; }

int main() {
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
  
  for ( i = 1; i <= n; i++ ) {
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1; tail = n + 1;
  
  while ( head != tail ) {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if ( u.t > 0 ) enqueue(u);
    else {
      printf("%s %d\n", u.name, elaps);
    }
  }
  
  return 0;
}


Measured memory_bytes: 11856
import sys

N,K=list(map(int,input().split()))
h=list(map(int,input().split()))+[0]*100000

dp=[sys.maxsize]*(N+K+10)
dp[1]=0

for i in range(1,N):
        for k in range(1,K+1):
            dp[i+k]=min(dp[i+k],dp[i]+abs(h[i+k-1]-h[i-1]))

print(dp[N])

Measured memory_bytes: 54112