akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string o, e;
  string ans = "";
  cin >> o >> e;
  for(int i = 0; i < min(o.size(), e.size()); i++)
  {
    ans = ans + o[i] + e[i];
  }
  if(o.size() > e.size())
    ans = ans + o[o.size() - 1];
  else
  if(o.size() < e.size())
    ans = ans + e[e.size() - 1];
  cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

int main() {
  string s, t;
  cin >> s >> t;
  t.pop_back();
  if (s==t) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    int x,a,b; cin>>x>>a>>b;
    if(abs(x-a)>abs(x-b)){
        cout<<"B"<<endl;
    }else{
        cout<<"A"<<endl;
    }
    
}


Measured memory_bytes: 3604
n=int(input())
a=input()
b=input()
c=input()
ans=0
for i in range(n):
  if a[i]!=b[i] and b[i]!=c[i] and a[i]!=c[i]:
    ans+=2
  elif a[i]==b[i] and b[i]==c[i]:
    None
  else:
    ans+=1
print(ans)

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

using namespace std;

void Main()
{
    int k, x;
    cin >> k >> x;

    cout << (500 * k >= x ? "Yes" : "No");
}

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

    std::cout << std::fixed << std::setprecision(10);

#ifdef DEBUG_BUILD
    while (true)
    {
        Main();
        cout << std::endl;
    }
