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

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;

typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<" "<<y<<endl
#define pl(x)                   out<<x
#define p2l(x,y)                out<<x<<" "<<y
#define p1d(a,n)                for(int ix=0;ix<n;ix++) out<<a[ix]<<" "; out<<endl
#define p2d(a,n,m)              for(int ix=0;ix<n;ix++){ for(int jx=0;jx<m;jx++) out<<a[ix][jx]<<" "; out<<endl;}
#define range(v)                v.begin(),v.end()
#define w(x)                    while(x--)
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

void ssolve(std::istream& in, std::ostream& out){
int a,b,c;
s3(a,b,c);
int x = c - a - b;
if(x <= 0){
    out<<"No"<<endl;
    return;
}
if(x*x > 4*a*b){
    out<<"Yes"<<endl;
    return;
}
    out<<"No"<<endl;
}

class CSqrtInequality {
public:
	void solve(std::istream& in, std::ostream& out) {
        ios_base::sync_with_stdio(false);
        in.tie(0);out.tie(0);
        int t;
        int READ = 0;
        if(READ) s(t);
        else t = 1;
        while(t--){
            ssolve(in, out);
        }
	}
};


integer main() {
	CSqrtInequality solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
}


Measured memory_bytes: 256
/**
 *   created: 01 September 2019  17:13:12
**/
#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef vector< pair<int , int> > vii;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long , long long> pll;
typedef vector< pair<long long , long long> > vll;

#define PB push_back
#define PPB pop_back
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rrep(i,a,b) for(int i = (int)(a-1); i>=(int)(b); i--)
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


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

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================

int main()
{
	optimizeIO();
	int tt=1;
	//cin>>tt;
	while(tt--){
		int a,b;
		cin>>a>>b;
		if(b==1){
			cout<<0;
			return 0;
		}
		int cnt=0,c=0;
		while(c+a<b){
			c += a-1;
			cnt++;
		}
		cout<<cnt+1;
	}
	return 0;
}


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

int main() {

	int n;
	cin >> n;
	vector <int> a(n);

	for(int i=0; i<n; i++) {
		cin >> a[i];
	}


	int cnt = 0;
	for(int i=0; i<n; i++) {
		if(a[i] % 2 == 0) {
			cnt++;
			if(a[i] % 3 == 0 || a[i] % 5 == 0) {
				cnt--;
			} 
		}

	}

	if(cnt == 0) {
		cout << "APPROVED";
	} else {
		cout << "DENIED";
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

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

    string s;
    cin >> s;
    s = "+" + s;
    int b;
    cin >> b;

    int n = s.size();

    // mul-first
    int a1 = 0;
    rep(i, n) {
        if (s[i] == '+') {
            int t = 1;
            rep2(j, i + 1, n) {
                if (isdigit(s[j])) {
                    t *= s[j] - '0';
                }
                if (s[j] == '+') {
                    break;
                }
            }
            a1 += t;
        }
    }

    // left-to-right
    int a2 = 0;
    rep(i, n) {
        if (s[i] == '+') {
            a2 += s[i + 1] - '0';
        }
        if (s[i] == '*') {
            a2 *= s[i + 1] - '0';
        }
    }

    if (b == a1 && b != a2) {
        cout << "M" << endl;
    }
    if (b != a1 && b == a2) {
        cout << "L" << endl;
    }
    if (b == a1 && b == a2) {
        cout << "U" << endl;
    }
    if (b != a1 && b != a2) {
        cout << "I" << endl;
    }

}

Measured memory_bytes: 3216
import sys
from collections import deque
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = IL()
ab = [IL() for i in range(N)]
cd = [IL() for i in range(M)]

for a,b in ab:
  ans = ""
  num = MAX_INT
  for i in range(M):
    tmp = abs(a-cd[i][0]) + abs(b-cd[i][1])
    if tmp < num:
      ans = i+1
      num = tmp
  print(ans)

Measured memory_bytes: 39280
#include <cstdlib>

#include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI = 3.1415926535897932;

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;
}

