akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
int n,lm,rm,ans,lng,su[200005];
pii a[200005],b[200005];
bool cmp(pii a,pii b){return a.fi>b.fi;}
int main()
{
    scanf("%d",&n);
    rep(i,1,n) scanf("%d%d",&a[i].fi,&a[i].se);
    rep(i,1,n) {
        if(lm==0||a[i].fi>a[lm].fi) lm=i;
        if(rm==0||a[i].se<a[rm].se) rm=i;
    }
    rep(i,1,n) lng=max(lng,a[i].se-a[i].fi+1);
    ans=max(a[rm].se-a[lm].fi+1,0)+lng;
    rep(i,1,n){
        b[i].fi=max(a[i].se-a[lm].fi+1,0);
        b[i].se=max(a[rm].se-a[i].fi+1,0);
    }
    sort(b+1,b+n+1,cmp);
    su[n]=b[n].se;
    per(i,n-1,1) su[i]=min(su[i+1],b[i].se);
    rap(i,1,n) ans=max(ans,b[i].fi+su[i+1]);
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 2176
import java.util.Arrays

fun main(args: Array<String>) {
    val list = readLine()!!.split(" ").map(String::toInt)
    val N = list[0]
    val K = list[1]

    val set: MutableSet<Int> = setOf<Int>().toMutableSet()
    for (i in 0..K-1) {
        readLine()
        val A = readLine()!!.split(" ").map(String::toInt)
        A.forEach {
            j -> set.add(j)
        }
    }
    println(N-set.size)
}

Measured memory_bytes: 39168
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[100];
    char c[100],l[100];
    cin>>c>>s>>l;
    if(c[0]>='a' && c[0]<='z')
    c[0]-=32;
    if(s[0]>='a' && s[0]<='z')
    s[0]-=32;
    if(l[0]>='a' && l[0]<='z')
    l[0]-=32;
    cout<<c[0]<<s[0]<<l[0];
    
    return 0;
}

Measured memory_bytes: 256
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws FileNotFoundException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new File("c:\\0515-input.txt"));
		while (true) {
			int n = scan.nextInt();
			if (n == 0)
				break;
			Map map = new Map(n);
			for (int i = 0; i < n; i++)
				map.add(scan.nextInt(), scan.nextInt());
			map.sort();
			// map.print();
			System.out.println(map.getMax());
		}

		scan.close();
		System.exit(0);
	}

}

class Map {
	class Loc {
		private int x, y;

		public Loc(int _x, int _y) {
			x = _x;
			y = _y;
		}

	}

	class LocComp implements Comparator<Loc> {

		@Override
		public int compare(Loc o1, Loc o2) {
			if (o1.x >= o2.x)
				return 1;
			else if (o1.x == o2.x)
				if (o1.y > o2.y)
					return 1;
				else
					return 0;
			else
				return -1;
		}
	}

	static final int mm = 5001;
	List<Loc> loc = new ArrayList<Loc>();
	boolean[][] ex = new boolean[mm][mm];

	public Map(int n) {
	}

	public int getMax() {
		int max = 0;
		for (int i = 0; i < loc.size(); i++)
			for (int j = i + 1; j < loc.size(); j++) {
				if (loc.get(i).y > loc.get(j).y)
					continue;
				int a = this.area(i, j);
				if (a > max)
					max = a;
			}
		return max;
	}

	private int area(int i, int j) {
		int dx = loc.get(j).x - loc.get(i).x;
		int dy = loc.get(j).y - loc.get(i).y;
		if (loc.get(i).x - dy < 0)
			return 0;
		if (loc.get(i).y + dx >= mm)
			return 0;
		if (loc.get(j).x - dy < 0)
			return 0;
		if (loc.get(j).y + dx >= mm)
			return 0;
		if (!ex[loc.get(i).x - dy][loc.get(i).y + dx] || !ex[loc.get(j).x - dy][loc.get(j).y + dx])
			return 0;
		return (dx * dx + dy * dy);
	}

	public void print() {
		for (int i = 0; i < loc.size(); i++)
			System.out.println(loc.get(i).x + " " + loc.get(i).y);

	}

	public void sort() {
		Collections.sort(loc, new LocComp());
	}

	public void add(int x, int y) {
		loc.add(new Loc(x, y));
		ex[x][y] = true;

	}

}

Measured memory_bytes: 149200
//I am so vegetable
#include <bits/stdc++.h>
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _defor(i,a,b) for((i) = (a);(i)<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
//#define _LOCAL_
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll N = 2005;
const int MOD = 1e9 + 7;
const double exps = 1e-6;
int main() {
#ifdef _LOCAL_
	ifstream cin("E:\\acm dream\\in.txt");
	ofstream cout("E:\\acm dream\\out.txt");
#endif
	//srand((unsigned)time(nullptr));
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n, l;
	string s;
	cin >> n >> l;
	vector<string>ans;
	_for(i, 0, n) { cin >> s; ans.push_back(s); }
	sort(ans.begin(), ans.end());
	_sfor(it, ans)cout << it;
	cout<<'\n';
	return 0;
}

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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 1; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))

// π M_PI
// deg = rad*180/M_PI

bool pair_Cs_R(const pair<ll, ll>& firstElof, const pair<ll, ll>& secondElof) {
    return firstElof.second > secondElof.second;
}

