akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const long long mod = 1e9+7;
long long power(long long a, long long b, long long m = mod) {
    if(b < 0) {
        return power(power(a, -b), mod-2);
    }
    long long x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
const int N = 3e5+9;
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    string s, t; cin >> s >> t;
    if(s + t.back() == t) {
        cout << "Yes\n";
    } else cout << "No\n";
    




    return 0;
    
}


Measured memory_bytes: 3608
n, m = map(int, input().split())
# どの問題を正解したかのリストをつくる
ac = [0 for _ in range(n)]
pen = [0 for _ in range(n)]

for _ in range(m):
  p, s = input().split()
  p = int(p) - 1
  if s == 'WA':
    if ac[p] == 0:
      pen[p] += 1
  else:
    ac[p] = 1
# ここまでで、ACしていな問題のWAをカウントしてしまっているので、除外する
for p in range(n):
  if ac[p] == 0:
    pen[p] = 0
print(str(sum(ac)) + ' ' + str(sum(pen)))

Measured memory_bytes: 4656
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);

vector<int> prod_perm(const vector<int>&a, const vector<int> &b) {
	//bに置換aを実行して返す。
	//すなわち、[0..N]→a になるような置換"→"によって、
	//b→ansとなるようなansを求めて返す。

	assert(a.size() == b.size());

	vector<int>ans(b.size());
	rep(i, b.size())ans[i] = b[a[i]];
	return ans;
}

vector<int> pow_perm(const vector<int>&perm, const int K) {
	//置換permのK乗を返す。
	
	if (K == 0) {
		vector<int>ans(K - 1);
		rep(i, ans.size())ans[i] = i;
		return ans;
	}
	if (K == 1)return perm;

	vector<int>half = pow_perm(perm, K / 2);

	if (K % 2 == 0)return prod_perm(half, half);
	else return prod_perm(prod_perm(half, half), perm);
}

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

	int N, M, K;
	cin >> N;
	vector<int>x(N);
	rep(i, N)cin >> x[i];
	cin >> M >> K;
	vector<int>a(M);
	rep(i, M)cin >> a[i];

	vector<int>perm(N - 1);
	rep(i, N - 1)perm[i] = i;
	rep(i, M)swap(perm[a[i] - 2], perm[a[i] - 1]);
	auto permK = pow_perm(perm, K);

	vector<int>dx(N - 1);
	rep(i, N - 1)dx[i] = x[i + 1] - x[i];

	int ans = x[0];
	rep(i, N - 1) {
		cout << ans << endl;
		ans += dx[permK[i]];
	}
	cout << ans << endl;


	return 0;
}

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


using namespace std;
using ll = long long;


int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  ll res = 0;
  for(auto& x : a) {
    cin >> x;
    res ^= x;
  }
  for(auto x : a) {
    cout << (res ^ x) << " ";
  }
  cout << "\n";

    



  return 0;
}



Measured memory_bytes: 4812
import java.util.PriorityQueue;
import java.util.Scanner;

//Icicles
public class Main{

	class R implements Comparable<R>{
		int i, x;
		public R(int i, int x) {
			this.i = i;
			this.x = x;
		}
		public int compareTo(R o) {
			return o.x-x;
		}
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int L = sc.nextInt();
		int[] a = new int[n+2];
		PriorityQueue<R> q = new PriorityQueue<R>();
		for(int i=1;i<=n;i++){
			a[i]=sc.nextInt();
			q.add(new R(i, a[i]));
		}
		long[] t = new long[n+2];
		long max = 0;
		while(!q.isEmpty()){
			R r = q.poll();
			t[r.i] = L-r.x+Math.max(t[r.i-1], t[r.i+1]);
			max = Math.max(max, t[r.i]);
		}
		System.out.println(max);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 17000
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	X := readI()

