akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author YahiaAshraf74
 */

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <complex>
#include <string>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <fstream>
#include <iomanip>
#include <assert.h>

using namespace std;
#define el  '\n'
#define ll long long
#define clr(a, b)memset(a,b,sizeof(a))
#define sz(a) (int)(a).size()
const long long N = (int) 2e5 + 74, OO = 0x3f3f3f3f, MOD = (int) 1e9 + 7;

vector<int> adj[N];
bool vis[N];
int dp[N];

class GLongestPath {
public:
    void init() {
        for (int i = 0; i < N; i++)
            adj[i].clear();
        clr(vis, false);
        clr(dp, 0);
    }

    void dfs(int u, int d) {
        vis[u] = true;
        for (int v : adj[u]) {
            if (!vis[v]) {
                dfs(v, d + 1);
            }
            dp[u] = max(dp[u], dp[v] + 1);
        }
    }

    void solve(istream &cin, ostream &cout) {
        init();
        int n, m;
        cin >> n >> m;
        while (m--) {
            int u, v;
            cin >> u >> v;
            adj[u].push_back(v);
        }
        int mx;
        for (int i = 1; i <= n; i++) {
            if (!vis[i]) {
                dfs(i, 0);
            }
        }
        cout << *max_element(dp,dp+n+1) << el;
    }
};
int main() {
	ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
	GLongestPath solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 10240
import sys
#input = sys.stdin.readline
from collections import Counter

def main():
    n, y = map(int, input().split())
    y = y // 1000

    s10, s5, s1 = -1, -1, -1
    for i_s10 in range((y // 10) + 1):
        for i_s5 in range(((y - i_s10 * 10) // 5) + 1):
            if (n - i_s10 - i_s5) == y - i_s10 * 10 - i_s5 * 5:
                s10, s5, s1 = i_s10, i_s5, n - i_s10 - i_s5
    print(s10, s5, s1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <map>
#include <list>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int a,b,c,x,y;
int main()
{
	fast; 
	cin>>a>>b>>c>>x>>y;
	if (a+b<=2*c)
	   cout<<a*x+b*y;
	else if (x>y)
	   cout<<min(2*y*c+a*(x-y),2*c*max(x,y));
	else
	   cout<<min(2*x*c+b*(y-x),2*c*max(x,y));
	return 0;
}


Measured memory_bytes: 256
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun main() {
    val (x, n) = readIntList()
    if (n == 0) {
        println(x)
        return
    }
    val p = readIntList()
    val pSet = mutableSetOf<Int>()
    p.forEach { pSet.add(it) }

    for (d in 0..x) {
        listOf(-1, 1).forEach {
            val num = x + d * it
            if (num !in pSet) {
                println(num)
                return
            }
        }
    }
}


Measured memory_bytes: 38996
def f(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
n=int(input())
ans=[1 for i in range(n+1)]
mod=10**9+7
tmp=1
for i in range(2,n+1):
    t=f(i)
    for j,k in t:
        ans[j]+=k
for i in range(n+1):
    tmp=tmp*ans[i]%mod
print(tmp)

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
  string s;
  cin >> s;
  
  for(int i=0; i< (1 << 3); i++){
    bitset<3> bs(i);
    int ans = ctoi(s[0]);
    for(int j=0; j<3; j++){
      if(bs.test(j)){
        ans += ctoi(s[j+1]);
      }else{
        ans -= ctoi(s[j+1]);
      }
    }
    
    if(ans == 7){
      cout << ctoi(s[0]);
      for(int j=0; j<3; j++){
        if(bs.test(j)){
          cout << '+' << s[j+1];
        }else{
          cout << '-' << s[j+1];
        }
      }
      cout << "=7" << endl;
      return 0;
    }
  }
}

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

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

	vector<bitset<64> > v(10);
	bitset<64> bs;

	int n, q, k, com, i;

	cin >> n;
	for (int j = 0; j < n; j++) {
		cin >> k;
		while (k--) {
			cin >> i;
			v[j][i] = 1;
		}
	}

	cin >> q;
	while (q--) {
		cin >> com >> i;
		if (com == 0) cout << bs.test(i) << endl;
		if (com == 1) bs |= v[i];
		if (com == 2) bs &= ~v[i];
		if (com == 3) bs ^= v[i];
		if (com == 4) cout << ((bs & v[i]) == v[i]) << endl;
		if (com == 5) cout << ((bs & v[i]).to_ulong() != 0) << endl;
		if (com == 6) cout << ((bs & v[i]).to_ulong() == 0) << endl;
		if (com == 7) cout << (bs & v[i]).count() << endl;
		if (com == 8) cout << (bs & v[i]).to_ulong() << endl;
	}
}


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

struct Pos
{
  int x;
  int y;
};

const Pos moves[] = {
    {0, 1},
    {1, 0},
    {0, -1},
    {-1, 0},
};

int main()
{
  int h, w;
  int map[100][100]; // max 50 * 50
  // 白マスの数
  int count_white = 0;

  cin >> h >> w;
  Pos goal = {w - 1, h - 1};

  string buff;
  for (int y = 0; y < h; ++y)
  {
    cin >> buff;
    for (int x = 0; x < w; ++x)
    {
      if (buff[x] == '.')
      {
        map[x][y] = 0;
        count_white++;
      }
      else
      {
        map[x][y] = -1;
      }
    }
  }
  queue<Pos> positions;
  positions.push({0, 0}); // スタート
  map[0][0] = 1;

  while (!positions.empty())
  {
    auto pos = positions.front();
    positions.pop();

    for (int i = 0; i < 4; ++i)
    {
      auto move = moves[i];
      Pos next = {pos.x + move.x, pos.y + move.y};
      if (next.x < 0 || w <= next.x || next.y < 0 || h <= next.y)
      {
        continue;
      }
      if (map[next.x][next.y] == 0)
      {
        int turn = map[pos.x][pos.y] + 1;
        map[next.x][next.y] = turn;
        positions.push(next);
      }
    }
  }

  // 到達していない
  if (map[goal.x][goal.y] == 0)
  {
    cout << "-1" << endl;
  }
  else
  {
    cout << count_white - map[goal.x][goal.y] << endl;
  }

  return 0;
}

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

int main() {
  int x, y;
  cin >> x >> y;
  for(int i = 0; i <= x; i++) {
    if(y == (2 * i) + (4 * (x - i))) {
      cout << "Yes" << endl;
      break;
    }
    else if(i == x) {
      cout << "No" << endl;
    }
  }
}

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

suma = sum(a)
suma2 = sum([a[x] for x in range(1,n,2)])
b = [suma-suma2*2]
for i in range(1,n):
    b.append(a[i-1]*2-b[i-1])
print(*b)

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

int main()
{
    long long  c=0,n;
    string  s,s1;
    cin>>s>>s1;
    n=s.size();
    for(int i=0;i<n;i++){
        if(s[i]!=s1[i]) c++;
     }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 3892
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include "bits/stdc++.h"
using namespace std;
#define endl '\n'
#define stop system("pause")
#define sz(x) (int)(x.size())
#define all(x) begin(x),end(x)
#define lla(x) x.rbegin(),x.rend()
using ll = long long;using vi = vector<int>;
#define debug(v) cout<<#v<<":";cout<<v<<endl
using pii = pair<int, int>;const int MX = 2e5 + 10;
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i,b) for(register int i=0,i##len=(int)(b);i< i##len;++i)
#define rpp(i,b) for(register int i=1,i##len=(int)(b);i<=i##len;++i)
template <typename T> istream& operator>>(istream &is,vector<T> &v) {for(auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template <typename T> ostream& operator<<(ostream &os,const vector<T> &v) {for(auto i = begin(v);i!=end(v);i++) os<<*i<<(i==end(v)-1?"\n":" ");return os;}
template<typename T>inline void rd(T &s){s=0;T t=1,k=getchar();for(;k<'0'||k>'9';k=getchar())if (k=='-')t=-1;for(;k>='0'&&k<='9';k=getchar())s=(s<<1)+(s<<3)+(k^48);s*=t;}
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


signed main()
{
    map<int,int>mp;
    int n,x,y;cin>>n>>x>>y;
    for(int i=1;i<=n;++i)
        for(int j=i+1;j<=n;++j)
            ++mp[min(j-i,abs(x-i)+abs(y-j)+1)];
    rpp(i,n-1) cout<<mp[i]<<endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a+b==15)cout<<"+"<<endl;//和为15
    else if(a*b==15)cout<<"*"<<endl;//积为15 由于和和积不同时为15，可以放心大胆地else if
    else cout<<"x"<<endl;//都不是
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define gt(n) scanf("%d", &n)
#define gtll(n) scanf("%ld", &n)
#define out(n) printf("%d", n)
#define outll(n) printf("%ld", n)
#define loop(n) for(int i=0; i<n; i++)
#define MAXX 1001
#define mem(x, y) memset(x, y, sizeof(x))
#define loop1(n) for(int i=1; i<=n; i++)
#define ll long long
#define pb push_back
#define pi acos(-1)
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
//(only in c)char[33];itoa(n,buffer,base);printf("%s",buffer);
#define dec_to_bin(n) std::string binary = std::bitset<64>(n).to_string();
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int main()
{
    fast;
    int n,m;
    cin>>n>>m;
    int sum=max(n,m);
    if(m>=n)m--;
    else n--;
    sum+=max(n,m);
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m,sum=0,wyn=0; cin>>n>>m;
	vector<int> v;
	for(int i=0;i<n;i++){
		int foo; cin>>foo;
		sum+=foo;
		v.push_back(foo);
	}
	for(auto x : v){
		if(x>=int(ceil(double(sum+0.0)/double(4*m+0.0)))) wyn++;
	}
	if(wyn>=m) cout<<"Yes";
	else cout<<"No";


	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  
  int age;
  scanf("%d",&age);
  
  if(age == 1)
    printf("Hello World");
  else if(age == 2){
    int a,b;
    scanf("%d%d",&a,&b);
    printf("%d",a + b);
  }
  
  return 0;
  
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

pii bound(vector<pii> &e, int k){
	int eind = 0;	
	int x = 0, y = 0;
	int mn = -1, mx = -1;
	while(eind < e.size()){
		int cur = e[eind].first;
		while(eind < e.size() && e[eind].first == cur){
			if(e[eind].second == 1){
				++x;	
				if(mn == -1 && x >= k)mn = cur;
			}
			else{
				++y;	
				if(mx == -1 && y >= k)mx = cur;
			}
			++eind;
		}
	}
	return {mn,mx};
}

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<pii> e;
	rep(i,0,n){
		int x,y;
		cin >> x >> y;
		e.emplace_back(x,1);
		e.emplace_back(y,-1);
	}
	sort(all(e));
	if(n&1){
		auto res = bound(e,n/2+1);
		cout << res.second-res.first+1 << '\n';
	}
	else{
		auto res1 = bound(e,n/2);
		auto res2 = bound(e,n/2+1);
		cout << res1.second+res2.second-res1.first-res2.first + 1 << '\n';
	}
}


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

*/
int lcsMemo(int i, int j, string &s, string &t, vector<vector<int>>& dp){
    if(i >= (int)s.size() || j >= (int)t.size() || i<0 || j<0)
        return 0;
    if(dp[i][j] != -1){
        return dp[i][j];
    }else if(s[i] == t[j]){
        dp[i][j] = 1 + lcsMemo(i+1, j+1, s, t, dp);
        return dp[i][j];
    }else{
        int firstRemoval = lcsMemo(i+1, j, s, t, dp);
        int secondRemoval = lcsMemo(i, j+1, s, t, dp);
        dp[i][j] = max(firstRemoval, secondRemoval);
        return dp[i][j];
    }

}
string lcsWord(vector<vector<int>>& dp, string s, string t){
    int i = 0, j = 0;
    string res = "";
    while(i<dp.size() && j<dp[0].size()){
        // cout<<i<<" "<<j<<" ";
        if(s[i] == t[j]){
            // cout<<"1"<<endl;
            res += s[i];
            i++; j++;
        }else if(i+1 == dp.size()){
            j++;
        }else if(j+1 == dp[0].size()){
            i++;
        }else if(dp[i+1][j] > dp[i][j+1]){
            // cout<<2<<endl;
            i++;
        }else{
            // cout<<3<<endl;
            j++;
        }

    }
    // reverse(res.begin(), res.end());
    return res;
}
int main(){
    string s,t;
    cin>>s>>t;
    vector<vector<int>> dp((int)s.size(), vector<int>((int)t.size(), -1));
    int lcsLength = lcsMemo(0,0,s,t,dp);
    // for(int i=0; i< (int)s.size(); i++){
    //     for(int j=0; j< (int)t.size(); j++){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    string answer = lcsWord(dp, s, t);
    cout<<answer<<endl;
    return 0;
}

Measured memory_bytes: 39112
using System;
using System.Collections.Generic;
using System.Linq;
using CompLib.Util;

public class Program
{
    private char[] S;
    private int Q;

    public void Solve()
    {
        var sc = new Scanner();
        S = sc.NextCharArray();
        Q = sc.NextInt();
        var list = new LinkedList<char>();
        foreach (char c in S)
        {
            list.AddLast(c);
        }

        bool inv = false;
        for (int i = 0; i < Q; i++)
        {
            char t = sc.NextChar();
            if (t == '1')
            {
                inv = !inv;
            }
            else
            {
                char f = sc.NextChar();
                char c = sc.NextChar();
                if (f == '1' ^ inv)
                {
                    list.AddFirst(c);
                }
                else
                {
                    list.AddLast(c);
                }
            }
        }

        string ans;
        if (inv)
        {
            var ar = list.ToArray();
            Array.Reverse(ar);
            ans = new string(ar);
        }
        else
        {
            ans = new string(list.ToArray());
        }
        
        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 33572
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
num_pack, mod = map(int,input().split())
pack_ls = list(map(int, input().split()))
num_pack_0 = 0
num_pack_1 = 0
for i in range(num_pack):
    if pack_ls[i] % 2 == 0:
        num_pack_0 += 1
    else:
        num_pack_1 += 1

if mod == 1:
    pattern_0 = 2 ** num_pack_0
    pattern_1 = 0
    i = 1
    while i <= num_pack_1:
        pattern_1 += combinations_count(num_pack_1, i)
        i += 2
    ans = pattern_0 * pattern_1
else:
    pattern_0 = 2 ** num_pack_0
    pattern_1 = 0
    i = 0
    while i <= num_pack_1:
        pattern_1 += combinations_count(num_pack_1, i)
        i += 2
    ans = pattern_0 * pattern_1

print(ans)
    







Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
  ll n,k;
  cin >> n >> k;
  vll a(n);
  rep(i,0,n) cin >> a[i];
  ll g=a[0];
  rep(i,1,n) g=__gcd(g,a[i]);
  
  ll m=*max_element(all(a));
  
  if(m>=k&&((m-k)%g==0)) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  
}

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5;
struct P {
	int val,id;
	bool operator <(const P &t)const {
		if(val!=t.val) return val>t.val;
		return id<t.id;
	}
}p[N*3];
int main() {
    //freopen("in.txt","r",stdin);
	int x,y,a,b,c;
	scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
	for(int i=0,d;i<a;i++) {
		scanf("%d",&d),p[i]={d,1};
	}
	for(int i=0,d;i<b;i++) {
		scanf("%d",&d),p[i+a]={d,2};
	}
	for(int i=0,d;i<c;i++) {
		scanf("%d",&d),p[i+a+b]={d,0};
	}
	a=a+b+c;
	sort(p,p+a);
	ll ans=0;
	int t=0;
	for(int i=0;i<a;i++) {
		if(p[i].id==1) {
			if(x) x--,ans+=p[i].val;
		}
		else if(p[i].id==2) {
			if(y) y--,ans+=p[i].val;
		}
		else {
			t++,ans+=p[i].val;
		}
		if(t==x+y) break;
	}
	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <map> 
#include <algorithm>
#include <cstring>

#define ll long long
using namespace std; 

void solve(){
  int x; 
  cin >>x ; 
  cout << (!x) << "\n"; 
}

int main(){
  int t=1; 
  // cin>>t; 
  while(t--){
    solve(); 
  }
 return 0;
}

Measured memory_bytes: 3640
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 2005
const ll oo=1000000007;
vector<pair<ll,ll>> v;
ll dp[MAX][MAX];
ll n;
ll solve(int l, int r)
{
    if(r<l) return 0;
    if(dp[l][r]!=-1) return dp[l][r];
    int i=n-(r-l+1)+1;
    ll x= v[i].first*abs(l-v[i].second) + solve(l+1,r);
    ll y= v[i].first*abs(r-v[i].second) + solve(l,r-1);
    dp[l][r]=max(x,y);
    return dp[l][r];
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
     cin>>n;
    v.push_back({oo,0});
    for(int i=1;i<=n;i++){
        ll a; cin>>a;
        v.push_back({a,i});
    }
    sort(v.rbegin(),v.rend());
    memset(dp,-1,sizeof(dp));
    cout<<solve(1,n);
}

Measured memory_bytes: 35240
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class C
{
	public static void Main()
	{
		string S = Console.ReadLine();
		
		long ans = 0;
		for(int b = 0; b < (1 << (S.Length - 1)); b++)
		{
			int head = 0;
			for(int tail = 0; tail < S.Length - 1; tail++)
			{
				if(((b >> tail) & 1) == 1)
				{
					int len = tail - head + 1;
					ans += Int64.Parse(S.Substring(head,len));
					head = tail + 1;
				}
			}
			ans += Int64.Parse(S.Substring(head,S.Length - head));
		}
		
		Console.WriteLine(ans);
	}	
}





Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef map<int,int> mp;
#define MOD 1000000007
#define pi acos(-1)

#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main(){
    fastio;
    double r;
    cin>>r;
    cout<<2*pi*r<<endl;
return 0;
}


Measured memory_bytes: 3804
import java.util.*;

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

    System.out.println(oclock);
  }

  private static String convertSecondsToOclock(int seconds) {
    int hours = 0;
    int minutes = 0;

    while (seconds >= 60) {
      if (seconds >= 3600) {
        seconds -= 3600;
        hours++;
      } else {
        seconds -= 60;
        minutes++;
      }
    }
    return String.format("%d:%d:%d", hours, minutes, seconds);
  }
}

Measured memory_bytes: 26288
from itertools import permutations as perm

def warshall(d, n):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if d[i][k] + d[k][j] < d[i][j]:
                    d[i][j] = d[i][k] + d[k][j]

n,m,r = map(int, input().split())
rr = [i-1 for i in map(int, input().split())]

inf = float('INF')
route = [[inf for j in range(n)] for i in range(n)]
for _ in range(m):
    a,b,c = map(int, input().split())
    route[a-1][b-1] = route[b-1][a-1] = c

warshall(route, n)

ans = inf
for tmp in perm(rr):
    cost = 0
    for i in range(r-1):
        cost += route[tmp[i]][tmp[i+1]]
    if cost < ans:
        ans = cost
print(int(ans))

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

int main(){
    int n,x,y;
    cin >> n >> x >> y;
    int ans[n];
    fill(ans,ans+n,0);
    for(int i=1; i<=n; i++){
        for(int j=i+1; j<=n; j++){
            int t = min(j-i,abs(x-i)+1+abs(j-y));
            t = min(t,abs(y-i)+1+abs(j-x));
            ans[t]++;
        }
    }
    for(int i=1; i<n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
#define MAX 200005
#define MOD 1000000007
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define si set<int>
#define mp map<ll,ll>
#define mpi map<ii,ll>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#include <unordered_map> 
#define ump unordered_map<ll,ll>
ll i;
ll vis[200005];
vi adj[200005];
ll value[200005];
void call_dfs()
{
	queue<int> q;
	q.push(1);
	while(!q.empty())
	{
		int u=q.front();
		vis[q.front()]=1;
		q.pop();
		for(i=0;i<adj[u].size();i++)
		{
			vis[u]=1;
			if(vis[adj[u][i]]==0)
			{
				q.push(adj[u][i]);
				value[adj[u][i]]=value[u]+value[adj[u][i]];
			}
		}
	}
}
int main()
{ 
	fast 
	ll n,q;
	cin>>n>>q;
	for(i=0;i<n-1;i++)
	{
		ll x,y;
		cin>>x>>y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	for(i=0;i<q;i++)
	{
		ll x,y;
		cin>>x>>y;
		value[x]=value[x]+y;
	}
	call_dfs();
	for(i=1;i<=n;i++)
	{
		cout<<value[i]<<" ";
	}

}

Measured memory_bytes: 17908
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int area = a*b;
        int length =2*(a+b);
        System.out.println(area + " " + length);
        sc.close();
    }
}



Measured memory_bytes: 26200
#include<bits/stdc++.h>
#define cases long long t;cin>>t;while(t--)
#define f_io ios::sync_with_stdio(false)
#define foi(a,n) for(long long i=a;i<n;i++)
#define foj(a,n) for(long long j=a;j<n;j++)
#define fok(a,n) for(long long k=a;k<n;k++)
#define ll long long
#define MOD 1000000007
using namespace std;

int main()
{
    f_io;
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll ans=0;
    foi(0,n-2)
    {
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
            ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
typedef long long ll;
using Graph =vector<int>;
typedef pair<int,int> P;
const ll MAX_N=131072;
const ll INF=1000000;
const ll MOD=1000000007;
int main(){
    string S;cin>>S;
    reverse(S.begin(),S.end());
    string L[4]={"dream","dreamer","erase","eraser"};
    rep(i,4){
        reverse(L[i].begin(),L[i].end());
    }
    while(!S.empty()){
        bool f=false;
        rep(i,4){
            if (S.substr(0,L[i].size())==L[i]){
                S=S.substr(L[i].size());
                f=true;
                break;
            }
        }
        if (!f){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;

}


Measured memory_bytes: 512
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(X,Y):
    return X + Y//2

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_a, str_b] = line.split(' ')
    return (int(str_a), int(str_b))

def main():
    a, b = readQuestion()
    answer = solve(a, b)
    print(answer)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#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>;
const ll INF = 1LL << 60;

int g[15][15];

int main(void){
    int n;
    cin >> n;
    rep(i,n)rep(j,n) g[i][j] = -1;
    // input
    rep(i,n) {
        int a;
        cin>>a;
        rep(j,a) {
            int x,y;
            cin >> x >> y;
            --x;
            g[i][x] = y;
        }
    }

    // 2^15通りの割り当て
    int ans = 0;
    rep(i,1<<n) {
        vector<int> d(n);
        rep(j,n) if (i>>j&1) {
            d[j] = 1;
        }
        bool ok = true;
        rep(j,n) {
            if (d[j]) {
                rep(k,n) {
                    if(g[j][k] == -1) continue;
                    if(g[j][k] != d[k]) ok = false;
                }
            }
        }
        if(ok) ans = max(ans, __builtin_popcount(i));
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int a[200000];
int b[200000];

int main() {
	int n;
	cin>>n;
	rep(i,n){
		cin>>a[i];
		b[i]=a[i];
	}
	
	sort(a,a+n);
	rep(i,n){
		if(b[i]==a[n-1]){
			cout<<a[n-2]<<endl;
		}else{
			cout<<a[n-1]<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= c && c <= b)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B105 solver = new B105();
        solver.solve(1, in, out);
        out.close();
    }

    static class B105 {
        private static final int[] SPECIAL_NUMBERS = {105, 135, 165, 189, 195};

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int ans = 0;
            for (int s : SPECIAL_NUMBERS) {
                if (s <= n) {
                    ans++;
                }
            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 23764
// AOJ 2311: Dessert Witch
// 2018.1.8 bal4u@uu

#include <stdio.h>

char map[8][10];
int mv[8][2] = {{-1,0},{-1,1},{0,1},{1,1},{1,0},{1,-1},{0,-1},{-1,-1}};

int mami(int *rr, int *cc)
{
	int i, r, c, r2, c2, f, f2, max;

	max = 0;
	for (r = 0; r < 8; r++) for (c = 0; c < 8; c++) {
		if (map[r][c] != '.') continue;
		f = 0; for (i = 0; i < 8; i++) {
			r2 = r, c2 = c, f2 = 0; while (1) {
				r2 += mv[i][0], c2 += mv[i][1];
				if (r2 < 0 || r2 >= 8 || c2 < 0 || c2 >= 8) break;
				if (map[r2][c2] == '.') break;
				if (map[r2][c2] == 'o') { f += f2; break; }
				f2++;
			}
		}
		if (f > max) max = f, *rr = r, *cc = c;
	}
	return max; 
}

int majo(int *rr, int *cc)
{
	int i, r, c, r2, c2, f, f2, max;

	max = 0;
	for (r = 7; r >= 0; r--) for (c = 7; c >= 0; c--) {
		if (map[r][c] != '.') continue;
		f = 0; for (i = 0; i < 8; i++) {
			r2 = r, c2 = c, f2 = 0; while (1) {
				r2 += mv[i][0], c2 += mv[i][1];
				if (r2 < 0 || r2 >= 8 || c2 < 0 || c2 >= 8) break;
				if (map[r2][c2] == '.') break;
				if (map[r2][c2] == 'x') { f += f2; break; }
				f2++;
			}
		}
		if (f > max) max = f, *rr = r, *cc = c;
	}
	return max; 
}

void act(int rr, int cc, char m)
{
	int i, r, c;

	map[rr][cc] = m;
	for (i = 0; i < 8; i++) {
		r = rr, c = cc;
		while (1) {
			r += mv[i][0], c += mv[i][1];
			if (r < 0 || r >= 8 || c < 0 || c >= 8) break;
			if (map[r][c] == '.') break;
			if (map[r][c] == m) {
				r = rr, c = cc;
				while (1) {
					r += mv[i][0], c += mv[i][1];
					if (map[r][c] == m) break;
					map[r][c] = m;
				}
				break;
			}
		}
	}
}

int main()
{
	int r, c, f;
	
	for (r = 0; r < 8; r++) scanf("%s", map[r]);
	f = 1; while (f) {
		f = 0;
		if (mami(&r, &c)) f = 1, act(r, c, 'o');
		if (majo(&r, &c)) f = 1, act(r, c, 'x');
	}
	for (r = 0; r < 8; r++) puts(map[r]);
	return 0;
}



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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 998244353;

void solve() {
    int n, k;
    cin >> n >> k;

    vector<pair<int, int>> v(k);
    for (int i = 0; i < k; i++) cin >> v[i].first >> v[i].second;

    vector<int> pre(n + 1), dp(n + 1);
    dp[1] = pre[1] = 1;
    for (int i = 2; i <= n; i++) {
        for (auto x: v) {
            int l = x.first, h = x.second, mid, ans = -1;
            while (l <= h) {
                mid = l + h >> 1;
                if (i - mid >= 1)ans = mid, l = mid + 1;
                else h = mid - 1;
            }
            if (ans != -1)dp[i] += (pre[i - x.first] - pre[i - ans - 1] + MOD) % MOD;
            if (dp[i] >= MOD)dp[i] -= MOD;
        }
        pre[i] = dp[i] + pre[i - 1];
        if (pre[i] >= MOD)pre[i] -= MOD;
    }
    cout << dp[n] << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 6340
package main

// ABC112D - Partition(400)
// https://atcoder.jp/contests/abc112/tasks/abc112_d
// a1+a2+....aN = Mの整数列がある時、GCDの最大値を求めよ
// GCDをDとすると、a1=b1*D, a2=b2*D, .... aN=bN*Dとなるので、MもDの倍数(m*D)となる。
// これからDはMの約数であることがわかる(M=m*D)
// DがMの約数であるとき、a1,a2,...aN >=Dなので、M>=N*Dとなる。
// このとき、a1=a2=a3....=aN-1=D、かつaN=M-(N-1)*Dのようにaを構成することが必ずできる。
// したがって、M>=N*Dから、M/N >= Dであるため、Mの約数で、M/N以下のうちの最大のものを選べば良い

import (
	"fmt"
	"sort"
)

func divisors(n int) []int {
	r := make([]int, 0)
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			r = append(r, i)
			if i*i != n {
				r = append(r, n/i)
			}
		}
	}
	return r
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	d := divisors(M)
	sort.Ints(d)
	ans := 1
	for i := 0; i < len(d); i++ {
		if d[i] <= M/N {
			ans = d[i]
		} else {
			break
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define     PI                       acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void GO(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
const int N=1000000+9;
int solve(int x){

   if(x>=400&&x<=599) return 8;
   if(x>=600&&x<=799) return 7;
   if(x>=800&&x<=999) return 6;
   if(x>=1000&&x<=1199) return 5;
   if(x>=1200&&x<=1399) return 4;
   if(x>=1400&&x<=1599) return 3;
   if(x>=1600&&x<=1799) return 2;
   if(x>=1800&&x<=1999) return 1;

}
int main(){
    GO();
    int T;
   // cin>>T;
   T=1;
    while(T--){

        int x;
        cin>>x;
        cout<<solve(x)<<"\n";





    }

}




































































Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF = 2e9
#define LINF = 1e18
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << "=" << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO")
#define Yes(n) cout << ((n) ? "Yes" : "No")
#define PI 3.141592653589793

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

    Yes(a+b >= c) << endl;
}

Measured memory_bytes: 3644
import sys
def prim(n, m):
	d = [sys.maxsize]*n
	p = [-1]*n
	c = [False]*n
	d[0] = 0
	while True:
		minv = sys.maxsize
		u = -1
		for i in range(n):
			if minv > d[i] and c[i] == False:
				minv = d[i]
				u = i
		if u == -1:
			break
		c[u] = True
		for i in range(n):
			if m[u][i] != sys.maxsize:
				if m[u][i] < d[i] and c[i] == False:
						d[i] = m[u][i]
						p[i] = u
	sum = 0
	for i in range(n):
		if p[i] != -1:
			sum += m[i][p[i]]
	return sum

n = int(input())
m = [[0 for x in range(n)] for x in range(n)]
for i in range(n):
	a = list(map(int, input().split()))
	for j in range(n):
		if a[j] == -1:
			m[i][j] = sys.maxsize
		else:
			m[i][j] = a[j]
print(prim(n, m))



Measured memory_bytes: 5916
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define re register
#define ll long long
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
char s[500010];
int main(){
	scanf("%s",s+1);int n=strlen(s+1);
	for(int i=1;i<n;i++)
		if(s[i]==s[i+1]){printf("%d %d\n",i,i+1);return 0;}
		else if(i+1!=n && s[i]==s[i+2])return printf("%d %d\n",i,i+2),0;
	puts("-1 -1");
	return 0;
}


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

using namespace std;

int main()
{
	int d, l;
	cin >> d >> l;
	int ans = 10000;
	for (int i = 0; i < (d + l - 1) / l; i++)
		ans = min(ans, d / l + d % l);
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3088
n=gets.to_i
a=gets.split.map(&:to_i)
b=gets.split.map(&:to_i)
c=gets.split.map(&:to_i)

ans = b.inject(:+)

(n-1).times do |i|
    if a[i+1] == a[i] + 1
        ans += c[a[i]-1]
    end
end

p ans

Measured memory_bytes: 3836
#include <cstdlib>
#include <iostream>

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

    int n,a,b,c;
    bool f;
    std::cin >> n;
    while (std::cin >> a >> b >> c) {
        f = false;
        if (c*c == a*a+b*b) {
            f = true;
        } else if (a*a == b*b+c*c) {
            f = true;
        } else if (b*b == c*c+a*a) {
            f = true;
        } else {
            std::cout << "NO" << std::endl;
        }
        if (f) {
            std::cout << "YES" << std::endl;
        }
    }
    return EXIT_SUCCESS;
}


Measured memory_bytes: 3080
n = int(input())

my_dict = dict()

for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            tmp = i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i
            if tmp in my_dict:
                my_dict[tmp] += 1
            else:
                my_dict[tmp] = 1

for i in range(1, n+1):
    if i in my_dict:
        print(my_dict[i])
    else:
        print(0)


Measured memory_bytes: 11652
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; i++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

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

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

Measured memory_bytes: 256
N, K = map(int, input().split())
LR = []
for _ in range(K):
    L, R = map(int, input().split())
    LR.append((L, R))

MOD = 998244353

def f_dp(i):
    if 0 <= i < N:
        return dp[i]
    else:
        return 0

dp = [0] * N
dp[0] = 1
for i in range(1, N):
    temp = 0
    for k in range(K):
#         temp += dp[i - LR[k][0]] - dp[i - LR[k][1]-1]
        temp += f_dp(i - LR[k][0]) - f_dp(i - LR[k][1]-1)
    dp[i] = (temp + dp[i-1]) % MOD

print((dp[-1] - dp[-2]) % MOD)


Measured memory_bytes: 16932
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


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

    int H, W; cin >> H >> W;
    vs S(H+2); 
    S[0] = string(W + 2, '.');
    FOR(i, 1,H+1) {
        string t; cin >> t;
        S[i] = "." + t + ".";
    }
    S[H+1] = string(W + 2, '.');

    bool ok = true;
    FOR(i,1,H+1){
        FOR(j,1,W+1) {
            if (S[i][j]=='#' &&
                S[i-1][j] == '.' && S[i+1][j]=='.' &&
                S[i][j-1] == '.' && S[i][j+1] == '.') {
                ok = false;
                break;
            }
        }
        if (!ok) break;
    }

    string ans = ok ? "Yes" : "No";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int a, b, c;
    
    scanf("%d%d%d", &a, &b, &c);
    
    if (!((a == b && a == c) || (a != b && a != c && b != c))) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    
    return 0;
}









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

int main() {
  int A,B;
  cin>>A>>B;
  rep(i,2000){
   if((int)(0.08*i)==A and (int)(0.1*i)==B){
      cout<<i;
      return 0;
    }
  }
  cout<<-1;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
#define typeof(x) __typeof__(x)
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) UB(c,x)-LB(c,x)
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define PB push_back
#define MP make_pair
#define vec vector

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

using namespace std;

typedef pair<int,int> P;
struct edge {
  int to, cost;
};

const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
  int len = v.size();
  s << "[";
  for (int i = 0; i < len; i++) {
    s << v[i]; if (i < len - 1) s << " ";
  }
  s << "]";
  return s;
}


class UNION_FIND
{
  private:
    vector<int> par, myrank;
  public:
    UNION_FIND(int n) {
      par = vector<int>(n);
      myrank = vector<int>(n,0);
      for (int i = 0; i < n; i++) {
        par[i] = i;
      }
    }
    int find(int x) {
      if (par[x] == x) return x;
      return par[x] = find(par[x]);
    }
    void unite(int x, int y) {
      x = find(x);
      y = find(y);
      if (x == y) return;
      if (myrank[x] < myrank[y]) {
        par[x] = y;
      } else {
        par[y] = x;
        if(myrank[x] == myrank[y]) myrank[x]++;
      }
    }
    bool same(int x, int y)
    {
      return find(x) == find(y);
    }
};

int prim(const vector< vector<edge> >& G)
{
  int sum = 0;
  vector<bool> used(G.size(), false);
  priority_queue<P, vector<P>, greater<P> > que;
  que.push(P(0, 0));
  while (!que.empty()) {
    int cost = que.top().first;
    int from = que.top().second;
    que.pop();
    if (used[from]) continue;
    used[from] = true;
    sum += cost;
    for (int i = 0; i < G[from].size(); i++) {
      edge e = G[from][i];
      if (!used[e.to]) {
        que.push(P(e.cost, e.to));
      }
    }
  }
  return sum;
}



signed main()
{
  int N; cin >> N;
  vec< pair<int,int> > x(N), y(N);
  rep(i, 0, N) {
    int a, b; cin >> a >> b;
    x[i] = MP(a, i);
    y[i] = MP(b, i);
  }
  SORT(x); SORT(y);

  vec< vec<edge> > G(N, vec<edge>());
  rep(i, 0, N-1) {
    int dist = abs(x[i+1].first - x[i].first);
    int u = x[i].second, v = x[i+1].second;
    G[u].PB((edge){ v, dist });
    G[v].PB((edge){ u, dist });
  }
  rep(i, 0, N-1) {
    int dist = abs(y[i+1].first - y[i].first);
    int u = y[i].second, v = y[i+1].second;
    G[u].PB((edge){ v, dist });
    G[v].PB((edge){ u, dist });
  }

  cout << prim(G) << endl;

  return 0;
}


Measured memory_bytes: 16884
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
using namespace std;
typedef long long int lli;
int main(void)
{
    int N, i;
    cin >> N >> i;
    cout << N - i + 1 << endl;
    return 0;
}


Measured memory_bytes: 3604
/** 
 *                                                                   
 *   |    |                        ,   .              ,--.,--.,--.,--.
 *   |    |    ,---..    ,,---.    |   |,---..   .      -||  ||  ||  |
 *   |    |    |   | \  / |---'    `---'|   ||   |       ||  ||  ||  |
 *   `    `---'`---'  `'  `---'      |  `---'`---'    `--'`--'`--'`--'
 *                                   `                                
**/
#include <bits/stdc++.h>
using namespace std;

long long n, w, wei[105], val[105];
long long dp[105][100005];

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

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	cin >> n >> w;
	for (int i = 1; i <= n; i++) {
		cin >> wei[i] >> val[i];
	}

	for (int i = 0; i <= 100000; i++) {
		dp[0][i] = 1e14;
	}

	int ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= 100000; j++) {
			dp[i][j] = dp[i - 1][j];
			if (j - val[i] >= 0) dp[i][j] = min(dp[i][j], dp[i - 1][j - val[i]] + wei[i]);
			if (j <= val[i]) dp[i][j] = min(dp[i][j], wei[i]);

			if (dp[i][j] <= w) ans = max(ans, j);
		}
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
//using namespace __gnu_pbds; 
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int> >, rb_tree_tag,tree_order_statistics_node_update>
#define standardVar ll n,m,i,j,k,num,num1,num2,flag=0
#define nn <<"\n"
#define __ <<" "<<
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define ittr(x,v) for(auto x=v.begin();x!=v.end();x++)
#define itr(x,n) for(x=0;x<n;x++)
#define itrab(x,a,b) for(x=a;x<b;x++)
#define itpr(v) ittr(x,v)cout<<*x<<" "; cout nn
#define itppr(v) ittr(x,v)cout<<(*x).ff<<" "<<(*x).ss<<"  "; cout nn
#define pi 3.14159265359
#define dTor(x) ((x)*pi)/180.0
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef map<ll,ll> ml;
typedef set<ll> sl;
typedef string str;
typedef pair<ll, ll> pl;
typedef vector< pl > vpl;
typedef map<pl,ll> mpl;
typedef set< pl > spl;
typedef vector<str> vst;
typedef vector<vl> vvl;

const ll M=1000000007;
const ll N=998244353;

ll power(ll x, ll y, ll p){     //MODULAR EXPONENTIATION
    ll res=1;
    x=x%p;
    if(x==0)
        return 0;
    while(y>0){
        if(y&1)
            res=(res*x)%p;
        y=y>>1;
        x=(x*x)%p;
    }
    return res;
}
ll inv(ll x, ll m){             //FERMAT INVERSE
    return power(x,m-2,m);
}
struct comp{                    //COMPARISON ON PAIRS
    template<typename T>        
    bool operator()(const T &a, const T &b){
        if (a.ff==b.ff)
            return (a.ss<b.ss);
        else
            return (a.ff<b.ff);
    }
};
bool mod(const pair<ll,ll> &a, const pair<ll,ll> &b){   //COMPARATOR FOR PAIRS (SORTING)
    if(a.ff!=b.ff)
        return (a.ff<b.ff);
    else
        return (a.ss<b.ss);
}
void sieve(vl &prime){          //SIEVE OF ERATOSTHENES
    ll maxN=1e6;
    vector<bool> pr(maxN+1,1);
    for(int i=2;i*i<=maxN;i++)
        if(pr[i]==1)
            for(int j=i*i;j<=maxN;j+=i)
                pr[j]=0;
    for(ll i=2;i<=maxN;i++)
        if(pr[i]==1)
            prime.pb(i);
}
bool isValid(ll i, ll j, ll n, ll m){   //CHECKS FOR OVERFLOW
    if(i>=0&&i<n&&j>=0&&j<m){
        return true;
    }
    return false;
}

//MAIN FUNCTION STARTS HERE

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    standardVar;
    ll d;
    cin>>n>>d;
    ll c=0;
    itr(i,n){
        cin>>num1>>num2;
        if(num1*num1+num2*num2<=d*d){
            c++;
        }
    }
    cout<<c nn;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a;
  int jk;
  jk = 0;
  for(int i=0; i < a; i++){
    cin >> b >> c;
    jk = jk+(c-b+1);
  }
  cout << jk << endl;
}
    
     

Measured memory_bytes: 256