int main() {
    ll k, n;
    cin >> k >> n;
    ll a[n];
    std::vector<ll> v;
    ll ans = 0;
    rep(i, n) {
        cin >> a[i];
        if ( i > 0 ) {
            v.push_back(a[i]-a[i-1]);
        }
    }
    v.push_back(k-a[n-1]+a[0]);
    Sort(v);
    ans = k - *max_element(ALL(v));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3444
#include <iostream>
#include <cstdio>

using namespace std;

const int INF = 1e9;
int k;
int a[100005];

void f(int p, int q)
{
    if(a[p] <= q) return;
    a[p] = q;
    f(p * 10 % k, q);
    f((p + 1) % k, q + 1);
}

int main()
{
    scanf("%d", &k);
    for(int i = 0; i < k; i++) a[i] = 99;
    f(1, 1);
    printf("%d", a[0]);
    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <string>

using namespace std;

const int MAX_LEN = 105;
const int ALPHA = 26;

bool reach [ALPHA][MAX_LEN][MAX_LEN];

int main () {
  string str;
  cin >> str;

  int length = (int) str.size();
  for (int i = 0; i < length; i++) {
    reach[str[i] - 'a'][0][i] = true;
  }

  for (int i = 0; i < ALPHA; i++) {
    for (int j = 1; j < MAX_LEN; j++) {
      for (int k = 0; k < MAX_LEN - 1; k++) {
        reach[i][j][k] = reach[i][j - 1][k] | reach[i][j - 1][k + 1];
      }
    }
  }

  int ans = MAX_LEN;
  for (int i = 0; i < ALPHA; i++) {
    for (int j = 0; j < MAX_LEN; j++) {
      bool ok = true;
      for (int k = 0; k < length - j; k++) {
        ok &= reach[i][j][k];
      }
      
      if (ok) {
        ans = min(ans, j);
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h> //AtCoder
#include <iostream> //Codeforces
#include <vector> //Codeforces

#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Vc vector<char>
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define cyes cout<<"yes"<<endl
#define cno cout<<"no"<<endl

using namespace std;
/****************************** START ******************************/

signed main(){
  int N,X,M;
  cin >> N >> X >> M;
  map<int,int> A,B;
  
  A[1] = X;
  //int now = X;
  int start,end,last;
  int cnt = 1;
  int sum = 0;
  bool loop = false;
  
  repeq(i,2,N){
    if(B[A[i-1]]!=0){
      start = B[A[i-1]];
      end = i-1;
      loop = 1;
      break;
    }
    B[A[i-1]] = i-0;
    A[i] = A[i-1] * A[i-1] % M;
  }
  
  int ans = 0;
  if (loop){
    repeq(i,1,start - 1){
      ans += A[i];
    }
    
    repeq(i,start,end){
      sum += A[i];
    }
    cnt = (N - (start - 1))/(end - (start - 1)); 
    ans += sum * cnt;
    
    last = start + (end - (start - 1)) * cnt;
    repeq(i,last,N){
      ans += A[i- (last - start)];
    }
  } else {
    repeq(i,1,N){
      ans += A[i];
    }
  }
  cout << ans;
  
}


Measured memory_bytes: 9796
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i) 
using namespace std;
using ll = long long;
int main() {
int k,s;
cin >> k >> s;
int ans = 0;
for (int i=0; i<=k;i++){
  for (int j=0; j<=k; j++){
      if((s-i-j>=0) && (s-i-j<=k)) ans++;
    }
  }
cout << ans << endl;
   }

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

using namespace std;
using ll  = long long;
using pii = pair<int, int>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  bool t[N] = {false};
  vector<pii> ab(N);
  vector<pii> cd(N);
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    ab[i] = make_pair(b, a);
  }
  for (int i = 0; i < N; i++) {
    int c, d;
    cin >> c >> d;
    cd[i] = make_pair(c, d);
  }
  sort(ab.begin(), ab.end());
  reverse(ab.begin(), ab.end());
  sort(cd.begin(), cd.end());
  int count = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (ab[i].first < cd[j].second && ab[i].second < cd[j].first && !t[j]) {
        t[j] = true;
        count++;
        break;
      }
    }
  }
  cout << count << '\n';
  return 0;
}


Measured memory_bytes: 256
///byYerko
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pb push_back
using namespace std;
const int MXX = 2e3 + 7;
const int MXN = 1e6 + 7;
const int N = 1e9 + 7;

ll a[102][102], dp[102][102], n;

int main() {
  cin >>n;
  for(int i = 1; i <= 2; i ++) {
    for(int j = 1; j <= n; j ++) {
      cin >>a[i][j];
    }
  }

  dp[1][1] = a[1][1];
  for(int i = 1; i <= 2; i ++) {
    for(int j = 1; j <= n; j ++) {
      dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]) + a[i][j];
    }
  } cout <<dp[2][n];
  return 0;
}


Measured memory_bytes: 256
// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

int n, m, k, res = 1e9, a[13][1300], dp[13][1300];
char xx[13][1300];

int que(int x1, int y1, int x2, int y2) {
  return dp[x2][y2]-dp[x1-1][y2]-dp[x2][y1-1]+dp[x1-1][y1-1];
}

int main() {
  init_ios();
  cin >> n >> m >> k;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      cin >> xx[i][j];
      if (xx[i][j] == '1')
        a[i][j] = 1;
    }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      dp[i][j] = a[i][j]+dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1];
  for (int i = 0; i < (1<<(n-1)); ++i) {
    int lst = 0, tmp = __builtin_popcount(i);
    VI prz;
    prz.PB(0);
    for (int j = 0; j < n-1; ++j)
      if (i&(1<<j))
        prz.PB(j+1);
    prz.PB(n);
    bool ok = true;
    for (int j = 1; ok && j <= m; ++j) {
      for (int l = 0; l+1 < (int)prz.size(); ++l) {
        int x2 = prz[l+1], x1 = prz[l]+1;
        int y1 = lst+1, y2 = j;
        if (que(x1, y1, x2, y2) > k) {
          if (y1 == y2) {
            ok = false;
            break;
          }
          lst = j-1;
          ++tmp;
          --j;
          break;
        }
      }
    }
    if (!ok)
      continue;
    res = min(res, tmp);
  }
  cout<<res<<"\n";
}

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