	ans := 0
	for X/500 != 0 {
		ans += 1000
		X -= 500
	}
	for X/5 != 0 {
		ans += 5
		X -= 5
	}
	fmt.Println(ans)
}

/*-----------Utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}


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



class list {
public:
    int val;
    list* prev;
    list* next;
};
list* nil;
void initialize()
{
    nil = new list;
    nil->prev = nil;
    nil->next = nil;
}

void insert_(int val)
{
    list* p = new list;
    p->val = val;
    p->prev = nil;
    p->next = nil->next;
    p->next->prev = p;
    p->prev->next = p;
}

void delete_(int val)
{
    for (list* p = nil->next; p != nil; p = p->next) {
        if (p->val == val) {
            p->prev->next = p->next;
            p->next->prev = p->prev;
            delete p;
            return;
        }
    }
}

void deleteFirst()
{
    list* p = nil->next;
    p->prev->next = p->next;
    p->next->prev = p->prev;
    delete p;
}

void deleteLast()
{
    list* p = nil->prev;
    p->prev->next = p->next;
    p->next->prev = p->prev;
    delete p;
}

void trace()
{
    for (list* p = nil->next; p != nil; p = p->next) {
        cout << p->val;
        if (p->next != nil) {
            cout << " ";
        } else {
            cout << "\n";
        }
    }
}

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

    list* head;

    for (int i = 0; i < n; i++) {
        string command;
        cin >> command;
        if (command == "deleteFirst") {
            deleteFirst();
            continue;
        }
        if (command == "deleteLast") {
            deleteLast();
            continue;
        }
        int val;
        cin >> val;
        if (command == "insert") {
            insert_(val);
        } else {
            delete_(val);
        }
    }
    trace();
}

Measured memory_bytes: 34356
#include<bits/stdc++.h>
#define sag (root+root+1)
#define sol (root+root)
#define ort  ((bas+son)/2)
#define mod 1000000007

using namespace std;
typedef long long ll;
ll fac_arr[200005];
ll exponentiation(ll base, ll exp) 
{ 
    ll t = 1; 
    while (exp > 0)  
    { 
        //cout << exp << endl;
        
        if (exp % 2 != 0) 
            t = (t * base) % mod; 
  
        base = (base * base) % mod; 
        exp /= 2; 
        //cout << exp << endl;
        //cout << base << endl;
    } 
    //cout << t << endl;
    //cout << base << endl;
    return t % mod; 
} 

ll comb(ll x, ll y){
    ll ans = 1;
    //for(int i=0;i<y;i++) ans = (ans*(x-i))%mod;
    ll bol = (exponentiation (fac_arr[y], mod-2) ) ;
    ll bol2 = (exponentiation(fac_arr[x-y], mod-2));

    
    ans = (fac_arr[x]*bol) % mod;
    ans = (ans*bol2) % mod;
    return ans;
}

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    
    fac_arr[0] = 1;
    for(int i=1; i<=n; i++) fac_arr[i]= (i*fac_arr[i-1]) % mod;
    k = min(k, n-1);
    for(int i=1; i<=k; i++){
        ans = (ans+ (comb(n,i)*comb(n-1,n-i-1)) % mod) % mod;
        //cout << "test" << endl;
    }
            
        
    ans++;
    cout << ans % mod ;
    return 0;
}

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

    int N = sc.nextInt();

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

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
using ll =long long;

int main() {
	ll X, A, B;

	cin >>X>> A>>B;
	if (B <=A) {

		cout << "delicious";

	}
	else if (X+A<B) {

		cout << "dangerous";
	}
	else {
		cout << "safe";

	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
struct UnionFind{
  int n,num;
  vector<int> r,p,e;
  UnionFind(){}
  UnionFind(int sz):n(sz),num(sz),e(sz,0),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
  int find(int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) {e[x]++;return;}
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];e[x]+=e[y]+1;
    p[y]=x;
    num--;
  }
  int size(int x){  //頂点数
    return r[find(x)];
  }
  int size2(int x){  //辺の数
    return e[find(x)];
  }
  int count() const{
    return num;
  }
};
//main
signed main(){
  int N,H,W;cin>>N>>H>>W;
  typedef pair<int,int> P;
  typedef pair<int,P> PP;
  priority_queue<PP> que;
  for(int i=0;i<N;i++){
    int r,c,a;cin>>r>>c>>a;r--;c--;
    que.push(PP(a,P(r,c+100000)));
  }
  int ans=0;
  UnionFind uf(200000);
  while(que.size()){
    PP p=que.top();que.pop();
    int a=p.first,u=p.second.first,v=p.second.second;
    if(uf.same(u,v)){
      if(uf.size2(u)<uf.size(v)){
        uf.unite(u,v);
        ans+=a;
      }
    }
    else{
      int p=uf.size(u)+uf.size(v);
      int e=uf.size2(u)+uf.size2(v);
      if(e<p){
        uf.unite(u,v);
        ans+=a;
      }
    }
  }
  cout<<ans<<endl;
}


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

_sum = N * (1+N)/2

if N >= 3:
  _min = 3
  _max = 3 * (N // 3)
  num = (_max - _min) / 3 + 1
  _sum -= num*(_min+_max)/2

if N >= 5:
  _min = 5
  _max = 5 * (N // 5)
  num = (_max - _min) / 5 + 1
  _sum -= num*(_min+_max)/2

if N >= 15:
  _min = 15
  _max = 15 * (N // 15)
  num = (_max - _min) / 15 + 1
  _sum += num*(_min+_max)/2

print(int(_sum))

Measured memory_bytes: 9216
import java.util.*

fun main(args : Array<String>) {
    val (h, w) = readLine()!!.split(" ").map { it.toInt() }
    val c = readLine()!!.split(" ").map { it.toInt()-1 }
    val d = readLine()!!.split(" ").map { it.toInt()-1 }
    val ss = Array(h) { readLine()!! }

    val seen = Array(h) { IntArray(w) {-1} }
    val bfs = PriorityQueue<Step>(){ s1, s2 ->
        return@PriorityQueue s1.warp - s2.warp
    }

    bfs.add(Step(c[0], c[1], 0))
    seen[c[0]][c[1]] = 0

    while (bfs.isNotEmpty()) {
        val step = bfs.poll()
        if (seen[step.h][step.w] < step.warp) continue

        if (step.h == d[0] && step.w == d[1]) {
            println(step.warp)
            return
        }

        val hs = Math.max(step.h-2, 0)
        val he = Math.min(step.h+2, h-1)
        val ws = Math.max(step.w-2, 0)
        val we = Math.min(step.w+2, w-1)

        for (i in hs..he) {
            for (j in ws..we) {
                if (ss[i][j] == '.') {
                    if ((i == step.h-1 && j == step.w) || (i == step.h+1 && j == step.w) ||
                        (i == step.h && j == step.w-1) || (i == step.h && j == step.w+1)) {
                        if (seen[i][j] == -1 || seen[i][j] > step.warp) {
                            bfs.add(Step(i, j, step.warp))
                            seen[i][j] = step.warp
                        }
                    } else if (seen[i][j] == -1 || seen[i][j] > step.warp+1) {
                        bfs.add(Step(i, j, step.warp+1))
                        seen[i][j] = step.warp+1
                    }
                }
            }
        }
    }

    println(-1)
}

data class Step(val h: Int, val w: Int, val warp: Int)

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

int a[31];

int main(){
	int n,m,k,x,ans=0;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		scanf("%d",&k);
		while(k--)	scanf("%d",&x),++a[x];
	}
	for(int i=1;i<=m;i++)
		if(a[i]==n)	++ans;
	cout<<ans<<endl;
	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;

int main()
{
    string s;
    cin >> s;
    int n = s.length();
    bool flag=true;
    for (int i=0; i < (n-1)/4; i++) {
        if (s[i] == s[(n-1)/2 - 1 - i]) continue;
        else {
            flag = false;
            break;
        }
    }
    for (int j=(n+3)/2-1; j < 3*(n+1)/4; j++) {
        if (s[j] == s[n-1-j]) continue;
        else {
            flag = false;
            break;
        }
    }
    for (int k=0; k < n/2; k++) {
        if (s[k] == s[n-1-k]) continue;
        else {
            flag = false;
            break;
        }
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int main() {
    int A;
    int jg5=0,jg7=0;
    for(int i=0;i<3;i++){
        cin >> A;
        if(A==5) jg5++;
        else if(A==7) jg7++;
    }
    if(jg5==2 && jg7==1) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>


using ll = long long;
typedef std::pair<int, int>p;

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

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

const ll Z = 1000000007;
const ll INF = 1 << 30;
bool flag = true;
struct edge { int to, cost; };
std::vector<edge>v[100];
bool u[100];


int main() {
	ll n;
	std::cin >> n;
	ll a[10010], b[10010], suma = 0, sumb = 0;
	for (int i = 0;i < n;i++) {
		std::cin >> a[i];
		suma += a[i];
	}
	for (int i = 0;i < n;i++) {
		std::cin >> b[i];
		sumb += b[i];
	}
	if (suma > sumb) {
		std::cout << "No" << std::endl;
		flag = false;
	}
	if (flag) {
		ll t = sumb - suma;
		for (int i =0 ;i < n;i++) {
			if (b[i] > a[i]) {
				t -= (b[i] - a[i] + 1) / 2;
			}
		}
		if (t < 0) {
			std::cout << "No" << std::endl;
		}
		else {
			std::cout << "Yes" << std::endl;
		}
	}
}

Measured memory_bytes: 384
n = gets.to_i
num = gets.strip.split.map(&:to_i)
if n==1
  puts "Yes"
  exit
end
s = 1
i = n-1
while i > 0 do
  if num[i]==num[i-1]-1
    num[i-1] -= 1
  elsif num[i]<num[i-1]-1
    s = 0
    break
  end
  i -= 1
end
if s==0
  puts "No"
else
  if num.sort == num
    puts "Yes"
  else
    puts "No"
  end
end

Measured memory_bytes: 23340
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL
#define chmin(xx, yy) (xx) = min((xx) , (yy))
int main() {
	ll		a,b,c,d,w,h,i,j,k,l,m,n,x,y,z,ch,cw,dh,dw;
	ll		ans = 0;
	string	ss;
	cin >> h >> w >> ch >> cw >> dh >> dw;
	vector<vector<char>>	s(h+2 , vector<char>(w+2,'#'));

	for(i=1;i<=h;i++) {
		cin >> ss;
		for(j=1;j<=ss.size();j++) s[i][j] = ss[j-1];
	}
	
	/*//dbg
	for(i=0;i<=h+1;i++) {
		for(j=0;j<=w+1;j++) cout << s[i][j];
		cout << endl;
	}
	*/
	
	
	vector<vector<ll>>	wp(h+2 , vector<ll>(w+2,INFL));
	queue<pair<ll,ll>> que0,que1;