int main()
{
	int N;
	cin >> N;
	const ll INF = (int)1e10;
	vector<ll> h(N, 0);
	rep(i, N) cin >> h[i];

	vector<ll> dp(N, INF);

	dp[0] = 0;
	for (int i = 1; i < N; ++i) {
		chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}

	cout << dp[N-1] << endl;
	return 0;
}

Measured memory_bytes: 4836
// ~maqsat~
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n";
#define TEZ ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout);
 
using namespace std;
using namespace __gnu_pbds;
 
using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef vector<int> vi;
typedef vector<ll> vl;
 
template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T, class U> inline void cmin(T &a, U b) { a = min(a, b); }
template <class T, class U> inline void cmax(T &a, U b) { a = max(a, b); }
template <class T, class U, class X, class Y> inline void psmn(T &a, U b, X &p, Y i) { if(b < a)a = b,p = i; }
template <class T, class U, class X, class Y> inline void psmx(T &a, U b, X &p, Y i) { if(b > a)a = b,p = i; }
 
const int oo = 0x3f3f3f3f;
const ll N = 1e5 + 345;
const ll MOD = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846

ll cnt[30]; 
int main() {
	fre(""); TEZ;

	string s;
	cin >> s;
	ll n = sz(s);

	for(ll i = 0; i < n; i++) cnt[ll(s[i]-'a')]++;
	ll temp = 0;
	for(ll i = 0; i < 26; i++) {
		ll x = cnt[i] - 1, y = cnt[i];
		if(x & 1ll) y /= 2;
		else x /= 2;
		temp += (x * y);
	}
	ll ans = n - 1;
	if(n & 1ll) ans /= 2;
	else n /= 2;
	cout << (ans * n) - temp + 1ll;

	return 0;
}


Measured memory_bytes: 720
import java.util.Scanner;
import java.util.stream.Stream;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long[] nums = Stream.of(sc.nextLine().split(" ")).mapToLong(Long::parseLong).toArray();
    long w = nums[0];
    long h = nums[1];
    long x = nums[2];
    long y = nums[3];
    double max = w * h / 2.0;
    boolean isMulti = x + x == w && y + y == h;
    StringBuilder sb = new StringBuilder();
    sb.append(max);
    sb.append(" ");
    sb.append(isMulti ? 1 : 0);
    System.out.print(sb.toString());
  }
}

Measured memory_bytes: 27092
N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
a, c, cnt = 0, 0, 0
for b in B:
  while a < N and A[a] < b:
    a += 1
  while c < N and C[c] <= b:
    c += 1
  cnt += a * (N - c)
print(cnt)


Measured memory_bytes: 24096
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(a,i,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);	
}
int main()
{
//	fopen();
	int n,m;
	cin>>n>>m;
	vector<string>v[n];
	rep(i,m)
	{
		int p;string q;
		cin>>p>>q;
		v[p-1].pb(q);
	}
	int a=0,b=0;
	rep(i,n)
	{
		int f=0;
		int k=0;
		itr(x,v[i])
		{
			if(*x=="AC")
			{
				a+=1;f=1;break;
				
			}
			k+=1;
		}
		if(f==1){b+=k;}

	}
	cout<<a<<" "<<b;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
const int MAXN = 100005;

int main(){
	int p[4] = {0, 4, 6, 8};
	string s = "AKIHABARA";
	set<string> x;
	for(int i=0; i<16; i++){
		vector<int> v;
		v.push_back(-1);
		for(int j=0; j<4; j++){
			if((i >> j) & 1) v.push_back(p[j]);
		}
		v.push_back(9);
		string t;
		for(int j=0; j<v.size()-1; j++){
			for(int k=v[j] + 1; k<v[j+1]; k++){
				t.push_back(s[k]);
			}
		}
		x.insert(t);
	}
	string y;
	cin >> y;
	cout << (x.find(y) == x.end() ? "NO" : "YES") << endl;
}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}


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

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

void y() {
    cout << "Yes" << endl;
    exit(0);
}

void n() {
    cout << "No" << endl;
    exit(0);
}

