akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;

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

template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;

int main() {
	int a[5];
	rep(i, 5) {
		cin >> a[i];
	}
	rep(i, 5) {
		if (a[i] == 0) {
			cout << i + 1 << endl;
		}
	}
	return 0;
}

// 1000000000000000
//  999999999999999
// 1000000000000000 9.99

Measured memory_bytes: 3580
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<cmath>
 
#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
 
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9
#define MOD 1000000007
 
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; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
 
 
using namespace std;

int main()
{
    ll n, y;
    cin >> n >> y;
    vector<ll> x(n);

    rep(i, n){
        ll tmp;
        cin >> tmp;
        x[i] = abs(tmp - y);
    }

    ll ans;
    rep(i, n){
        if(i == 0) ans = x[i];
        else ans = gcd(ans, x[i]);
    }
    cout << ans;



}

Measured memory_bytes: 1024
import java.util.Scanner;
	public class Main {
		public static void main(String args[]) {
			solve();
		}
		static void solve() {
			Scanner sc = new Scanner(System.in);
			String s = sc.next();
			sc.close();
			for(int i = 0;i<s.length();i++) {
				System.out.print("x");
			}
		}
	}


Measured memory_bytes: 25172
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() { cin.tie(nullptr); ios_base::sync_with_stdio(false); }
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

int N, K;
i64 dp[100100], h[100100];

signed main()
{
  cin >> N >> K;
  for (int i = 0; i < N; ++i) {
    cin >> h[i];
  }

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

  cout << dp[N-1] << endl;

  return 0;
}



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


int main()
{
    const int kMaxLineNum = 100;
    int row, col;
    int cells[kMaxLineNum][kMaxLineNum] = {0};
    
    cin >> row >> col;
    for (int i=0; i<row; ++i)
    {
        for (int j=0; j<col; ++j)
        {
            cin >> cells[i][j];
        }
    }

    int sum, allSum=0;
    for (int i=0; i<row; ++i)
    {
        sum = 0;
        for (int j=0; j<col; ++j)
        {
            cout << cells[i][j] << ' ';
            sum += cells[i][j];
        }
        cout << sum << endl;
        allSum += sum;
    }
    
    for (int i=0; i<col; ++i)
    {
        sum = 0;
        for (int j=0; j<row; ++j)
        {
            sum += cells[j][i];
        }
        cout << sum << ' ';
    }
    cout << allSum << endl;
    
    return 0;
}

Measured memory_bytes: 1208
# li = [[0] * 4 for i in range(3)]

# A = list.map(int, input().split())

S = input()

Q = int(input())
hanten = 0

ato = []
mae = []

for i in range(Q):
    li = input().split()

    one = int(li[0])
    if one == 1:
        hanten += 1
    else:
        F = int(li[1])
        C = li[2]
        if (hanten + F) % 2 == 1:
            mae.append(C)
        else:
            ato.append(C)

if hanten % 2 == 0:
    mae.reverse()
    print("".join(mae) + S + "".join(ato))
else:
    ato.reverse()
    S1 = "".join(list(reversed(S)))

    print("".join(ato) + S1 + "".join(mae))


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

int main(){
string S;
cin >> S;
    
    if(S == "SUN") cout<<"7"<<endl;
    else if(S == "MON") cout<<"6"<<endl;
    else if(S == "TUE") cout<<"5"<<endl;
    else if(S == "WED") cout<<"4"<<endl;
    else if(S == "THU") cout<<"3"<<endl;
    else if(S == "FRI") cout<<"2"<<endl;
    else  cout<<"1"<<endl;

return 0;
}


Measured memory_bytes: 256
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    unused_imports,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::{fastout, input, marker::*};
//use std::collections::HashSet;
use std::collections::*;
//use std::collections::BTreeMap;
//use std::cmp::*;
//use std::num;
//use petgraph::unionfind::UnionFind;

#[fastout()]
fn main() {
    input! {
        N:Chars
    }
    // N 支払うのに、交換する紙幣の枚数の最小値。

    let mut m: Vec<usize> = N.iter().map(|&c| (c as u8 - '0' as u8) as usize).collect();
    let mut pay = vec![0; m.len() + 1];
    let mut get = vec![0; m.len() + 1];
    let mut ans = 0;
    let mut dp = vec![vec![0, 0]; m.len() + 1];
    dp[0][0] = 0;
    dp[0][1] = 1;
    for i in 0..m.len() {
        dp[i + 1][0] = std::cmp::min(dp[i][0] + m[i], dp[i][1] + 10 - m[i]);
        dp[i + 1][1] = std::cmp::min(dp[i][0] + m[i] + 1, dp[i][1] + 9 - m[i]);
    }
    ans = dp[m.len()][0];
    println!("{}", ans);
}


Measured memory_bytes: 69256
#include <stdio.h>

#define swap(a,b) do{int tmp_in_swap_macro = a; a = b; b = tmp_in_swap_macro;}while(0)

