akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int2(int *a1, int64_t *a2) {
  scanf("%d %lld", a1, a2);
  return 0;
}

#define NUM_MAX 50

int main(void) {
    int layers;
    int64_t cnt;
    get_int2(&layers, &cnt);

    static int64_t patties[NUM_MAX+1];
    static int64_t total[NUM_MAX+1];
    patties[0] = 1;
    total[0] = 1;
    int i;
    for(i = 1; i <= layers; i++) {
        patties[i] = patties[i-1]*2 + 1;
        total[i] = total[i-1]*2 + 3;
    }

    int64_t ans = 0;
    for(i = layers; i >= 0; i--) {
        if(cnt == 0) break;
        int64_t half = total[i]/2;
        // top half
        if(cnt > half) {
            ans += patties[i-1]+1;
            cnt -= half;
        // bottom half
        } else {
            if(i == 0) ans += 1;
        }
        cnt -= 1;
#ifdef DEBUG
        printf("%d: %lld, ans: %lld\n", i, cnt,  ans);
#endif
    }
    printf("%lld\n", ans);
    return 0;
}

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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

template<typename T> inline istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> inline ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

template<typename T> inline T min(vector<T>& v) {return *min_element(v.begin(), v.end());}

template<typename T> inline T max(vector<T>& v) {return *max_element(v.begin(), v.end());}

template<typename T> inline void sort(vector<T>& v) {sort(v.begin(), v.end());}

template<typename T, typename Function> inline void sort(vector<T>& v, Function func) {sort(v.begin(), v.end(), func);}

template<typename T> inline void rsort(vector<T>& v) {sort(v.rbegin(), v.rend());}

template<typename T> inline void reverse(vector<T>& v) {reverse(v.begin(), v.end());}

template<typename T> inline void unique(vector<T>& v) {v.erase(unique(v.begin(), v.end()), v.end());}

template<typename T> inline void nth_element(vector<T>& v, int n) {nth_element(v.begin(), v.begin() + n, v.end());}

template<typename T> inline bool next_permutation(vector<T>& v) {return next_permutation(v.begin(), v.end());}

template<typename T> inline int find(vector<T>& v, T t) {return find(v.begin(), v.end(), t) - v.begin();}

template<typename T> inline int in(vector<T> v, T t) {return find(v, t) != (int)v.size();}

template<typename T> inline int lower_bound(vector<T>& v, T t) {return lower_bound(v.begin(), v.end(), t) - v.begin();}

template<typename T> inline int upper_bound(vector<T>& v, T t) {return upper_bound(v.begin(), v.end(), t) - v.begin();}

template<typename T> inline T accumulate(const vector<T>& v) {return accumulate(v.begin(), v.end(), T(0));}

template<typename T> inline void adjacent_difference(vector<T>& v, vector<T>& u) {adjacent_difference(v.begin(), v.end(), u.begin());}

template<typename T> inline void partial_sum(vector<T>& v, vector<T>& u) {partial_sum(v.begin(), v.end(), u.begin());}

template<typename T> inline T inner_product(vector<T>& v, vector<T>& u) {return inner_product(v.begin(), v.end(), u.begin(), T(0));}

template<typename T, typename Function> inline int count_if(vector<T> v, Function func) {return count_if(v.begin(), v.end(), func);}

template<typename T, typename Function> inline void remove_if(vector<T>& v, Function func) {v.erase(remove_if(v.begin(), v.end(), func), v.end());}

template<typename T, typename Function> inline bool any_of(vector<T> v, Function func) {return any_of(v.begin(), v.end(), func);}

int main() {
  int n, res = 0;
  cin >> n;
  vector<int> l(2 * n);
  cin >> l;
  sort(l);
  for (int i = 0; i < n; ++i) res += l[2 * i];
  cout << res << endl;
}


Measured memory_bytes: 256
/*
ID: simpgoo1
TASK: 
LANG: C++14            
*/
// timus 219263UI
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <ctime>
#include <queue>
#include <vector>
#include <cstdlib>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <unordered_map>
using namespace std;
typedef long long ll;
#define y1 needtrainharder
#define F first
#define S second
#define gg exit(0)
#define sz() size()
#define sz() size()
#define sz() size()
#define sz() size()
#define sz() size()
#define sz() size()
#define sz() size()
#define sz() size()
#define sz() size()
#define sz() size()
#define sz() size()
#define sz() size()
#define sz() size()
#define sz() size()
#define sz() size()

#define pb push_back
#define mp make_pair
#define skip continue
#define all(x) x.begin(), x.end()
#define boost ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define file(s,x) if(x == 1)freopen(s".in","r",stdin),freopen(s".out","w",stdout);
#define task "sorting"
const int INF = 1e9 + 100;  
const ll INFLL = 1e18 + 100;  
const int MAXN = 3e5 + 100; 

bool pr[211111], nc[211111];

int ans[211111];

