akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>
#include <stack>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

void Topological_sort(Vvec<int> &to, std::vector<int> &ans)
{
    const int V = to.size();
    // std::vector<int> ans; // 結果
    std::stack<int> st; // 入次数0の頂点
    ans.clear();

    // 入次数のカウント
    std::vector<int> in_deg(V, 0);
    for(auto& u_to: to){
        for(int& v: u_to) in_deg[v]++;
    }

    // 入次数0の頂点追加
    for(int i=0; i<V; i++){
        if(in_deg[i] == 0) st.push(i);
    }

    // 更新
    while(!st.empty()){
        int u = st.top(); st.pop();
        ans.push_back(u);
        for(int &v: to[u]){
            in_deg[v]--;
            if(in_deg[v] == 0) st.push(v);
        }
    }
}

int main()
{
    int N, M;
    cin >> N >> M;
    Vvec<int> graph(N);
    for(int i=0; i<M; i++){
        int u, v;
        cin >> u >> v;
        u--; v--;
        graph[u].push_back(v);
    }

    vector<int> tp;
    Topological_sort(graph, tp);
    vector<int> dp(N);
    for(int i=0; i<N; i++){
        int u = tp[i];
        for(auto& v: graph[u]) dp[v] = max(dp[v], dp[u]+1);
    }

    cout << *max_element(dp.begin(), dp.end()) << endl;
}

Measured memory_bytes: 6780
import java.util.Scanner;

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

		int x[] = new int[5];

		for(int i=0;i<5;i++) {
			x[i]=sc.nextInt();
		}

		for(int i=0;i<5;i++) {
			if(x[i]==0) {
				System.out.println(i+1);
			}
		}
	}
}


Measured memory_bytes: 35684
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left

#======================================================#

def get_lucas(n):
    if n == 0: return 2
    if n == 1: return 1
    ll = [0]*(n+1)
    ll[0] = 2
    ll[1] = 1
    for i in range(2,n+1):
        ll[i] = ll[i-1] + ll[i-2]
    return ll[n]

def main():
    n = II()
    print(get_lucas(n))

if __name__ == '__main__':
    main()

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b,t; cin>>a>>b>>t;
	cout<<(t/a)*b<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i, N, s[101];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(s[i]));
	
	int j, flag[10000] = {1}, max = 0;
	for (i = 1; i <= N; i++) {
		for (j = 9999; j >= s[i]; j--) {
			if (flag[j - s[i]] == 1 && flag[j] == 0) {
				flag[j] = 1;
				if (j > max && j % 10 != 0) max = j;
			}
		}
	}
	
	printf("%d\n", max);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 256
const val MOD = 1000000007L
fun main(args: Array<String>) {
    val (N, A, B) = listOfInt()
    fun pow2(n: Int): ModInt {
        if (n == 0) return ModInt(1)
        var x = pow2(n / 2)
        x *= x
        if (n % 2 == 1) x *= 2
        return x
    }
    fun C(n: Int, a: Int): ModInt {
        var x = ModInt(1)
        var y = ModInt(1)
        repeat(a) { i ->
            x *= n - i
            y *= i + 1
        }
        return x / y
    }
    var ans = pow2(N)
    ans -= 1
    ans -= C(N, A)
    ans -= C(N, B)
    println(ans.toString())
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)


data class ModInt(private var v: Long) {
    companion object {
        private const val MOD = 1000000007L
    }
    init {
        if (v >= MOD) v %= MOD
    }
    constructor(n: Int): this(n.toLong())
    operator fun plus(other: Int): ModInt {
        val x = v + other
        if (x >= MOD) {
            return ModInt(x - MOD)
        }
        return ModInt(x)
    }
    operator fun minus(other: Int): ModInt {
        val x = v + MOD - other
        if (x >= MOD) {
            return ModInt(x - MOD)
        }
        return ModInt(x)
    }
    operator fun minus(other: ModInt): ModInt {
        val x = v + MOD - other.v
        if (x >= MOD) {
            return ModInt(x - MOD)
        }
        return ModInt(x)
    }
    operator fun times(other: Int): ModInt {
        return ModInt(v * other % MOD)
    }
    operator fun times(other: ModInt): ModInt {
        return ModInt(v * other.v % MOD)
    }
    operator fun div(other: ModInt): ModInt {
        return ModInt(v * calc(other.v, MOD - 2) % MOD)
    }
    private fun calc(a: Long, b: Long): Long {
        if (b == 0L) return 1L
        if (b % 2L == 0L) {
            val d = calc(a, b / 2)
            return d * d % MOD
        }
        return a * calc(a, b - 1) % MOD
    }
    override fun toString(): String {
        return v.toString()
    }
}

Measured memory_bytes: 42896
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N >> M >> K;
	for (int i = 0; i < K; i++) {
		if (i % 2) {
			M = M / 2;
			N += M;
		}
		else {
			N = N / 2;
			M += N;
		}
	}
	cout << N << " " << M << endl;
	return 0;

}