	que0.push(make_pair(ch,cw));
	que1.push(make_pair(ch,cw));
	wp[ch][cw] = 0;
	while (que0.size() || que1.size()) {
		while(que0.size()) {
			pair<ll,ll> p = que0.front();
			que0.pop();
			x = p.first;
			y = p.second;
			if (x==dh && y == dw) break;

			if (x>1) if (s[x-1][y]=='.') { if (wp[x-1][y]==INFL) que0.push(make_pair(x-1,y)); que1.push(make_pair(x-1,y)); wp[x-1][y] = wp[x][y]; }
			if (x<h) if (s[x+1][y]=='.') { if (wp[x+1][y]==INFL) que0.push(make_pair(x+1,y)); que1.push(make_pair(x+1,y)); wp[x+1][y] = wp[x][y]; }
			if (y>1) if (s[x][y-1]=='.') { if (wp[x][y-1]==INFL) que0.push(make_pair(x,y-1)); que1.push(make_pair(x,y-1)); wp[x][y-1] = wp[x][y]; }
			if (y<w) if (s[x][y+1]=='.') { if (wp[x][y+1]==INFL) que0.push(make_pair(x,y+1)); que1.push(make_pair(x,y+1)); wp[x][y+1] = wp[x][y]; }
		}

		if (x==dh && y == dw) break;

		if (que1.size()) {
			pair<ll,ll> p = que1.front();
			que1.pop();
			x = p.first;
			y = p.second;
			//cout << "que1 " << x << ' ' << y << endl;
			
			for(i=x-2;i<=x+2;i++) {
				if (i<1 || i>h) continue;
				for(j=y-2;j<=y+2;j++) {
					if (j<1 || j>w) continue;
					if (i==x && j==y) continue;
					//cout << "que1 i j " << i << ' ' << j << endl;
					//if (i==2 && j==5) {
					//	cout << s[i][j] << ' ' << wp[i][j] << endl;
					//}
					if (s[i][j]=='.') if (wp[i][j]==INFL) { que0.push(make_pair(i,j)); que1.push(make_pair(i,j)); wp[i][j] = wp[x][y]+1;}
				}
			}
		}


	}