int main(){ 
  boost; 
  srand(time(NULL));
  if(fopen(task".in", "r")){  
    freopen(task".in", "r", stdin);
    freopen(task".out","w",stdout); 
  }

  int q;
  cin>>q;
  pr[1] = 1;
  for(int i = 2; i <= 210111; ++i){
    if(!pr[i]){
      if(i * 1ll * i <= 210111){
        for(int j = i * 2; j <= 210111; j += i)
          pr[j] = 1;
      }
    }
  }

  for(int i = 3; i <= 110111; ++i){
    if(!pr[i]&&!pr[(i+1)/2]){
      ++ans[i];
    }
    ans[i] += ans[i-1];
  }

  int l, r;
  while(q--){
    cin>>l>>r;
    cout<<ans[r]-ans[l - 1]<<'\n';
  }


  return 0;
}


Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace D {
    class questionD {
        static void Main(string[] args) {
            int[] NKinput = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();//2つ以上のスペース区切り入力の取得
            int N = NKinput[0];
            int K = NKinput[1];
            int[,] whites = new int[K, 2 * K];
            for (int i = 0; i < N; i++) {
                string[] input = Console.ReadLine().Split(' ').ToArray();
                int x = int.Parse(input[0]) % (2 * K);
                int y = int.Parse(input[1]) % (2 * K);
                string mark = input[2];
                if (mark == "W") {
                    if (x >= K) {
                        x = (x + K) % (2 * K);
                        y = (y + K) % (2 * K);
                    }
                } else {
                    x = (x + K) % (2 * K);
                    if (x >= K) {
                        x = (x + K) % (2 * K);
                        y = (y + K) % (2 * K);
                    }
                }
                whites[x, y]++;
            }
            int[,] Ysums = new int[K, 2 * K];
            for (int i = 0; i < K; i++) {
                int sum = 0;
                for (int j = 0; j < K; j++) {
                    sum += whites[i, j];
                }
                Ysums[i, 0] = sum;
                //Console.WriteLine(Ysums[i, 0]);
            }
            //Console.WriteLine("abcdef");
            for (int i = 0; i < K; i++) {
                for (int j = 1; j < 2 * K; j++) {
                    Ysums[i, j] = Ysums[i, j - 1] + whites[i, (j - 1 + K) % (2 * K)] - whites[i, j - 1];
                    //Console.WriteLine(Ysums[i, j]);
                }
            }
            int max = 0;
            for (int j = 0; j < K; j++) {
                int sum = 0;
                for (int k = 0; k < K; k++) {
                    sum += Ysums[k, j];
                }
                if (sum > max) {
                    max = sum;
                }
                //Console.WriteLine(sum);
                for (int i = 0; i < K; i++) {
                    sum += Ysums[i, j + K] - Ysums[i, j];
                    if (sum > max) {
                        max = sum;
                    }
                    //Console.WriteLine(sum);
                }
                for (int i = 0; i < K; i++) {
                    sum += Ysums[i, j] - Ysums[i, j + K];
                    if (sum > max) {
                        max = sum;
                    }
                    //Console.WriteLine(sum);
                }
            }
            // Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
            // Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);//改行付き出力
            Console.WriteLine(max);
        }
    }
}

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

using namespace std;

const int maxn = 100001;
typedef long long ll;
ll dp[maxn], v[maxn];
int n, W, w[maxn];

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

    cin >> n >> W;

    for(int i = 1; i <= n; i++)
        cin >> w[i] >> v[i];
    for(int i = 1; i <= n; i++)
        for(int j = W; j >= w[i]; j--)
            dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
    ll ans = 0;
    for(int i = 1; i <= W; i++)
        ans = max(ans, dp[i]);
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
#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"
#include "cassert"
#include "functional"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

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

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

	vector<int>v(5);
	for (auto &i : v) {
		cin >> i;
		i = max(i, 40);
	}
	cout << accumulate(v.begin(), v.end(), 0) / 5 << endl;
	return 0;
}


Measured memory_bytes: 3160
import sys
 
def main():
    for line in iter(sys.stdin.readline, ""):
        a = line.rstrip("\n").split(" ")
        b = []
        b.append(int(a[0]))
        b.append(int(a[1]))
        if (b[0] == 0 and b[1] == 0):
            return
 
        print(str(min(b)) + " " + str(max(b)))
      
if __name__ == "__main__":
    main()