#define ll long long int
#define mod 1000000007

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;


int main()
{  
    ios::sync_with_stdio(false);
    cin.tie(0);
    
   
    ll n,k;
    cin>>n>>k;
    n%=k;
    cout<<min(n,abs(n-k))<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair
//#define int         int64_t

using namespace std;

const int N = 15;
const int nMask = 1 << 15 | 1;
const int inf = (int)1e9;

typedef pair<int, int> pii;
int n, m, u, v, c, rem, w[N][N];
int f[nMask][N], lg[nMask], cost[nMask][N];
vector<int> bit;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    fill_n(&f[0][0], nMask * N, inf);
    fill_n(&w[0][0], N * N, inf);
    cin >> n >> m;
    for(int i = 0; i < m; ++i) {
        cin >> u >> v >> c; --u, --v;
        w[u][v] = w[v][u] = c;
    }
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < (1 << n); ++j) {
            for(int k = 0; k < n; ++k) {
                if((j >> k & 1) && w[i][k] != inf) cost[j][i] += w[i][k];
            }
        }
    }
    f[1][0] = 0;
    for(int mask = 1; mask < (1 << n); ++mask) {
        if(!(mask & 1)) continue;
        bit.clear();
        for(int i = 0; i < n; ++i)
            if(mask >> i & 1) {
                bit.pb(i);
                for(int sub = mask; sub > 0; sub = (sub - 1) & mask) {
                    if(!(sub >> i & 1) || !(sub & 1) || sub == mask) continue;
                    c = 0; rem = mask ^ sub;
                    for(int j = 0; j < n; ++j)
                        if((sub >> j & 1) && (j != i)) c += cost[rem][j];
                    f[mask][i] = min(f[mask][i], f[sub][i] + c);
                }
            }
        for(int x: bit) {
            for(int y: bit) {
                if(x == y) continue;
                if(w[y][x] != inf)
                    f[mask][x] = min(f[mask][x], f[mask ^ (1 << x)][y] + cost[mask ^ (1 << x) ^ (1 << y)][x]);
            }
        }
    }
    cout << f[(1 << n) - 1][n - 1];
}


Measured memory_bytes: 4096
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

fn calulate_unvisited_neighbors(now: usize, edges: &Vec<Vec<bool>>, visited: &Vec<usize>) -> Vec<usize> {
    let mut neighbors: Vec<usize> = Vec::new();
    for (neighbor, &edge) in edges[now].iter().enumerate() {
        if edge && !visited.contains(&neighbor) {
            neighbors.push(neighbor);
        }
    }
    neighbors
}

fn traversal(now: usize, edges: &Vec<Vec<bool>>, visited: &Vec<usize>) -> i64 {
    let mut visited = visited.clone();
    visited.push(now);
    let neighbors = calulate_unvisited_neighbors(now, edges, &visited);
    let mut counter = 0;
    if neighbors.is_empty() {
        if visited.len() == edges.len() - 1 {
            // println!("visited={:?}", visited);
            return 1
        } else {
            // println!("edges.len()=={:?}", edges.len());
            // println!("*visited={:?}", visited);
            // println!("neighbor={:?}", neighbors);
            return 0
        }
    }
    for &neighbor in neighbors.iter() {
        let now = neighbor;
        counter += traversal(now, edges, &visited);
    }
    counter
}

fn main() {
    let (n, m) = input!(usize, usize);
    let mut edges = vec![vec![false; n+1]; n+1];
    for _ in 0..m {
        let (a, b) = input!(usize, usize);
        edges[a][b] = true;
        edges[b][a] = true;
    }
    // for edge in edges.iter() {
        // println!("{:?}", edge);
    // }
    println!("{:?}", traversal(1, &edges, &vec![]));
}


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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int N;
int A[110000], B[110000];
int deg[110000];
bool used[110000];
vint G[110000];
signed main() {
    cin >> N;
    for (int i = 0; i < N - 1; i++) {
        cin >> A[i] >> B[i];
        deg[A[i]]++, deg[B[i]]++;
        G[A[i]].push_back(B[i]), G[B[i]].push_back(A[i]);
    }
    queue<int> one;
    for (int i = 1; i <= N; i++) {
        if (deg[i] == 1)one.push(i);
    }
    while (!one.empty()) {
        int x = one.front(); one.pop();
        if (used[x])continue;
        used[x] = true;
        int y = -1;
        for (int i = 0; i < G[x].size(); i++) {
            if (used[G[x][i]])continue;
            deg[G[x][i]]--, y = G[x][i];
            if (deg[G[x][i]] == 1)one.push(G[x][i]);
        }
        if (y == -1) {
            cout << "First" << endl;
            return 0;
        }
        used[y] = true;
        for (int i = 0; i < G[y].size(); i++) {
            if (used[G[y][i]])continue;
            deg[G[y][i]]--;
            if (deg[G[y][i]] == 1)one.push(G[y][i]);
        }

    }
    cout << "Second" << endl;

}


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

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

        for (int i = 0; i < N; i++) {
			tree[i] = sc.nextInt();
		}
        sc.close();
        Arrays.sort(tree);
        int min = tree[N-1];
        
        for (int i = 0; i < N-M+1; i++) {
        	int a = 0;
        	a = tree[i+M-1] - tree[i];
        	min = Math.min(a,min);
        	if(min == 0) break;
		}
        System.out.println(min);
    }
}