	/*//dbg
	for(i=1;i<=h;i++) {
		for(j=1;j<=w;j++) {
			if (wp[i][j]==INFL) wp[i][j] = -1;
			cout << wp[i][j] << ' ';
		}
		cout << endl;
	}
	cout << endl;
	*/
	//}

	if (wp[dh][dw]==INFL) wp[dh][dw] = -1;
	cout << wp[dh][dw] << endl;
	return 0;
}


Measured memory_bytes: 12848
#include<bits/stdc++.h>
using namespace std;
const int N=101;
int a[N];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,ans=0,i;
	cin>>n;
	for(i=0;i<n-1;i++)
		cin>>a[i];
	ans+=a[0];
	for(i=1;i<n-1;i++)
		ans+=min(a[i-1],a[i]);
	ans+=a[n-2];
	cout<<ans<<'\n';
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#define MAXN 1000
using namespace std;
int main(){
	int n;
	cin>>n;
	int m;cin>>m;
	int sum=1;
	for(int i=n;i>=0;i--){
		if(i!=m){
			sum++;
		}else{
			break;
		}
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
	"bufio"
	"strconv"
)

func main() {

	var A [800000]string
	var n int
	fmt.Scan(&n)
	
	first_idx := 400000
	last_idx := 400000
	var scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	for i:=0; i<n; i++ {
		
		scanner.Scan()
		query, _ := strconv.Atoi(scanner.Text())

		switch query {
		case 0 :
			scanner.Scan()
			d, _ := strconv.Atoi(scanner.Text())
			scanner.Scan()
			x := scanner.Text()
			switch d {
			case 0 :
				if i>0 {
					first_idx--
				}
				A[first_idx] = x
			case 1 :
				if i>0 {
					last_idx++
				}
				A[last_idx] = x
			}
		case 1 :
			scanner.Scan()
			p, _ := strconv.Atoi(scanner.Text())
			fmt.Println(A[p+first_idx])
		case 2 :
			scanner.Scan()
			d, _ := strconv.Atoi(scanner.Text())
			switch d {
			case 0 :
				A[first_idx] = "NULL"
				first_idx++
			case 1 :
				A[last_idx] = "NULL"
				last_idx--
			}
		}
	}
}


Measured memory_bytes: 16460
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,k;
    int i=0,i2=0;
    int ary[100];
    scanf("%d %d %d",&a,&b,&k);
    
    while(i<a || i<b){
        i++;
        if(a%i==0 && b%i==0){
            ary[i2]=i;
            i2++;
        }
    }
    printf("%d",ary[i2-k]);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
const int N=200005;
const int mod=1e9+7;
const double eps=1e-8;
const double PI = acos(-1.0);
#define lowbit(x) (x&(-x))
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll qpow(ll a,ll b){ll res=1;while(b){if(b&1) res=res*a%mod;a=a*a%mod;b>>=1;}return res;}
ll inv(ll a,ll p){return qpow(a,p-2);}
int main()
{
    std::ios::sync_with_stdio(false);
    int n,l;
    string s[105];
    cin>>n>>l;
    priority_queue<string,vector<string>,greater<string>> pq;
    for(int i=1;i<=n;i++)
    {
        cin>>s[i];
        pq.push(s[i]);
    }
    while(!pq.empty())
    {
        cout<<pq.top();
        pq.pop();
    }
    cout<<endl;
  //  sort(s[1],s[n+1]);
    return 0;
}


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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

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

    int N, M;
    cin >> N >> M;
    
    ll sum=N;
    
    rep(i, M)
    {
        int a;
        cin >> a;
        sum -= a;
        if(sum<0)
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << sum << endl;

    

 

 

    return 0;
}
 

//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find



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

using namespace std;

typedef long long int64;

int main()
{
  int64 N, P, Q, C[500000] = {};
  scanf("%lld %lld %lld", &N, &P, &Q);
  int64 all = 0;
  for(int i = 0; i < N; i++) {
    int64 A;
    scanf("%lld", &A);
    all += A;
    C[i + 1] = A + P * i;
  }
  sort(C + 1, C + N + 1);
  for(int i = 1; i <= N; i++) C[i] += C[i - 1];
  int64 ret = all;
  for(int i = 0; i <= N; i++) {
    ret = max(ret, all+ P * i * (Q + i - 1) - C[i]);
  }
  printf("%lld\n", ret);
}

Measured memory_bytes: 7188
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<tuple<string, int, int>> v;
	for (int i = 0; i < N; ++i) {
		string S;
		int P;
		cin >> S >> P;
		v.emplace_back(S, -P, i + 1);
	}
	sort(v.begin(), v.end());
	for (auto &x : v) {
		cout << get<2>(x) << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s=="RRR")
    	cout<<3<<endl;
    else if(s=="RRS" || s=="SRR")
    	cout<<2<<endl;
    else if(s=="SSR" || s=="SRS" || s=="RSS" || s=="RSR")
    	cout<<1<<endl;
    else
    	cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 3624
//「鏡文」(https://beta.atcoder.jp/contests/cf16-relay-open/tasks/relay_b)

#include<iostream>
#include<string>

int main(){
	//標準入力
	std::string str;
	std::cin>>str;

	//処理
	//鏡文処理をした文字列を作り、比較。
	//メモリが少し無駄だが、まあいいでしょう
	std::string mirrorStr=str;//同じ長さの文字列を用意
	for(size_t i=0,len=str.size();i<len;i++){
		switch(str[len-i-1]){
		case('b'):
			mirrorStr[i]='d';
			break;
		case('d'):
			mirrorStr[i]='b';
			break;
		case('p'):
			mirrorStr[i]='q';
			break;
		case('q'):
			mirrorStr[i]='p';
			break;
		}
	}

	//出力
	std::cout<<(str==mirrorStr?"Yes":"No")<<std::endl;	

	return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<set>
#include<algorithm>

using namespace std;

int main(){
    int num_query,command,val,val2;
    scanf("%d",&num_query);
    set<int> int_set;
    set<int>::iterator itr;
    
    for(int i = 0;i < num_query;i++){
        scanf("%d %d",&command,&val);
        if(command == 0){
            int_set.insert(val);
            printf("%d\n",int_set.size());
        }else if(command == 1){
            itr = int_set.find(val);
            if(int_set.end() == itr) printf("0\n");
            else printf("1\n");
        }else if(command == 2){
            itr = int_set.find(val);
            if(int_set.end() != itr) int_set.erase(itr);
        }else if(command == 3){
            scanf("%d",&val2);
            itr = int_set.lower_bound(val);
            while(int_set.end() != itr && *itr <= val2){
                printf("%d\n",*itr);
                itr++;
            }
        }
    }
    
    return 0;
}



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

using namespace std;

#define int long long

const int INF = 1e18;

signed main(){

  int H, W;
  vector<string> field;
  vector<string> ans1, ans2;

  cin>>H>>W;

  field.resize(H);

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

  ans1 = field;
  ans2 = field;

  for(int i = 0; i < W; i++){
    ans1[0][i] = '#';
  }
  for(int i = 1; i < W; i++){
    ans2[H-1][i] = '#';
  }

  for(int i = 0; i < W; i++){
    if(i%2){
      for(int j = 0; j < H-1; j++){
        ans1[j][i] = '#';
      }
    } else {
      for(int j = 1; j < H; j++){
        ans2[j][i] = '#';
      }
    }
  }

  for(int i = 0; i < H; i++){
    cout<<ans1[i]<<endl;
  }
  cout<<endl;

   for(int i = 0; i < H; i++){
    cout<<ans2[i]<<endl;
  }
   /*
 for(int i = 0; i < H; i++){
   for(int j = 0; j < W; j++){
     cout<<(ans1[i][j] == '#' && ans2[i][j] == '#' ? '#' : '.');
   }
   cout<<endl;
  }
   */
  return 0;
}


Measured memory_bytes: 1536
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; 
const ll INF = 1e18 + 10 ; 
int main(){
    fastio
    string s , x ;
    cin >> s >> x ; 
    int n = (int) s.size() ; 
    int cnt = 0 ;
    for(int i = 0; i < n; i++){
        if ( s[i] == x[i] ) cnt++;
    }
    cout << cnt << endl;
    return 0 ;
}

Measured memory_bytes: 256
from collections import Counter

def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    
    c = Counter(A).most_common()
    
    if c[0][0] == 0 and c[0][1] == N:
        print("Yes")
    elif len(c) == 2 and c[0][1] == 2*N//3 and c[1][0] == 0 and c[1][1] == N//3:
        print("Yes")
    elif len(c) == 3 and int(c[0][0])^int(c[1][0]) == int(c[2][0]) and c[0][1] == c[1][1] and c[1][1] == c[2][1]:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

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

using namespace std;
typedef long long LL;

int a[3][100010];
int dp[3][100010];

int main() {
    int n;
    cin>>n;
    for (int i=0;i<n;i++) scanf("%d%d%d", &a[0][i], &a[1][i], &a[2][i]);
    memset(dp,-1,sizeof(dp));
    for (int i=0;i<3;i++) dp[i][n-1]=a[i][n-1];
    for (int i=n-1;i>=1;i--)
        for (int j=0;j<3;j++)
            if (dp[j][i]!=-1) {
                for (int k=0;k<3;k++)
                    if (j!=k && (dp[k][i-1]==-1 || dp[k][i-1]<dp[j][i]+a[k][i-1])) dp[k][i-1]=dp[j][i]+a[k][i-1];
            }
    cout<<max(dp[0][0], max(dp[1][0], dp[2][0]))<<endl;
}

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

int main(){
	int n,a[55],b[55],k=0,f=1;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n;i++)
	{
		if(a[i]!=b[i])
		k++;
		if(k>2){
			printf("NO");
			f=0;
			break;
		}
	}
	if(f)
	    printf("YES");
	return 0;   
}

Measured memory_bytes: 256
// You either die a hero, or you live long enough to see yourself become the villain.

/**
 *   author:  Blind_is_love
 *   created: 12.10.2019, 19:10
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

#define endl "\n"
#define vll vector<int>
#define max_heap priority_queue<int>
#define min_heap priority_queue<int , vector<int>, greater<int> >
#define pb push_back
#define all(container) container.begin(), container.end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define printArr(name,from,to) for(int x = from; x < to; x++) {cout << name[x] << " ";} cout << endl;
#define fi first
#define se second
#define mp make_pair
#define prime1 304933
#define prime2 15486277 
#define mod2 179424691
#define int ll

typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

const ll MOD = 1000000007;
const ll MAX = 1e5+10;
const double PI = 3.1415926;
const ll INF = 1e18;
const double EPS = 1e-5;

int n,k;
int arr[101];
bool dp[MAX];
bool seen[MAX];

bool solve(int i) {

	if (i == 0) return false;
	if (seen[i]) return dp[i];
	bool ans = false;
	for(int j = 0; j < n; ++j){
		if (arr[j] <= i){
			bool f = solve(i - arr[j]);
			ans = ans | (!f);
		}
	}
	seen[i] = true;
	return dp[i] = ans;
}

signed main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	clock_t t1, t2;
	t1 = clock();
	cin >> n >> k;
	
	for(int i = 0 ; i < n; ++i){
		cin >> arr[i];
	}

	if (solve(k)) cout << "First" << endl;
	else cout << "Second" << endl;

	t2 = clock(); cerr << "time taken: " << (t2-t1)/(long double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 3584
h ,w = map(int, input().split())
board = [list(input()) for tate in range(h)]
now = 0
flag = False
for i in board:
    direction = i.count("#")
    if (flag != True):
        now = direction 
        flag = True
    else:
        if(direction == 1):
            continue
        else:
            now  = now + direction - 1

if (now == w):
    print("Possible")
else:
    print("Impossible")

Measured memory_bytes: 9056
program a179

implicit none
character(len=1002) :: s
integer :: i, j

read *, s

do i= 1, 1001
 if(s(i:i)==' ') then
  j = i-1
  exit
 end if
end do

!print *, j

if(s(j:j)=='s') then
 s(j+1:j+2) = 'es' 
else
 s(j+1:j+1) = 's'
end if

print *, trim(s)

end program a179

Measured memory_bytes: 2860
#include<bits/stdc++.h>
using namespace std;
#define num 1000000007
//#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define avg(a,b) ((a)+(b))/2
#define push push_back
#define pop pop_back
#define mp make_pair
#define sf int flag=0     //Remember semicolon
#define assmin(a,b) if(b<=a) { a=b; }
#define assmax(a,b) if(b>=a) { a=b; }
#define f first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
typedef long long ll;
ll mod(ll a, ll b)
{
	if(a%b<0)
	{
		return a%b + b;
	}
	return a%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll mymod(ll a,ll b)
{
    return ((a%b)+b)%b;
}
bool prime[200000];
vll v;
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=200000; p++) 
    { 
        if (prime[p] == true) 
        { 
            v.push(p);
            for (int i=p*p; i<=200000; i += p) 
                prime[i] = false; 
        } 
    } 
}
ll powe[20];
void power()
{
    powe[0]=1;
    REP(i,1,10)
    {
        powe[i]=10*powe[i-1];
    }
}
ll gcdExtended(ll,ll,ll *,ll *);
ll modInverse(ll a, ll m) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
        ll res = (x%m + m) % m;
        return res;
} 
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
} 
ll fact[100005];
void factorial()
{
    fact[0]=1;
    REP(i,1,100002)
    {
        fact[i]=mymod(i*fact[i-1], num);
    }
}
pll fldig(ll n)
{
    pll ans;
    ll temp=n;
    ans.s=n%10;
    while(temp>=10)
    {
        temp/=10;
    }
    ans.f=temp;
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll count[10][10];
    REP(i,1,10)
    {
        REP(j,1,10)
        {
            count[i][j]=0;
        }
    }
    REP(i,1,n+1)
    {
        pll p=fldig(i);
        count[p.f][p.s]++;
    }
    ll ans=0;
    REP(i,1,10)
    {
        REP(j,i,10)
        {
            //cout<<i<<" "<<j<<" "<<m[{i,j}]<<" "<<m[{j,i}]<<"\n";
            if(i==j)
            ans+=count[i][j]*count[j][i];
            else
            ans+=2*count[i][j]*count[j][i];
        }
    }
    cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
n,y=map(int,input().split())
flag=False
for i in range(min(n+1,y//10000+1)):
    for j in range(min(n-i+1,(y-10000*i)//5000+1)):
        if y-10000*i-5000*j==1000*(n-i-j):
            print(i,j,n-i-j)
            flag=True
            break
    if flag:
        break
if not flag:
    print(-1,-1,-1)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(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 sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005


int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        
        int n;
        cin >> n;
        int i,a[n+1];
        int ans[n+1];
        vector<pair<int,int>>v;
        for(i=1; i<=n; i++){
            cin >> a[i];
            v.pb(mkp(a[i],i));
        }
        sort(v.rbegin(),v.rend());
        ans[v[0].second]=v[1].first;
        for(i=1; i<n; i++){
            ans[v[i].second]=v[0].first;
        }
        for(i=1; i<=n; i++){
            cout << ans[i] << '\n';
        }
        

}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    ll n, a, b; cin >> n >> a >> b;
    ll x = n / (a + b);
    ll y = n % (a + b);
    cout << x * a + min(a, y) << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from fractions import gcd
a, b = map(int, input().split())
g = gcd(a, b)
ans = {}
for i in range(2, int(g**0.5 + 1)):
    while g % i == 0:
        ans[i] = ans[i] + 1 if i in ans else 1
        g //= i
if g != 1:
    ans[g] = 1
print(len(ans) + 1)


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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

const int N = 2e5;
const int MOD = 998244353;
int delta[N];

int add(int x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
  if (x < 0) x += MOD;
  return x;
}

void solve() {
  int n, k; cin >> n >> k;
  vector<int> l(k), r(k);
  for (int i = 0; i < k; i++) {
    cin >> l[i] >> r[i];
  }
  delta[1] = 1, delta[2] = -1;
  ll dp = 0;
  for (int i = 1; i <= n; i++) {
    dp = add(dp, delta[i]);
    for (int j = 0; j < k; j++) {
      int dl = i + l[j], dr = i + r[j];
      if (dl > n) continue;
      dr = min(dr, n);
      delta[dl] = add(delta[dl], dp);
      delta[dr + 1] = add(delta[dr + 1], -dp);
    }
  }
  cout << dp;
}

// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES (n == 1)

int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(2);
  //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
  solve();
}


Measured memory_bytes: 4392
#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 (LONG_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
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a%b);
}
#endif


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

    int N;  cin >> N;
    vi A(N); REP(i, N) cin >> A[i];

    int ans = A[0];
    FOR(i, 1, N) ans = gcd(ans, A[i]);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#define MAX 101
typedef unsigned long long ull;
using namespace std;

int main(int argc, char *argv[])
{
    int n, m;
    int A[MAX][MAX] = {0};
    int b[MAX] = {0};
    ull C[MAX] = {0};

    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            int t = 0;
            scanf("%d", &t);
            A[i][j] = t;
        }
    }

    for (int j = 0; j < m; j++)
    {
        scanf("%d", &b[j]);
    }

    for (int i = 0; i < n; i++)
    {
        ull temp = 0;
        for (int j = 0; j < m; j++)
        {
            temp += A[i][j] * b[j];
        }
        C[i] = temp;
    }

    for (int i = 0; i < n; i++)
    {
        printf("%llu\n", C[i]);
    }





    return 0;
}



Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,D;cin>>N>>D;
  int H=0;
  for(int U=0;U<N;U++){
    long double X,Y;cin>>X>>Y;
    if(sqrt(X*X+Y*Y)<=D){
      H++;
    }
  }
  cout<<H<<endl;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("~/Downloads/02.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

class UnionFind {
public:
    // 親の番号を格納する。親だった場合-size
    vector<int> parents;
    vector<int> distance;

    UnionFind(int n) {
        parents = vector<int>(n, -1);
        distance = vector<int>(n, 0);
    }

    // aがどのグループに属しているか
    int root(int a) {
        if (parents[a] < 0) {
            return a;
        }

        int a_parent = parents[a];
        int a_ancestor = root(parents[a]);
        if (a_parent == a_ancestor) {
            return a_ancestor;
        }
        int a_distance = distance[a];
        int a_parent_distance = distance[a_parent];
        distance[a] = a_distance + a_parent_distance;

        parents[a] = a_ancestor;
        return a_ancestor;
    }

    int size(int a) {
        return -parents[root(a)];
    }

    // aとbをくっつける
    bool connect(int a, int b, int d) {
        int ra = root(a);
        int rb = root(b);



        if (ra == rb) {
            int distance_a = distance[a];
            int distance_b = distance[b];
            int all_distance =  distance_a - distance_b;
            if (all_distance != d) {
                cout << "No" << endl;
                exit(0);
            }
            return false;
        }

        // 大きいほうにA
        if (size(ra) < size(rb)) {
            swap(ra, rb);
            swap(a, b);
        } else {
            d *= -1;
        }

        parents[ra] += parents[rb];
        parents[rb] = ra;
        distance[rb] = (distance[a] - distance[b]) + d;
        return true;
    }

};


int main() {

//    ifstream myfile("/home/riku/Downloads/02.txt");


    int n, m;
    cin >> n >> m;

    UnionFind uf(n);

    rep(i, m) {
        int l, r, d;
        cin >> l >> r >> d;
        l--;
        r--;

        uf.connect(l, r, d);
    }

    cout << "Yes" << endl;

}

Measured memory_bytes: 1024
#include <stdio.h>
int main(){

  int x, y, tmp;

  while(1){
    scanf("%d%d", &x, &y);
    if( x == 0 && y == 0 ){
      break;
    }
     if( x > y ){
       tmp = x; x = y; y = tmp;
     }
    printf("%d %d\n", x, y);

  
  }


  return 0;

}



Measured memory_bytes: 1928
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define all(v)    ((v.begin()),(v.end()))
#define sz(v)     ((int)(v.size()))
#define forv(i, v) for(int i = 0; i < sz(v); ++i)
#define forn(i,n)   for(int i = 0; i < (int)(n); i++)
using namespace std;

typedef long long       ll;
typedef long double     ld;
typedef vector<int>     vi;
typedef vector<double>  vd;
typedef vector< vi >    vii;
typedef vector< vd >    vdd;
typedef vector<string>  vs;

const ll INF = 1e18L + 5;

int main()
{
	ll n, W;
	scanf("%lld%lld", &n, &W);
	vector<ll> v(n), w(n);
	ll max_sum = 0;
	for (int i = 0; i < n; i++) {
		scanf("%lld%lld", &w[i], &v[i]);
		max_sum += v[i];
	}
	vector<ll> dp(max_sum + 3, INF);
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = max_sum - v[i]; j >= 0; j--) {
			dp[j + v[i]] = min(dp[j + v[i]], dp[j] + w[i]);
		}
	}
	ll ans = 0;
	for (int i = 0; i <= max_sum; i++) {
		if (dp[i] <= W) {
			ans = max(ans, (ll) i);
		}
	}
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <ctime>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

const int INF = 100000000;
const int MAX_M = 100000;



int main(int argc, char *args[]) {
	string s;
	cin >> s;
	bool flag = true;
	if (s.size() == 1 && s[0] == 'L') flag = false;
	for (int i = 0; i < s.size()/2; i++) {
		if (s[2 * i] == 'L') {
			flag = false;
			break;
		}
		if (s[2 * i + 1] == 'R') {
			flag = false;
			break;
		}
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100010];
int gcd(int x,int y) {
	return y==0?x:gcd(y,x%y);
}
int main() {
	int n,k;
	scanf("%d%d",&n,&k);
	int m=-1;
	for(int i=0;i<n;i++) {
		scanf("%d",&a[i]);
		m=max(m,a[i]);
	}
	int gg=a[0];
	for(int i=1;i<n;i++) gg=gcd(gg,a[i]);
	if(k<=m&&k%gg==0) printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N;
ll ans;

int main()
{
    
    cin>>N;
	if(N==1){
		ans=0;
	}else{
    for(int i=1;i<N;i++)
    {
        ans+=i;
    }
	}
    
        cout<<ans;
    cout<<endl;
    return 0;
}

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

int main(void){
  long long n, m;
  cin >> n >> m;
  long long ans = 0;
  if(n > m / 2){
    cout << m / 2 << endl;
    return 0;
  }
  ans = n;
  m -= n * 2;
  ans += m / 4;
  cout << ans << endl;
  return 0;
}


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

void calc_distance(vector<vector<int>>& to, vector<int>& dist, int n, int p, int d)
{
  dist[n] = d;
  for (auto a : to[n]) {
    if (a == p) continue;
    calc_distance(to, dist, a, n, d + 1);
  }
}

int main()
{
  int n, takahashi, aoki;
  cin >> n >> takahashi >> aoki;
  vector<vector<int>> to(n, vector<int>());
  takahashi--;
  aoki--;

  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  vector<int> distance_from_takahashi(n);
  vector<int> distance_from_aoki(n);

  calc_distance(to, distance_from_takahashi, takahashi, -1, 0);
  calc_distance(to, distance_from_aoki, aoki, -1, 0);

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (distance_from_takahashi[i] < distance_from_aoki[i]) {
      ans = max(ans, distance_from_aoki[i]);
    }
  }
  cout << --ans << endl;
}


Measured memory_bytes: 12928
A, B, N = list(map(int, input().split()))


def f(n):
    return (A*n) // B - A * (n//B)


if B > N:
    print(f(N))
else:
    ans = f(N)
    N = N // B * B - 1
    ans = max(ans, f(N))
    print(ans)


Measured memory_bytes: 61804
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b;
    cin>>a>>b;
    if(a==1)    a=14;
    if(b==1)    b=14;
    if(a>b){
        cout<<"Alice"<<endl;
    }else if(a<b){
        cout<<"Bob"<<endl;
    }else{
        cout<<"Draw"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array

main = do
  n <- (read::String -> Int) <$> getLine
  case n of
    22 -> putStrLn "Christmas Eve Eve Eve"
    23 -> putStrLn "Christmas Eve Eve"
    24 -> putStrLn "Christmas Eve"
    25 -> putStrLn "Christmas"
    _ -> return () 
    

Measured memory_bytes: 508