void Y() {
    cout << "YES" << endl;
    exit(0);
}

void N() {
    cout << "NO" << endl;
    exit(0);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}

/*   kokomade  */

int cnt = 0;
bool is_prime[ 50000 + 1 ];
vector<int> P;
void Eratosthenes( const int N )
{
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;//初期化
    }
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
}

int main() {
    IOS;
    //int n,x,t;cin>>n>>x>>t;
    // int a,b,c;cin>>a>>b>>c;
    // string str;cin>>str;
    //vector<int> l(n);
    // vector<string> s(n);
    Int n,T;
    cin>>n>>T;
    vector<Int> t(n);
    for (int j = 0; j < n; ++j) {
        cin>>t[j];
    }
    Int ans=T,cnt=1,next;
    for (int i = 0; i < n-1; ++i) {
        if(t[i+1]-t[i]>T)ans+=T;
        else ans+=t[i+1]-t[i];
    }
    cout<<ans;



    cout<<endl;
    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 1792
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        Map<Integer, int[]> map = new TreeMap<>();
        for (int i = 0; i < m; i++) {
            int a = Integer.parseInt(sc.next());
            int[] ary = new int[2];
            ary[0] = a;
            ary[1] = i;
            int b = Integer.parseInt(sc.next());
            map.put(b, ary);
        }
        String[] ans = new String[m];
        int[] pary = new int[n];
        for (int[] num : map.values()) {
            pary[num[0] - 1]++;
            ans[num[1]] = String.format("%06d%06d", num[0], pary[num[0] - 1]);
        }
        StringBuilder sb = new StringBuilder();
        for (String s: ans) {
            sb.append(s + "\n");
        }
        System.out.println(sb.toString());
    }
}

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

#define DBG(a)	cerr << #a << " = " << a << endl;