#endif

    Main();
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int k,s;
	cin>>k>>s;
	int sum=0;
	for(int i=0;i<=k;i++)
	{
		for(int j=0;j<=k;j++)
		{
			if(s-i-j<=k&&s-i-j>=0)
			{
				sum++;
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;
 
#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif
 
typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
 
const int N = 100100;
int n;
vector<int> g[N];
int dp[N];
int m;
 
bool solve(int v, int par) {
	vector<int> a;
	if ((int)g[v].size() & 1) a.push_back(0);
	for (int u : g[v]) {
		if (u == par) continue;
		if (!solve(u, v)) return false;
		if (dp[u] != -1)
			a.push_back(dp[u] + 1);
	}
	sort(a.begin(), a.end());
/*
	printf("%d :", v);
	for (int x : a)
		printf(" %d", x);
	printf("\n");
*/
	if ((int)a.size() & 1) {
		int l = -1, r = (int)a.size();
		while(r - l > 1) {
			int x = (l + r) / 2;
			int p1 = 0, p2 = (int)a.size() - 1;
			bool ok = true;
			while(p1 < p2) {
				if (p1 == x) p1++;
				if (p2 == x) p2--;
				if (a[p1] + a[p2] > m) {
					ok = false;
					break;
				}
				p1++;
				p2--;
			}
			if (ok)
				r = x;
			else
				l = x;
		}
		if (r == (int)a.size()) return false;
		dp[v] = a[r];
		return true;
	} else {
		for (int i = 0; i < (int)a.size(); i++)
			if (a[i] + a[(int)a.size() - 1 - i] > m)
				return false;
		dp[v] = -1;
		return true;
	}
}
 
int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
 
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		int v, u;
		scanf("%d%d", &v, &u);
		v--;u--;
		g[v].push_back(u);
		g[u].push_back(v);
	}
	int ans = 0;
	for (int i = 0; i < n; i++)
		ans += (int)g[i].size() & 1;
	printf("%d ", ans / 2);
	int l = 0, r = n;
	while(r - l > 1) {
		m = (l + r) / 2;
		if (solve(0, -1))
			r = m;
		else
			l = m;
	}
	printf("%d\n", r);
 
	return 0;
}


Measured memory_bytes: 16768
//Grid Repainting 2
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    int h,w;
    cin >> h >> w;
    string board[60];
    rep(i,h) cin >> board[i];

    //四方向の埋め込み
    vector<int> dx{1,-1,0,0};
    vector<int> dy{0,0,1,-1};

    //判定にはbool型変数が便利だしわかりやすい．
    bool can = true;
    rep(i,h){
        rep(j,w){
            if(board[i][j] == '#'){
                can = false;//「少なくとも一個存在」を考えたい場合は先に逆の判定を入れておく．
                rep(k,4){
                    int x = i + dx[k];
                    int y = j + dy[k];
                    if(x>=0 && x<h && y>=0 && y<w && board[x][y]=='#'){
                        can=true;
                        continue;
                    }
                }
                if(can==false) break;
            }
        }
        if(can==false) break;
    }
    if(can) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Ho{
  static void Main(){
    var n = int.Parse(Console.ReadLine());
    var aho = Console.ReadLine().Split();
    var p = new List<int>();
    var moto = new List<int>();
    foreach(var a in aho){
      p.Add(int.Parse(a));
      moto.Add(int.Parse(a));
    }
    p.Sort();
    int kai=0;
    for(var i = 0;i<p.Count;i++){
      if(moto[i] != p[i]){
        kai++;
      }    
    }
    if(kai <= 2) Console.WriteLine("YES");
    else Console.WriteLine("NO");
  }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int h,a;
    cin >> h >> a;
    cout << (h + a - 1) / a << endl;
    return 0;
}

Measured memory_bytes: 256
/* ******* MD Imran Hosen *******
     *******  BSMRSTU  *******
                :)
                (:
*/
#include<bits/stdc++.h>
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
int main()
{
    float n1=0,n,i,j,k,m=0,b=0,a1=0,a2=0,a3=0,a4=0;
    int a5=0,a6=0,a7=0;
    cin>>n;
    a1=(n/1.08);
    a5=ceil(a1);
    a6=a5*1.08;
   // cout<<a1<<" "<<a5<<" "<<a6<<endl;
    if(n!=a6)
    {
        cout<<":("<<endl;
    }
    else
    {
        cout<<a5<<endl;
    }




 	return 0;
}


Measured memory_bytes: 256
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")
#define int long long

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 100000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

vector<int> nw;
int n, a[N], dp[N][4];
bool What[N];

int POW(int x){
	return (x % 2 ? -1 : 1);
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for( int i = 1; i <= n; i++){
		cin >> a[i];
		if (i != n){
			char c;
			cin >> c;
			if (c == '-') What[i] = 1;
		}
	}
	for( int i = 0; i < N; i++) for (int j = 0; j < 3; j++) dp[i][j] = -INF;
	dp[0][0] = 0;
	//cout << POW(1) << ' ' << POW(2) << '\n';
	for (int i = 1; i <= n; i++){
		for (int j = 0; j <= 2; j++){
			if (What[i - 1]){
				dp[i][j + 1] = max(dp[i][j + 1], dp[i - 1][j] + POW(j + 1) * a[i]);
				if (j != 0){
					dp[i][j - 1] = max(dp[i][j - 1], dp[i - 1][j] + POW(j + 1) * a[i]);
				}
				dp[i][j] = max(dp[i][j], dp[i - 1][j] + POW(j + 1) * a[i]);
			}else{
				//cout << i << '\n';
				if (j != 0) dp[i][j - 1] = max(dp[i][j - 1], dp[i - 1][j] + POW(j) * a[i]);
				dp[i][j] = max(dp[i][j], dp[i - 1][j] + POW(j) * a[i]);
			}
		}
	}
	//cout << dp[1][0] << ' ' << dp[2][1] << ' ' << dp[3][1] << ' ' << dp[4][0] << '\n';
	ll ans = max(dp[n][0], max(dp[n][2], dp[n][1]));
	cout << ans;









	return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;


int main()
{
  int n, m, c;
  cin >> n >> m >> c;
  int b[m], a[n][m];
  for(int i = 0; i < m; i++) {
    cin >> b[i];
  }
  int s = 0, x[n];
  fill(x, x + n, 0);
  for(int i = 0; i < n; i++)
    for(int j = 0; j < m; j++) {
      cin >> a[i][j];
      x[i] += a[i][j]*b[j];
    }
    int br = 0;
  for(int i = 0; i < n; i++) {
      if(x[i] + c > 0)
        br++;
    }
  cout << br;
}


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

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < (EPS))

#define COUNTER_CLOCKWISE (1)
#define CLOCKWISE (-1)
#define ONLINE_BACK (2)
#define ONLINE_FRONT (-2)
#define ON_SEGMENT (0)

struct Point 
{
  double x, y;
  
  Point() {}
  
  Point(double x, double y) : x(x), y(y) {}
  
  void input() { scanf("%lf %lf", &x, &y); }
  void output() { printf("%.10f %.10f\n", x, y); }
  double abs() { return (sqrt(norm())); }
  double norm() { return (x * x + y * y); }
  
  Point operator + (Point d) { return (Point(x + d.x, y + d.y)); }
  Point operator - (Point d) { return (Point(x - d.x, y - d.y)); }
  Point operator - () { return (Point(-x, -y)); }
  Point operator * (double a) { return (Point(x * a, y * a)); }
  Point operator / (double a) { return (Point(x / a, y / a)); }
  
};

struct Segment
{
  Point p1, p2;
  
  Segment() {}
  Segment(Point p1, Point p2) : p1(p1), p2(p2) {}

  void input() { p1.input(); p2.input(); }
  
};

typedef Point Vector;
typedef vector < Point > Polygon;
typedef Segment Line;

double dot(Vector a, Vector b)
{
  return (a.x * b.x + a.y * b.y);
}

double cross(Vector a, Vector b)
{
  return (a.x * b.y - a.y * b.x);
}

Point project(Line l, Point p)
{
  Vector base = l.p2 - l.p1;
  return (l.p1 + base * (dot(p - l.p1, base) / base.norm()));
}

Point reflect(Line l, Point p)
{
  return (-p + project(l, p) * 2.0);
}

double getDistanceLP(Line l, Point p)
{
  return (abs(cross(l.p2 - l.p1, p - l.p1) / (l.p2 - l.p1).abs()));
}

double getDistanceSP(Segment s, Point p)
{
  if(dot(s.p2 - s.p1, p - s.p1) < 0.0) return ((p - s.p1).abs());
  if(dot(s.p1 - s.p2, p - s.p2) < 0.0) return ((p - s.p2).abs());
  return (getDistanceLP(s, p));
}

double getDistance(Segment s1, Segment s2)
{
  return (0.0);
}

int ccw(Point p0, Point p1, Point p2)
{
  Vector a = p1 - p0, b = p2 - p0;
  
  if(cross(a, b) > EPS) return (COUNTER_CLOCKWISE);
  if(cross(a, b) < -EPS) return (CLOCKWISE);
  if(dot(a, b) < -EPS) return (ONLINE_BACK);
  if(a.norm() < b.norm()) return (ONLINE_FRONT);
  
  return (ON_SEGMENT);
}
  

main()
{
  int n;
  Point p0, p1;
  
  p0.input(); p1.input();
  cin >> n;
  for(int i = 0; i < n; i++) {
    
    Point p2;
    int ans;
    
    p2.input();
    ans = ccw(p0, p1, p2);
    
    if(ans == 0) cout << "ON_SEGMENT" << endl;
    else if(ans == 1) cout << "COUNTER_CLOCKWISE" << endl;
    else if(ans == 2) cout << "ONLINE_BACK" << endl;
    else if(ans == -1) cout << "CLOCKWISE" << endl;
    else if(ans == -2) cout << "ONLINE_FRONT" << endl;

  }

  return (0);
}

Measured memory_bytes: 3224
n=int(input())
g=[[] for _ in range(n+1)]

class tree:
    def __init__(self,n):
        self.size=n
        self.parent=[-1]*(n+1)
        self.child=[[] for _ in range(n+1)]
    
    def findparent(self,x):
        return self.parent[x]
    
    def append(self,p,x):
        self.parent[x]=p
        self.child[p].append(x)
    
    def retchild(self,p):
        return self.child[p]
        

for i in range(n-1):
    a,b=list(map(int,input().split()))

    g[a].append(b)
    g[b].append(a)

t=tree(n)
stack=[1]
visited=[0]*(n+1)

while len(stack)>0:
    u=stack.pop()
    visited[u]=1

    for v in g[u]:
        if visited[v]==1:
            continue

        stack.append(v)
        t.append(u,v)

r=n
cnt=1
while t.findparent(r)>0:
    r=t.findparent(r)
    cnt+=1

tmpcnt=cnt//2-1
r=n
while tmpcnt>0:
    r=t.findparent(r)
    tmpcnt-=1

stack=[r]
rest=1

while len(stack)>0:
    u=stack.pop()
    rest+=len(t.retchild(u))

    for v in t.retchild(u):
        stack.append(v)

snu=rest-cnt//2
fen=n-rest-(cnt+1)//2

if (cnt%2==0 and fen>snu) or (cnt%2==1 and fen>=snu):
    print('Fennec')
else:
    print('Snuke')

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

using namespace std;

#define IO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define ull unsigned long long int

const int INF = 1e9 + 7;
const int N = 1e5+5;


int main() {

	IO;

	string s;
	cin >> s;
	
	cout << (s[s.size() - 1] == 's' ? s+"es" : s+'s');
	
}


Measured memory_bytes: 3628
a, b, c = map(int, input().split())
count = 0
for i in range(10**3):
    if a%2 != 0 or b%2 != 0 or c%2 != 0:
        print(count)
        exit()
    a, b, c = b/2 + c/2, a/2 + c/2, a/2 + b/2
    count += 1
print(-1)

Measured memory_bytes: 62072
#include<bits/stdc++.h>
#define oo 0x3fffffff
#define N 505
using namespace std;


int n,k,m,d[N];

int main(void){
    int i,j,x,y;
   // freopen("in.txt","r",stdin);
    for(i=0;i<3;i++){
        scanf("%d %d",&x,&y);
        d[x]++;d[y]++;
        if(x<1 || x>4 || y<1 || y>4){
            printf("NO");
            return 0;
        }
    }
    for(i=1;i<=4;i++){
        if(d[i]>2){
            printf("NO");
            return 0;
        }
    }
    printf("YES");
    return 0;
}


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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;

ll mod = 1e9 + 7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll inf = 1ll << 60;
int jmax = 100100;



int main() {
    int a, b;
    scanf("%d%d", &a, &b);
    rp(i, 1, b+1) {
        if(a * i == b) {
            printf("%d", a + b);
            return 0;
        }
    }
    printf("%d", b - a);
    return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  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 << "Yes";
  }else{
    cout << "No";
  }
}


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