Measured memory_bytes: 256
#include<iostream>
const long P=1000000000+7;
using namespace std;
long long a,b,ans;
int main()
{
    ios::sync_with_stdio(false);
    cin>>a>>b;
    ans=1;
    if(abs(a-b)>1) ans=0;
    else 
    {
        for(int i=1;i<=a;++i)
            ans=ans*i%P;
        for(int i=1;i<=b;++i)
            ans=ans*i%P;
        if(a==b) ans=ans*2%P;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace std;
namespace mp = boost::multiprecision;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define rep0(i,n) for (int i=0; i<=(int)(n); ++i)
#define rep1(i,n) for (int i=1; i<=(int)(n); ++i)
#define rrep(i,n) for (int i=(int)(n)-1; i>=0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using llGraph = vector<vl>;
using vb = vector<bool>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

template<typename T>
struct is_vector : false_type{};

template<typename T>
struct is_vector<vector<T>> : true_type{};

template<typename T>
ostream &operator << (ostream &ostr, const vector<T> &vec) {
  if (vec.empty()) {
    return ostr;
  }
  ostr << vec.front();
  for (auto itr = ++vec.begin(); itr != vec.end(); ++itr) {
    if (is_vector<T>()) ostr << "\n" << *itr;
    else ostr << ' ' << *itr;
  }
  return ostr;
}

template<typename T>
bool CompareBySecond(pair<T, T> a, pair<T, T> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

template<typename T>
bool CompareBySlope(pair<T, T> a, pair<T, T> b) {
// counterclockwise from 12 o'clock direction
  if (a.first * b.first < 0) {
    return a.first < b.first;
  }
  if (a.first == 0) {
    if (a.second >= 0) {
      return true;
    }
    return a.first < b.first;
  }
  if (b.first == 0) {
    if (b.second >= 0) {
      return false;
    }
    return a.first < b.first;
  }
  return a.second * b.first < a.first * b.second;
}

template<typename T>
T GCD(T a, T b) {
  T c = a % b;
  while (c != 0) { a = b; b = c; c = a % b; }
  return b;
}


/* -------- <templates end> -------- */


void solve() {
  string s; cin >> s;
  vector<string> day = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  rep(i,7) {
    if (s == day[i]) {
      cout << 7 - i << endl;
      return;
    }
  }
}


/* -------- <programs end> -------- */


int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  solve();
  return 0;
}


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

int main(void)
{
	int n;
	cin>>n;
	int time[n+1];
	int sum=0;
	for(int i=0;i<n;i++){
		cin>>time[i];
		sum+=time[i];
	}
	int k;
	cin>>k;
	int p,x;
	for(int i=0;i<k;i++){
		cin>>p>>x;
		cout<<sum-time[p-1]+x<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,i,j,m;
            cin>>n>>m;
            int ar[m+1];
            int sum=0;
            for(i=1;i<=m;++i)
            {
                cin>>ar[i];
                sum=sum+ar[i];
            }
            if(sum>n)
            {
                cout<<-1<<endl;
            }
            else
            {
                cout<<n-sum<<endl;
            }
        }
        return 0;
    }


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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

class Puzzle {
public:
  string puzzle;
  Puzzle(string puzzle):puzzle(puzzle){}
  void rotate1(){
    swap(puzzle[6],puzzle[21]);
    swap(puzzle[7],puzzle[22]);
    swap(puzzle[8],puzzle[23]);
    swap(puzzle[17],puzzle[12]);
    swap(puzzle[11],puzzle[9]);
  }

  void rotate2(){
    swap(puzzle[0],puzzle[27]);
    swap(puzzle[1],puzzle[28]);
    swap(puzzle[2],puzzle[29]);
    swap(puzzle[15],puzzle[14]);
    swap(puzzle[18],puzzle[20]);
  }

  void rotate3(){
    swap(puzzle[0],puzzle[23]);
    swap(puzzle[3],puzzle[26]);
    swap(puzzle[6],puzzle[29]);
    swap(puzzle[15],puzzle[17]);
    swap(puzzle[9],puzzle[20]);
  }

  void rotate4(){
    swap(puzzle[2],puzzle[21]);
    swap(puzzle[5],puzzle[24]);
    swap(puzzle[8],puzzle[27]);
    swap(puzzle[11],puzzle[18]);
    swap(puzzle[12],puzzle[14]);
  }
  
};

struct Data {
  Puzzle p;
  int c;
};

int main(){
  map<string,int> mp;
  mp["111111111222444666555333333333"] = 0;
  deque<Data> deq;
  deq.push_back((Data){Puzzle("111111111222444666555333333333"),0});
  while( !deq.empty() ){
    Data data = deq.front(); deq.pop_front();
    data.c++;
    data.p.rotate1();
    if( !mp.count(data.p.puzzle) ) {
      mp[data.p.puzzle] = data.c;
      deq.push_back(data);
    }
    data.p.rotate1();

    data.p.rotate2();
    if( !mp.count(data.p.puzzle) ) {
      mp[data.p.puzzle] = data.c;
      deq.push_back(data);
    }
    data.p.rotate2();

    data.p.rotate3();
    if( !mp.count(data.p.puzzle) ) {
      mp[data.p.puzzle] = data.c;
      deq.push_back(data);
    }
    data.p.rotate3();

    data.p.rotate4();
    if( !mp.count(data.p.puzzle) ) {
      mp[data.p.puzzle] = data.c;
      deq.push_back(data);
    }
    data.p.rotate4();
    
  }

  int n;
  cin >> n;
  while( n-- ){
    string s = "";
    rep(i,30) {
      char c;
      cin >> c;
      s += string(1,c);
    }
    assert( mp.count(s) );
    cout << mp[s] << endl;
  }

  return 0;
}

Measured memory_bytes: 1272
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [i32; n],
    }

    let mut count = 0;

    for num in 0..n {
        if (num + 1) % 2 != 0 {
            if a[num] % 2 != 0 {
                count += 1;
            }
        }
    }

    println!("{}", count);
}

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

