akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
struct edge{int u,v;};
struct tree{
  vector<vector<int>> G,son,ancestor;
  vector<int> depth,parent;
  queue<int> que;
  int root=-1;
  bool made_lca=false;

  tree(int n):G(n),son(n),parent(n,-1),depth(n,-1),ancestor(n){
    for(int i=0;i<n;i++)ancestor[i].resize(30);
  }

  void add_edge(int u,int v){
    G[u].push_back(v);
    G[v].push_back(u);
  }

  inline void reset_root(){
    root=-1;
    fill(depth.begin(),depth.end(),-1);
    fill(parent.begin(),parent.end(),-1);
    for(auto &p:ancestor)for(int &q:p)q=-1;
    for(auto &p:son)p.resize(0);
    made_lca=false;
  }

  void have_root(int r){
    reset_root();
    root=r;
    que.push(r);
    while(que.size()){
      int p=que.front();que.pop();
      for(int q:G[p]){
        if(parent[p]==q)continue;
        son[p].push_back(q);
        parent[q]=p;
        que.push(q);
      }
    }
  }

  void set_depth(){
    assert(~root);
    depth[root]=0;
    que.push(root);
    while(que.size()){
      int p=que.front();que.pop();
      for(int q:son[p]){
        depth[q]=depth[p]+1;
        que.push(q);
      }
    }
  }

  inline void make_lca(){
    assert(~root);
    if(depth[root]<0)set_depth();
    for(int i=0;i<G.size();i++)ancestor[i][0]=parent[i];
    for(int j=1;j<30;j++)
      for(int i=0;i<G.size();i++)
        if(~ancestor[i][j-1])
          ancestor[i][j]=ancestor[ancestor[i][j-1]][j-1];
    made_lca=1;
  }

  int lca(int u,int v){
    if(!made_lca)make_lca();
    if(depth[u]>depth[v])swap(u,v);
    int diff=depth[v]-depth[u],cnt=0;
    while(diff){
      if(diff&1)v=ancestor[v][cnt];
      cnt++;
      diff>>=1;
    }
    if(u==v)return u;
    for(int k=28;k>=0;k--)
      if(ancestor[u][k]!=ancestor[v][k])
        u=ancestor[u][k],v=ancestor[v][k];
    return ancestor[u][0];
  }
};

int black[1<<20],have[50][20];

signed main(){
  int n,m;cin>>n;
  vector<edge> a(n-1);
  tree t(n);
  for(int i=0;i<n-1;i++){
    int u,v;cin>>u>>v;u--;v--;
    a[i]={u,v};
    t.add_edge(u,v);
  }
  cin>>m;
  vector<int> u(m),v(m);
  for(int i=0;i<m;i++){cin>>u[i]>>v[i];u[i]--;v[i]--;}
  for(int i=0;i<n-1;i++){
    t.have_root(a[i].u);
    for(int j=0;j<m;j++)have[i][j]+=(t.lca(u[j],v[j])==a[i].u);
    t.have_root(a[i].v);
    for(int j=0;j<m;j++)have[i][j]+=(t.lca(u[j],v[j])==a[i].v);
  }
  black[0]=1;
  for(int i=0;i<n-1;i++){
    int tmp=0;
    for(int j=0;j<m;j++)if(have[i][j]==2)tmp+=1<<j;
    for(int j=(1<<20)-1;j>=0;j--)black[j|tmp]+=black[j];
  }
  cout<<black[(1<<m)-1]<<endl;
}


Measured memory_bytes: 8448
s = gets.chomp
num1=0
num0=0
num=0
last=s[0]
if last=="0"
    num0+=1
else
    num1+=1
end
s[1..-1].split('').each do |t|
    if t=="0"
        num0+=1
    else
        num1+=1
    end
    next if last==t
    if last==""
        last=t
        next
    end
    if t=="0"
        num+=num0
        num1-=num0
        num0-=1
    else
        num+=num1
        num0-=num1
        num1-=1
    end
    if num0==0 && num1==0
        last=""
    end
end
puts num*2

Measured memory_bytes: 22444
N = gets.to_i
A = gets.split.map(&:to_i)
Q = gets.to_i

nums = Array.new(10**5+1,0)
sum = 0
A.each do |a|
    sum += a
    nums[a] += 1
end

Q.times do |q|
    b, c = gets.split.map(&:to_i)
    nums[c] += nums[b]
    sum = sum - b * nums[b] + c * nums[b]
    nums[b] = 0
    puts sum
end

Measured memory_bytes: 22192
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int A, B, b;

    cin >> A >> B;

    b = B + B;

    if(A>b) {
        cout << A-b << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
    
}