int main(void)
{
  int X, Y, Z;
  scanf("%d%d%d", &X, &Y, &Z);
  
  swap(X, Y);
  swap(X, Z);
  
  printf("%d %d %d\n",X, Y, Z);
  
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
   int n,i,j,count=0,a[200100]={0},b[200100]={0};
   scanf("%d",&n);
   for(i=0;i<n;i++)
    scanf("%d",&a[i]);
   int min=0;
   for(i=0;i<n;i++)
   {
    if(a[i]<=a[min])
    {
    count++;
    min=i;
    }
   }
   printf("%d",count);
   return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 30

signed main()
{
    string S;
    cin >> S;
    int ans = 0;
    REP(i, S.length()) { if(S[i] == '1') { ans++; } }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
// using u128 = __uint128_t;
#define pb push_back
#define all(c) (c).begin() , (c).end()
const ll inf = 1e18 + 7;


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n;
    cin >> n;
    vi a(410,0);
    vvi dp(405, vi(405));
    for (int i = 0; i < n; i++)
        cin >> a[i];
    
    for (int l = n - 1; l >= 0; l--)
        for (int r = l; r < n; r++)
        {    if (l == r)
                dp[l][r] = 0;
            else
            {
                dp[l][r] = inf;
                ll s = accumulate(a.begin()+l, a.begin()+r+1,0ll);
                for (int i = l; i < r; i++)
                    dp[l][r] = min(dp[l][r], dp[l][i] + dp[i+1][r] + s);
            }
        }
            
    cout << dp[0][n-1] << endl;
    return 0;
}

Measured memory_bytes: 1536
#include<stdio.h>
#include<string.h>
#define Length 100005

typedef struct Point{
char name[100];
int t;
  }Strc;

Strc L[Length];
int head,tail,n;

void enqueue(Strc x) {
L[tail] = x;
tail = (tail+1) % Length;
}

Strc dequeue() {
Strc x = L[head];
head = (head + 1) % Length;
  return x;
}

int min(int m, int k)
    {return m<k ? m:k;}
int main(){
  int elaps = 0,c;
  int i,q;
  Strc u;
  scanf("%d %d",&n,&q);
for(i=1;i<=n;i++){
scanf("%s",L[i].name);
scanf("%d",&L[i].t);
  }
  head = 1; tail = n+1;
while (head != tail){
u = dequeue();
c = min(q,u.t);
u.t -= c;
elaps += c;
if(u.t > 0) enqueue(u);
else{
  printf("%s %d\n",u.name, elaps);
}

}
  return 0;
}

Measured memory_bytes: 10756
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let p: i32 = s.next().unwrap().parse().unwrap();
	let s: Vec<_> = s.next().unwrap().bytes().rev().collect();
	let mut ans = 0;
	if p == 2 || p == 5 {
		for (i, c) in s.iter().enumerate() {
			let d = (c - b'0') as i32;
			if d % p == 0 {
				ans += n - i;
			}
		}
	} else {
		let mut pos = vec![vec![]; p as usize];
		let mut base = 1;
		let mut r = 0;
		for (i, c) in s.iter().enumerate() {
			r = (r + base * (c - b'0') as i32) % p;
			pos[r as usize].push(i);
			base = (base * 10) % p;
		}
		let mut base = 1;
		let mut r = 0;
		for (i, c) in s.iter().enumerate() {
			ans += pos[r as usize].len() - pos[r as usize].lower_bound(&i);
			r = (r + base * (c - b'0') as i32) % p;
			base = (base * 10) % p;
		}
	}
	println!("{}", ans);
}

trait BinarySearch<'a, T: 'a> {
	fn lower_bound(&self, x: &T) -> usize;
}

impl<'a, T: 'a + Ord> BinarySearch<'a, T> for [T] {
	fn lower_bound(&self, x: &T) -> usize {
		let mut first = 0;
		let mut len = self.len() - first;
		while len > 0 {
			let half = len >> 1;
			let mid = first + half;
			use std::cmp::Ordering;
			match self[mid].cmp(x) {
				Ordering::Less => {
					first = mid + 1;
					len = len - half - 1;
				}
				Ordering::Equal | Ordering::Greater => {
					len = half;
				}
			}
		}
		first
	}
}