Measured memory_bytes: 50072
#include<bits/stdc++.h>
using namespace std;
long long n,m,k,a[300010],b[300010],x[300010],y[300010],ans,c,d,f,aa,bb;
int main(){
	cin>>n>>m>>k;
	for (int i=0;i<k;i++){
		cin>>x[i]>>y[i];
		a[x[i]]++;
		b[y[i]]++;
	}
	for (int i=1;i<=n;i++) c=max(c,a[i]);
	for (int i=1;i<=n;i++) if (a[i]==c) aa++;
	for (int i=1;i<=m;i++) d=max(d,b[i]);
	for (int i=1;i<=m;i++) if (b[i]==d) bb++;
	for (int i=0;i<k;i++) if (a[x[i]]==c&&b[y[i]]==d) f++;
	if (f==aa*bb)
		cout<<c+d-1<<endl;
	else
		cout<<c+d<<endl;
	return 0;
}

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

int main(){
  ll x;
  cin>>x;
  int s=0;
  ll t=100;
  while(t<x){
    t+=t*0.01;
    s++;
  }
  cout<<s<<endl;
  
}


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

    val n = readLine()!!.toInt()

    var num = IntArray(1001,{it -> 0})

    for(i in 2..n){
        var tmp = i
        for(j in 2..i){
            if(tmp == 1)break;
            while(tmp % j == 0){
                num[j]++;
                tmp /= j
            }
        }
    }

    var ans = 1L

    for(i in 0..1000){
        ans *= num[i] + 1
        ans %= 1000000007
    }

    println(ans)

}


Measured memory_bytes: 29956
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char s[20]={0},t[20]={0},flag=1;
	scanf("%s%s",s,t);
	for(int i=0;s[i];i++)
	{
		if(s[i]!=t[i])
		{
			flag=0;
			break;
		}
	}
	if(flag==0)
		printf("No\n");
	else
		printf("Yes\n");
	return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if ((a+b) < (c+d)){
    cout << "Right" << endl;
  }
  else if ((a+b) > (c+d)){
    cout << "Left" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
}

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

//Track and Field Competition
public class Main{