Measured memory_bytes: 256
#include <vector>
#include <string>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 999999999
int main(){
    int n,k;
    cin >> n >> k;
    if(n%k==0){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }
}


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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    // (a1 + a2 + a3 + ... + an) = n (mod k)
    // (a1 + a2 + a3 + ... + an) - n = 0 (mod k)
    // ((a1 - 1) + (a2 - 1) + ... + (an - 1)) = 0 (mod k)

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    vector<int> ps(n + 1);
    for (int i = 0; i < n; i++) {
        ps[i + 1] = (ps[i] + (a[i] - 1)) % k;
    }

    map<int, int> cnt;
    long res = 0;
    for (int i = 0; i <= n; i++) {

        if (i - k >= 0) {
            cnt[ps[i - k]]--;
        }
        
        res += cnt[ps[i]];
        cnt[ps[i]]++;
    }

    cout << res;


    return 0;
}

Measured memory_bytes: 11264
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdlib.h>
#include<stack>
using namespace std;
const int N=1e4+50;
const int INF=0x3f3f3f;
char s1[N],s2[N],s3[N];
int main()
{
    scanf("%s%s%s",s1,s2,s3);
    int l1=strlen(s1),l2=strlen(s2),l3=strlen(s3);
    int a=-1,b=-1,c=-1;
    int turn=97;
    while(1)
    {
        if(turn==97)
        {
        if(a==l1-1)
        {
            printf("A\n");
            return 0;
        }
            a++;
            turn=s1[a];
        }
        else if(turn==98)
        {
        if(b==l2-1)
        {
            printf("B\n");
            return 0;
        }
            b++;
            turn=s2[b];
        }
        else if(turn==99)
        {
        if(c==l3-1)
        {
            printf("C\n");
            return 0;
        }
            c++;
            turn=s3[c];
        }
    }

}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define sz size()
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)

#define ll long long

int main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    // freopen("input.in","r",stdin);

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

    int a[300010] = {0};
    int b[300010] = {0};

    int maxx = -1;
    int maxy = -1;

    int kojx,kojy;

    map< pair<int, int>, int> mapa;

    std::vector<int> xov;
    std::vector<int> yov;

    int i;
    for (i=0;i<targets;i++) {
        int x,y;
        cin>>x>>y;
        mapa[{x,y}] = 1;
        a[x]++;
        if (a[x]>maxx) {
            maxx = a[x];
            kojx = x;
            xov.clear();
            xov.pb(x);
        } else
        if (a[x] == maxx) {
            xov.pb(x);
        }
        b[y]++;
        if (b[y]>maxy) {
            maxy = b[y];
            kojy = y;
            yov.clear();
            yov.pb(y);
        } else
        if (b[y] == maxy) {
            yov.pb(y);
        }
    }
    int j;
    for (i=0;i<xov.size();i++)
    for (j=0;j<yov.size();j++)
    if (mapa[{xov[i], yov[j]}] == 0) {
        cout<<maxx + maxy<<"\n";
        return 0;
    }

    int br = maxx+maxy;

    if (mapa[{kojx, kojy}] == 1) {
        br--;
    }

    cout<<br<<"\n";



    return 0;
}


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

int main(){
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
    cout << "vowel" << endl;
  
  else
    cout << "consonant" << endl;
}
    


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define rep2(i,a,n) for (int i = a; i < n; i++)
using namespace std;
int K;
int A, B;
int main() {
    cin >> K;
    cin >> A >> B;
    // if((B+1-A)/K < 1 && (B/K) == (A/K)) {
    //     cout << "NG" << endl;
    // } else {
    //     cout << "OK" << endl;
    // }
    int len = K;
    bool flaf = false;
    while(len <= B) {
        if(A<=len && len <= B) {
            flaf = true;
            break;
        }
        len += K;
    }
    if(flaf) cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}


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

using namespace std;


typedef long long ll;

const int M = 1e9+7 ;


int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n , p ;
    cin >> n >> p ;

    string s; 
    cin >>  s ; 
    
    if (p == 2 ){   
        ll ans = 0 ; 

        for(int i = 0 ; i < n ; ++i){
            if ((s[i] - '0' ) % 2 ==0){
                ans += i + 1; 
            }
        }

        cout << ans << "\n";
        return 0 ;
    }
    else if (p == 5){

        ll ans = 0 ;
        for(int i = 0 ; i < n ; ++i){
            if ((s[i] - '0') % 5 == 0){
                ans += i + 1 ;
            }
        }

        cout << ans << "\n";

        return 0 ;
    }

    ll P = 1 ;
    ll suf = 0  ;
    map<ll,ll> m ; 
    m[0] = 1 ;
    ll ans = 0 ;
    for(int i = n - 1 ; i >=0  ;--i){
        suf = (suf + (s[i] - '0')*P) % p;
        ans = ans + m[suf];
        m[suf]++; 

        P = (10*P)% p ;
    }
    cout << ans << "\n";

    
  
    return 0;
}



Measured memory_bytes: 1044
import math
import sys