Measured memory_bytes: 10492
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f
#define pi 3.1415926535898
using namespace std;
ll m,n;
const int N=1e6+10;
struct A
{
    int x,v;
}f[N];
int cmp(A a,A b)
{
    return a.x<b.x;
}
ll sum[N];
int main()
{
    int a;
    cin>>n>>m>>a;
    for(int i=1;i<=n;i++)
    {
        cin>>f[i].x>>f[i].v;
    }
    sort(f+1,f+1+n,cmp);
    ll ans=0;
    ll now=0;
    for(int i=1;i<=n;i++)
    {
        sum[i]+=sum[i-1];
        f[i].v+=sum[i];
        if(f[i].v<=0)
        {
            continue;
        }
        int l=1,r=n,res=0;
        while(l<=r)
        {
            int mid=(l+r)/2;
            if(f[mid].x<=f[i].x+2*m)
            {
                res=mid;
                l=mid+1;
            }
            else
            {
                r=mid-1;
            }
        }
        int t=f[i].v/a;
        if(f[i].v%a)
        {
            t++;
        }
        ans+=t;
        sum[i]-=t*a;
        sum[res+1]+=t*a;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6704
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

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

  vector<ll> A(N);
  rep(i, N) cin >> A[i];

  int cnt = 0;
  for(int i = 0; i < N; i++){
    if(A[i] < 0) cnt++;
    A[i] = abs(A[i]);
  }

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

  ll ans = 0;
  if(cnt%2 == 0){
    for(int i = 0; i < N; i++) ans +=A[i];
  } else {
    ans = -A[0];
    for(int i = 1; i < N; i++) ans +=A[i];
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 1024
// https://atcoder.jp/contests/arc069/tasks/arc069_a

#include <bits/stdc++.h>
using namespace std;
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define endl '\n'
#define cerr if(false) cerr
#define int long long

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

    int N, M;
    cin >> N >> M;

    int l = 0;
    int r = M;

    int ans = 0;
    while(l <= r) {
        int m = (l+r)/2;

        // remove rem c pieces
        int rem = m;

        int s = N+(rem/2);
        int c = M-rem;

        if(s*2 > c) {
            // remove less
            r = m-1;
            cerr << "too many c" << endl;
        } else {
            // if we have too many s pieces, remove more c
            l = m+1;
            cerr << " too many s" << endl;
        }

        cerr << "if we remove " << rem << " we can have " << min(s, c/2) << endl;
        watch(s)
        watch(c)
        cerr << endl;
        ans = max(ans, min(s, c/2));
    }

    cout << ans << endl;
}

/*

7 4

-> dont remove any c pieces

3 10

-> remove 2 pieces

*/

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n, c, k; cin >> n >> c >> k;
    vint a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    int now = 0;
    int ans = 0;
    while (now < n) {
        int id = upper_bound(all(a),a[now]+k)-a.begin();
        int next = min(id-now,c)+now;
        ans++;
        swap(next,now);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << -1; return;}
#define yes {cout << "Yes"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

void solve() {
    int n, m;
    cin >> n >> m;
    vector <pi> v(m);
    loop(i, m)
        cin >> v[i].F >> v[i].S;
    sort(all(v));
    v.resize(unique(all(v)) - v.begin());
    loop1(i, (int)v.size() - 1)
        if (v[i].F == v[i - 1].F)
            no;
    if (!v.empty() && v[0] == mkp(1ll, 0ll) && n > 1)
        no;
    vector <int> ans(n);
    for (pi p : v)
        ans[p.F - 1] = p.S;
    if (!ans[0] && n > 1)
        ans[0] = 1;
    for (int x : ans)
        cout << x;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
long long n,a,f[(int)2e5+10],s;
int main(){
    scanf("%lld",&n);
    for(int i = 1; i <= n; ++i){
        scanf("%lld",&a);
        if(i&1)s+=a; // s is sum of odd indices
        if(i == 1)continue;
        if(i&1)f[i] = std::max(f[i-2]+a,f[i-1]); // at odd place either f[i-2]+a (common sense) or previous
        else f[i] = std::max(f[i-2]+a,s); // at even either normal or we just take odd ones
    }
    return printf("%lld\n",f[n]),0;
}

Measured memory_bytes: 5368
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int T[300][300],W[300],n;
int dfs(int i,int j){
	if(~T[i][j])return T[i][j];
	if(abs(W[i]-W[j])<=1){
		if(i+1==j)return 2;
		if(dfs(i+1,j-1)==j-i-1)return T[i][j]=j-i+1;
	}
	int r=0,t,k=i;
	for(;k<j;k++){
		t=dfs(i,k)+dfs(k+1,j);
		r=r>t?r:t;
	}
	return T[i][j]=r;
}
int main(){
	int i;
	for(;scanf("%d",&n),n;printf("%d\n",dfs(0,n-1)))
		for(memset(T,0xff,sizeof(T)),i=0;i<n;i++)scanf("%d",W+i);
	return 0;
}

Measured memory_bytes: 984
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
    long long H, A;

    cin >> H >> A;

  	long long cnt = 1;
    while(1)
    {
        if(H - A <= 0)
        {
            cout << cnt << endl;
            return 0;
        }
        else
        {
            H = H - A;
            cnt++;
        }
    }
    return 0;
}


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

int main()
{
    std::string str,str2;
    std::cin >> str >> str2;
    
    str2.pop_back();

    if(str==str2 ){
     std::cout << "Yes" << std::endl;
    }
    else{
        std::cout << "No" << std::endl;
    }
}

Measured memory_bytes: 3440
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main() {
  char  S[4], T[4];
  int i, result;
  scanf ("%s %s", S, T);
  
  result=0;
  for (i=0;i<3;i++) if (S[i]==T[i]) result++;
  
  
  printf("%d", result);
  return 0;
}




Measured memory_bytes: 128
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  a=[LI() for _ in range(n)]
  b=[LI() for _ in range(n)]

  ans=-inf
  for i in range(1,1<<10):
    _ans=0
    for _i,x in enumerate(a):
      counter=0
      for j in range(10):
        if i&(1<<j) and x[j]==1:
          counter+=1
      _ans+=b[_i][counter]
    ans=max(ans,_ans)
  return ans

# main()
print(main())


Measured memory_bytes: 5684
use std::io;
use std::cmp;

fn main() {
    let s = read_line().trim().to_owned();
    let (mut a, mut b, mut c) = (0, 0, 0);

    for ch in s.chars(){
        if ch == 'a' {
            a += 1;
        } else if ch == 'b' {
            b += 1;
        } else {
            c += 1;
        }
    }
    let max = cmp::max(a, cmp::max(b, c));
    let min = cmp::min(a, cmp::min(b, c));
    if max - min <= 1 {
        println!("YES");
    } else {
        println!("NO");
    }
}

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

fn read<T>() -> T
    where T: std::str::FromStr,
          T::Err: std::fmt::Debug
{
    read_line().trim().parse().unwrap()
}

fn read_values<T>() -> Vec<T>
    where T: std::str::FromStr,
          T::Err: std::fmt::Debug
{
    read_line()
        .split(' ')
        .map(|a| a.trim().parse().unwrap())
        .collect()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

int const MAXN=440;
int const MAXM=110000;
int N,M;
int x[MAXM],y[MAXM];
bool S[MAXN][MAXN];
bool can[MAXN];

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	cin>>N>>M;
	rep(i,0,M) cin>>x[i]>>y[i];
	
	rep(i,1,N+1) {
		rep(j,1,N+1) S[i][j]=false;
		S[i][i]=true;
		can[i]=true;
	
		per(j,0,M) {
			if (S[i][x[j]] && S[i][y[j]]) {
				can[i]=false;
				break;
			} else if (S[i][x[j]]) {
				S[i][y[j]]=true;
			} else if (S[i][y[j]]) {
				S[i][x[j]]=true;
			}
		}
	}
	
	int res=0;
	rep(i,1,N+1) rep(j,i+1,N+1) if (can[i] && can[j]) {
		bool canBoth=true;
		rep(k,1,N+1) if (S[i][k] && S[j][k]) {
			canBoth=false;
			break;
		}
		if (canBoth) res++;		
	}
	
	cout<<res<<"\n";
}


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

int main(){
	int l,r,d;
	while(~scanf("%d %d %d",&l,&r,&d)){
		int c=0;
		for(int i=1;i<=r;i++){
			if(d*i>=l && d*i<=r) c++;
		}
		printf("%d\n",c);
	}
	return 0;
} 

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
void run_case(){
    int n;
    cin>>n;
    bool t=false;
    int x=0;
    int a,b;
    for(int i=0;i<n;i++){
        cin>>a>>b;\
        if(t)continue;
        else{}{
        if(a!=b)x=0;
        else{
            if(x==2)t=true;
            else x++;
        }}
    }
    if(t)cout<<"Yes";
    else cout<<"No";
}
int main(){
	ios_base::sync_with_stdio(false),cin.tie(nullptr);
    int t=1;
    while(t--){
        run_case();

    }
}



Measured memory_bytes: 3640
import itertools

N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]

state = ['A', 'B', 'C', 'D']
loop = list(itertools.product(state, repeat=N))

m = 10**8

for i in range(4**N):
    takeA = 0
    takeB = 0
    takeC = 0
    syn = -3
    for j in range(N):
        if loop[i][j] == 'A':
            takeA += l[j]
            syn += 1
        elif loop[i][j] == 'B':
            takeB += l[j]
            syn += 1
        elif loop[i][j] == 'C':
            takeC += l[j]
            syn += 1
    if takeA!=0 and takeB!=0 and takeC!=0:
        m = min(m, abs(takeA-A)+abs(takeB-B)+abs(takeC-C)+10*syn)
        
print(m)

Measured memory_bytes: 10996
#include<bits/stdc++.h> 
using namespace std;
#define pb push_back
#define vi vector<int>
#define ss second
#define ff first
#define ll long long
#define pii pair<int,int>
#define mii map<int,int>
#define mod 1000000007
#define w(x) int x; cin>>x; while(x--)
#define ps(x,y) fixed<<setprecision(y)<<x;
ll ab(ll a,ll b)
{
      if(a>b)
      return a-b;
return b-a;
}
int main() 
{
      ll n,i=1,j=1;
      cin>>n;
      ll a[n+1][4];
      while(i<=n)
      {
            j=1;
            while(j<=3)
            {
            cin>>a[i][j];
            j++;
            }
            i++;
      }
      ll dp[n+1][4];
      dp[1][1]=a[1][1];
      dp[1][2]=a[1][2];
      dp[1][3]=a[1][3];
      for(ll i=2;i<=n;i++)
      {
            dp[i][1]=a[i][1]+max(dp[i-1][2],dp[i-1][3]);
            dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][3]);
            dp[i][3]=a[i][3]+max(dp[i-1][1],dp[i-1][2]);
      }
      cout<<max(dp[n][1],max(dp[n][3],dp[n][2]));
      return 0;
}

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