	static class T implements Comparable<T>{
		int id;
		double t;
		public T(int id, double t) {
			this.id = id;
			this.t = t;
		}
		public int compareTo(T o) {
			return t-o.t<0?-1:o.t-t<0?1:0;
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		T[][] r = new T[3][8];
		for(int i=0;i<3;i++){
			for(int j=0;j<8;j++)r[i][j]=new T(sc.nextInt(),sc.nextDouble());
			Arrays.sort(r[i]);
		}
		T[] t = new T[6];
		int x = 0;
		for(int i=0;i<3;i++){
			System.out.printf("%d %.2f\n", r[i][0].id, r[i][0].t);
			System.out.printf("%d %.2f\n", r[i][1].id, r[i][1].t);
			t[x++] = r[i][2];
			t[x++] = r[i][3];
		}
		Arrays.sort(t);
		System.out.printf("%d %.2f\n", t[0].id, t[0].t);
		System.out.printf("%d %.2f\n", t[1].id, t[1].t);
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type& a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

int main(){
	int n;
	cin>>n;
	
	llong ans=0;
	for(int i=1;i<n;++i) ans+=i;
	
	cout<<ans<<endl;
}

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

int main(){
  int sx,sy,tx,ty;cin>>sx>>sy>>tx>>ty;
  string mx0,mx1,mx2,mx3,my0,my1,my2,my3;
  
  if(sx<tx){
    REP(i,tx-sx){mx0+='R';mx1+='L';}
    mx2="RL";mx3="LR";
  }else{
    REP(i,sx-tx){mx0+='L';mx1+='R';}
    mx2="LR";mx3="RL";  
  }
  
  if(sy<ty){
    REP(i,ty-sy){my0+='U';my1+='D';}
    my2="DU";my3="UD";
  }else{
    REP(i,sy-ty){my0+='D';my1+='U';}
    my2="UD";my3="DU";
  }
  
  cout<<mx0<<my0<<mx1<<my1;
  cout<<my2.at(0)<<mx0<<mx2.at(0)<<my2.at(1)<<my0<<mx2.at(1);
  cout<<my3.at(0)<<mx1<<mx3.at(0)<<my3.at(1)<<my1<<mx3.at(1);
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
#D - Patisserie ABC
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, M = map(int, readline().split())
data = [[] for _ in range(8)]
for _ in range(N):
    A = list(map(int,readline().split()))
    for i in range(1<<3):
        tmp = 0
        for j in range(3):
            if i>>j & 1:
                tmp+=A[j]
            else:
                tmp+=-A[j]
        data[i].append(tmp)

ans = 0
for row in data:
    row = sorted(row,reverse=True)[:M]
    total = sum(row)
    ans = max(ans,total)
print(ans)

Measured memory_bytes: 74132
#include <iostream>
#include <vector>

using namespace std;

void solve(int w,int n){
  vector<int> v;
  for(int i=0;i<w+1;i++){
    v.push_back(i);
  }
  for(int i=0;i<n;i++){
    int a,b;
    char c;
    cin >> a >>c>> b;
    int temp = v[a];
    v[a] = v[b];
    v[b] = temp;
  }
  for(int i=1;i<w+1;i++){
    cout << v[i] << endl;
  }
}
int main(){
  int w,n;
  cin >> w;
  cin >> n;
  solve(w,n);
  return 0;
}

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

int main()
{
    int p,q,x,y;
    string a,b,c;
    cin>>a>>b;
    cin>>p>>q;
    cin>>c;
    if(a[0]==c[0])
    {
        x=p-1;
        y=q;
    }
    else if(b[0]==c[0])
    {
        x=p;
        y=q-1;
    }
    cout<<x<<" "<<y<<endl;
    return 0;
}


Measured memory_bytes: 256
import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

seq = [0] * n
for i in range(n):
    seq[i] = i + 1

allpat = list(itertools.permutations(seq))

p_num = 0
q_num = 0

for i in range(len(allpat)):
    if allpat[i] == p:
        p_num = i
    if allpat[i] == q:
        q_num = i

print(abs(p_num-q_num))

Measured memory_bytes: 45040
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define ld double
#define pb push_back
#define EPS 1e-9
#define all(a) a.begin(),a.end()
#define sz(a) int((a).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
using namespace std;
typedef pair<int, int> II;
typedef pair<II, int> III;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n;
    cin >> n;
    if (n < 1200) cout << "ABC";
    else if (n < 2800) cout << "ARC";
    else cout << "AGC";
    return 0;
}


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

typedef long long ll;
#define debug(x) cerr << #x <<" : "<< x << endl;
#define INF (1<<20)
const int MAX_N = (1 << 18);

int main() {
	int N, Q;
	cin >> N >> Q;
	string S;
	cin >> S;
	vector<int> s(N+1,0);
	for (int i = 0; i < N-1; i++) {
		if (S[i] == 'A' && S[i + 1] == 'C') {
			s[i+2] = s[i+1] + 1;
		}
		else {
			s[i+2] = s[i+1];
		}
	}

	for (int i = 0; i < Q; i++) {
		int l, r;
		cin >> l >> r;
		l; r;

		cout << s[r] - s[l] << endl;
	}
}

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

int main() {
	int a, b;
	while (cin >> a >> b, a | b) {
		vector<int>s(b);
		for (int c = 0; c < b; c++)cin >> s[c];
		for (int d = 0; d < a; d++) {
			for (int e = 0; e < b; e++) {
				int f;
				cin >> f;
				s[e] -= f;
			}
		}
		for (int g = 0; g < b; g++) {
			if (s[g] < 0) { cout << "No" << endl; break; }
			if (b - 1 == g)cout << "Yes" << endl;
		}
	}
}

Measured memory_bytes: 3096
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>

using namespace std;

#define LINE DEBUG{ printf("LINE : %d\n", __LINE__); }
#define DEBUG if(false)

using ll = long long;
template<class T> using vec = vector<T>;

const int MOD = 1000000007;

int main(){
  ll N, K;
  cin >> N >> K;

  ll Ans = 1;;
  ll min = N*(N+1)/2;
  ll max = N*(N+1)/2;
  for(int i = 0; i < N-K+1; i++){
    min = min - (N-i);
    max = max - i;
    Ans = (Ans + (max-min+1)) % MOD;
  }

  cout << Ans << endl;

  return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define Max 100   //最大スタック量
#define MAX 1000000000

int top=0;
int S[Max];
char s[MAX];

void initialize(); 
//topを0としスタックを空にする
int isEmpty();     
//topが0かどうかを調べスタックが空かどうか判断する
int isFull();      
//スタックが満杯かどうかを判断
void push(int);
//topを1つ増やしそこにxを追加
int pop();         
//topが示す要素(スタックの頂点の要素)を返しつつtopの値を１つ減し頂点の要素を削除


void initialize(){
  top = 0;
}

void push(int x){
 top++;
 S[top] = x;
}

int pop(){ 
  top--;
  return S[top+1];
}



int main(){
  int a,b;
  int x;

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a = pop();
      b = pop();
      push(a+b);
    } 
    else if ( s[0] == '-' ){
      a = pop();
      b = pop();
      push(b-a);
    } 
    else if ( s[0] == '*' ){
      a = pop();
      b = pop();
      push(a*b);
    } 
    else {
      x = atoi(s);
      push(x);
    }
  }

  printf("%d\n",pop());
  return 0;
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))


int main(){
    ll N,Q;
    cin >> N >> Q;
    string S;
    cin >> S;

    vector<ll>lef(Q),rig(Q);

    for(ll i = 0;i < Q;i++){
        cin >> lef.at(i) >> rig.at(i);
    }

    vector<ll>rui(N+1);
    rui.at(0) = 0;

    bool Afla=false;
    for(ll i = 0;i < N;i++){
        if(S.at(i) == 'A'){
            Afla = true;
            rui.at(i+1) = rui.at(i);
        }else if(S.at(i) == 'C' and Afla == true){
            Afla = false;
            rui.at(i+1) = 1 + rui.at(i);
        }else{
            Afla = false;
            rui.at(i+1) = rui.at(i);
        }
    }

    for(ll i = 0;i < Q;i++){
        cout << rui.at(rig.at(i)) - rui.at(lef.at(i)) << endl;
    }

    return 0;
}

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

using namespace std;

int main() {
  long long n;
  cin >> n;

  int res = 0;
  while (9 < n) {
    long long tmp = n % 10;
    n /= 10;
    if (tmp < 9) {
      tmp = 9;
      n--;
    }
    res += tmp;
  }

  res += n;

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 256
#16D8101023J 久保田凌弥 kubotarouxxx python3

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

if x>y:
  while 1:
   if (x%y)==0:
    print(y)
    break
   a=x%y
   x=y
   y=a
else:
  while 1:
   if (y%x)==0:
    print(x)
    break
   a=y%x
   y=x
   x=a



Measured memory_bytes: 5596
N = int(input())
t = [0 for _ in range(N + 10)]
x = [0 for _ in range(N + 10)]
y = [0 for _ in range(N + 10)]
res = 'Yes'
for i in range(N):
  t[i], x[i], y[i] = map(int, input().split(' '))
for i in range(N):
  if abs(x[i]) + abs(y[i]) <= t[i] and (abs(x[i]) + abs(y[i])) % 2 == t[i] % 2:
    x[i + 1] -= x[i]
    y[i + 1] -= y[i]
    t[i + 1] -= t[i]
  else:
    res = 'No'
    break
print(res)

Measured memory_bytes: 11816
import sys
import math

read = sys.stdin.readline
S = read()

a, b = map(int, S.split())

fin = False
for i in range(1000+1):
    if a == math.floor(i * 0.08):
        if b == math.floor(i * 0.1):
            print(i)
            fin = True
            break
if not fin:
    print(-1)

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

int main(){
    long long int n, k;
    cin >> n >> k;

    long long int q = n / k;
    long long int ans = min(abs(n - q*k), abs(n - (q+1)*k));
    cout << ans << endl;
    return 0;
}

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

int main() {
  vector<int> arr(3);
  for (auto &a : arr) cin >> a;
  int k; cin >> k;
  sort(arr.rbegin(), arr.rend());
  arr[0] *= (1<<k);
  cout << accumulate(arr.begin(), arr.end(), 0) << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
AC = 0
TLE = 0
WA = 0
RE = 0
for i in range(N):
    s = input()
    if s == "AC":
        AC += 1
    elif s == "TLE":
        TLE += 1
    elif s == "WA":
        WA += 1
    elif s == "RE":
        RE += 1
print("AC x ",AC)
print("WA x ",WA)
print("TLE x ",TLE)
print("RE x ",RE)

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

int main(){
  int N,L; cin>>N>>L;
  vector<string> s(N);
  for(int i=0;i<N;i++){
    cin>>s[i];
  }
  sort(s.begin(),s.end());
  for(int i=0;i<N;i++){
    cout<<s[i];
  }
  return 0;
}


Measured memory_bytes: 256
"use strict";

const main = arg => {
    // 標準入力の不要な空白と改行を削除し、配列に格納する
    const input = arg.trim().split(" ");
    const N = parseInt(input[0], 10);

     if (N % 2 === 0) {
         console.log(N / 2);
     } else {
         console.log(Math.floor((N / 2),10) + 1);
     }
    
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;

typedef long long LL;

const int N = 1000010;

int main()
{
    int n;
    cin >> n;

    int res = 0;
    for(int i = 1; i <= n; i++)
    {
        if(i % 2 == 0) continue;

        int cnt = 0;
        for(int j = 1; j <= i; j++)
            if(i % j == 0)
                cnt++;
        if(cnt == 8) res++;
    }

    cout << res << endl;

    return 0;
}


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

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

  long long A,B,C;
  cin>>A>>B>>C;

  if(A==B&&B==C){
    if(A%2==0){
      cout<<-1<<endl;
      return 0;
    }else{
      cout<<0<<endl;
      return 0;
    }

  }

  long long ans=0;
  long long At,Bt,Ct;
  while(A%2==0&&B%2==0&&C%2==0){
    At = B/2 + C/2;
    Bt = A/2 + C/2;
    Ct = B/2 + A/2;
    A = At;
    B = Bt;
    C = Ct;
    //cout<<A<<','<<B<<','<<C<<endl;
    ans++;
  }
  cout<<ans<<endl;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int WWW = 0;WWW < (n);WWW++)cerr << v[WWW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007

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

int moveA[2222][2222];
int moveB[2222][2222];
int dp[2222][2222];
int W[2222];
int B[2222];

int main(){
	int n;cin >> n;
	REP(i,2*n){
		char c;
		int tmp;
		cin >> c >> tmp;tmp--;
		if(c == 'B')B[tmp] = i;
		else W[tmp] = i;
	}
	
	REP(i,2222)REP(j,2222)dp[i][j] = INF;
	
	REP(i,n){
		int cou = 0;
		REP(j,i)if(W[j] < W[i])cou++;
		moveA[i+1][0] = W[i] - cou;
		REP(j,n){
			if(B[j] < W[i])cou++;
			moveA[i+1][j+1] = W[i] - cou;
		}
	}
	
	REP(i,n){
		int cou = 0;
		REP(j,i)if(B[j] < B[i])cou++;
		moveB[i+1][0] = B[i] - cou;
		REP(j,n){
			if(W[j] < B[i])cou++;
			moveB[i+1][j+1] = B[i] - cou;
		}
	}
	
	dp[0][0] = 0;
	REP(i,n+1){
		REP(j,n+1){
			dp[i+1][j] = min(dp[i+1][j],dp[i][j] + moveA[i+1][j]);
			dp[i][j+1] = min(dp[i][j+1],dp[i][j] + moveB[j+1][i]);
		}
	}
	DBG(
	cout << "W" << endl;
	SHOW1d(W,n+1);
	cout << "B" << endl;
	SHOW1d(B,n+1);
	cout << "moveA" << endl;
	SHOW2d(moveA,n+1,n+1);
	cout << "moveB" << endl;
	SHOW2d(moveB,n+1,n+1);
	cout << "dp" << endl;
	SHOW2d(dp,n+1,n+1);)
	
	cout << dp[n][n] << endl;
			
	
	return 0;
}


Measured memory_bytes: 57600
import java.io.*;
import java.util.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    
    int a = Integer.parseInt(f.readLine());
    StringTokenizer vals = new StringTokenizer(f.readLine());
    StringTokenizer costs = new StringTokenizer(f.readLine());
    
    int val;
    int cost;
    int profit = 0;
    
    for (int i = 0; i < a; i++) {
      val = Integer.parseInt(vals.nextToken());
      cost = Integer.parseInt(costs.nextToken());
      if (val > cost) {
        profit += val - cost;
      }
    }
    
    out.write(String.valueOf(profit));
    out.close();
  }
}


Measured memory_bytes: 21204
# coding: utf-8
# Your code here!

n = int(input())
a = list(map(int, input().split()))
ans = 100 ** 5

for i in range(max(a) + 1):
  x = 0
  for j in a:
    x += (i - j) ** 2
  ans = min([x, ans])

print(ans)
   


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

int main() {
    int n, m;
    vector<string> b, r;
    map<string, int> mp;
    cin >> n;
    FOR(i, n){
        string temp;
        cin >> temp;
        mp[temp]++;
    }
    cin >> m;
    FOR(i, m){
        string temp;
        cin >> temp;
        mp[temp]--;
    }
    int max = 0;
    for(auto x:mp) {
        if(x.second > max) max = x.second;
    }
    cout << max << endl;



    return 0;
}


Measured memory_bytes: 256
class Elements:
    s = set()

    def __init__(self, *elements):
        self.s = set(elements)

    def add(self, x):
        self.s.add(x)

    def remove(self, x):
        self.s.remove(x)

    def union(self, e):
        self.s |= e.s


class Hoge:
    h = {}
    elements_set = set()

    def add(self, at, new_item):
        self.h[at].add(new_item)
        self.h[new_item] = self.h[at]

    def union(self, x, y):
        if len(self.h[y].s) > len(self.h[x].s):
            x, y = y, x

        self.h[x].union(self.h[y])
        self.elements_set.remove(self.h[y])
        for i in self.h[y].s:
            self.h[i] = self.h[x]

    def new_pair(self, x, y):
        u = Elements(x, y)
        self.h[x] = u
        self.h[y] = u
        self.elements_set.add(u)

    def add_pair(self, x, y):
        if x in self.h:
            if y in self.h:
                if self.h[x] is self.h[y]:
                    pass
                else:
                    self.union(x, y)
            else:
                self.add(x, y)
        else:
            if y in self.h:
                self.add(y, x)
            else:
                self.new_pair(x, y)

    def equals(self, *l):
        result = 0

        # 動かさなくても条件を満たすものを数える
        for i, x in enumerate(l):
            if i == x and x not in self.h:
                result += 1

        # 互換の適用によって条件を満たせるものを数える
        for es in self.elements_set:
            s = es.s
            for x in s:
                if l[x] in s:
                    result += 1

        return result


def main():
    n, m = map(int, input().split())
    l = map(lambda s: int(s)-1, input().split())
    hoge = Hoge()
    for i in range(1, m + 1):
       pair = map(lambda s: int(s)-1, input().split())
       hoge.add_pair(*pair)
    print("{0:d}".format(hoge.equals(*l)))


main()


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

int N;
vector<vector<int>> G(101010);
// dp[i][0]:iの全ての塗り方、dp[i][1]:iを白で塗る
ll dp[101010][2];

void solve(int v, int p){
  dp[v][0]=dp[v][1]=1;
  dp[v][0]=dp[v][1]=1;
  for(int u:G[v]) if(u!=p){
    solve(u,v);
    (dp[v][1]*=dp[u][0])%=MOD;
    (dp[v][0]*=dp[u][1])%=MOD;
  }
  (dp[v][0]+=dp[v][1])%=MOD;
}

int main(){
  cin>>N;
  rep(i,N-1){
    int X,Y; cin>>X>>Y; X--,Y--;
    G[X].push_back(Y);
    G[Y].push_back(X);
  }
  solve(0,-1);
  cout<<dp[0][0]<<endl;
  return 0;
}


Measured memory_bytes: 14208
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		if (a + b > c + d) {
			System.out.println("Left");
		} else if (a + b < c + d) {
			System.out.println("Right");
		} else {
			System.out.println("Balanced");
		}
		}
	}

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