// #define int long long
struct Fast {Fast() {cin.tie(0); ios::sync_with_stdio(false);}} fast;

signed main(void) {
  // int num; // num
  // num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  // num = numeric_limits<int>::max(); // min
  double num;
  num = numeric_limits<double>::min();
  int N;
  int M;
  // array<int, 10000> A;
  // string S;
  // string T;
  
  cin >> N >> M;

  for (int i = 0; i <= N; ++i) {
    for (int j = 0; i + j <= N; ++j) {
      int k = N - i - j;

      if (M == i * 10000 + j * 5000 + k * 1000) {
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
      
    }
  }

  cout << "-1 -1 -1" << endl;
  // cout << num << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.readline
import time
import math
import itertools as it
def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
start_time = time.perf_counter()
# ------------------------------

n, k, q = inpl()
A = [inp()-1 for i in range(q)]
dp = [0] * n
for a in A:
    dp[a] += 1
cnt = 0
for i in dp:
    if k - q + i > 0:
        print('Yes')
    else:
        print('No')

# -----------------------------
end_time = time.perf_counter()
print('time:', end_time-start_time, file=sys.stderr)

Measured memory_bytes: 13788
n=input()
count=0

for i in range(2):
    A1=""
    if i==1:
        A1="A"

    for j in range(2):
        A2=""
        if j==1:
            A2="A"

        for k in range(2):
            A3=""
            if k==1:
                A3="A"

            for l in range(2):
                A4=""
                if l==1:
                    A4="A"

                ANS=A1+"KIH"+A2+"B"+A3+"R"+A4
                if n==ANS:
                    print("YES")
                    count=count+1
            

if count==0:
    print("NO")

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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


int main(){
  ll a,b; cin >> a >> b;
  vl axor(60); vl bxor(60);
  
  vl p2(60); p2[0] = 1;
  
  rep(i,50){
    p2[i+1] = 2*p2[i];
  }
  
  b++;
  
  rep(i,50){
    if(a >= p2[i]){
      if(i == 0){
        ll per = a % 4;
        if(per == 2 or per == 3) axor[0]++;
      }
      
      else{
        if((a % p2[i+1]) <= p2[i] or (a % p2[i+1]) % 2 == 0){
        axor[i] == 0;
      }
      else axor[i]++;
      }
    }
    
    if(b >= p2[i]){
      if(i == 0){
        ll per = b % 4;
        if(per == 2 or per == 3) bxor[0]++;
        
        continue;
      }
      
      if((b % p2[i+1]) <= p2[i] or (b % p2[i+1]) % 2 == 0){
        bxor[i] == 0;
      }
      else bxor[i]++;
    }
  }
  
  a = 0; b = 0;
  
  rep(i,60){
    a += p2[i]*axor[i];
    b += p2[i]*bxor[i];
  }
  
  cout << ( a^b ) << endl;
  
  
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
#include <math.h>
#include<algorithm>
using namespace std;

int A[20],n;

int divc(int i,int m){
  if(m==0) return 1;
  if(i==n) return 0;
  return divc(i+1,m-A[i]) || divc(i+1,m);
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int data;
    scanf("%d",&data);
    if(divc(0,data)) cout<<"yes"<<endl;
    else cout<<"no"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3232
local n=io.read("n")
local a={}
for i=1,n do
    a[i]={}
    for j=1,n do
        a[i][j]=io.read("n")
    end
end

local d={}
for i=1,n do
    d[i]={}
end

for k=1,n do
    for i=1,n do
        for j=1,n do
            if a[i][j]>a[i][k]+a[k][j] then
                print(-1)
                return
            elseif a[i][j]==a[i][k]+a[k][j] and a[i][k]>0 and a[k][j]>0 then
                d[i][j]=true
            end
        end
    end
end

local total=0
for i=1,n do
    for j=1,i do
        total=total+(not d[i][j] and a[i][j] or 0)
    end
end
print(total)

Measured memory_bytes: 5248
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		map<int,bool>tmp;
		loop(i,1,n){
			int t=i*i;
			t%=n;
			tmp[t]=true;
		}
		vi in;
		for(map<int,bool>::iterator it=tmp.begin();it!=tmp.end();it++)
			in.pb(it->first);
		//cout<<in.size()<<endl;
		vi out((n-1)/2+1,0);
		rep(i,in.size())rep(j,in.size())if(i!=j){
			int t=in[i]-in[j];
			t=abs(t);
			if(t>(n-1)/2)t=n-t;
			//if(t<0)t+=n;
			out[t]++;
		}
		loop(i,1,(n-1)/2+1)cout<<out[i]<<endl;
	}
}

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

int n, m;
bool inside(int x, int y) {
	if (0 <= x and x < n and 0 <= y and y < m) return true;
	else return false;
}

int DI[4] = {1, 0, -1, 0};
int DJ[4] = {0, 1, 0, -1};

int main() {
	cin >> n >> m;
	vector<string> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	int S = n*m, T = n*m+1;
	mf_graph<int> g(n*m+2);
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			if (a[i][j] == '#') continue;
			if ((i+j) % 2) g.add_edge(i*m + j, T, 1);
			else {
				g.add_edge(S, i*m + j, 1);
				for (int k = 0; k < 4; ++k) {
					int di = i+DI[k], dj = j+DJ[k];
					if (inside(di, dj) and a[di][dj] == '.') g.add_edge(i*m + j, di*m + dj, 1);
				}
			}
		}
	}
	cout << g.flow(S, T) << endl;
	for (auto e : g.edges()) {
		if (e.from == S or e.to == T or e.flow == 0) continue;
		int i0 = e.from/m, j0 = e.from%m;
		int i1 = e.to/m, j1 = e.to%m;
		if (i1 == i0 - 1) {
			a[i0][j0] = '^';
			a[i1][j1] = 'v';
		} else if (i1 == i0 + 1) {
			a[i0][j0] = 'v';
			a[i1][j1] = '^';
		} else if (j1 == j0 - 1) {
			a[i0][j0] = '<';
			a[i1][j1] = '>';
		} else {
			a[i0][j0] = '>';
			a[i1][j1] = '<';
		}
	}

	for (int i = 0; i < n; ++i) cout << a[i] << endl;
	return 0;
}