#define ll long long
#define endl "\n"
#define ios ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);

using namespace std;

int main() {
    ios
    string s, t;
    cin >> s >> t;
    int ans = t.size();
    for (int i = 0; i < s.size() - t.size() + 1; ++ i) {
        int cnt = 0;
        for (int j = 0; j < t.size(); ++ j) {
            if (s[i + j] != t[j]) {
                ++ cnt;
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

// Morris-Pratt
template<typename T> struct MP {
  T t; vector<int> a;
  int operator[](int i) { return a[i];}
  MP(const T& t): t(t) {
    a = vector<int>(t.size()+1);
    a[0] = -1;
    
    int j = -1;
    for (int i = 0; i < t.size(); ++i) {
      while (j != -1 && t[j] != t[i]) j = a[j];
      a[i+1] = ++j;
    }
  }
  vector<int> findAll(const T& s) {
    vector<int> res;
    int j = 0;
    for (int i = 0; i < s.size(); ++i) {
      while (j != -1 && t[j] != s[i]) j = a[j];
      if (++j == t.size()) {
        res.push_back(i-t.size()+1);
        j = a[j];
      }
    }
    return res;
  }
};

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

  vector<int> s(n),t(n);
  rep(i,n){
    s[i] = a[i] ^ a[i+1];
    t[i] = b[i] ^ b[i+1];
  }
  t.insert(t.end(),t.begin(),t.end());

  vector<int> ks = MP<vector<int>>(s).findAll(t);
  rep(i,ks.size()) ks[i] = n-ks[i];
  sort(ks.begin(),ks.end());
  for(int k : ks){
    if (k<n) {
      int x = a[k]^b[0];
      cout << k << " " << x << endl;
    }
  }
}


Measured memory_bytes: 10596
//////////////////////////////////
// Created By Piyush Lakhotiya 
//////////////////////////////////
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

#define vi vector<int>
#define vl vector<ll>
#define mi map<int,int>
#define pi pair<int,int>

#define For(i,a,b) for(int i=a; i<b; i++)

#define pb push_back
#define mp make_pair

#define read(a, n) for(int i=0; i<n; i++) cin >> a[i];
#define print(x) cout << "X: == " << x << endl;
#define printMap(a) for(auto it=a.begin() ; it!= a.end() ; it++) {cout << it->first << "  " << it->second << endl; }
#define printVector(a) for(auto it = a.begin() ; it!= a.end() ;it++) {cout << *it << endl;}

using namespace std;
int main() {
    IOS
    int n;
    cin >> n;
    string s;
    getline(cin >> ws, s);
    if(s.size() <= n) {
        cout << s << endl;
    } else {
        For(i, 0, n) {
            cout << s[i];
        }
        cout << "...\n";
    }
    return 0;
}

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

int main(void)
{
	char str[2][1000];
	int array[2][1000], sum[1000], i, j, k, n, overflow, not0;
	
	scanf("%d", &n);
	
	for (k = 0; k < n ; k++){
		overflow = 0;
		not0 = 0;
		
		for (i = 0; i < 2; i++){
			for (j = 0; j < 1000; j++){
				array[i][j] = 0;
				sum[j] = 0;
			}
		}
		
		scanf("%s %s", str[0], str[1]);
		
		for (i = 0; i < 2; i++){
			for (j = 0; j < strlen(str[i]); j++){
				array[i][j] = str[i][strlen(str[i]) - j - 1] - '0';
			}
		}
		
		for (i = 0; i < 1000; i++){
			sum[i] += array[0][i] + array[1][i];
			
			if (sum[i] > 9){
				sum[i] -= 10;
				sum[i + 1]++;
			}
		}
		
		for (i = 999; i >= 0; i--){
			if (sum[i] != 0){
				if (i > 79){
					overflow = 1;
					break;
				}
				else {
					not0 = 1;
				}
			}
			
			if (not0 == 1 || (i == 0 && not0 == 0)){
				printf("%d", sum[i]);
			}
		}
		
		if (overflow == 1){
			printf("overflow");
		}
		
		puts("");
	}
	
	return (0);
}

Measured memory_bytes: 628
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    
    int[] value;
    value = new int[N];
    for( int i = 0 ; i < N ; i++ ){
      value[i] = sc.nextInt();
    }
    
    int[] cost;
    cost = new int[N];
    for( int i = 0 ; i < N ; i++ ){
      cost[i] = sc.nextInt();
    }
    
    int max = 0;
    for( int i = 0 ; i < N ; i++ ){
      if ( value[i] > cost[i] ){
        max += value[i] - cost[i] ;
      }
    }
    System.out.println(max);
    }
  }


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

int main()
{
    int list[100000];
    int N, K;
    cin >> N >> K;
    if(((N - K) % (K - 1)) == 0) {
        cout << ((N - K) / (K - 1)) + 1 << endl;
    }
    else {
        cout << ((N - K) / (K - 1)) + 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int GCD(int a,int b){
  if(a < b){
    int tem = a;
    a = b;
    b = tem;
  }
  while(b != 0){
    int c = a % b;
    a = b;
    b = c;
    if(b == 0) return a;
  }
}
int main(){
  int n,k;
  cin >> n >> k;
  vector<int> num(n);
  for(int i = 0;i < n;i++) cin >> num[i];
  int gcd = GCD(num[0],num[0]);
  sort(num.begin(),num.end(),greater<int>());
  if(num[0] < k) cout << "IMPOSSIBLE" << endl;
  else{
    for(int i = 0;i < n;i++){
      gcd = GCD(gcd,num[i]);
    }
    if(k % gcd == 0)cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
  }
}


Measured memory_bytes: 640
import Data.List
import Control.Monad

main = do
  [n,m] <- map read.words <$> getLine
  abs <- replicateM n $ (\[a,b]->(a,b)).map read.words <$> getLine
  let abs' = sortBy (\(a,_) (b,_) -> compare a b) abs
  print $ solve m abs'

solve m ((a,b):abs)
  | m <= b = a*m
  | otherwise = a*b + solve (m-b) abs

Measured memory_bytes: 130428
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 +7;

int main() {

    
    ll n, m;
    cin >> n >> m;
    
    vector<vector<ll>> vs(m, vector<ll>());
    vector<ll> p(m);
    
    for (int i = 0; i < m; ++i)
    {
        ll k;
        cin >> k;
        for (int j = 0; j < k; ++j)
        {
            ll s;
            cin >> s;
            s--;
            vs[i].push_back(s);
        }
    }
    
    for (int i = 0; i < m; ++i)
    {
        cin >> p[i];
    }
    
    ll ret = 0;
    for (int i = 0; i < (1ll << n); ++i)
    {
        bool f = 1;
        for (int j = 0; j < vs.size(); ++j)
        {
            ll tmp = 0;
            for (int k = 0; k < vs[j].size(); ++k)
            {
                if ((1ll << vs[j][k]) & i)
                {
                    tmp++;
                }
            }
            if ((tmp % 2) != p[j])
            {
                f = 0;
                break;
            }
            
        }
        if (f)
        {
            ret++;
        }
    }
    
    cout << ret << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int A = scan.nextInt();
		int B = scan.nextInt();
		int sum = 0;
		int tmp = 0;
		for(int i = 1; i <= N; i++) {
			for(int j = 0; j < Integer.toString(i).length(); j++) {
				tmp += Integer.parseInt(Integer.toString(i).substring(j, j + 1));
			}
			if(tmp >= A && tmp <= B) {
				sum += i;
			}
			tmp = 0;
		}
		System.out.println(sum);
		scan.close();
	}

}


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

#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)

using namespace std;
using ll = long long;
using pos = pair<ll, ll>;

ll a,b;
void solve();

int main() {

   solve();
   return 0;

}

void solve() {
	cin >>a>>b;
	if (a+b<10){
		cout << a+b;
	}else{
		cout << "error";
	}
	cout << endl;
	

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define rof(i,a,b) for(int (i)=(a);(i) > (b); --(i))
#define pb push_back
#define pr pair<int,int>
#define mp make_pair
#define ll long long int
const int mod=1e9+7;
int main(){
float x = 22.0f, y = 7.0f;
int  r;
cin>>r;
printf("%.20f\n", 6.28318530717958623200*r);
return 0;
}

Measured memory_bytes: 3760
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;
int n,m;
int x,y;
int main()
{
    cin>>n>>m;
    x=n+m;
    y=x%2;
    cout<<x/2+y;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)

int main()
{
	int m; cin >> m;
	rep(_m, 0, m)
	{
		string s; cin >> s;

		set<string> _set;
		_set.insert(s);
		rep(i, 1, s.length())
		{
			string a = s.substr(0, i);
			string b = s.substr(i);

			string aa = a;
			reverse(aa.begin(), aa.end());

			string bb = b;
			reverse(bb.begin(), bb.end());

			_set.insert(a + bb);
			_set.insert(aa + b);
			_set.insert(aa + bb);
			_set.insert(b + a);
			_set.insert(b + aa);
			_set.insert(bb + a);
			_set.insert(bb + aa);
		}

		cout << _set.size() << endl;
	}
}

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

int main(){
    vector<int> x(3);
    cin >> x[0] >> x[1] >> x[2];
    sort(x.begin(),x.end());
    int res = x[2]*10+x[1]+x[0];
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
	
	double n,m;
	vector<double> vec;
	cin>>n>>m;
	double i ,sum=0,count=0;
	for(i=0;i<n;i++)
	{
	    int temp;
	    cin>>temp;
	    sum+=temp;
	    vec.push_back(temp);
	}
	double ans = sum/(4*m);
	//cout<<ans;
	for(int i=0;i<n;i++)
	{
	    if(vec[i]>=ans) count++;
	}
	if(count>=m) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let n = line.trim().parse::<usize>().unwrap();
    if n == 7 || n == 5 || n == 3 {
        println!("YES");
    } else {
        println!("NO");
    }
}


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

int main(){

    int N;
    cin >> N;
    long double A[N];
    long double sum = 1;
    for(int i = 0; i < N ; i++){
        cin >> A[i];
    }
    
    sort(A,A+N);
    for(int i = 0; i < N ; i++){
        if(A[i]==0){
            cout << 0 <<endl;
            return 0;
        }
    }
    long double memo;
    
    for(int i = 0; i < N ; i++){
        //cout << A[i] <<endl;
        memo = sum;
        if(sum * A[i] >(long long)(1e18)){
            
            cout << -1 <<endl;
            return 0;
        }
        sum *= A[i];
        if(sum / A[i]!=memo){
          
            cout << -1 <<endl;
            return 0;
        }
    }
    
    cout << (long long)sum <<endl;

}


Measured memory_bytes: 5232
#include <iostream>

using namespace std;

typedef long long ll;

int main()
{
  int N;
  cin >> N;
  int D[N][2];
  for(int i=0; i < N ; ++i)
  {
    cin >> D[i][0] >> D[i][1]; 
  }
  for(int i=0 ; i < N - 2 ; ++i)
  {
    if ( D[i][0] == D[i][1] && D[i+1][0] == D[i+1][1]  && D[i+2][0] == D[i+2][1] )
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

int ans;
string s;

signed main(){
	cout<<fixed<<setprecision(7);
	
	cin>>s;
	
	
	for(int i = 0, counta = 0, x = 0; i < s.size(); i++){
		if('R' == s[i])x++,counta++;
		else x--,counta--;
		x=(x+4)%4;
		// cout<<i<<" "<<x<<" "<<counta<<endl;
		// counta = max((int)counta,0);
		if(counta < 0)counta = 0;
		if(x == 0){
			if(counta == 4)ans++;
			counta = 0;
		}
		
	}
	
	cout<<ans<<endl;
	
	return 0;
}


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

int n, k;

void T_T(){ puts("No"); exit(0); }

int main(){
	scanf("%d%d", &n, &k);
	if(k == 1 || k == 2 * n - 1) T_T();
	puts("Yes");
	if(k <= n){
		for(int i = k + 1; i <= n; i++) printf("%d\n", i);
		for(int i = 1; i <= k; i++) printf("%d\n", i);
		for(int i = n + 1; i < 2 * n; i++) printf("%d\n", i);
	}
	else{
		for(int i = 1; i < n; i++) printf("%d\n", i);
		for(int i = k; i < 2 * n; i++) printf("%d\n", i);
		for(int i = n; i < k; i++) printf("%d\n", i);
	}
}

Measured memory_bytes: 1536
#include<iostream>
using namespace std;
int main()
{
    int N;
    int d=0;
    cin>>N;
    for(int i=1;i<10;i++){
        int num = N/i;
        int amari = N%i;
        if(num<10 && amari==0){
            d=1;
        }
    }
if(d)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  int ans = N % K ? 1 : 0;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <complex>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << "\n"
static const int INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[300][300];
char field[200][200];

int main(){
  ll p;
  cin >> n >> m >> l;
  cin >> p;
  if(p % 2)print(m-n);
  else print(n-m);
  return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc128/tasks/abc128_d
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF (1e9)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
// int gcd(long a, long b) { return b ? gcd(b, a % b) : a; }
// int lcm(long a, long b) { return a * b / gcd(a, b); }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> v(n), ans(100, -INF);
    REP(i, n) cin >> v[i];
    // 左側から取り出す処理
    int suml = 0;
    multiset<int> que1;
    for (int i = 0; i <= min(k, n); i++) {
        if (i > 0) {
            que1.insert(v[i - 1]);
            suml += v[i - 1];
        }
        int sumr = 0;
        multiset<int> que2 = que1;
        // 右側から取り出す処理
        for (int j = 0; i + j <= min(k, n); j++) {
            if (j > 0) {
                que2.insert(v[n - j]);
                sumr += v[n - j];
            }
            ans[i + j] = max(ans[i + j], suml + sumr);
            int cnt = 0, mi = 0;
            for (auto x : que2) {
                cnt++;
                if (i + j + cnt > k)
                    break;
                mi += x;
                ans[i + j + cnt] = max(ans[i + j + cnt], suml + sumr - mi);
            }
        }
    }
    cout << *max_element(ALL(ans)) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

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

// EOF

Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define putchar putchar_unlocked
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char ci[cm];
char *cn = ci + cm;
inline char getcha() {
	if (cn - ci == cm) { fread(ci, 1, cm, stdin); cn = ci; }
	return *cn++;
}

inline int getint() {
	char C = getcha();
	int A = C - '0';
	while ((C = getcha()) >= '0') A = A * 10 + C - '0';
	return A;
}

inline void putint(int X) {
	if (X == 0) putchar('0');
	int keta = 0;
	char C[10];
	while (X) {
		C[keta] = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--) putchar(C[i]);
	putchar('\n');
}

int oya;
int D[100001];
int P[100001];
pair<int, int> E[100001], EN[100001];
int sagasu(int A) {
	if (*(D + A)) return *(D + A);
	if (A == oya) return 1;
	int ret = 0;
	int p = (*(EN + A)).first;
	int q = (*(EN + A)).second;
	rep(i, q) {
		int j = (*(E + p + i)).second;
		int kari = sagasu(j) + 1;
		if (ret < kari) {
			ret = kari;
			*(P + A) = j;
		}
	}
	*(D + A) = ret;
	return ret;
}

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


	int N, M;
	N = getint();
	M = getint();
	bool kodomo[100001] = {};
	rep(i, N + M - 1) {
		int a, b;
		a = getint();
		b = getint();
		E[i] = mp(b, a);
		kodomo[b] = true;
	}

	rep1(i, N) {
		if (!kodomo[i]) {
			oya = i;
			break;
		}
	}

	sort(E, E + N + M - 1);
	int k = 0;
	int mae = 0;
	rep1(i, N) {
		while (k < N + M - 1 && E[k].first == i) k++;
		EN[i] = mp(mae, k - mae);
		mae = k;
	}

	rep1(i, N) {
		sagasu(i);
		putint(P[i]);
	}

	Would you please return 0;
}

Measured memory_bytes: 7424
n = int(input())
S = input()

r, g, b = 0, 0, 0
for i in range(n):  #O(n)
    if S[i] == 'R':
        r += 1
    elif S[i] == 'G':
        g += 1
    elif S[i] == 'B':
        b += 1
    else:
        pass

ans = r * g * b
for i in range(1, n-1): #O(n)
    d = i
    if d > n-1 - d:
        d = n-1 - d
    else:
        pass
    for j in range(1, d+1): #O(n)
        if S[i] != S[i-j] and S[i] != S[i+j] and S[i-j] != S[i+j]:
            ans -= 1
        else:
            pass
print(ans)


Measured memory_bytes: 9108
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
ans=0
temp=0
abs_min=10000
for i in range(n):
    temp=t-(h[i]*0.006)
    if abs(a-temp)<abs_min:
        ans=i+1
        abs_min=abs(a-temp)
print(ans)

Measured memory_bytes: 9264
from collections import defaultdict
import sys
def input() -> str:
    return sys.stdin.readline()
n = int(input())
s = [input() for _ in range(n)]
cnt = defaultdict(int)
ans = 0
for si in s:
    ana = "".join(sorted(si))
    ans += cnt[ana]
    cnt[ana] += 1
print(ans)

Measured memory_bytes: 25328
n, m, = gets.split.map(&:to_i)
ary = Array.new(n){[]}
ARGF.readlines.each_with_index do |line, t|
  ki, year, = line.split.map(&:to_i)
  ary[ki - 1] << [year, t]
end
res = []
ary.each_with_index do |ken, ki|
  ken.sort.each_with_index{|i, si| res << [i[1], sprintf('%06d%06d', ki+1, si+1)] }
end
puts res.sort.map(&:last)


Measured memory_bytes: 41724
/*
これを入れて実行
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;
}

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 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 a, b;
    cin >> a >> b;

    if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0){
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int T,a,b,k,n;
int main()
{
	cin>>k>>a>>b;
	while(true) {
		if(n>=a&&n<=b) T=1;
		n+=k;
		if(n>b) break;
	}
	if(T) puts("OK");
	else puts("NG");
}

Measured memory_bytes: 3480
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cassert>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
//---------------------------------------------------------------
const int mod = 1000000007;
struct mint {
int64_t x;
mint(int64_t x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {if ((x += a.x) >= mod) x -= mod;return *this;}
mint& operator-=(const mint a) {if ((x += mod-a.x) >= mod) x -= mod;return *this;}
mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
mint operator+(const mint a) const { return mint(*this) += a;}
mint operator-(const mint a) const { return mint(*this) -= a;}
mint operator*(const mint a) const { return mint(*this) *= a;}
mint pow(int64_t t) const {if (!t) return 1;mint a = pow(t>>1);a *= a;if (t&1) a *= *this;return a;}
mint inv() const { return pow(mod-2);}
mint& operator/=(const mint a) { return *this *= a.inv();}
mint operator/(const mint a) {return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

ll facctorialMethod(ll k,ll m){
   ll sum = 1;
   if(k==0) return 1;
   for (int i = m+1; i <= k; ++i)
   {
       sum *= i;
       sum%=mod;
   }
   return sum;
}

ll facctorialMethod1(ll k){
   ll sum = 1;
   if(k==0) return 1;
   for (int i =1; i <= k; ++i)
   {
       sum *= i;
       sum%=mod;
   }
   return sum;
}



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

    ll s;
    cin>>s;

    ll n=s/3;

    mint ans=0;
    rep(i,n){
        mint num = facctorialMethod(s-3*(i+1)+i,s-3*(i+1));
        num/=facctorialMethod1(i);
        ans+=num;
    }

    cout<<ans<<endl;


}

Measured memory_bytes: 3660
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long int ll;
const int maxn = 100000 + 5;
const ll MOD = 1000000007;
int check[maxn];
ll rem[maxn];
int n, m;

ll solve()
{
	for(int i = 0; i <= n; i++)
	{
		if(i!=0)
		{
			if(check[i]) rem[i] = -1;
			else if(i == 1) rem[i] = 1;
			else
			{
				if(rem[i-1] >= 0 && rem[i-2] >= 0)
				{
					rem[i] = (rem[i-1] + rem[i-2]) % MOD;
				}
				else if(rem[i-1]>=0 || rem[i-2]>=0) rem[i] = max(rem[i-1], rem[i-2]);
				else return 0;
			}
		}
		else rem[i] = 1;
	}
	return rem[n] % MOD;
}

void Print2()
{
	printf("check\n");
	for(int i = 0; i < n; i++)
		printf("%d ", check[i]);
	printf("\n");
}

void Print()
{
	printf("rem\n");
	for(int i = 0; i <= n; i++)
		printf("%lld ", rem[i]);
	printf("\n");
}

int main()
{
	scanf("%d %d", &n, &m);
	for(int i = 0; i < m; i++)
	{
		int c; scanf("%d", &c);
		check[c] = 1;
	}
	printf("%lld\n", solve());
	//Print2();
	//Print();
}

Measured memory_bytes: 1408
def main():
    A, B, M = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    ans = min(a) + min(b)
    for _ in range(M):
        x, y, c = map(int, input().split())
        ans = min(ans, a[x-1] + b[y-1] - c)

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 65852
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        try {
            BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
            
            String line;
            
            while((line = stdReader.readLine()) != null) {
                double r = Double.parseDouble(line);
                double area   = r * r * Math.PI;
                double length = 2 * r * Math.PI;
                
                String circleArea   = String.format("%.6f", area);
                String circleLength = String.format("%.6f", length);
                
                System.out.println(circleArea + " " + circleLength);
            }
            stdReader.close();
        } catch(Exception e) {
            e.getStackTrace();
            System.exit(-1);
        }
    }
}

Measured memory_bytes: 24688
// Ivan Carvalho
// Problem J - Educational Dynamic Programming Contest - AtCoder
// Link : https://atcoder.jp/contests/dp
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 302;

double dp[MAXN][MAXN][MAXN];
int N, vis[MAXN][MAXN][MAXN];

double solve(int x, int y, int z) {

	if (vis[x][y][z]) return dp[x][y][z];
	//printf("Solving %d %d %d\n",x,y,z);
	vis[x][y][z] = 1;

	if (x == 0 && y == 0 && z == 0) return dp[x][y][z] = 0;

	int soma = x + y + z;
	double convertido = (double)soma;
	double tot = (N - soma) / convertido;

	//printf("Tot antes %d %d %d %d %lf\n",N - soma,x,y,z,tot);

	if (x != 0) tot += x * ((solve(x - 1, y, z) + 1) / convertido);
	if (y != 0) tot += y * ((solve(x + 1, y - 1, z) + 1) / convertido);
	if (z != 0) tot += z * ((solve(x, y + 1, z - 1) + 1) / convertido);

	//printf("Tot (%d,%d,%d) = %lf\n",x,y,z,tot);

	return dp[x][y][z] = tot;

}

int main() {

	int a[4] = {0, 0, 0, 0};	

	cin >> N;

	for (int i = 1; i <= N; i++) {
		int x;
		cin >> x;
		a[x]++;
	}

	printf("%.9lf\n", solve(a[1], a[2], a[3]));

	return 0;
}

Measured memory_bytes: 321792
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size))scanf("%d",&(name)[i])
#define MOD 1000000007

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=n;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    GI(N);
    ll c=0,last=0;
    FOR(i,N){
        GI(A);
        if(i==0&&A!=0){
            print(-1);
            return 0;
        }
        if(i!=0){
            if(A>last+1){
                print(-1);
                return 0;
            }else if(A==last+1){
                c+=1;
            }else{
                c+=A;
            }
        }
        last=A;
    }
    print(c);
    return 0;
}

Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<int32_t, int32_t>;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int32_t a, b, c;
  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: 3204
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(){
    int X, N; 
    cin >> X >> N;
    set<int> pSet;
    rep(i, N){
        int tmp;
        cin >> tmp;
        pSet.insert(tmp);
    }

    int ans=0;
    for(int i=0;i<=100;i++){
        auto result1 = pSet.insert(X-i);
        // cout << result1.second << endl;
        if(result1.second){
            ans = X-i;
            break;
        }
        auto result2 = pSet.insert(X+i);
        // cout << result2.second << endl;
        if(result2.second){
            ans = X+i;
            break;
        }
    }
    cout << ans << endl;

    

    return 0;
}

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

template <class Abel>
class UnionFind{
    vector<int> par_, weight_;
public:
    UnionFind(size_t n){
        par_.assign(n, -1);
        weight_.assign(n, 0);
    }

    int root(int x){
        if (par_[x] < 0) {
            return x;
        }else{
            int res = root(par_[x]);
            weight_[x] += weight_[par_[x]];
            return par_[x] = res;
        }
    }

    int weight(int x){
        root(x);
        return weight_[x];
    }

    int weight(int x, int y){
        return weight(y) - weight(x);
    }

    int size(int x){
        return -par_[root(x)];
    }

    bool IsSame(int x, int y){
        return root(x) == root(y);
    }

    void Merge(int x, int y, Abel w){
        w += weight(x);
        w -= weight(y);
        x = root(x);
        y = root(y);
        if (x == y)
            return;
        if (size(x) < size(y)) {
            w = -w;
            swap(x, y);
        }
        par_[x] += par_[y];
        par_[y] = x;
        weight_[y] = w;
    }
};

int main(){
    int n, m;
    cin >> n >> m;
    UnionFind<int> uf(n);

    vector<int> P(n);
    for (auto &p: P){
        cin >> p;
        p--;
    }

    for (int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        uf.Merge(x, y, 0);
    }

    int64_t ans = 0;
    for (int i = 0; i < n; i++){
        if (uf.IsSame(P[i], i))
            ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1408