struct Node {
	list<pair<int, long>> ns;
	long long d;
	Node() {
		d = -1;
	}
};

void CalcDis(vector<Node> &ns, int n, int k, long d = 0) {
	if (ns[k].d != -1) return;
	ns[k].d = d;
	for (auto next : ns[k].ns) {
		CalcDis(ns, n, next.first, d + next.second);
	}
}

int main() {
	int n;
	cin >> n;
	vector<Node> ns(n);
	for (int i = 1; i < n; i++) {
		int a, b;
		long c;
		cin >> a >> b >> c;
		ns[a - 1].ns.push_back(make_pair(b - 1, c));
		ns[b - 1].ns.push_back(make_pair(a - 1, c));
	}
	int q, k;
	cin >> q >> k;
	CalcDis(ns, n, k - 1);
	for (int i = 0; i < q; i++) {
		int x, y;
		cin >> x >> y;
		cout << ns[x - 1].d + ns[y - 1].d << endl;
	}
}

Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
string num[10001];

ll s2i(string a){
  ll res=0;
  for(int i=0;i<a.size();i++) res=res*10+a[i]-'0';
  return res;
}

bool compare(string a,string b){
  if(a.size()!=b.size()) return a.size()<b.size();
  return s2i(a)<s2i(b);
}


int main(){

  cin>>n;
  for(int i=0;i<n;i++)cin>>num[i];
  sort(num,num+n,compare);

  vector<ll> ans;
  for(int i=0;i<min(n,10LL);i++)
    for(int j=0;j<min(n,10LL);j++)
      if(i!=j)ans.push_back(s2i(num[i]+num[j]));
  sort(ans.begin(),ans.end());
  cout<< ans[2]<<endl;
       

  
  return 0;
}

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