typedef long long ll;

int main() {
    int N, M, L, R, D;
    cin >> N >> M;
    vector<vector<pair<int, int>>> edge(N);
    rep(i, M) {
        cin >> L >> R >> D;
        L--;
        R--;
        edge[L].push_back(make_pair(R, D));
        edge[R].push_back(make_pair(L, -D));
    }
    vector<bool> done(N, false);
    vector<ll> x(N);
    rep(i, N) {
        if (done[i]) continue;
        done[i] = true;
        queue<pair<int, ll>> q;
        x[i] = 0;
        q.push(make_pair(i, 0));
        ll minx = 0, maxx = 0;
        while (!q.empty()) {
            auto p = q.front();
            q.pop();
            int u = p.first;
            ll y = p.second;
            rep(j, edge[u].size()) {
                int v = edge[u][j].first;
                ll d = edge[u][j].second;
                if (done[v]) {
                    if (y + d != x[v]) {
                        cout << "No\n";
                        return 0;
                    }
                } else {
                    x[v] = y + d;
                    done[v] = true;
                    minx = min(minx, x[v]);
                    maxx = max(maxx, x[v]);
                    if (maxx - minx > 1e9) {
                        cout << "No\n";
                        return 0;
                    }
                    q.push(make_pair(v, x[v]));
                }
            }
        }
    }
    cout << "Yes\n";
}

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