int main(){
	int n;	cin >> n;
	map<int, int> mp;
	for (int i = 0; i < n; ++i){
		int a;	cin >> a;
		if(mp[a] == 1){
			cout << "NO" << endl;
			return 0;
		}	
		mp[a] = 1;
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 9600
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
class UnionFind{
 public:
  vector<int> nodes;
  UnionFind(int n):nodes(n){
    for(int i = 0;i < n;i++){
      nodes[i] = i;
    }
  }
  int root(int x){
    if(x == nodes[x])return x;
    return nodes[x] = root(nodes[x]);
  }
  void merge(int x,int y){
    nodes[root(x)] = root(y);
  }
  bool sameUnion(int x,int y){
    return root(x) == root(y);
  }
  
};
struct edge{
  edge(int x,int y):x(x),y(y){}
  int x,y;
};
bool operator<(edge e1,edge e2){
  if(e1.x == e2.x)return e1.y < e2.y;
  return e1.x < e2.x;
}
int main(){
  int v,e;
  cin >> v >> e;
  vector<pair<int,edge> > edges;
  UnionFind u(v);
  for(int i = 0;i < e;i++){
    int s,t,w;
    cin >> s >> t >> w;
    edges.push_back(make_pair(w,edge(s,t)));
  }
  sort(edges.begin(),edges.end());
  int weight = 0;
  for(int i = 0;i < edges.size();i++){
    int w = edges[i].first;
    edge e = edges[i].second;
    if(u.root(e.x) != u.root(e.y)){
      weight += w;
      u.merge(e.x,e.y);
    }
  }
  cout << weight << endl;
}

Measured memory_bytes: 2736
#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>

int main (){
	int N, K, Q;
	scanf("%d", &N);
	scanf("%d", &K);
	scanf("%d", &Q);
	std::vector<int> A;
	A.resize(N);
	int temp;
	for (int i=0; i<Q; i++){
		scanf("%d", &temp);
		temp--;
		A[temp]++;
	}
	for (int i=0; i<N; i++){
		if (K-(Q-A[i])>0){
			printf("Yes\n");
		} else {
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using ll = long long;
using P = pair<long long, long long>;
using MATRIX = vector< vector<ll> >;
template <class T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <class T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}

const long long MOD = 1000000007;

const long long MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (long long i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(long long n, long long k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  COMinit();
  long long S;
  cin >> S;
  long long x = S;
  long long ans = 0;
  for(long long k = 1; S - 3 * k >= 0; k++) {
    ans += COM(S - 2 * k - 1, k - 1);
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 15588
#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() {
    ll n,d,ans = 0;
    cin >> n >> d;
    vector<vector<long long>> data(n, vector<long long>(2));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 2; j++) {
            cin >> data.at(i).at(j);
        }
    }
    rep(i,n){
        if((abs(data.at(i).at(0))*abs(data.at(i).at(0)) + abs(data.at(i).at(1))*abs(data.at(i).at(1)))<=d*d){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 14024
#include<iostream>
#include<climits>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<functional>
#include<stack>
#include<list>
#include<string>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define PII pair<int,int>
#define PCC pair<char,char>
#define PCI pair<char,int>
#define PIC pair<int,char>
#define MP make_pair
#define DEBUG(x) cout<<#x<<": "<<x<<endl

int main()
{
	while (1)
	{
		vector<int> N;
		int n, r;
		cin >> n >> r;
		for(int i=1;i<=n;i++)N.push_back(i);
		if (n == 0)break;
		REP(i, r)
		{
			int p, c;
			cin >> p >> c;
			for(int l=c;l>0;l--)
			{
				int k = n - p -c+1 ;
				int temp = *(N.begin() + k);
				N.push_back(temp);
				N.erase(N.begin() + k);
			}
		}
		cout << N[n-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 3108
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)
const int INF = (1<<30);
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

class HOGE{
  public:
    ll index;
    ll value;
    HOGE(ll index, ll value){
      this->index = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "index : " << index << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, M;
  cin >> N;
  cin >> M;
  vector<ll> A(N), B(M);
  ll D = 1;
  for(int i=0; i<9; ++i){
    D*=10;
  }
  D+=7;
  for(int i=0; i<N; ++i){
    cin >> A[i];
  }
  for(int i=0; i<M; ++i){
    cin >> B[i];
  }

  sort(A.begin(), A.end());
  sort(B.begin(), B.end());

  ll ans=1;

  /*
  printf("%d\n", N*M);
  for(int i=0; i<N; ++i){
    printf("%d ", A[i]);
  }
  printf("\n");
  for(int i=0; i<M; ++i){
    printf("%d ", B[i]);
  }
  printf("\n");
  */

  ll x=N-1;
  ll y=M-1;
  ll left=0;
  ll x_left=0;
  ll y_left=0;
  for(int i=0; i<N*M; ++i){
    //printf("%d, %d, %d, %d, %d, %d : %d\n", i, left, x, y, x_left, y_left, ans);
    if(A[x] == N*M-i && B[y] == N*M-i && x>=0 && y>=0){
      //printf("hoge0\n");
      left += x_left;
      left += y_left;
      x--;
      y--;
      x_left = (N-x-1);
      y_left = (M-y-1);
    }else if(A[x]==N*M-i && x>=0){
      //printf("hoge1\n");
      ans*=y_left;
      ans%=D;
      left += y_left-1;
      x--;
      x_left = (N-x-1);
      y_left = (M-y-1);
    }else if(B[y]==N*M-i && y>=0){
      //printf("hoge2\n");
      ans*=x_left;
      ans%=D;
      left += x_left-1;
      y--;
      x_left = (N-x-1);
      y_left = (M-y-1);
    }else{
      //printf("hoge3\n");
      ans*=left;
      ans%=D;
      left -= 1;
    }
  }

  if(ans<0){
    printf("0\n");
    return 0;
  }

  printf("%d\n", ans%D);

  return 0;
}

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

int main() {
	int N;
  	cin >> N;
 
  	int start, end, output;
  
  	for(int n_loop = 0; n_loop<N; n_loop++){
  	
     cin >> start >> end;
     output += end - start + 1;
      
    }
  	cout << output << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N = 2*10**5
g1 = [1, 1]
g2 = [1, 1]
inv = [0, 1]

for i in range(2, N+1):
    g1.append((g1[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD//i)) % MOD)
    g2.append((g2[-1] * inv[-1]) % MOD)

def solve(N: int, M: int, K: int):
    ans = 0
    for i in range(1, M):
        ans += i * N**2 * (M-i)
        ans %= MOD
    for i in range(1, N):
        ans += i * M**2 * (N-i)
        ans %= MOD
    ans *= cmb(N*M-2, K-2, MOD)
    ans %= MOD
    print(ans)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, M, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 28872
import java.util.Scanner;

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

        int X = sc.nextInt();
        int t = sc.nextInt();

        System.out.println(solve(X, t));

        sc.close();
    }

    static int solve(int X, int t) {
        return Math.max(0, X - t);
    }
}

Measured memory_bytes: 22612
x,y = map(int, input().split())
a = 0
b = 0
if x>y:
  while x>y:
    x-=2
    y-=1
    a+=1
if x<y:
  while x<y:
    x-=1
    y-=2
    b+=1
if x == y and x%3==0:
    a+=x//3
    b+=y//3
else:
  print(0)
  exit(0)
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

print(cmb(a+b,b,mod))

Measured memory_bytes: 127564
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main(){
    int a,b,c;
    int ans=0;
    cin >> a >> b >> c;
    for(int i=a;i<=b;i++){
        if(c%i == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1164
#ifdef __GNUC__
#include <bits/stdc++.h>
#endif // __GNUC_

int main() {

    int N;
    std::cin >> N;
    int count = 0;
    int64_t min = INT64_MAX;
    int64_t sum = 0;
    for (int i = 0; i < N; ++i) {
        int64_t A;
        std::cin >> A;
        if (A <= 0)++count;
        min = std::min(min, std::abs(A));
        sum += abs(A);
    }

    std::cout << sum - (count % 2 ? min * 2 : 0) << std::endl;

}

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

using namespace std;

typedef long long ll;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"

int f[4];

int main () {
    ios::sync_with_stdio (false);
    cin.tie (0); cout.tie (0);
    int a, b;
    cin >> a >> b;
    f[a]++;
    f[b]++;
    for (int i = 1; i <= 3; i++)
    if (!f[i]) {
        cout << i;
        return 0;
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) {}
  bool unionSet(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) { return root(x) == root(y); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  int size(int x) { return -data[root(x)]; }
};

int main() {
  int N, M;
  while (cin >> N >> M) {
    UnionFind uf(N + M);
    for (int i = 0; i < N; i++) {
      int K;
      cin >> K;
      for (int j = 0; j < K; j++) {
        int L;
        cin >> L;
        --L;
        uf.unionSet(i, N + L);
      }
    }
    bool res = true;
    for (int i = 1; i < N; i++) res &= uf.findSet(0, i);
    cout << (res ? "YES" : "NO") << endl;
  }
  return 0;
}


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

int main(){
    int n,flg;
    cin>>n;
    flg=0;

    string w[100];
    for(int i=0;i<n;i++){
        cin>>w[i];
    }/*

    for(int i=0;i<n;i++){
        cout<<w[i]<<"\n";
    }
    */
   
    for(int i=0;i<n;i++){
        for(int j=0;j<i;j++){
            if(w[j]==w[i]){
                flg=1;
            }
        }
    }
    // cout<<"checked same words flg=="<<flg<<"\n";
    for(int i=0;i<n-1;i++){
        if(w[i].back()!=w[i+1][0]){
            //cout<<"w["<<i<<"].back()="<<w[i].back()<<" w["<<i+1<<"][0]="<<w[i+1][0]<<"\n";
            flg=1;
        }
    }
    //cout<<"checked chain words flg=="<<flg<<"\n";
    

    if(flg==0){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }

}

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

int main() {
  int a;
  int b;

  cin >> a;
  cin >> b;

 int ans;
  ans = a * b;

  if (ans % 2 == 0 ) {
    std::cout << "Even" << '\n';
  } else {
    std::cout << "Odd" << '\n';
  }
}

Measured memory_bytes: 256
n, m = map(int, input().split())

x = list(map(int, input().split()))

y = sorted(x)

l = [0] * (m-1)

for i in range(0,m-1):
    l[i] = y[i+1] - y[i]

ll = sorted(l)

s = 0

for i in range(0,m-n):
    s = s + ll[i]

print(s)

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

int main() {
  int N; cin >> N;
  vector<int>A(N);
  for(int i=0; i<N; i++)cin >> A.at(i);
  
  sort(A.begin(), A.end());
  
  int ans=N;
  int64_t ookisa = A.at(0);
  int count =1;
  for(int i=1; i<N; i++){
    if(ookisa *2 >=A.at(i)){
      ookisa += A.at(i);
      count ++;
    }
    else{
      ans -= count;
      count =1;
      ookisa +=A.at(i);
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

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

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int  x;
    cin >> x;
    cout << !x << '\n';
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
int digits_sum(int n){
  int sum = 0;
  while(n>0){
    sum = sum + n%10;
    n = n/10;
  }
  return sum;
}
int main(){
  int n = 0;
  scanf("%d",&n);
  int i = 0;
  int min = digits_sum(1)+digits_sum(n-1);
  int tmp = 0;
  for(i=2;i<=n/2;i++){
    tmp=digits_sum(i)+digits_sum(n-i);
    if(tmp<min){
      min = tmp;
    }
  }
  printf("%d\n",min);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{
  int x,s,t;
  
  scanf("%d",&x);
  
  s=x/500;
  x=x-500*s;
  
  t=x/5;
  x=x-5*t;
  
  printf("%d",1000*s+5*t);
  
  return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    int ans = 0;

    if (s[0] == 'S' && s[1] == 'S' && s[2] == 'S') {
        cout << 0 << endl;
    } else if (((s[0] == 'R' || s[2] == 'R') && s[1] != 'R') || (s[1] == 'R' && s[0] != 'R' && s[2] != 'R')) {
        cout << 1 << endl;
    } else if ((s[0] == 'R' && s[1] == 'R' && s[2] != 'R') || (s[0] != 'R' && s[1] == 'R' && s[2] == 'R')) {
        cout << 2 << endl;
    } else if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R') {
        cout << 3 << endl;
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include<math.h>
using namespace std;
 
int main()
{
 long long A,B,N,x,y,max=0;
 cin>>A>>B>>N;
 if(B-1<=N){
     x=B-1;
          y=floor((A*x)/B)-A*floor(x/B);
     if(y>max){
         max=y;
 }
 }
 if(floor(B/A)+1<=N){
     x=floor(B/A)+1;
      y=floor((A*x)/B)-A*floor(x/B);
     if(y>max){
         max=y;
 }
 }
 x=N-1;
      y=floor((A*x)/B)-A*floor(x/B);
     if(y>max){
         max=y;
     }
     x=N;
        y=floor((A*x)/B)-A*floor(x/B);
     if(y>max){
         max=y;
     }
 cout<<max<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,m,v,p;
int a[MAXN];
bool check(int id)
{
    if(id<=p) return true;
    if(a[id]+m<a[p]) return false;
    ll s=1LL*(n-id+1)*m;
    for(int i=1;i<id;i++)
    {
        if(i<=p-1) s+=m;
        else s+=(a[id]+m-a[i]);
    }
    return s>=1LL*m*v;
}
int main()
{
    scanf("%d%d%d%d",&n,&m,&v,&p);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+n+1,greater<int>());
    int l=0,r=n+1;
    while(r-l>1)
    {
        int mid=(l+r)/2;
        if(check(mid)) l=mid; else r=mid;
    }
    printf("%d\n",l);
}

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

public class Main {
final static int INF=(int) 1e9;
static int []w;
static int []v;
static long memo[][];
static int n;
	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		int maxw=sc.nextInt();
		v=new int[n+1];
		w=new int[n+1];
		memo=new long[maxw+1][n+1];
		for(int i=0;i<=maxw;i++)
			Arrays.fill(memo[i],-1);
		for(int i=0;i<n;i++ ) {
			w[i]=sc.nextInt();
			v[i]=sc.nextInt();
		}
		
		System.out.println(dp(maxw,0));
		
	}
	public static long dp(int remw,int idx) {
		if(remw<0) {
			return -INF;
		}
		if(remw==0||idx==n) {
			return 0;
		}
		if(memo[remw][idx]!=-1)
			return memo[remw][idx];
		
		return memo[remw][idx]=Math.max(dp(remw-w[idx],idx+1)+v[idx],dp(remw,idx+1));
	}

}


Measured memory_bytes: 128724
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
using namespace std;

bool isss(string s) {
	string a, b;
	for (int i = 0; i < s.size(); i++) {
		if (i < s.size() / 2)a.push_back(s[i]);
		else b.push_back(s[i]);
	}
	return a == b;
}
int main() {
	string s;
	cin >> s;
	while (s.size()) {
		s.pop_back();
		s.pop_back();
		if (isss(s)) {
			cout << s.size() << endl;;
			return 0;
		}
	}
	cout << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(x) cerr<<(#x)<<": "<<(x)<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

int n;
string s;
vector<int> g[2000];

// using P = pair<int,int>; // <sum, cnt>


struct P
{
    int l, r, cnt;
};

P dfs(int cur, int par){
    int r_sum = 0, cnt = 0;
    pair<int,int> lmax = {0,0};
    for (int to : g[cur]) {
        if (par == to) continue;
        P ch = dfs(to, cur);
        r_sum += ch.r;
        cnt += ch.cnt;
        lmax = max(lmax, pair<int,int>{ch.l, -ch.r});
    }
    if (s[cur] == '1') {
        cnt++;
    }
    return {
        max(0,lmax.first - (r_sum - (-lmax.second))) + cnt,
        r_sum + cnt, cnt
    };
}

int main(void){
    cin >> n >> s;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int res = INF;
    rep(root, n){
        P p = dfs(root, -1);
        if (p.l == p.cnt && (p.r - p.cnt)%2 == 0) {
            res = min(res, (p.r - p.cnt)/2);
        }
    }
    cout << (res < INF ? res : -1) << endl;

    return 0;
}


Measured memory_bytes: 640
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty |) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty | $n:expr) => {
        (0..$n).map(|_| get!($t |)).collect::<Vec<_>>()
    };
}
macro_rules! tern {
    ($condition: expr, $_true: expr, $_false: expr) => {
        if $condition {
            $_true
        } else {
            $_false
        }
    };
}

fn main() {
    let N = get!(usize);
    let Hs = get!(u64 | );

    let mut dp = vec![0; N+1];
    for i in 2..(N+1) {
        let H = Hs[i-1];
        let Hprev = Hs[i-2];
        if Hprev >= H {
            dp[i] = dp[i-1] + 1
        } else {
            dp[i] = 0
        }
    }
    println!("{}", dp.iter().max().unwrap());
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  ll n,k;cin>>n>>k;
  ll ans=k;
  if(n==1){
    P(k);
  }else{
    while(n>1){
      ans*=(k-1);
      n--;
    }
    P(ans);
  }
  return 0;
}


Measured memory_bytes: 512
fun main(args: Array<String>) {

    val n = readLine()!!.toInt()
    val p = (1..n).map { readLine()!!.toInt() }

    val sortedList = p.sortedDescending()
    var ans = sortedList.first() / 2

    val remain = sortedList.drop(1)

    ans += remain.sum()
    println(ans)
}

Measured memory_bytes: 36120
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
	int n, k;
	int i, j;
	double sum = 0.0;
	int num;
	double count;
	
	scanf("%d%d", &n, &k);
	
	for(i = 1; i <= n; i++) {
		num = i;
		count = 1.0 / n;
		while(1) {
			if(num >= k) {
				break;
			}
			num *= 2;
			count /= 2.0;
		}
		sum += count;
	}
	
	printf("%.12lf\n", sum);
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

// 深さ優先探索
int ans = 0;
vector<bool> seen;
void dfs(const Graph& G, int v, int& ans) {
    seen[v] = true; // v を訪問済にする

    bool end = true;
    for (int i = 0; i < seen.size(); i++) {
        if (i == v) continue;
        if (!seen[i]) end = false;
    }
    if (end) {
        ans++;
        seen[v] = false;
        return;
    }
    
    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) {
        if (seen[next_v]) {
            continue; // next_v が探索済だったらスルー
        }
        dfs(G, next_v, ans); // 再帰的に探索        
    }

    seen[v] = false;
}

int main() {

    // 頂点数と辺数
    int N, M; cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int ans = 0;

    // 頂点 s をスタートとした探索
    seen.assign(N, false); // 全頂点を「未訪問」に初期化
    dfs(G, 0, ans);
	
    cout << ans << endl;
	return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;

  string s = "";
  char tmp;
  for (int i = 0; i < H; i++) {
    s.clear();
    for (int j = 0; j < W; j++) {
      cin >> tmp;
      s.push_back(tmp);
    }
    cout << s << endl << s << endl;
  }
  return 0;
}

Measured memory_bytes: 3600
import java.util.*;

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

                int result=0;
                boolean flag = false;
                for(int i = 0; i < 3; i++){
                        if(str.charAt(i) == 'R'){
                                result++;
                                flag = true;
                        }
                        else{
                                if(flag == true) break;
                        }
                }

                System.out.println(result);
        }
}


Measured memory_bytes: 35716
#include<stdio.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define PRN(n) printf("%d\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)

int main(void){
  int n,a;
  double ans=0;
  scanf("%d",&n);
  FOR(n){
    scanf("%d",&a);
    ans+=1.0/a;
  }
  printf("%.10lf\n",1.0/ans);
  return 0;
}

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

bridge = []
for i in range(1, N):
    for j in range(i + 1, N + 1):
        if(N % 2 == 0):
            if(i + j == N + 1):
#                print("skip = [{}, {}]".format(i,j))
                continue
        else:
            if(i + j == N):
#                print("skip = [{}, {}]".format(i,j))
                continue
        bridge.append([i, j])

print(str(len(bridge)))
for i in bridge:
    print(" ".join(map(str, i)))


Measured memory_bytes: 3828
#define _GLIBCXX_DEBUG
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 0) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N;
  std::cin >> N;
  std::vector< ll > va(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
  }

  ll x = *std::max_element(va.begin(), va.end());
  ll y = *std::min_element(va.begin(), va.end());
  print(x-y);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

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

int main(){
    int a,b; cin >> a >> b;
    if(a < 10 && b < 10)cout << a*b << endl;
    else cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
set<string> c;
const ll inf=(1e18);
const ll mod=1000000007;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
map<ll,P> mp;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
  int h,w,d;
  cin>>h>>w>>d;
  vector<vector<ll>> a(h,vector<ll>(w));
  for(int i=0;i<h;i++)for(int j=0;j<w;j++){
      cin>>a[i][j];
      mp[a[i][j]]=P(i,j);
  }
  vector<ll> sum(h*w+1,0);
  for(int i=1;i<=h*w;i++){
      if(i+d>h*w)continue;
      ll cost=abs(mp[i+d].fi-mp[i].fi)+abs(mp[i+d].se-mp[i].se);
      sum[i+d]=sum[i]+cost;
  }
  int q;cin>>q;
  while(q--){
      int l,r;cin>>l>>r;
      cout<<sum[r]-sum[l]<<endl;
  }
}


Measured memory_bytes: 8192
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
  int n;
  cin >> n;
  double sum=0;
  rep(i, n) {
    double a;
    cin >> a;
    sum += 1/a;
  }
  sum = 1/sum;

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	int box[100001];
	int i;
	int x;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>x;
		box[x]=i;
	}
	for(i=1;i<=n;i++)	cout<<box[i]<<endl;
	return 0;
}

Measured memory_bytes: 1152