Measured memory_bytes: 5496
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,x,m;
int l[11],r[11],s[11];
int ans;
vector<int> arr;
void dfs(vector<int> v){
  if(v.size()==n){
    for(int i=0;i<m;i++){
      int tmp=0;
      for(int j=l[i]-1;j<r[i];j++){
    tmp+=v[j];
      }
      if(tmp!=s[i]) return;
    }
    int res=0;
    for(int i=0;i<n;i++) res+=v[i];
    if(ans<res){
      ans=res;
      arr=v;
    }
    return;
  }
  for(int i=0;i<=x;i++){
    v.push_back(i);
    dfs(v);
    v.pop_back();
  }
}
signed main(){
  cin>>n>>x>>m;
  for(int i=0;i<m;i++) cin>>l[i]>>r[i]>>s[i];
  ans=-1;
  dfs(vector<int>(0));
  if(ans<0) cout<<ans<<endl;
  else for(int i=0;i<n;i++) cout<<arr[i]<<" \n"[i==n-1];
  return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

ll n, a, b, c, d;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n >> a >> b >> c >> d;
	bool flag = false;
	ll cur = (n-1) * d + (d+c);
	FOR(i, n) {
		cur -= (d+c);
		if (b <= a + cur && b >= a + cur - (n-1)*(d-c)) flag = true;
	}
	if (flag) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using llong = long long;
const int MOD=1000000007;

int gcd(int x, int y) { return y ? gcd(y, x%y) : x; }

// int bin_gcd(vector<int>& a, int* s, int* e){
//     int n = a.size();
//     if (n == 2){
//         return euclidean_gcd(a[0], a[1]);
//     }
//     if (n == 3){
//         return euclidean_gcd(euclidean_gcd(a[0], a[1]), a[2]);
//     }
//
//     return euclidean_gcd(bin_gcd(a, *s, *s+n/2), bin_gcd(*s+n/2+1, *e))
//
//     }
// }
//
// int main(int argc, char**argv){
//     int n;
//     cin >> n;
//     vector<int> a(n);
//     for (int i = 0; i < n; i++){
//         scanf("%d", &a[i]);
//     }
//
//     sort(a.begin(), a.end());
//     reverse(a.begin(), a.end());
//
//     int ans = 0;
//     for (int i = 0; i < n; i++){
//         int tmp = a[i];
//         if (i < n-1) a[i] = a[i+1];
//         else a[i] = a[i-1];
//         ans = max(ans, bin_gcd(a, a.begin(), a.end()));
//         a[i] = tmp;
//     }
//
//     cout << ans << endl;
//
//     return 0;
// }

int main(int argc, char**argv){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }

    vector<int> left(n+1, 0), right(n+1, 0);
    for (int i = 0; i < n; i++){
        left[i+1] = gcd(left[i], a[i]);
    }
    for (int i = n-1; i >= 0; i--){
        right[i] = gcd(right[i+1], a[i]);
    }

    int res = 0;
    for (int i = 0; i < n; i++){
        int l = left[i];
        int r = right[i+1];

        res = max(res, gcd(l, r));
    }
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 1408
#include <iostream>

int main() {
    const int inf = 100000;
    char masu[60][60];
    int _masu[60][60];
    int h, w, dots = 0;
    std::cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            char t;
            std::cin >> t;
            if (t == '.') dots++;
            masu[i][j] = t;
            _masu[i][j] = inf;
        }
    }
    _masu[0][0] = 0;
    for (int c = 0; c < h * w; c++) {
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (_masu[i][j] < inf) {
                    if (i > 0 && _masu[i-1][j] == inf && masu[i-1][j] == '.')
                        _masu[i-1][j] = _masu[i][j] + 1;
                    if (j > 0 && _masu[i][j-1] == inf && masu[i][j-1] == '.')
                        _masu[i][j-1] = _masu[i][j] + 1;
                    if (i < h-1 && _masu[i+1][j] == inf && masu[i+1][j] == '.')
                        _masu[i+1][j] = _masu[i][j] + 1;
                    if (j < w-1 && _masu[i][j+1] == inf && masu[i][j+1] == '.')
                        _masu[i][j+1] = _masu[i][j] + 1;
                }
            }
        }
    }
    int len = _masu[h-1][w-1];
    if (len == inf) {
        std::cout << -1 << std::endl;
    } else {
        std::cout << dots - (len + 1) << std::endl;
    }

    /*
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            std::cout << _masu[i][j] << " ";
        }
        std::cout << std::endl;
    }
    */
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> x(N);
  for(int i=0; i<N; i++){
    cin >> x[i];
  }
  int ans=INFI;
  for(int i=0; i<N-K+1; i++){
    ans = min(ans,abs(x[i]-x[i+K-1])+min(abs(x[i]),abs(x[i+K-1])));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
n, x = list(map(int, input().split()))

def b_size(N): #バーガーの大きさ
    return 2 ** (N+2) - 3

def p_num(N): #そのレベルのパティの数
    return 2 ** (N+1) - 1

def f(level, X):
    if X == 0:
        return 0

    if level == 0:
        return 1

    if X <= b_size(level-1)+1:
        return f(level-1, X-1)
    else:
        return p_num(level-1) + f(level-1, X-b_size(level-1)-2) + 1

print(f(n, x))

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

int main(){
  string S;
  string ans = "Yes";
  cin >> S;
  
  for(int i = 0; i < S.size(); i++ ){
    if( i%2 == 0 && S.at(i) == 'L' ){
      ans = "No";
    }
    if( i%2 == 1 && S.at(i) == 'R' ){
      ans = "No";
    }
  }
  
  cout << ans << endl;
}

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

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

  int mini = 1e9 + 7;

  for (int i = -100; i <= 200; i++){
    int sum = 0;
    for (int j = 0; j < n; j++){
      sum += pow(a[j] - i, 2);
    }
    mini = min(mini, sum);
  }

  cout << mini << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll gcd(ll a, ll b);
ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int main(void){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (abs(c - a) <= d || (abs(a - b) <= d && abs(b - c) <= d))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

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

ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
 
int main(){
  long long n,m,a,b;
  cin >> n >> m;
  long long d[n];
  for (long long i = 0; i < n; ++i) d[i] = 0;
  
  int h[n];
  for (long long i = 0; i < n; ++i) cin >> h[i];
  
  for (long long i = 0; i < m; ++i) {
  	cin >> a >> b;
    if (h[a-1] == h[b-1]){
      d[b-1] += 1;
      d[a-1] += 1;
  	}else if (h[a-1] > h[b-1]){
      d[b-1] += 1;
    }else{
      d[a-1] += 1;
    }
  }
  
  int ans = 0;
  for (int i = 0; i < n; ++i) {
   	if (d[i] == 0) ans += 1; 
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4804
#include<bits/stdc++.h>
 
#define fi first
#define se second
#define pb push_back
 
#define limit (int) (1e6 + 5) 
#define mod (long long int) (1e9 + 7)
 
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
using ld = long double;

int k;
int ans[limit];

int main()
{
	// ios_base::sync_with_stdio(false);cin.tie(NULL);   
    lli a,b,c,d;

    cin >> a >> b >> c >> d;

    lli ans = a*c;
    ans = max(a*d,ans);
    ans = max(b*c,ans);
    ans = max(b*d,ans);

    cout << ans;
    return 0;
}




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

int main() {
	int n, u, v; cin >> n >> u >> v;
	u--; v--;
	vector<vector<int>> con(n);
	for (int i = 0; i < n - 1; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		con.at(a).push_back(b);
		con.at(b).push_back(a);
	}
	vector<int> vec1(n, -1);
	vec1.at(u) = 0;
	queue<int> q;
	q.push(u);
	while (q.size() > 0) {
		int p = q.front();
		q.pop();
		for (int c : con.at(p)) {
			if (vec1.at(c) >= 0) continue;
			vec1.at(c) = vec1.at(p) + 1;
			q.push(c);
		}
	}
	vector<int> vec2(n, -1);
	vec2.at(v) = 0;
	queue<int> r;
	r.push(v);
	while (r.size() > 0) {
		int p = r.front();
		r.pop();
		for (int c : con.at(p)) {
			if (vec2.at(c) >= 0) continue;
			vec2.at(c) = vec2.at(p) + 1;
			r.push(c);
		}
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (vec1.at(i) < vec2.at(i)) ans = max(ans, vec2.at(i) - 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 6656
#include<stdio.h>
const int MAX_V = 1000000;
int prime[1000001];
int main(){
  int n, i, k;
  for(i = 2;i <= MAX_V;i++){
    prime[i] = 1;
  }
  for(i=2;i*i<=MAX_V;i++){
    if(prime[i]){
      for(k = 2*i;k <= MAX_V;k += i){
        prime[k] = 0;
      }
    }
  }
  scanf("%d", &n);
  while(n != 0){
    for(i=n;i>0;i--){
      if(prime[i]){
        if(prime[i-2]){
          printf("%d %d\n", i-2, i);
          break;
        }
      }
    }
    scanf("%d", &n);
  }
  return 0;
}

Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=305;
int f[N][N],c[N][N],s[N][N],n,m,MOD;

int main()
{
	scanf("%d%d%d",&n,&m,&MOD);
	for (int i=0;i<N;i++)
	{
		c[i][0]=1;
		for (int j=1;j<=i;j++)
			c[i][j]=(c[i-1][j-1]+c[i-1][j])%MOD;
	}
	for (int i=0;i<=m;i++) f[1][i]=1,s[1][i]=(m-i+1)%MOD;
	for (int i=2;i<=n+1;i++)
	{
		for (int j=0;j<=m;j++)
			for (int k=1;k<i;k++)
				f[i][j]=((LL)f[k][j]*s[i-k][j+1]%MOD*c[i-2][k-1]%MOD+f[i][j])%MOD;
		for (int j=m;j>=0;j--)
			s[i][j]=(s[i][j+1]+f[i][j])%MOD;
	}
	printf("%d\n",f[n+1][0]);
	return 0;
}


Measured memory_bytes: 1280
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

lo n,m,b[li],a[li],k,flag,t;
lo cev;
string s;
vector<lo> v;

int main(void){
	scanf("%lld %lld",&n,&m);
	lo at=n+m;
	lo kat=n-m;
	at=max(at,kat);
	at=max(at,n*m);
	//~ int kat=n+m;
	printf("%lld\n",at);
	return 0;
}


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

using namespace std;

struct restaruant {
    string city;
    short score;
    short order;
    bool operator<(const restaruant &op) const {
        if (city == op.city)
            return score > op.score;
        return city < op.city;
    }
};

int main() {
    int n;
    cin >> n;
    restaruant *lst = new restaruant[n];
    for (int i = 0; i < n; ++i) {
        cin >> lst[i].city >> lst[i].score;
        lst[i].order = i + 1;
    }
    sort(lst, lst + n);
    for (int i = 0; i < n; ++i) {
        cout << lst[i].order << endl;
    }
    return 0;
}


Measured memory_bytes: 256
program main
implicit None
integer(8)::d,g,i,s,n,j,k,ma
integer(8),allocatable::p(:),c(:),a(:),e(:)
character::b*10,f*1
	
	read*,d,g
	g = g/100
	allocate(p(d),c(d),a(d),e(d))
	do i = 1,d
		read *,p(i),c(i)
		c(i) = c(i)/100
		a(i) = i*p(i)+c(i)
	enddo
	
	k = sum(p)
	
	do i = 0,2**d-1
		write(b,"(b10.10)")i
		e =0
		do j = 11-d,10
			f = b(j:j)
			read(f,"(i1)")e(11-j)
		enddo
		s =0;n =0
		do j = 1,d
			s = s + a(j)*e(j)
			n = n + p(j)*e(j)
		enddo
		
		if(s >=g)then
			if(n < k) k = n
			cycle
		endif
		
		do j = d,1,-1
			if(e(j) == 0) exit
		enddo
		
		if(g-s <= j*p(j))then
			n = n + (g-s)/j
			if(mod(g-s,j)/=0) n = n+1
			if(n < k) k = n
		endif
	enddo
	
	print "(i0)",k
	
end program main

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n,m,f[101010];
vector<int>g[101010];
bool was[101010];
int dfs(int v)
{
	if(was[v])
	{
		return f[v];
	}
	was[v]=true;
	for(int i=0;i<g[v].size();i++)
	{
		int to=g[v][i];
		f[v]=max(f[v],dfs(to)+1);
	}
	return f[v];
}
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		g[a].push_back(b);
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		ans=max(ans,dfs(i));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8320
#include<stdio.h>
                                                                                               
int main(){
  int x[4];
  int y[4];

  scanf("%d %d %d %d", &x[0], &y[0], &x[1], &y[1]);
  
  x[3] =-(y[1] - y[0]) + x[0];
  y[3] = (x[1] - x[0]) + y[0];
  
  x[2] = x[1] + x[3] - x[0];
  y[2] = y[1] + y[3] - y[0];

  printf("%d %d %d %d\n", x[2], y[2], x[3], y[3]);

  return 0;
}


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

const double PI=3.14159265358979323846;

int main() {

    double r;
    cin >> r;
    double ans;
    ans = 2 * PI * r;
    printf("%.10f", ans);
    return 0;
}

Measured memory_bytes: 3704
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
#define MAX_N 100005
ll inv[MAX_N], fac[MAX_N], finv[MAX_N];
void make() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i=2; i<MAX_N; i++) {
    inv[i] = mod - inv[mod%i] * (mod/i) % mod;
    fac[i] = fac[i-1] * (ll)i % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}
ll perm(ll n, ll r) {
  if(n < 0)       return 0;
  else if(n < r)  return 0;
  else            return (fac[n] * finv[n-r]) % mod;
}
ll comb(ll n, ll r) {
  ll ans = 1;
  ans = perm(n, r); // n * (n-1) * ... * (n-r+1)
  ans = (ans * finv[r]) % mod; // フェルマーの小定理
  return ans;
}
int main() {
  make();
  int N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  sort(all(A));
  ll ans = 0;
  rep(i, N) {
    ans -= A[i] * comb(N-i-1, K-1);
    ans %= mod;
    ans += A[i] * comb(i, K-1);
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1;
#define cni cin

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
//typedef unsigned int uint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int n,m;
int x,y,z;

main(){
	cin>>n>>m;
	m/=1000;
	int a=m-n,b=5*n-m,l=m/10;
	for(int i=0;i<=l;i++){
		int a=m-n,b=5*n-m;
		if(a%4==0&&b%4==0&&a>=0&&b>=0){
			cout<<i<<' '<<a/4<<' '<<b/4<<endl;
			return 0;
		}
		m-=10;
		n-=1;
	}
	cout<<"-1 -1 -1"<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#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 ALL(a) a.begin(), a.end()

int main() {
  string S;
  cin >> S;
  int A = S[0] - '0';
  int B = S[1] - '0';
  int C = S[2] - '0';
  int D = S[3] - '0';
  if (A + B + C + D == 7) {
    printf("%d+%d+%d+%d=7\n", A, B, C, D);
    return 0;
  }
  if (A - B + C + D == 7) {
    printf("%d-%d+%d+%d=7\n", A, B, C, D);
    return 0;
  }
  if (A + B - C + D == 7) {
    printf("%d+%d-%d+%d=7\n", A, B, C, D);
    return 0;
  }
  if (A + B + C - D == 7) {
    printf("%d+%d+%d-%d=7\n", A, B, C, D);
    return 0;
  }
  if (A - B - C + D == 7) {
    printf("%d-%d-%d+%d=7\n", A, B, C, D);
    return 0;
  }
  if (A + B - C - D == 7) {
    printf("%d+%d-%d-%d=7\n", A, B, C, D);
    return 0;
  }
  if (A - B + C - D == 7) {
    printf("%d-%d+%d-%d=7\n", A, B, C, D);
    return 0;
  }
  if (A - B - C - D == 7) {
    printf("%d-%d-%d-%d=7\n", A, B, C, D);
    return 0;
  }
  return 0;
}

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

using namespace std;

typedef pair<long long int,pair<long long int,long long int>> node;

int main(){
	long long int N,M,cap;
	while(cin>>N>>M>>cap, N||M||cap){
		string src, dest;
		cin>>src>>dest;
		map<string,long long int>X;
		X[src]=0;
		X[dest]=1;
		long long int idx=2;
		vector<pair<pair<string, string>,long long int>>input(N);
		for(int i = 0; i < N; i++){
			cin>>input[i].first.first>>input[i].first.second>>input[i].second;
			if(X.count(input[i].first.first)==0){
				X[input[i].first.first]=idx;
				idx++;
			}
			if(X.count(input[i].first.second)==0){
				X[input[i].first.second]=idx;
				idx++;
			}
		}
		vector<vector<pair<long long int,long long int>>>D(idx);
		for(int i = 0; i < N; i++){
			D[X[input[i].first.first]].push_back(make_pair(X[input[i].first.second], input[i].second));
			D[X[input[i].first.second]].push_back(make_pair(X[input[i].first.first], input[i].second));
		}
		set<long long int>Station;
		for(int i = 0; i < M; i++){
			string s;
			cin>>s;
			Station.insert(X[s]);
		}


		priority_queue<node, vector<node>,greater<node>>que;
		que.push(make_pair(0, make_pair(0, cap * 10)));
		vector<vector<node>>memo(idx);
		//memo[0].push_back(make_pair(0, make_pair(0, cap * 10)));
		bool ok=false;
		while(que.size()){
			auto now= que.top();que.pop();
			//cout << now.first<<" "<<now.second.first<<" "<<now.second.second<<endl;
			if(now.second.first==1){
				cout<<now.first<<endl;
				ok=true;
				break;
			}
			bool f=false;
			for(auto check:memo[now.second.first]){
				if(now.first>=check.first && now.second.second <= check.second.second){
					f=true;
					break;
				}
			}
			if(f)continue;
			memo[now.second.first].push_back(now);
			if(Station.count(now.second.first)){
				now.second.second=cap*10;
			}
			for(auto nextPoint:D[now.second.first]){
				auto next=now;
				next.second.first=nextPoint.first;
				next.first+=nextPoint.second;
				next.second.second-=nextPoint.second;
				if(next.second.second<0)continue;
				que.push(next);
			}
		}
		if(!ok)cout<<-1<<endl;
	}
}

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

typedef pair<int, int> P;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

void solve(int n){
	int x[2] = {}, y[2] = {};
	vector<P> v(n);
	v[0] = P(0, 0);
	for(int i=1; i<n; ++i){
		int a, b;
		cin >> a >> b;
		v[i] = P(v[a].first + dx[b], v[a].second + dy[b]);
		x[0] = min(x[0], v[i].first);
		x[1] = max(x[1], v[i].first);
		y[0] = min(y[0], v[i].second);
		y[1] = max(y[1], v[i].second);
	}
	cout << x[1] - x[0] + 1 << " " << y[1] - y[0] + 1 << "\n";
}

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	while(1){
		int n;
		cin >> n;
		if(n == 0) return 0;
		solve(n);
	}
}


Measured memory_bytes: 3076
def main():
    N = int(input())

    cnt = 0
    for i in range(N):
        da, db = tuple([int(_x) for _x in input().split()])

        if da == db:
            cnt += 1
        else:
            cnt = 0

        if cnt == 3:
            print("Yes")
            return
    print("No")


main()


Measured memory_bytes: 9168
#include<bits/stdc++.h>
#define append push_back
#define endl "\n"
#define N 100001
#define M 1000000007
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int 
#define cover(arr,val) memset(arr,val,sizeof(arr)) 
using namespace std;
ll solve(ll n,ll w);
ll wt[N],val[N],dp[N][101];
int main()
{
	IOS;
	ll n,w;
	cin >> n >> w;
	for(int i=0;i<n;i++)
		cin >> wt[i] >> val[i];
	memset(dp,-1,sizeof(dp));
	dp[0][0] = 0;
	cout << solve(n,w) << endl;
	return 0;
}
ll solve(ll n,ll w)
{
	if(n<=0 || w<=0)return dp[0][0];
	else if(dp[w][n]!=-1)return dp[w][n];
	else if(w<wt[n-1])
	{
		dp[w][n] = solve(n-1,w);
		return dp[w][n];//if we cannot use the existing weighted iite for the answer
	}
	else
	{
		ll temp = val[n-1]+solve(n-1,w-wt[n-1]);
		dp[w][n] = max(temp,solve(n-1,w));
		return dp[w][n];
	}
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,k,q;
  cin >> n >> k >> q;
  VI m(n,k-q);
  rep(i,q){
    int x;
    cin >> x;
    x--;
    m[x]++;
  }
  rep(i,n){
    if(m[i] > 0) cout << "Yes" << "\n";
    else cout << "No" << "\n";
  }
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n, a, b; cin >> n >> a >> b;
    cout << min(a*n, b) << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <stdio.h>
#include <set>
#include <map>
#include <vector>

using namespace std;

#define ll long long
// #define rep(i, n) for (ll i = 1; i < (n+1); i++)
// #define rep(j, n) for (ll j = 1; j < (n+1); j++)
// #define rep(k, n) for (ll k = 1; k < (n+1); k++)


int main()
{
    ll K;
    ll a = 100;
    cin >> K;
    ll year = 0;
    while (a < K) {
        a = a * 1.01;
        // a = float(a);
        // cout << a << endl;
        year++;
    }
    cout << year << endl;
}



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

signed main(){
	lint N; cin >> N;
	set<lint> SET;
	for(lint i = 0; i < N; i++){
		lint x; cin >> x;
		SET.insert(x);
	}
	lint n = SET.size();
	if(n % 2 == 1) cout << n << endl;
	else cout << n - 1 << endl;
}


Measured memory_bytes: 4992
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    D = int(input())
    c = [0] + list(map(int, input().split()))
    s = [[0]*27]
    for _ in range(D):
        s.append([0] + list(map(int, input().split())))
    for i in range(1, D+1):
        print(s[i].index(max(s[i])))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define INF 1000000000000000000
#define all(x) x.begin(), x.end()
#define PI 3.141592653589793

int main() {
    double R;
    cin >> R;
    double res = 2 * R * PI;
    cout << fixed << setprecision(10) << res << endl;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); 
  ll n;
  cin >> n;
  ll a=sqrt(n);
  for(ll i=a;i>=1;i--){
    if(n%i==0){cout << i+n/i-2 << endl; return 0;}
  }
}

Measured memory_bytes: 384
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

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

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()
	a := nextInts(n)

	l := make([]int, n)
	r := map[int]int{}
	for i := range a {
		l[i] = i + a[i]
		if i-a[i] >= 0 {
			r[i-a[i]]++
		}
	}

	ans := 0
	for i := 0; i < n; i++ {
		ans += r[l[i]]
	}

	puts(ans)
}


Measured memory_bytes: 15680