Measured memory_bytes: 7776
def z_algo(S):
    N = len(S)

    A = [0] * N
    A[0] = N
    i = 1
    j = 0

    while i < N:
        while i + j < N and S[j] == S[i + j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while N - i > k < j - A[k]:
            A[i + k] = A[k]
            k += 1
        i += k
        j -= k
    return A


N = int(input())
S = input()

ans = 0
for i in range(N - 1):
    A = z_algo(S[i:])
    for idx, length in enumerate(A):
        if idx + 1 > length:
            ans = max(ans, length)

print(ans)


Measured memory_bytes: 50092
text = ''
while(True):
    try:
        text += input().lower()
    except:
        break

count = [0 for i in range(26)]
for c in text:
    if c < 'a'  or c > 'z':
        continue

    count[ord(c) - ord('a')] += 1

for i, c in enumerate(count):
    print('{0} : {1}'.format(chr(i + ord('a')), c))

Measured memory_bytes: 7496
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()
 
ll dp[3010][3010][4];
ll item[3010][3010];
 
int main(){
  int R,C;ll K;
  cin>>R>>C>>K;
  rep(i,K){
    int r,c;cin>>r>>c;r--,c--;
    int v;cin>>v;
    item[r][c]=v;
  }
  dp[0][0][1] = item[0][0];
  rep(i,R){
    rep(j,C){
      rep(k,4){
        dp[i+1][j][0] = max(dp[i+1][j][0],dp[i][j][k]);
        dp[i+1][j][1] = max(dp[i+1][j][1],dp[i][j][k]+item[i+1][j]);
        dp[i][j+1][k] = max(dp[i][j+1][k],dp[i][j][k]);
        if(k+1<=3) dp[i][j+1][k+1] = max(dp[i][j+1][k+1], dp[i][j][k] + item[i][j+1]);
      }
    }
  }
  cout << *max_element(dp[R-1][C-1], dp[R-1][C-1]+4) << endl;
  return 0;
}

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


int main(){
	int h=0 ,m=0 ,s;
	cin >> s;
	while(s >= 3600){
		h += 1;
		s -= 3600;
	}
	while(s >= 60){
		m += 1;
		s -= 60;
	}
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}


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

int main() {
    int n, kk; cin >> n >> kk;
    deque<long long> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    long long ans = 0;
    for (int i = 0; i <= n; i++) {
        for (int j = i; j <= n; j++) {
            int k = kk;
            if (i + n-j > k) continue;
            long long tmp = 0;
            multiset<long long> p;
            for (int u = 0; u < i; u++) {
                if (u == i) continue;
                p.insert(v[u]);
                tmp += v[u]; k--;
            }
            for (int u = j; u < n; u++) {
                if (j == n) continue;
                p.insert(v[u]);
                tmp += v[u]; k--;
            }
            priority_queue<long long> q;
            while (k > 0 && !p.empty() && *p.begin() < 0) {
                tmp -= *p.begin();
                q.push(*p.begin()); p.erase(p.begin());
                k--;
            }
            if (k % 2) {
                if (!p.empty()) {
                    ans = max(ans, tmp - *p.begin());
                }
                if (!q.empty()) {
                    ans = max(ans, tmp + q.top());
                }
            }
            //cout << tmp << " " << i << " " << j << endl;
            ans = max(ans, tmp);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# Aizu Problem 0219: A Popular Ice-cream Shop

import sys, math, os, fractions

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")



while True:
    n = int(input())
    if n == 0:
        break
    cnt = [0] * 10
    for _ in range(n):
        cnt[int(input())] += 1
    for c in cnt:
        print('*' * c if c > 0 else '-')

Measured memory_bytes: 10144
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;
mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ;; ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { println ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }

fn main() {
    let x = get!(u64);

    let ans = (1..).find(|&t| (t + 1) * t / 2 >= x).unwrap();

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


Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>

int main() {
    int i, j;
    char S[100], a ,abc[] = "abc";
    
    scanf("%s", S);

    for(i=0; S[i]!=0; i++) {
        for(j=i+1; S[j]!=0; j++) {
            if(S[i] > S[j]) {
                a = S[i];
                S[i] = S[j];
                S[j] = a;
            }
        }
    }

    if(strcmp(S, abc) == 0) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
N=int(input())
TA=[list(map(int, input().split())) for _ in range(N)]
ls=[[TA[0][0],TA[0][1]]]
for i in range(1,N):
    tmp=[TA[i][0],TA[i][1]]
    a=max(-(ls[-1][0]//(-tmp[0])),-(ls[-1][1]//(-tmp[1])))
    tmp[0]*=a
    tmp[1]*=a
    ls.append([tmp[0],tmp[1]])
print(ls[-1][0]+ls[-1][1])


Measured memory_bytes: 3316
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"

	"strconv"
)

func solve(in io.Reader, out io.Writer) error {
	sc := bufio.NewScanner(in)
	sc.Split(bufio.ScanWords)

	a, b := nextInt(sc), nextInt(sc)

	var c int = 0

	for i := a; i <= b; i++ {
		if i/10000 == i%10 && i/1000%10 == i/10%10 {
			c++
		}
	}

	fmt.Fprintln(out, c)
	return nil
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	err := solve(os.Stdin, os.Stdout)
	if err != nil {
		log.Fatal(err)
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG_ARR(x, a, b) for(int i=a; i<=b; i++) cerr<<x[i]<<" "; cerr<<endl;
#define DEBUG_STR(x, a, b) for(int i=a; i<=b; i++) cerr<<x[i]; cerr<<endl;


using namespace std;

typedef long long ll;
typedef unsigned long long llu;

string s;

bool isPalindrome(int start, int end){
	bool palin = true;
	for(int i=start; i<=(start+(end-start+1)/2); i++){
		if(s[i] != s[end - i]){
			palin = false;
		}
	}
	
	return palin;
}


int main() {
	FIO;
	cin>>s;
	bool fir, sec, all;
	all = isPalindrome(0, s.size()-1);
	fir = isPalindrome(0, (s.size()/2)-1);
	sec = isPalindrome((s.size()/2)+1, (s.size() -1));
	bool ans = (fir && sec && all);
	cout<<(ans ? "Yes" : "No");	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i< (n);i++)
#define SORT(a) sort((a).begin(),(a).end());
#define che(a,string) cout<<string<<":"<<(a)<<endl;
#define ch(a,string) cout<<string<<":"<<(a)<<" ";
using namespace std;
typedef pair<int,int> p;
int main(){
  string s;
  cin>>s;
  if(s=="Sunny"){
	  cout<<"Cloudy"<<endl;
	}
	else if(s=="Cloudy"){
		cout<<"Rainy"<<endl;
	  }
	  else{
		  cout<<"Sunny"<<endl;
		}
}	



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

int main(){
  int a,i,n = 0;
  char str[100];
  scanf("%s\n",str);
      
  a = strlen(str);
      
  if(a % 2 == 1){
   for(i=0;i<=((a-1)/2)-1;i++){
    if(str[i] != str[a-i-1]){
      n++;
    }
    }
  }
  else{
    for(i=0;i <= (a/2)-1;i++){
    if(str[i] != str[a-i-1]){n++;}
    }
  }
  printf("%d\n",n);
  return 0;
}


Measured memory_bytes: 128
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    ans="No"
    for i in 0:div(n,4)
        if (n-4i)%7==0
            ans="Yes"
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 112412
#include <stdio.h>
int a,b,c;
int main(void) {
scanf("%d%d%d",&a,&b,&c);
if((a+b)==c)
printf("Yes");
else if((a+c)==b)
printf("Yes");
else if((c+b)==a)
printf("Yes");
else
printf("No");
return 0;
}

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

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

    //sort
    for(int i = 0;i < n;i++)
    {
        int min = i;
        for(int j = i;j < n;j++)
        {
            if(a[j] < a[min])
                min = j;
        }
        if(min != i)
        {
            swap(a[i], a[min]);
            cnt++;
        }
    }

    for(int i = 0;i < n;i++)
    {
        if(i == n-1)
            cout<<a[i]<<endl;
        else
            cout<<a[i]<<" ";
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3108
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c<=32)c=_buff.get();return c;}
int n;
pair<int,int> a[5011];
ll dp[5011];
int main()
{
	geti(n);
	for(int i=1;i<=n;i++)
	{
		int x,y;
		getii(x,y);
		a[i]=MP(x+y,y);
	}
	sort(a+1,a+n+1);
	memset(dp,31,sizeof(dp));
	dp[0]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=i-1;j>=0;j--)
		{
			if(dp[j]+a[i].SS<=a[i].FF)
			{
				dp[j+1]=min(dp[j+1],dp[j]+a[i].SS);
			}
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(dp[i]<dp[n+1])
		{
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
/*input
5 4
1 4 2 3 5
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long ll;
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=2e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b,ll MOD){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
int pre[maxn];
map<int,int> m;
int32_t main(){
    int n,k;
    cin>>n>>k;
    ll ans=0;
    m[0]++;
    for(int i=1,x;i<=n;i++){
        cin>>x;
        pre[i]=((pre[i-1]+x-1)%k+k)%k;
        if(i>=k)
            m[pre[i-k]]--;
        ans+=m[pre[i]];
        m[pre[i]]++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 10368
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    s = input()
    t = len(s)//2
    ls = s[:t]
    rs = None
    c = 0
    if len(s)%2==0:
        rs = s[t:]
    else:
        rs = s[t+1:]
    rs = rs[::-1]
    #print(ls,rs)
    for l,r in zip(ls,rs): 
        if l != r:
            c += 1
    print(c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5616
/*input

*/
#include <bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long a[1000005],n;

int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	#endif
	long long q,m,k,h,ans=0,sum=0,p,x,y;
	cin>>n;
	for(int i=0;i<n;++i){
		char c;
		cin>>c;
		ans|=(c=='Y');
	}
	cout<<(ans?"Four":"Three");
}

Measured memory_bytes: 256
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: u32,
        d: [u32; n],
    };

    //let mut d = d;

    //d.sort();
    //d.dedup();

    let d = d.iter().collect::<BTreeSet<_>>();

    println!("{}", d.len());


}


Measured memory_bytes: 4352
l,r=map(int,input().split())
if r-l>=2019:
	print(0)
else:
	L=l%2019
	R=r%2019
	if L>R:
		print(0)
	else:
		a=2018
		for i in range(l,r+1):
			for j in range(i+1,r+1):
				a=min(a,i*j%2019)
		print(a)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> 
#define int long long int
#define fr(i,x,y) for(int i=x;i<y;i++)
#define f(n) for(int i=0;i<n;i++)
#define ff(m) for(int j=0;j<m;j++)
#define F(x) for(auto it:x)
#define in insert
#define pb push_back
#define em emplace_back
#define pi pair<int,int>
#define si second
#define fi first
// new include starts here.
#define endl '\n'
#define vi vector <int>
#define vii vector <pair<int,int>>
#define __s(x) cout<<#x<<"-> "; cout<<"{ ";F(x){cout<<it<<" ";}cout<<" }";cout<<endl;
#define _s(x) cout<<#x<<"-> "<<x<<endl;
#define _sp(x) cout<<#x<<"-> "<<x.fi<<" "<<x.si<<endl;
#define __sp(x) cout<<#x<<"-> "; cout<<"{ "<<endl;F(x){cout<<it.fi<<" "<<it.si<<endl;}cout<<" }";cout<<endl;
#define inf numeric_limits<int > :: max();
#define fit(it,y) for(auto it=y.begin(); it!=y.end();it++)
#define all(x) x.begin(),x.end()
// new includes end here .
//#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
//#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0;
#define FILEIO freopen("/home/adarsh/Desktop/codes/input", "r", stdin); //freopen("/home/adarsh/Desktop/codes/output.txt", "w", stdout);
using namespace __gnu_pbds;
using namespace std;

#define TRACE
#ifdef TRACE
#define _v(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define _v(...)
#endif

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rb;
void print(int a[],int n){f(n){cout<<a[i]<<" ";}cout<<endl;}
int m(int x){return x%1000000007;} 
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
int p(int a,int b){if(b==0)return 1;int t=(p(a,b/2)); if(b%2==0)return (t*t); else return ((a)*(t*t)); } 

//---------------------------------------------------------------------------------------------------------------------------------------------

signed main(){
 
	#ifndef ONLINE_JUDGE
	FILEIO
	#endif
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	//----sure_am-----


	int x, y;
	cin>>x>>y;
	if(y>=(2*x) && y<=(4*x) && y%2==0){
		cout<<"Yes"<<endl;
	}
	else{
		cout <<"No"<<endl;
	}

	
	return 0;
}   

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

LL sq[180002] = {0};
LL llsqrt(LL x){
	LL ret = -1;
	for(int i=0; i*i<=x; i++){
		if(i*i == x){
			ret = (LL) i;
			break;
		}
	}
	return ret;
}
int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, x, y, z;
	cin >> N;

	for(int i=0; i<=180000; i++){
		sq[i] = llsqrt(i);
	}

	LL ans;

	for(int k=1; k<=N; k++){
		ans = 0;
		for(x = 1; x<=100; x++){
			for(y = 1; y<=100; y++){
				LL u = 4*k - 3*x*x - 3*y*y - 2*x*y;
				if(u < 0 || u > 180000) continue;
				LL v = sq[u];
				if(v >= 0 && v - x - y > 0 && ((v-x-y) % 2) == 0){
					ans++;
				}
			}
		}
		printf("%lld\n", ans);
	}
	return 0;

}


Measured memory_bytes: 5044
def main():
    while True:
        d, w = map(int, input().split())
        if d == 0: break

        garden = []
        for i in range(d):
            garden.append(list(map(int, input().split())))

        pondmax = 0
        for tly in range(len(garden)):
            for tlx in range(len(garden[0])):
                for bry in range(tly + 2, len(garden)):
                    for brx in range(tlx + 2, len(garden[0])):
                        # sampling
                        l_gray = []
                        d_gray = []
                        for spy in range(tly, bry + 1):
                            for spx in range(tlx, brx + 1):
                                if spy == tly or spy == bry or spx == tlx or spx == brx:
                                    d_gray.append(garden[spy][spx])
                                else: l_gray.append(garden[spy][spx])
                        if min(d_gray) > max(l_gray):
                            pond = 0
                            for depth in l_gray:
                                pond += min(d_gray) - depth
                            if pond > pondmax: pondmax = pond

        print(pondmax)
                        
main()



Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
struct P {
	int l,r;
	bool operator <(const P &t)const {
		return r<t.r;
	} 
}p[N];
int main() {
	int n;
	scanf("%d",&n);
	for(int i=0,x,y;i<n;i++) {
		scanf("%d%d",&x,&y);
		p[i]={x-y,x+y};
	}
	sort(p,p+n);
	int ans=1,la=p[0].r;
	for(int i=1;i<n;i++) {
		if(p[i].l>=la) {
			la=p[i].r;
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define inf 10000000000ll
#define N 100005
#define M 10000005
using namespace std;
 
int n,trtot,cnt1,cnt2,h[N],rt1[N],rt2[N],sum[M],sz[M],ls[M],rs[M],P[M];
map<ll,int> mp1,mp2; ll m,a[N],b[N];
void ins(int &k,ll l,ll r,ll x,int y,int p){
	if (!k) k=++trtot;
	if (l==r){ sum[k]=1; sz[k]=y; P[k]=p; return; }
	ll mid=l+r>>1;
	if (x<=mid) ins(ls[k],l,mid,x,y,p); else ins(rs[k],mid+1,r,x,y,p);
	sum[k]=sum[ls[k]]+sum[rs[k]];
	sz[k]=sz[ls[k]]+sz[rs[k]];
}
int qry(int k,ll l,ll r,ll x,ll y){
	if (!sum[k] || x>y) return 0;
	if (x<=l && r<=y) return sum[k];
	ll mid=l+r>>1; int ans=0;
	if (x<=mid) ans+=qry(ls[k],l,mid,x,y);
	if (y>mid) ans+=qry(rs[k],mid+1,r,x,y);
	return ans;
}
int getp(int k,ll l,ll r,ll x,ll y){
	if (!sz[k] || x>y || l>y || r<x) return 0;
	if (l==r) return P[k];
	ll mid=l+r>>1; int t=0;
	if (x<=mid) t=getp(ls[k],l,mid,x,y);
	return (t)?t:getp(rs[k],mid+1,r,x,y);
}
void dlt(int x){
	ins(rt1[mp1[a[x]]],0,inf,b[x],0,x);
	ins(rt2[mp2[b[x]]],0,inf,a[x],0,x);
}
int main(){
	scanf("%d%d%d",&n,&h[1],&h[2]);
	int i,x,y,head=0,tail=2;
	for (i=1; i<=n; i++){
		scanf("%d%d",&x,&y);
		a[i]=x+y+1000000000ll; b[i]=x-y+1000000000ll;
	}
	m=max(abs(a[h[1]]-a[h[2]]),abs(b[h[1]]-b[h[2]]));
	for (i=1; i<=n; i++){
		if (!mp1[a[i]]) mp1[a[i]]=++cnt1;
		ins(rt1[mp1[a[i]]],0,inf,b[i],(i!=h[1] && i!=h[2])?1:0,i);
		if (!mp2[b[i]]) mp2[b[i]]=++cnt2;
		ins(rt2[mp2[b[i]]],0,inf,a[i],(i!=h[1] && i!=h[2])?1:0,i);
	}
	ll ans=0;
	while (head<tail){
		x=h[++head];
		ans+=qry(rt1[mp1[a[x]+m]],0,inf,b[x]-m,b[x]+m);
		ans+=qry(rt1[mp1[a[x]-m]],0,inf,b[x]-m,b[x]+m);
		ans+=qry(rt2[mp2[b[x]+m]],0,inf,a[x]-m+1,a[x]+m-1);
		ans+=qry(rt2[mp2[b[x]-m]],0,inf,a[x]-m+1,a[x]+m-1);
		while (y=getp(rt1[mp1[a[x]+m]],0,inf,b[x]-m,b[x]+m)){
			h[++tail]=y; dlt(y);
		}
		while (y=getp(rt1[mp1[a[x]-m]],0,inf,b[x]-m,b[x]+m)){
			h[++tail]=y; dlt(y);
		}
		while (y=getp(rt2[mp2[b[x]+m]],0,inf,a[x]-m+1,a[x]+m-1)){
			h[++tail]=y; dlt(y);
		}
		while (y=getp(rt2[mp2[b[x]-m]],0,inf,a[x]-m+1,a[x]+m-1)){
			h[++tail]=y; dlt(y);
		}
	}
	printf("%lld\n",ans>>1);
	return 0;
}

Measured memory_bytes: 165888
import sys
input = sys.stdin.readline
def main():
    S = list(input().rstrip())
    ok = False
    ans = len(S)
    while not ok:
        S.pop()
        ans -= 1
        if len(S) % 2 == 0 and S[:len(S)//2] == S[len(S)//2:]:
            ok = True
    print(ans)
if __name__ == "__main__":
    main()

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

int main() {
  int i, temp;
  int w, n, ai, bi;

  cin >> w;
  cin >> n;

  vector<int> amida;

  // initialize
  for (i = 0; i < w; i++) {
    amida.push_back(i + 1);
  }

  for (i = 0; i < n; i++) {
    scanf("%d,%d", &ai, &bi);

    // swap
    temp = amida.at(ai - 1);
    amida.at(ai - 1) = amida.at(bi - 1);
    amida.at(bi - 1) = temp;
  }

  for (i = 0; i < w; i++) {
    cout << amida.at(i) << endl;
  }

  return 0;
}

Measured memory_bytes: 1256
from fractions import gcd

Mod = 10**9+7
N = int(input())
A = list(map(int,input().split()))

lm = A[0]
for a in A[1:]:
    lm = lm*a//gcd(lm,a)

ans = 0
for i in range(N):
    ans += lm//A[i]
ans %= Mod

print(ans)

Measured memory_bytes: 6112
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    int n; cin >> n;
    vector<int> a(n), b(n);
    REP(i, n) {
        int x; cin >> x;
        a[i] = b[i] = x;
    }

    sort(a.begin(), a.end());
    
    int cnt = 0;
    REP(i, n) {
        if(a[i] != b[i]) cnt++;
    }

    if(cnt <= 2)
        cout << "YES" << endl;
    else 
        cout << "NO" << endl;

    return 0;
}


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

int main() {
	int sum=0,a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	sum=a+b*5+c*10+d*50+e*100+f*500;
	if(sum>=1000){
		cout<<1<<endl;
	}else{
		cout<<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
int A,B;
int main(){
	int ans;
	cin>>A>>B;
	if(B%A==0){
		ans=A+B;
	}else{
		ans=B-A;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
N,M = map(int,input().split())
switch = [[]for i in range(0,N+1,1)]
for i in range(0,M,1):
    lamp = list(map(int,input().split()))#[0]は要素数であることに注意
    for j in range(1,len(lamp),1):
        switch[lamp[j]].append(i+1)
p = [0] + list(map(int,input().split()))

count = 0
for i in range(0,pow(2,N),1):
    lamps = [0]*(M+1)
    for j in range(1,N+1,1):#swich
        if((i>>(j-1))&1):
            for k in range(0,len(switch[j]),1):
                lamps[switch[j][k]]+=1
    is_OK = True
    for j in range(1,M+1,1):#lamps
        if lamps[j]%2 != p[j]:
            is_OK=False
            break
        
    if is_OK:
        count+=1
print(count)

Measured memory_bytes: 42224
#include<iostream>
#include<vector>
#include<map>
#include<set>
using namespace std;


long long int powmod(long long int a,int n,long long m){
	long long int r=1;
	while(n){
		if(n&1)(r*=a)%=m;
		(a*=a)%=m;
		n>>=1;
	}
	return r;
}

int main(){
	long long int n;
	cin>>n;
	vector<long long int> a(n);
	long long int mod=1e9+7;
	
	
	vector<int> ch(n,0);
	long long int r=0;
	long long int l=0;
	long long int sa;
	for(int i=0;i<n;i++){
		cin>>a[i];
		ch[a[i]]++;
		if(ch[a[i]]==2){
			l=n-i;
			sa=a[i];
		}
	}
	
	for(int i=0;i<n;i++){
		if(a[i]==sa){
			r=i;
			break;
		}
	}
	
	long long int ans=1;
	long long int rmis=1;
	
	for(int k=0;k<n+1;k++){
		ans=(ans*(n+1-k))%mod;
		ans=(ans*powmod(k+1,1e9+7-2,1e9+7))%mod;
		
		if(k!=0){
			rmis=(rmis*(r+l-k+1))%mod;
			rmis=(rmis*powmod(k,1e9+7-2,1e9+7))%mod;
			if(r+l<k)rmis=0;
		}
		
		long long int ans2=(ans-rmis+mod)%mod;
		
		if(k==0){
			cout<<n<<endl;
		}else{
			cout<<ans2<<endl;
		}
	}
	
	return 0;
}

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

int main() {
  long long a, b;
  cin >> a >> b;
  if (a <= 0 && b >= 0) {
    cout << "Zero" << endl;
  }
  else if (a > 0) {
    cout << "Positive" << endl;
  }
  else if (b < 0) {
    long long tmp = b - a + 1;
    if (tmp%2 == 0) {
      cout << "Positive" << endl;
    }
    else {
      cout << "Negative" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>

typedef long long ll;
//vector<int>


using namespace std;

int main() {
    int a,b,c,d;
    int s;
    cin>>s;
    d=s%10;
    s/=10;
    c=s%10;
    s/=10;
    b=s%10;
    s/=10;
    a=s%10;
    if(a+b+c+d==7){
        cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"="<<"7"<<endl;
    }
    else if(a+b+c-d==7){
        cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"="<<"7"<<endl;
    }
    else if(a+b-c+d==7){
        cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"="<<"7"<<endl;
    }
    else if(a-b+c+d==7){
        cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"="<<"7"<<endl;
    }
    else if(a+b-c-d==7){
        cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"="<<"7"<<endl;
    }
    else if(a-b+c-d==7){
        cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"="<<"7"<<endl;
    }
    else if(a-b-c+d==7){
        cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"="<<"7"<<endl;
    }
    else{
        cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"="<<"7"<<endl;
    }


	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main()
{
    int n,t,x,y;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d",&t,&x,&y);
        if(x+y>t)
        {
            printf("No\n");
            return 0;
        }
        if((x+y)%2==0&&t%2==1)
        {
            printf("No\n");
            return 0;
        }
        if((x+y)%2==1&&t%2==0)
        {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

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

int n;
vector<ll> H(100010);
vector<ll> dp(100010, INF);

ll saiki(int i)
{
    //メモが残されていたら探索する必要なし
    if (dp[i] < INF)
        return dp[i];
    //1つ目は0
    if (i == 0)
    {
        dp[0] = 0;
        return dp[0];
    }
    //2つ目は例外
    if (i == 1)
    {
        dp[1] = abs(H[1] - H[0]);
        return dp[1];
    }
    //3つ目以降
    dp[i] = min(saiki(i - 1) + abs(H[i] - H[i - 1]), saiki(i - 2) + abs(H[i] - H[i - 2]));
    return dp[i];
}

int main()
{
    cin >> n;
    rep(i, n) cin >> H[i];
    cout << saiki(n - 1) << endl;
}

//メモ化再帰による別解

Measured memory_bytes: 7104
while(1):
    m,f,r=map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break
    
    elif m==-1 or f==-1:
        print("F")
    elif m+f>=80:
        print("A")
    elif m+f>=65 and m+f<80:
        print("B")
    elif m+f>=50 and m+f<65:
        print("C")
    elif m+f>=30 and m+f<50 and r>=50:
        print("C")
    elif m+f>=30 and m+f<50:
        print("D")
    elif m+f<30:
        print("F")




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

int main(void)
{
    int S;
    int W;
    scanf("%d", &S);
    scanf("%d", &W);
    if (S <= W)
    {
        printf("unsafe");
        return 0;
    }
    printf("safe");
    return 0;
}

Measured memory_bytes: 1712
//Joy Shree Kriskna
    #include<bits/stdc++.h>
    #define fast  ios_base::sync_with_stdio(false);cin.tie(NULL)
    #define rep(i,n) for(i=0;i<n;i++)
    #define rep1(i,n) for(i=n-1;i>=0;i--)
    #define rep2(j,t) for(j=1;j<=t;j++)
    #define rep3(i,a,b) for(i=a;i<=b;i++)
    #define PI acos(-1)
    #define remove(s) s.erase(unique(s.begin(),s.end()),s.end());
    #define e return 0
    //#define lcm(a,b) ((a*b)/__gcd(a,b))
    #define endl "\n"
    #define al(v) v.begin(),v.end()
    #define ll long long
    using namespace std;
    int main()
      {
           fast;
           int i,n,t;
           string s;
           cin>>s;
           if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes\n";
           else cout<<"No\n";
      }
//arupsaha52
//1704052_Arup


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

using namespace std;

int main() {
	
	int a, b, c, k;
	cin >> a >> b >> c >> k;

	if (k <= a) {
		cout << k << endl;
		return 0;
	}
	else if (k <= a + b) {
		cout << a << endl;
	}
	else {
		cout << a - (k - a - b) << endl;
	}

	return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    int a,b;
    cin>>a>>b;
    rep(i,0,max(a,b)){
        cout<<min(a,b);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int > pp;
typedef long long ll;
 
#define sz(x) (int)x.size() 
int const N=3e5+10,oo=1e9;
ll const OO=2e18;
double const eps=1e-8,PI=acos(-1);
int mod=oo+7;

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,an=0,mx=0;
  cin>>n;
  for(int i=0;i<n;i++){
  	int a;
  	cin>>a;
  	if(a>=mx)an++;
  	mx=max(mx,a);
  }
  cout<<an<<'\n';
  return 0;
}






Measured memory_bytes: 384
#include <cmath>
#include <algorithm>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>
using namespace std;


int main(){
  const int m = getInt();
  vector<int> d(6);
  REP(i,6) d[i] = getInt();

  const int s = getInt() - 1;
  const int g = getInt() - 1;

  vector<int> a(m);
  REP(i,m) a[i] = getInt();

  vector<int> dp(m, -1);
  vector<int> pr(m, -1);
  typedef pair<int, pair<int, int> > data;
  priority_queue<data, vector<data>, greater<data> > pq;

  pq.push(make_pair(0, make_pair(s, -1)));

  while(pq.size()){
    const data dt = pq.top(); pq.pop();
    const int pos = dt.second.first;
    const int prev = dt.second.second;
    const int cost = dt.first;

    if(dp[pos] != -1) continue;
    dp[pos] = cost;
    pr[pos] = prev;

    REP(i,6){
      REP(j,2){
	const int next = pos + (j == 0 ? 1 : -1) * d[i];
	if(next < 0 || m <= next) continue;
	const int next2 = next + a[next];
	if(next2 < 0 || m <= next2) continue;
	if(dp[next2] == -1) pq.push(make_pair(cost + 1, make_pair(next2, pos)));
      }
    }
  }

  vector<int> path;
  int pos = g;

  while(pos != s){
    path.push_back(pos);
    pos = pr[pos];
  }
  path.push_back(s);
  reverse(path.begin(), path.end());
  // REP(i,path.size()) printf("%d ", path[i]); puts("");

  REP(i,path.size() - 1){
    int exp = 0;
    int dir = 0;
    const int pos = path[i];
    REP(j,6){
      REP(k,2){
	const int next = pos + (k == 0 ? 1 : -1) * d[j];
	if(next < 0 || m <= next) continue;
	const int next2 = next + a[next];
	if(next2 < 0 || m <= next2) continue;
	// printf("pos:%d j:%d k:%d => %d => %d\n", pos, j, k, next, next2);
	if(next2 == path[i + 1]){
	  exp = j + 1;
	  dir = (k == 0 ? 1 : -1);
	  goto next;
	}
      }
    }
  next:
    // printf("pos: %d exp: %d dir: %d\n", pos, exp, dir);

    while(true){
      const int in = getInt();
      if(in == exp){
	printf("%d\n", dir);
	fflush(stdout);
	break;
      }else{
	printf("%d\n", 0);
	fflush(stdout);
      }
    }
  }

  return 0;
}

Measured memory_bytes: 1304
#include <bits/stdc++.h>
#define MAX 200010
#define MOD 1000000007
using namespace std;

char str[MAX];
int arr[MAX];

int prod(int a, int b)
{
	return 1LL * a * b % MOD;
}

int main(void)
{
	int N;
	cin >> N;
	cin >> str;
	int cur = 1;
	int ans = 1;
	for (int i = 1; i < 2 * N; i++)
	{
		if (str[i] == str[i - 1]) arr[i] = !arr[i - 1];
		else arr[i] = arr[i - 1];
		if (arr[i]) ans = prod(ans, cur--);
		else cur++;
	}
	if (cur || str[0] == 'W') ans = 0;
	for (int i = 1; i <= N; i++) ans = prod(ans, i);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define ll long long
#define pi pair<int,int>
#define pii pair<pi,int>
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main()
{
    go;
    int x,y;
    cin>>x>>y;
    if(x>=10||y>=10)
        cout<<-1;
    else
    cout<<x*y;
    return 0;
}


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

namespace CSharpSample01
{
	class Program
	{

		static void Main(string[] args)
		{
			var X = int.Parse( Console.ReadLine());

			if(X >= 30)
			{
				Console.WriteLine("Yes");
			}
			else
			{
				Console.WriteLine("No");
			}

		}
	}
}

Measured memory_bytes: 27520
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Atcoder
{
    class aaaa
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');

            int X = int.Parse(input[0]);int Y = int.Parse(input[1]);
            Console.WriteLine(X + (Y/2));
        }
    }
}

Measured memory_bytes: 11092