def calc_clock_angle(h, m):
    m_angle = (360 / 60) * m
    h_angle = (360 / 12) * h + ((360 / 12) / 60 ) * m
    angle = abs(m_angle - h_angle)
    if angle > 180:
        return 360 - angle
    else:
        return angle
    pass

a, b, h, m = map(int, input().split())
if h == 12 and m == 0:
    print(abs(a - b))
    sys.exit()

angle = calc_clock_angle(h, m)

t = math.sqrt(a**2 + b**2 - (2 * a * b * math.cos(math.radians(angle))))
print(t)


Measured memory_bytes: 9524
N = int(input())
A = [int(input()) for i in range(N)]

A.sort(reverse=True)

def p1(l):
    if N%2 == 1:
        ans = 0
        ans += sum(l[:(N-3)//2])*2
        ans += sum(l[(N-3)//2:(N-3)//2+2])
        ans += sum(l[(N-3)//2+2:])*(-2)
        return ans
    else:
        ans = 0
        ans += sum(l[:(N-2)//2])*2
        ans += sum(l[(N-2)//2:(N-2)//2+1])
        ans += sum(l[(N-2)//2+1:(N-2)//2+2])*(-1)
        ans += sum(l[(N-2)//2+2:])*(-2)
        return ans

def p2(l):
    if N%2 == 1:
        ans = 0
        ans += sum(l[:(N-1)//2])*2
        ans += sum(l[(N-1)//2:(N-1)//2+2])*(-1)
        ans += sum(l[(N-1)//2+2:])*(-2)
        return ans
    else:
        ans = 0
        ans += sum(l[:(N-2)//2])*2
        ans += sum(l[(N-2)//2:(N-2)//2+1])
        ans += sum(l[(N-2)//2+1:(N-2)//2+2])*(-1)
        ans += sum(l[(N-2)//2+2:])*(-2)
        return ans
print(max(p1(A),p2(A)))
    


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

int count_divisor(int N) {
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if(N % i == 0) {
      ans++;
    }
  }
  return ans;
}

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

  int ans;
  for (int i = 1; i <= N; i += 2) {
    if (count_divisor(i) == 8) {
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
// A - Buttons

#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

int main()
{
    int A,B;
    cin >> A >> B;

    int total = 0;
    if (A <= B) {
        int tmp = A;
        A = B;
        B = tmp;
    }

    total += A;
    A--;
    if (A >= B) {
        total += A;
    }
    else {
        total += B;
    }

    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n,m; cin >> n >> m;
	vector<string> a(n); rep(i,n) cin >> a[i];
	vector<string> b(m); rep(j,m) cin >> b[j];
	bool ans = false;
	rep(si,n-m+1)rep(sj,n-m+1){
		bool ok = true;
		rep(i,m){
//			cout << a[si+i].substr(sj,m) << endl;
//			cout << b[i] << endl;
			if(a[si+i].substr(sj,m)!=b[i]) ok = false;
		}
		if(ok) ans = true;
	}
	
	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3636
N = int(input())
T, A = list(map(int,input().split()))
H = list(map(int,input().split()))
diffs = [abs(A - (T - h * 0.006)) for h in H]
min_idx = -1
min = float('inf')
for i in range(len(diffs)):
    if min > diffs[i]:
        min = diffs[i]
        min_idx = i
print(min_idx+1)

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

using namespace std;

int a[10];

bool dfs(int i, int l, int r)
{
    if (i == 10) return true;

    if (l < a[i] && dfs(i + 1, a[i], r)) return true;
    if (r < a[i] && dfs(i + 1, l, a[i])) return true;

    return false;
}

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

    while (n--) {
        for (int i = 0; i < 10; ++i) cin >> a[i];
        cout << (dfs(0, 0, 0) ? "YES" : "NO") << endl;
    }
}

Measured memory_bytes: 1152
defmodule Main do
  require Integer

  def main do
    [x, y] = IO.gets("") |> String.trim() |> String.split() |> Enum.map(&String.to_integer/1)

    case Integer.is_even(y) do
      false ->
        "No"

      true ->
        case x * 4 < y do
          true ->
            "No"

          false ->
            case x * 2 > y do
              true ->
                "No"

              false ->
                "Yes"
            end
        end
    end
    |> IO.puts()
  end
end

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


	int a, b, c, d, e;

	scanf("%d", &a);
	scanf("%d", &b); 
	scanf("%d", &c);
	scanf("%d", &d);
	scanf("%d", &e);

	if (a == 0) {
		printf("1");
	}
	else if (b == 0) {
		printf("2");
	}

	else if (c == 0) {
		printf("3");
	}

	else if (d == 0) {
		printf("4");
	}

	else if (e == 0) {
		printf("5");
	}



	return 0;
}

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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


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

	ll ret = 0;
	for (int i = n-1; i >= 0; i--) {
		ll tmp = a[i]+ret;
//		cout << tmp << "\n";
		if (tmp%b[i]!=0) {
			ret += b[i]-tmp%b[i];
		}

	}
	cout << ret << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long int
#define MP make_pair
#define PB push_back
#define F first
#define S second
using namespace std;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef vector<PII> VP;
typedef pair<PII, int> PPI;
const int INF = 3e18;

int n, a[100010];
int *p[200010];
int pls[200010], mns[200010];
signed main()
{
  cin >> n;
  for(int i = 0; i < n; i++)
    cin >> a[i];

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

  if(n == 1)
    cout << "YES" << endl;
  else{
    for(int i = 0; i < n; i++){
      if(*p[i] >= *p[i + 1]){
	int diff = *p[i] - *p[i + 1];
	if(diff % (n - 1) == 0){
	  pls[i + 1] += diff / (n - 1);
	  mns[i + n] += diff / (n - 1);
	}
	else{
	  pls[i + 1] += diff / (n - 1) + 1;
	  mns[i + n] += diff / (n - 1) + 1;
	}
      }
    }
    
    int now = 0, many = 0;
    for(int i = 0; i < 2 * n; i++){
      now += pls[i];
      many += pls[i];
      *p[i] -= now;
      many -= mns[i];
      now -= mns[i] * n;
      now += many;
    }
    
    bool flag = true;
    for(int i = 0; i < n; i++){
      if(*p[i])
	flag = false;
    }
    
    cout << (flag ? "YES" : "NO") << endl;
  }
  return 0;
}


Measured memory_bytes: 4096
#include <iostream>
using namespace std;
int main(){
  	long long a,b,k;
  	cin>>a>>b>>k;
    if(a>k)
        a=a-k;
    else{
        b=b-k+a;
        a=0;
    }
  if(b<0)
    b=0;
	cout<<a<<" "<<b;
}


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

int main(){
	ll n;
	scanf("%lld", &n);
	ll an = 0;
	for (ll l = 1, r; l <= n; l = r + 1){
		r = n / (n / l);
		ll d = n / l;
		if (n % d)continue;
		ll t = n / d - 1;
		if (t >= l && t <= r)an += t;
	}
	printf("%lld\n", an);
}

Measured memory_bytes: 256
import java.util.*;

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

        if (a <= b) {
            System.out.println(a);
        } else {
            System.out.println(a - 1);
        }
    }
}

Measured memory_bytes: 21844
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	h, w := scanInt(), scanInt()
	c := make([][]int, 10)
	for i := 0; i < 10; i++ {
		c[i] = scanInts(10)
	}

	for k := 0; k < 10; k++ {
		for i := 0; i < 10; i++ {
			for j := 0; j < 10; j++ {
				c[i][j] = min(c[i][j], c[i][k]+c[k][j])
			}
		}
	}

	ans := 0
	for i := 0; i < h*w; i++ {
		a := scanInt()
		if a >= 0 {
			ans += c[a][1]
		}
	}

	fmt.Fprintln(wr, ans)
}


Measured memory_bytes: 1852
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,M,D; cin>>N>>M>>D;
  double X=(N-D)*2.0/N/N;
  if(D==0) X=1.0/N;
  printf("%.10lf\n",X*(M-1));
  }


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

int main()
{  ll a,b,c,k,sum=0;
   cin>>a>>b>>c>>k;
    if(k>a)
        sum+=a;
    else
    {sum+=k;
    cout<<sum;exit(0);}
    k-=a;

    if(k>b)
        k-=b;
    else
    {cout<<sum;exit(0);}

    if(k>c)
        sum-=c;
    else
        sum-=k;
    cout<<sum;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n, k, r, s, p;
  string t;
  cin >> n >> k >> r >> s >> p >> t;
  map<char, int> mp;
  mp['r'] = p;
  mp['s'] = r;
  mp['p'] = s;
  vector<bool> seen(n, false);
  vector<bool> win(n, false);
  ll ans = 0;
  rep(i,n) {
    if (seen.at(i)) continue;
    for (int j = i; j < n; j += k) {
      if (j >= n) continue;
      seen.at(j) = true;  
      if (!(j - k < 0) && (t.at(j-k) == t.at(j) && win.at(j-k))) continue;

      win.at(j) = true;      
      ans += mp.at(t.at(j));
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3768
#include <cstdio>
#include <cstdlib>
#include <algorithm>

int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	long long int *ppp = new long long int[n];
	long long int *ppn = new long long int[n];
	long long int *pnp = new long long int[n];
	long long int *pnn = new long long int[n];
	long long int *npp = new long long int[n];
	long long int *npn = new long long int[n];
	long long int *nnp = new long long int[n];
	long long int *nnn = new long long int[n];
	long long int x, y, z;
	long long int sum, max;
	int i, j;
	for(i = 0; i < n; i++) {
		scanf("%lld %lld %lld", &x, &y, &z);
		ppp[i] =  x + y + z;
		ppn[i] =  x + y - z;
		pnp[i] =  x - y + z;
		pnn[i] =  x - y - z;
		npp[i] = -x + y + z;
		npn[i] = -x + y - z;
		nnp[i] = -x - y + z;
		nnn[i] = -x - y - z;
	}
	std::sort(ppp, ppp+n);
	std::sort(ppn, ppn+n);
	std::sort(pnp, pnp+n);
	std::sort(pnn, pnn+n);
	std::sort(npp, npp+n);
	std::sort(npn, npn+n);
	std::sort(nnp, nnp+n);
	std::sort(nnn, nnn+n);

	sum = 0;
	for(i = 0; i < m; i++) {
		sum += ppp[n - i - 1];
	}
	max = sum;
	sum = 0;
	for(i = 0; i < m; i++) {
		sum += ppn[n - i - 1];
	}
	if (sum > max) {
		max = sum;
	}
	sum = 0;
	for(i = 0; i < m; i++) {
		sum += pnp[n - i - 1];
	}
	if (sum > max) {
		max = sum;
	}
	sum = 0;
	for(i = 0; i < m; i++) {
		sum += pnn[n - i - 1];
	}
	if (sum > max) {
		max = sum;
	}
	sum = 0;
	for(i = 0; i < m; i++) {
		sum += npp[n - i - 1];
	}
	if (sum > max) {
		max = sum;
	}
	sum = 0;
	for(i = 0; i < m; i++) {
		sum += npn[n - i - 1];
	}
	if (sum > max) {
		max = sum;
	}
	sum = 0;
	for(i = 0; i < m; i++) {
		sum += nnp[n - i - 1];
	}
	if (sum > max) {
		max = sum;
	}
	sum = 0;
	for(i = 0; i < m; i++) {
		sum += nnn[n - i - 1];
	}
	if (sum > max) {
		max = sum;
	}

	delete[] ppp;
	delete[] ppn;
	delete[] pnp;
	delete[] pnn;
	delete[] npp;
	delete[] npn;
	delete[] nnp;
	delete[] nnn;
	printf("%lld\n", max);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
int DBG = 1;										/* デバッグプリント 提出時は0 */
/* main *************************************************************/
int main()
{
	//月曜日は "mon"、火曜日は"tue"、水曜日は "wed"、木曜日は "thu"、金曜日は "fri"、土曜日は "sat"、日曜日は "sun" 
	
	int		f,a,b,c,i,j,k,n,m,x,y,ans = 0;
	char	str[7][4] = { "thu", "fri", "sat", "sun", "mon", "tue", "wed" };
	
	scanf("%d", &x);

	printf("%s\n",str[x%7]);

	return 0;
}



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

N += 1
total = 0

for i in range(N):
    if i % 3 == 0 and i % 5 == 0:
        continue
    elif i % 3 == 0:
        continue
    elif i % 5 == 0:
        continue
    else:
        total += i

print(total)

Measured memory_bytes: 9172
#include<stdio.h>
int main(){
	int a[3],i,j,temp;
	for(i=0;i<3;i++){
		scanf("%d",&a[i]);
	}
	for(i=0;i<3-1;i++){
		for(j=0;j<3-1-i;j++){
			if(a[j]>a[j+1]){
				temp=a[j];
				a[j]=a[j+1];
				a[j+1]=temp;
			}
		}
	}
	printf("%d %d %d\n",a[0],a[1],a[2]);
	return(0);
}

Measured memory_bytes: 596
# -*- coding: utf-8 -*-
import math
import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(X):
    d = [1, 0]
    c = [0, 0]
    eps = 10**-7
    X /= 360
    X *= 2*math.pi
    for i in range(1, 361):
        c[0] += d[0]
        c[1] += d[1]
        d = [
            d[0]*math.cos(X) - d[1]*math.sin(X),
            d[0]*math.sin(X) + d[1]*math.cos(X)
        ]

        if abs(c[0]) < eps and abs(c[1]) < eps:
            return i
    return i


def main():
    X = read_int()
    print(slv(X))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9592
import bisect
x, n = map(int, input().split())
p = sorted(list(map(int, input().split())))
b = []
if n == 0:
    print(x)
else :
    for i in range(-200, 300):
        if not i in p:
            b.append(i)
    index = bisect.bisect_left(b, x)
    a = abs(x-b[index-1]) 
    c = abs(x-b[index])
    if a <= c:
        print(b[index-1])
    else :
        print(b[index])



Measured memory_bytes: 9204
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        a: [[i32; 3]; 3],
        n: usize,
        b: [i32; n],
    }

    let mut card = vec![
        vec![false, false, false],
        vec![false, false, false],
        vec![false, false, false],
    ];
    b.into_iter().for_each(|b| {
        a.iter().enumerate().for_each(|(y, a)| {
            a.iter().enumerate().for_each(|(x, &a)| {
                if a == b {
                    card[y][x] = true;
                }
            });
        });
    });

    let mut ok = card.iter().any(|row| row.iter().all(|x| *x));
    ok = ok
        || (card[0][0] && card[1][0] && card[2][0])
        || (card[0][1] && card[1][1] && card[2][1])
        || (card[0][2] && card[1][2] && card[2][2])
        || (card[0][0] && card[1][1] && card[2][2])
        || (card[0][2] && card[1][1] && card[2][0]);
    println!("{}", if ok { "Yes" } else { "No" });
}


Measured memory_bytes: 2184
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
using namespace std;

long long MOD = 1000000007;
long long dp[101][8];

bool is_valid_bit_set(int bit_set, int W){
    for(int i = 0; i < W - 2; i++){
        if(((((bit_set >> i)) & 1) == 1) && (((bit_set >> (i + 1)) & 1) == 1)){
            return false;
        }
    }
    return true;
}

bool is_zero_bit(int bit_set, int pos){
    if(((bit_set >> pos) & 1) == 1){
        return false;
    }
    return true;
}

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

    if(W == 1){
        cout << 1 << endl;
        return 0;
    }
    dp[0][0] = 1;
    for(int i = 1; i <= H; i++){
        for(int bit_set = 0; bit_set < (1 << (W - 1)); bit_set++){
            if(is_valid_bit_set(bit_set, W)){
                for(int j = 0; j < W; j++){
                    if(j == 0){
                        if(is_zero_bit(bit_set, j)){
                            dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
                        } else {
                            dp[i][j] = (dp[i][j] + dp[i - 1][j + 1]) % MOD;
                        }
                    } else if(j == W - 1){
                        if(is_zero_bit(bit_set, j - 1)){
                            dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
                        } else {
                            dp[i][j] = (dp[i][j] + dp[i - 1][j - 1]) % MOD;
                        }
                    } else {
                        if(is_zero_bit(bit_set, j) && is_zero_bit(bit_set, j - 1)){
                            dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
                        } else if(!is_zero_bit(bit_set, j)){
                            dp[i][j] = (dp[i][j] + dp[i - 1][j + 1]) % MOD;
                        } else {
                            dp[i][j] = (dp[i][j] + dp[i - 1][j - 1]) % MOD;
                        }
                    }
                }
            }
        }
        /*
        for(int j = 0; j < W; j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
        */
    }

     
     /* 
    for(int i = 0; i < W; i++){
        cout << dp[H][i] << " ";
    }
    cout << endl;
    */ 

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


Measured memory_bytes: 256
import math
a,b,x=map(int,input().split())

if ((a**2)*b/2)>=x:
  t=2*x/(a*b)
  ans=math.atan(b/t)*180/math.pi
else:
  s=2*b-2*x/(a**2)
  ans=math.atan(s/a)*180/math.pi
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    int x,y,z;
    cin>>x>>y>>z;
    swap(x,y);
    swap(x,z);
    cout<<x<<" "<<y<<" "<<z;
    return 0;
}


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

typedef long long ll;

bool f(vector<ll> &A, vector<ll> &F, ll K, ll n) {
    ll sum = 0;
    for (int i = 0; i < A.size(); i++) {
        sum += max(0LL, A[i] - n / F[i]);
    }
    return sum <= K;
}

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N), F(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> F[i];

    sort(A.begin(), A.end());
    sort(F.begin(), F.end(), greater<ll>());

    ll lb = -1, ub = (ll)1e18;
    while (ub - lb > 1) {
        ll mid = lb + (ub - lb) / 2;
        if (f(A, F, K, mid)) {
            ub = mid;
        } else {
            lb = mid;
        }
    }

    cout << ub << endl;
    return 0;
}

Measured memory_bytes: 3328
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
        
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())
    
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}


n,m,k = inpl()
uf = UnionFind(n)
fr = [[] for _ in range(n)]
frs = [set() for _ in range(n)]
bl = [[] for _ in range(n)]
for _ in range(m):
    a,b = inpl()
    a,b = a-1,b-1
    fr[a].append(b)
    fr[b].append(a)
    frs[a].add(b)
    frs[b].add(a)
    uf.union(a,b)
for _ in range(k):
    a,b = inpl()
    a,b = a-1,b-1
    bl[a].append(b)
    bl[b].append(a)

for i in range(n):
    re = 0
    for j in bl[i]:
        if uf.same(i,j) and not j in frs[i]:
            re += 1
    print(uf.size(i) - len(fr[i]) - re - 1)
    

Measured memory_bytes: 144164
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

N = int(input())
T = list(map(int, input().split()))
M = int(input())
P = [] * M
X = [] * M
for i in range(M):
    p, x = map(int, input().split())
    P.append(p-1)
    X.append(x)

#print(P, X)

for i in range(M):
    ans = sum(T)
    p = P[i]
    x = X[i]
    ans -= (T[p]-x)

    print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());

        // 主処理
        String result = 10 <= a + b ? "error" : Integer.toString(a + b);

        // 出力
        System.out.println(result);
        sc.close();
    }
}

Measured memory_bytes: 21716
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations
import sys
import bisect
import string
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
mo=10**9+7

n=I()
a=LI()
ans=0
while a:
    ans+=1/(a.pop())
print(1/ans)

Measured memory_bytes: 38640
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a <= b)cout << a << endl;
	else cout << a - 1 << endl;

	return(0);
}

Measured memory_bytes: 256
//g++  7.4.0

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string str;
    cin >> n >> str;
    int l = 0;
    int r = n - 1;
    int cnt = 0;
    while(l < r){
        if(str[l] == 'R'){
            l++;
            continue;
        }
        if(str[r] == 'W'){
            r--;
            continue;
        }
        swap(str[l] , str[r]);
        l++;
        r--;
        cnt++;
    }
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=a;i<b;i++)
using namespace std;
using ll = long long;
int main() {
	string s;
	ll ans=0,sum;
	cin>>s;
	rep(i, 0, 1 << s.size()-1) {
      sum=0;
		rep(j, 0, s.size()) {
			if (1 & i >> j)sum = sum*10 + (int)(s[j] - '0');
			else ans += sum * 10 + (int)(s[j] - '0'),sum=0;
		}
	}
	cout<<ans<<endl;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N), C(N);
    for(int i=0; i<N; ++i) {
        C[i] = i + 1;
        cin >> A[i];
    }

    if(A == C) {
        cout << "YES" << endl;
        return 0;
    }

    for(int i=0; i<N; ++i) {
        for(int j=i+1; j<N; ++j) {
            swap(A[i], A[j]);
            if(A == C) {
                cout << "YES" << endl;
                return 0;
            }
            swap(A[i], A[j]);
        }
    }
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<int> p(a),q(b);
    vector<int> g(c);
    ll ans = 0;
    for(int i = 0; i < a; i++) cin >> p[i];
    for(int i = 0; i < b; i++) cin >> q[i];
    for(int i = 0; i < c; i++) cin >> g[i];
    sort(p.begin(),p.end(),greater<int>());
    sort(q.begin(),q.end(),greater<int>());
    for(int i = 0; i < x; i++) g.push_back(p[i]);
    for(int i = 0; i < y; i++) g.push_back(q[i]);
    sort(g.begin(),g.end(),greater<int>());
    for(int i = 0; i < x+y; i++) ans += g[i];
    cout << ans << endl;
}

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

#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx_ori[4] = { -1,0, 1,0 }, dy_ori[4] = { 0,1,0,-1 };
int dx[4] = {0, 0, 0, 0}, dy[4] = {0, 0, 0, 0};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//const ll MOD = 1000000007;
const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
  fio();
  ll n, a, b;
  cin >> n >> a >> b;
  a--; b--;
  if ((b - a) % 2 == 0) {
    cout << (b - a) / 2 << endl;
    return 0;
  }

  ll ans1 = 0, ans2 = 0;
  ans1 += a;
  ll a2 = a - a, b2 = b - a;
  ans1++;
  b2--;
  ans1 += b2 / 2;

  ans2 += (n - 1) - b;
  b2 = b + (n - 1) - b;
  a2 = a + (n - 1) - b;
  ans2++;
  a2++;
  ans2 += (n - 1 - a2) / 2;
  cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int main(int argc, char* argv[]) {
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);
    
    int space = max(a, b) - min(a, b) - 1;
    if (space & 1)
        puts("Alice");
    else
        puts("Borys");

    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
using namespace std;
const int MAX = 10005;
int c[MAX];
int main(void)
{
	//ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	int *a, *b;
	cin >> n;
	a = new int[n + 1];
	b = new int[n + 1];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		++c[a[i]];
	}
	int i;
	for (i = 0; i <= MAX; ++i)
	{
		if (c[i])
		{
			--c[i];
			cout << i;
			break;
		}
	}
	for (i = 0; i <= MAX; ++i)
	{
		while (c[i])
		{
			--c[i];
			cout << ' ' << i;
		}
	}
	cout << endl;
	return 0;
}

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



int main(){
  int flag=0;
  int64_t N;
    cin >> N;
  vector<int64_t> A(N),B(N);

  vector<pair<int64_t,int64_t>> p(N);

  for(int64_t i=0;i<N;i++){
    cin >> A.at(i) >>B.at(i);
  }
  /*for(int64_t i=0;i<N;i++){
    cout << A.at(i) <<B.at(i)<<endl;
  }*/

  
  for(int64_t i=0;i<N;i++){
    p.at(i)=make_pair(B.at(i), A.at(i));
  }
  
  sort(p.begin(),p.end());
  //cout << p.at(0).first <<endl;


  int64_t sum=0;
  for(int64_t i=0;i<N;i++){
      
        sum+=p.at(i).second;
      
      //cout << sum <<endl;
    if(sum>p.at(i).first){
      flag = 1;
      cout << "No" << endl;
      break;
    }
    

  }
  if(flag <= 0){
    cout << "Yes" <<endl;
  }

  }










Measured memory_bytes: 6528
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
using namespace std;
#define mod int(1e9+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,a,b) for(int i=a;i<=b;i++)
#define repn(i,a,b) for(int i=b-1;i>=a;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long int ll;

int main()
{ ios_base::sync_with_stdio(false); cin.tie(0);
 ll a,b,c; cin>>a>>b>>c;
 if(a==b+c || b==c+a || c==a+b) cout<<"Yes"<<endl;
else cout<<"No"<<endl; 
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace template
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var a = cin.ReadInt;
            var b = cin.ReadInt;

            Console.WriteLine((a*b)%2 == 0 ? "Even" : "Odd");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) 
                {
                    return inputStream.Dequeue();
                }

                string[] tmp = _stream.ReadLine().Split(_separator);
                
                for (int i = 0; i < tmp.Length; ++i)
                {
                    inputStream.Enqueue(tmp[i]);
                }
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 13268
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String args[]) throws Exception {
		MyScanner sc = new MyScanner();
		PrintWriter pr = new PrintWriter(System.out);
		String s = sc.next();
		String ans = "";
		char c = s.charAt(s.length() - 1);
		if(c == '2' || c == '4' || c == '5'|| c == '7'|| c == '9')
			ans = "hon";
		else if(c == '0'|| c == '1'|| c == '6'|| c == '8')
			ans = "pon";
		else
			ans = "bon";
		pr.println(ans);
		pr.close();
	}

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}

Measured memory_bytes: 32728
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
typedef pair<int, ll> P;
ll dp[300][300];
int dp2[300][300];
int main() {
	int N, M, L;
	cin >> N >> M >> L;
	fill((ll*)dp, (ll*)(dp + 300), 1LL << 60);
	for (int i = 0; i < N; i++) dp[i][i] = 0;
	for (int i = 0; i < M; i++) {
		int A, B, C;
		cin >> A >> B >> C;
		A--; B--;
		dp[A][B] = dp[B][A] = C;
	}
	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) {
			if (dp[i][j] > dp[i][k] + dp[k][j]) {
				dp[i][j] = dp[i][k] + dp[k][j];
			}
		}
	}
	fill((int*)dp2, (int*)(dp2 + 300), 1 << 25);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (dp[i][j] <= L) dp2[i][j] = 1;
		}
	}
	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (dp2[i][j] > dp2[i][k] + dp2[k][j]) {
					dp2[i][j] = dp2[i][k] + dp2[k][j];
				}
			}
		}
	}
	int Q;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int s, t;
		cin >> s >> t; s--; t--;
		if (dp2[s][t] == 1 << 25) cout << -1 << endl;
		else cout << dp2[s][t] - 1 << endl;
	}
}

Measured memory_bytes: 1536
def main():
    buf = input()
    S = list(buf)
    A_count = 0
    B_appeared = False
    op_count = 0
    for pointer, _ in enumerate(S):
        if S[pointer] == 'A':
            if B_appeared:
                B_appeared = False
                A_count = 0
            A_count += 1
        elif S[pointer] == 'B':
            if A_count == 0:
                pass
            elif not B_appeared:
                B_appeared = True
            else: # B_appeared
                B_appeared = False
                A_count = 0
        else: # S[pointer] == 'C'
            if not B_appeared:
                A_count = 0
            else:
                op_count += A_count
                B_appeared = False
    print(op_count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main() 
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    string s;
    cin>>s;
    string ans = "";
    ans.push_back(s[0]);
    ans.push_back(s[1]);
    ans.push_back(s[2]);
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 3640
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

int main()
{
	int x;
	scanf("%d", &x);
	int ans;
	for (ans = 1;; ans++) {
		x -= ans;
		if (x <= 0) break;
	}
	printf("%d\n", ans);
	return 0;
}


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

#define INF 1000000000000
#define MOD 1000000007

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

    int n;
    cin>>n;
    int cntr=0;
    for(int i=0; i<n; i++){
        int d1, d2;
        cin>>d1>>d2;
        if(d1==d2){
            cntr++;
        }else{
            cntr=0;
        }
        
        if(cntr==3){
            cout<<"Yes"<<endl;
            return 0;
        }
    }

    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3652