#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    string s;
    cin >> s;
    cout << (s[0]==s[2] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
const int N = 1100000;
int vis[2010][2010];
int main()
{
    int s1, t1, s2, t2;
    scanf("%d %d %d %d", &s1, &t1, &s2, &t2);
    for(int i=1;i<=(t2-t1);i++) printf("U");
    for(int i=1;i<=(s2-s1);i++) printf("R");
    for(int i=1;i<=(t2-t1);i++) printf("D");
    for(int i=1;i<=(s2-s1);i++) printf("L");
    printf("L");
    for(int i=1;i<=(t2-t1)+1;i++) printf("U");
    for(int i=1;i<=(s2-s1)+1;i++) printf("R");
    printf("D");
    printf("R");
    for(int i=1;i<=(t2-t1)+1;i++) printf("D");
    for(int i=1;i<=(s2-s1)+1;i++) printf("L");
    printf("U\n");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX 20000
typedef struct {
  int maxi;
  int maxj;
  double area;
}INF;

int main()
{
  int i,j,n,m=0,sum_p=0,sum_m=0,min=0,Area[MAX+1],k=0,sum=0;
  char word[MAX];
  INF L[MAX/2];

  scanf("%s",word);

  n=strlen(word);
  Area[0]=0;

  for(i=0;i<n;i++){
    if(word[i]=='/') sum_p++;
    if(word[i]=='\\') sum_m--;
    Area[i+1]=sum_p+sum_m;
    if(min>Area[i+1]){
      min=Area[i+1];
    }
  }

  for(i=0;i<n+1;i++){
    Area[i]=Area[i]-min;
  }

  for(i=0;i<n+1;i++){
    if(word[i]=='\\'){
      j=i+1;
      while(1){
	if(Area[i]==Area[j]){
	  L[m].maxi=i;
	  L[m].maxj=j;
	  m++;
	  i=j-1;
	  break;
	};
	j++;
	if(j==n+1) break;
      }
    }
  }

  for(i=0;i<m;i++){
    for(j=L[i].maxi;j<L[i].maxj;j++){
      if(word[j]=='\\'||word[j]=='/'){
	L[i].area+=(1/2+abs(Area[L[i].maxi]-Area[j]));
      }
      if(word[j]=='_') L[i].area+=Area[L[i].maxi]-Area[j];
    }
  }

  for(i=0;i<m;i++){
    sum=sum+L[i].area;
  }

  printf("%d\n%d",sum,m);

  for(i=0;i<m;i++){
    printf(" %d",(int)L[i].area);
  }

  printf("\n");

  return 0;
}

Measured memory_bytes: 2824
import collections


N=int(input())
c=0
ans=[]
for n in range(N):
    a=input()
    a=sorted(a)
    a=''.join(a)
    ans.append(a)
c = collections.Counter(ans)
values, counts = zip(*c.most_common())
uu=0
for n in range(len(counts)):
    uu+=(counts[n]*(counts[n]-1))/2
print(round(uu))


Measured memory_bytes: 31656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  vl x(n);
  rep(i, n) cin >> x[i];
  ll ans = 0;
  rep(i, n - 1) ans += min((x[i + 1] - x[i]) * a, b);
  cout << ans << endl;
}

Measured memory_bytes: 4012
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    int x1,x2,y1,y2,xmar,ymar;
    int x3,y3,x4,y4;
    scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
    xmar = x2-x1; ymar = y2-y1;
    x3 = x2-ymar; y3 = y2+xmar;
    x4 = x3-xmar; y4 = y3-ymar;
    printf("%d %d %d %d\n",x3,y3,x4,y4);
}

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