int main() {
	string s;
    cin >> s;
    int ans = 0;
    int n = s.size();
    for (int i = 0, rc = 0; i < n; ++i) {
        if(s[i] == 'R') {
            rc++;
            ans = max(ans, rc);
        } else rc = 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3600
{-# LANGUAGE BangPatterns #-}

import Data.Bits
import Data.List
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IntMap
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import Data.Coerce

gen :: Int -> [Int] -> Int -> [Int]
gen 0 [] !t = [t]
gen n xs !t = do
  k <- if length xs == n then xs else [3,5,7]
  gen (n-1) (xs \\ [k]) (10*t + k)

allNum = do
  n <- [3,4..9]
  gen n [3,5,7] 0

main :: IO ()
main = do
  x <- read <$> getLine :: IO Int
  putStrLn $ show $ length $ takeWhile (<= x) allNum

Measured memory_bytes: 1404
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;

int main(){
  int A,B,C,X,Y,val=0;
  cin>>A>>B>>C>>X>>Y;
  val = min(A+B,2*C) * min(X,Y);
  if(X>Y){
    val += ((X-Y) * min(A,2*C));
  }else{
    val += ((Y-X) * min(B,2*C));
  }
  cout<<val;

  return 0;
}

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

string shuffle (string s, int h) {
    string head = s.substr (0, h);
    string tail = s.substr (h, s.size() - h);
    return tail + head;
}

int main() {
    string cards;
    int m, h;

    while (1) {
        cin >> cards;
        if (cards == "-") break;

        cin >> m;
        for (int i = 0; i < m; i++) {
            cin >> h;
            cards = shuffle (cards, h);
        }
        cout << cards << endl;
    }
    return 0;
}


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

public class Main {
	static public void main(String[] argv) {
		try{
//			FileReader file_in = new FileReader("test.txt");
//			BufferedReader d = new BufferedReader( file_in );
			BufferedReader d = new BufferedReader(new InputStreamReader(System.in));
	
			while(true) {
				String buf = d.readLine();
				
				int num = Integer.valueOf(buf);
				if( num == 0 ) break;
				
				Dice dice = new Dice();
				int res = 1;
				
				for(int i = 0; i < num; i++) {
					buf = d.readLine();
					res += dice.operation(buf);
				}
				
				System.out.println(res);
			}
			
		} catch(Exception e) {
			e.printStackTrace();
		}
	}
}

class Dice {
	private int _top;
	private int _north;
	private int _east;
	
	public Dice() {
		_top = 1;
		_north = 5;
		_east = 3;
	}
	
	public int operation(String order) {
		if( order.equals("North") ) {
			return north();
		} else if( order.equals("South") ) {
			return south();
		} else if( order.equals("East") ) {
			return east();
		} else if( order.equals("West") ) {
			return west();
		} else if( order.equals("Left") ) {
			return left();
		} else if( order.equals("Right") ) {
			return right();
		}
		
		System.out.println("error: invalid order.");
		return 65535;
	}
	
	private int north() {
		int tmp = _north;
		_north = _top;
		_top = 7-tmp;
		return _top;
	}
	
	private int south() {
		int tmp = _north;
		_north = 7-_top;
		_top = tmp;
		return _top;
	}
	
	private int east() {
		int tmp = _east;
		_east = _top;
		_top = 7-tmp;
		return _top;
	}
	
	private int west() {
		int tmp = _east;
		_east = 7-_top;
		_top = tmp;
		return _top;
	}
	
	private int left() {
		int tmp = _north;
		_north = _east;
		_east = 7-tmp;
		return _top;
	}
	
	private int right() {
		int tmp = _north;
		_north = 7-_east;
		_east = tmp;
		return _top;
	}
}

Measured memory_bytes: 21772
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		System.out.println(a+b>=10 ? "error" : a+b);
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 35848
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int i,j,k,n,m;
  string s;
  cin >> s;
  if(s.at(2)==s.at(3)&&s.at(4)==s.at(5)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Sun Dec 23 23:56:53 2018
//
package main

import "fmt"

type problem struct {
	n, c int
}

func min(a, b int) int {
	if b < a {
		return b
	}

	return a
}

func main() {
	var D, G int
	fmt.Scan(&D, &G)

	problems := make([]problem, D)
	for i := range problems {
		fmt.Scan(&problems[i].n, &problems[i].c)
	}

	ans := 1 << 31
	for i := 0; i < (1 << uint8(len(problems))); i++ {
		solved, points := 0, 0
		for j := 0; j < len(problems); j++ {
			if i&(1<<uint8(j)) != 0 {
				solved += problems[j].n
				points += problems[j].c + (j+1)*100*problems[j].n
			}
		}

		if points >= G {
			ans = min(ans, solved)
			continue
		}

		for j := 0; j < len(problems); j++ {
			if i&(1<<uint8(j)) == 0 {
				rem := G - points
				num := (rem + ((j + 1) * 100) - 1) / ((j + 1) * 100)
				if num < problems[j].n {
					ans = min(ans, solved+num)
				}
			}
		}

	}

	fmt.Println(ans)
}


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

using namespace std;

int x,y,a,b;

int main()
{
    scanf("%d%d%d%d",&x,&y,&a,&b);
    printf("%.9f ",double(x)*double(y) / 2.0);
    if(2 * a == x && 2 * b == y)
        printf("1\n");
    else
        printf("0\n");
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<string>
#include<map>
#include<set>
#include<math.h>

using namespace std;
#define ll long long
#define ull unsigned long long
#define INF 1e9
#define eps 1e-6
#define PI acos(-1.0)
#define M 10010
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef pair<int, int>P;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 10;

string s[110];
map<string,int>mp;
int main() {
    IOS;
  //freopen("in.txt", "r", stdin);
  //freopen("out.txt","w",stdout);
  int n;
  cin >> n;
  for(int i = 0 ; i < n ; ++i ){
    cin >> s[i];
    mp[s[i]]++;
  }
  for(int i = 0 ; i < n ; ++i )
  if(mp[s[i]] > 1){
    cout << "No";
        return 0;
  }
  for(int i = 1 ; i < n ; ++i){
    if(s[i][0] != s[i-1][s[i-1].length()-1]){
        cout << "No";
        return 0;
    }
  }
  cout <<  "Yes";
  return 0;
}


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

public class Main {
	
	static int discTime = 0;
	static int[] l;
	static int x = 0, y = 1;
	
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int[][] v = new int[n+1][n];
		int[] d = new int[n+1];
		l = new int[n+1];
		
		
		for (int i = 0; i < n; i++) {
			int u = sc.nextInt();
			int k = sc.nextInt();
			d[u] = -1;
			for (int a = 0; a < k; a++) {
				v[u][a] = sc.nextInt();
			}
		}
		
		d[1] = 0;
		l[0] = 1;
		
		bfs(v,d);
		
		for (int i = 1; i <= n; i++) {
			System.out.println(i + " " + d[i]);
		}
		
	}
	
	static void bfs(int[][] v, int[] d){
		for (; x<y; x++) {
			int start = l[x];
			for (int i = 0; i < v[start].length; i++) {
				int end = v[start][i];
				if (d[end] == -1) {
					d[end] = d[start]+1;
					l[y++] = end;
				}
			}
			
		}
	}
	
	
	
}


Measured memory_bytes: 28100
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

W, H, x, y = MAP()


if x == W/2 and y == H/2:
	print(W*H/2, 1)
else:
	print(W*H/2, 0)


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

int main() {

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

	for(int i = 0; i < N; i++){
		if(i) cout << " ";
		cout << A[i];
	}
	cout << endl;

	for(int i = 1; i < N; i++){
		int v = A[i];
		int j = i - 1;
		while(j >= 0 && A[j] > v){
			A[j + 1] = A[j];
			j--;
			A[j + 1] = v;
		}
		for(int k = 0; k < N; k++){
			if(k) cout << " ";
			cout << A[k];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
using namespace std;
int main(void){
    int x,y;
    cin>>x>>y;
        if(x+y<0){
            cout<<-1<<endl;
            }
            if(x+y==0){
            cout<<0<<endl;
            }
            if(x+y>0){
            cout<<1<<endl;
            }
 
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

ll ans(ll n,ll x)
{
  //cout<<n<<x;
  if(n%x==0)
  {
    return 3*(n-x);
  }
  ll da=(n-x)*3;
  if(x%(n-x)==0)
  {
    return 3*x;
  }
  return da+ans(x,x-(n%x));

}


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout<<setprecision(10);
  ll n,x;
  cin>>n>>x;
  cout<<ans(n,x)<<endl;
  return 0;

}


Measured memory_bytes: 256
line = input()
a, b, k = line.split(" ")
a = int(a)
b = int(b)
k = int(k)
 
if k >= a+b:
    print(0,0)
else:
    if a - k < 0:
        print(0, b-(k-a))
    else:
        print(a - k, b)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define typeof(x) __typeof__(x)
#define int long long int
#define double long double
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) UB(c,x)-LB(c,x)
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (s).find(e)!=(s).end()
#define PB push_back
#define MP make_pair
#define vec vector

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

using namespace std;

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

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

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

signed main()
{
   int N; cin >> N;
   vec<int> A(N), B(N);
   rep(i, 0, N) {
      cin >> A[i] >> B[i];
   }

   vec<P> X(2*N);
   rep(i, 0, N) {
      X[i] = MP(A[i], i);
      X[N+i] = MP(B[i], N+i);
   }

   SORT(X);

   int sum = 0;
   vec<bool> used(2*N, false);
   rep(i, 0, N) {
      sum += X[i].first;
      used[X[i].second] = true;
   }

   bool pair_used = false, A_used = false, B_used = false;
   rep(i, 0, N) {
      if (used[i] && used[N+i]) {
         pair_used = true;
      } else if (used[i]) {
         A_used = true;
      } else if (used[N+i]) {
         B_used = true;
      }
   }

   if (pair_used || !(A_used && B_used)) {
      cout << sum << endl;
   } else {
      int min_diff = INF;
      for (int i = 0; i < N; i++) {
         int MAX = max(A[i], B[i]);
         if (i == X[N-1].second % N) {
            min_diff = min(min_diff, MAX - X[N-2].first);
         } else {
            min_diff = min(min_diff, MAX - X[N-1].first);
         }
      }
      cout << sum + min_diff << endl;
   }

   return 0;
}


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

int main() {
  list<int> l;
  int q;
  cin >> q;

  auto cursor = l.end();
  for (int i = 0; i < q; ++i) {
    int q;
    cin >> q;

    if (q == 0) { // insert
      int x;
      cin >> x;
      cursor = l.insert(cursor, x);
    }
    if (q == 1) { // move
      int d;
      cin >> d;
      advance(cursor, d);
    }
    if (q == 2) { // erase
      cursor = l.erase(cursor, next(cursor));
    }
  }

  for (auto e : l)
    cout << e << endl;
}


Measured memory_bytes: 18556
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int s=0;
	int i,j;
	for (i=1;;i++)
	{
		s+=i;
		if (s>n) break;
	}
	int c=s-n;
	for (j=1;j<=i;j++)
	{
		if (j!=c) cout << j <<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define X first
#define  Y second
#define mp make_pair
using namespace std;
typedef long long ll;
const int N = 200010;
int a[N],n;

int main(){
	scanf("%d",&n);
	int mx = 0,ab = 0,pos = -1;
	for(int i=1;i<=n;i++){
		scanf("%d",a+i);
		if(i==1) {
			mx = abs(a[i]);
			ab = a[i];
			pos =1;
		}
		if(abs(a[i])>mx){
			mx = abs(a[i]);
			ab =a[i];
			pos =i;
		}
	}
	printf("%d\n",2*(n-1));
	if(ab>=0){
		for(int i =1;i<=n;i++) if(i!=pos) printf("%d %d\n",pos,i);
		for(int i =1;i<n;i++) printf("%d %d\n",i,i+1);
	} else{
		for(int i =1;i<=n;i++) if(i!=pos) printf("%d %d\n",pos,i);
		for(int i =n;i>1;i--) printf("%d %d\n",i,i-1);
	}
	return 0;
}

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

int main(){
    ll N, M; cin >> N >> M;
    ll A[N]; rep(i,N) cin >> A[i];
    priority_queue<ll> p;
    rep(i,N) p.push(A[i]);

    rep(i,M){
        ll tmp = p.top(); p.pop(); tmp /= 2; p.push(tmp);
    }
  
    ll sum = 0;
    while(!p.empty()){
        ll tmp = p.top(); p.pop();
        sum += tmp;
    }
    cout << sum << endl;
}


Measured memory_bytes: 2168
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
#define INF 1000000001;


int main() {
  int n;
  cin >> n;
  long long a[n];
  long long s[n+1];

  s[0] = 0;

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

  long long ans = INF;
  ans *= 200;

  for (int i = 0; i < n-1; i++) {
   long long x = s[i+1] - s[0];
   long long y = s[n] - s[i+1];
   //cerr << x << "," << y <<endl;
   ans = min(ans, abs(x-y));
   
  }


  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3328
object Main {
  def convert(line: String): String = {
    if (line.matches(".*(the|that|this).*")) {
      line
    }
    else {
      convert(line.map {
        case ch if 'b' to 'z' contains ch => (ch - 1).toChar
        case ch if ch == 'a' => 'z'
        case ch => ch
      })
    }
  }

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    while (sc.hasNextLine) {
      println(convert(sc.nextLine()))
    }
  }
}

Measured memory_bytes: 47796
#include <iostream>
#include <vector>
#include <stack>
#include <queue>

int main()
{
  int n, q;
  std::cin >> n >> q;
  std::vector<std::vector<int>> vv(n);
  for (int i = 0; i < n-1; i++)
  {
    int a, b;
    std::cin >> a >> b;
    vv[a-1].push_back(b-1);
    vv[b-1].push_back(a-1);
  }
  std::vector<long long> score(n, 0);
  for (int i = 0; i < q; i++)
  {
    int p, x;
    std::cin >> p >> x;
    score[p-1] += x;
  }


  std::queue<int> queue;
  std::vector<bool> visited_nodes(n, false);
  int parent = -1;
  queue.push(0);
  while(!queue.empty())
  {
    int visited = queue.front(); queue.pop();
    visited_nodes[visited] = true;
    int current_score = score[visited];
    for(const auto& v: vv[visited]){
      if(visited_nodes[v])
      {
        continue;
      }
      score[v]+=current_score;
      queue.push(v);
    }
  }
  // std::stack<int> stack;
  // std::vector<bool> visited_nodes(n, false);
  // int parent = -1;
  // stack.push(0);
  // while(!stack.empty())
  // {
  //   int visited = stack.top(); stack.pop();
  //   visited_nodes[visited] = true;
  //   int current_score = score[visited];
  //   for(const auto& v: vv[visited]){
  //     if(visited_nodes[v])
  //     {
  //       continue;
  //     }
  //     score[v]+=current_score;
  //     stack.push(v);
  //   }
  // }
  for(const auto& s: score)
  {
    std::cout << s<<" " << std::endl;
  }

}


Measured memory_bytes: 16500
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T, class T2> void smin(T& a, T2 val) {if (a > val) a = val;}template<class T, class T2> void smax(T& a, T2 val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

double PI = acosl(-1);
double a, b, h, m;

vector<double> getPoints(double thetha, int x){
   vector<double> ans;

   double X, Y;
   X = x * cosl(thetha);     
   Y = x * sinl(thetha);
   // if (thetha <= 90){
   //    thetha = 90 - thetha;
   //    X = x * cosl(thetha);     
   //    Y = x * sinl(thetha);
   // }
   // else if (thetha <= 180){
   //    thetha -= 90;
   //    X = x * cosl(thetha);     
   //    Y = -x * sinl(thetha);
   // }
   // else if (thetha <= 270){
   //    thetha = 270 - thetha;
   //    X = -x * cosl(thetha);     
   //    Y = -x * sinl(thetha);
   // }
   // else{
   //    thetha = thetha - 270;
   //    X = -x * cosl(thetha);     
   //    Y = x * sinl(thetha);
   // }

   ans.push_back(X);
   ans.push_back(Y);
   return ans;
}

void solve(){
   cin >> a >> b >> h >> m;

   double thetha = ((h + (m / 60.0)) / 12.0) * 2 * PI;
   double delta = (m / 60.0) * 2 * PI;

   auto A = polar(a, thetha);
   auto B = polar(b, delta);

   cout << fixed << setprecision(15);
   cout << abs(A - B);
}

int32_t main(){_
   
   int t = 1;
   //cin >> t;

   while(t--){
     solve();
     cout << endl;
   }
   

   return 0;
}

Measured memory_bytes: 4100
#include <stdio.h>

#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INF 2000000000

int n, m[N][N], color[N], d[N], p[N];

void dijkstra(void);

int main() {
  int c, k, i, j, u, v;
  
  scanf("%d", &n);
  
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      m[i][j] = INF;
    }
  }

  for (i = 0; i < n; i++) {
    scanf("%d%d", &u, &k);
    for (j = 0; j < k; j++) {
      scanf("%d%d", &v, &c);
      m[u][v] = c;
    }
  }

  dijkstra();

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

  return 0;
}


void dijkstra(void) {
  int i, j, u, v, minc, sum = 0;

  for (i = 0; i < n; i++) {
    d[i] = INF;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0] = 0;
  
  while(1) {
    minc = INF;
    for (i = 0; i < n; i++) {
      if (color[i] != BLACK && d[i] < minc) {
	minc = d[i];
	u = i;
      }
    }
    
    if (minc == INF) break;

    color[u] = BLACK;

    for (v = 0; v < n; v++) {
      if (color[v] != BLACK && m[u][v] != INF) {
	if (d[u] + m[u][v] < d[v]) {
	  d[v] = d[u] + m[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }
}



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

vector<int> a,b,c;
vector<ll> d;
ll ans = 0;
int n,m,q;

void dfs(vector<int> v, int i){
	if(v.size() == n){
		ll count = 0;
		rep(i,q){
			if(v[b[i]] - v[a[i]] == c[i]) count += d[i];
		}
		ans = max(ans, count);
	}else{
		for (int j = i; j <= m; ++j) {
			v.push_back(j);
			dfs(v, j);
			v.pop_back();
		}
	}
	return;
}
int main(){
	cin >> n >> m >> q;
	a.resize(q);
	b.resize(q);
	c.resize(q);
	d.resize(q);
	rep(i,q) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--;
		b[i]--;
	}
	vector<int> u;
	dfs(u,1);
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
a, b, c, d = map(int, input().split())

if abs(a-c) <= d :
  print ("Yes")
  exit()
else :
  if abs(a-b) <= d and abs(b-c) <= d :
    print ("Yes")
    exit()
print ("No")



Measured memory_bytes: 38256
n,m=map(int,input().split())
l=[]
for i in range(m):
  l.append(int(input()))
l=set(l)
L=[0 for i in range(n+1)]
L[0]=1
if 1 in l:
  L[1]=0
else:
  L[1]=1
for i in range(2,n+1):
  if i in l:
    L[i]=0
  else:
    L[i]=L[i-1]+L[i-2]
    L[i]%=(10**9+7)
print(L[n])

Measured memory_bytes: 13200
#include <iostream>

using namespace std;

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

    auto left = 1;
    auto right = n;

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

        left = max(left, l);
        right = min(right, r);
    }

    cout << max(0, right - left + 1) << "\n";
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
bool pass[maxn];
int wrong[maxn];
int ac,pen;
int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n,m;
	cin>>n>>m;
	for (int i = 0; i < m; ++i)
	{
		int x;
		string s;
		cin>>x>>s;
		if(s=="AC"){
			if(!pass[x]) {
				pass[x]=1;
				pen+=wrong[x];
				ac++;
			}
		}
		else{
			if(!pass[x]) wrong[x]++;
		}
	}
	cout<<ac<<" "<<pen<<endl;
	return 0;
}

Measured memory_bytes: 768
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;
#define SZ(x) ( (int) (x).size() )
#define CNT(s, x) ( (s).find(x) != (s).end() )
#define ALL(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << " = " << x << endl;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long ll;

const int N = 55;

int n, c0, c1;
int p;
ll f[N][N];

int main() {
  scanf("%d%d", &n, &p);
  for(int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    if(x % 2 == 0) c0 ++;
    if(x % 2 == 1) c1 ++;
  }
  f[0][0] = 1;
  for(int i = 1; i <= n; i++) {
    f[i][i] = f[i][0] = 1;
    for(int j = 1; j < i; j++) {
      f[i][j] = f[i-1][j] + f[i-1][j-1];
    }
  }

  ll ans = 0;
  for(int i = p; i <= c1; i += 2)

    ans += f[c1][i];

  ans = ans * (1LL << c0);
  printf("%lld\n", ans);
  return 0;
}



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

using namespace std;

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

  int N, M;
  cin >> N >> M;
  vector<long long> count(N+1, 0);

  long long p, corr = 0, pen = 0;
  string s;
  while (M--) {
    cin >> p >> s;
    if (s == "AC" && count[p] >= 0) {
      corr++;
      pen += count[p];
      count[p] = -1;
    } else if (count[p] >= 0) {
      count[p]++;
    }
  }

  cout << corr << " " << pen << endl;

	return 0;
}



Measured memory_bytes: 1024