#define speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define all(c) c.begin(), c.end()
#define allr(c) c.rbegin(), c.rend()
#define tr(container, it) \
      for(typeof(container.begin()) it = container.begin(); it != --container.end(); it++,container.end()++)
#define present(container, element) (container.find(element) != container.end()) 
#define cpresent(container, element) (find(all(container),element) != container.end()) 
#define se second
#define fi first
#define sz(a) int((a).size()) 
#define pb push_back 



int main()
{
	//freopen("input.txt","r",stdin);
	speed;
	
	int a,b;
	cin>>a>>b;
	int c=b-a;
	int s=0;
	for(int i=1;i<c;i++)
		s+=i;
	cout<<s-a;
    return 0;
}

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

int n;
int a[100];

void print(int a[], int n) {
  rep(i,n) {
    if(i > 0) printf(" ");
    printf("%d", a[i]);
  }
  printf("\n");
}

void insertionSort(int a[], int n) {
  for(int i = 1; i < n; i++) {
    int key = a[i];
    int j = i - 1;
    while(j >= 0 && a[j] > key){
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = key;

    print(a, n);
  }

}

int main () {
  scanf("%d", &n);
  rep(i,n) scanf("%d", &a[i]);

  print(a, n);
  insertionSort(a, n);

  return 0;
}

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

int main (){
	int P, Q, R;cin>>P>>Q>>R;
	int max=0;
	if(max<P)max=P;
	if(max<Q)max=Q;
	if(max<R)max=R;
	cout<<P+Q+R-max<<endl;
    return 0;
}

Measured memory_bytes: 256