akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL MOD = 1e9+7;

int main() {
    int N, A, B, C;
    vector<int> T(4, 0);
    cin >> N >> T[0] >> T[1] >> T[2];
    vector<int> l(N);
    REP(i, N) {
        cin >> l[i];
    }
    int res = IINF;
    REP(i, 1<<(2*N)) {
        vector<int> v(4, 0);
        int mp = 0;
        REP(j, N) {
            int x = (i>>(2*j))&0b11;
            if(0 < v[x] && x < 3) {
                mp += 10;
            }
            v[x] += l[j];
        }
        if(v[0]*v[1]*v[2] == 0) {
            continue;
        }
        REP(j, 3) {
            mp += abs(T[j] - v[j]);
        }
        res = min(res, mp);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<iostream>
using namespace std;

const int maxn=110;
const int maxm=55;
const int mod=1e9+7;
int n, m;
int a[maxn];
vector<int> g[maxn];
int dp[maxm][maxn][maxn];

void add(int& x,int y){ x+=y; if(x>=mod) x-=mod; }

int main(){

	scanf("%d", &n); m=n*2-1;
	for(int i=1;i<=m;i++) scanf("%d", &a[i]);
	sort(a+1,a+1+m);
	// for(int i=1;i<=m;i++) printf("%d ", a[i]); puts("");
	dp[1][1][1]=1;
	for(int i=1;i<n;i++){
		int l=a[n-i]!=a[n-i+1], r=a[n+i]!=a[n+i-1];
		for(int j=1;j<=m;j++) for(int k=1;k<=j;k++) if(dp[i][j][k]){
			int t=k+l, t1=j+l+r;
			for(int l=1;l<t;l++) add(dp[i+1][t1-(t-l-1)][l], dp[i][j][k]);
			add(dp[i+1][t1][t], dp[i][j][k]);
			for(int l=t+1;l<=t1;l++) add(dp[i+1][t1-(l-t-1)][t+1], dp[i][j][k]);
		}
	}
	int ans=0;
	for(int j=1;j<=m;j++) for(int k=1;k<=j;k++) add(ans, dp[n][j][k]);
	printf("%d\n", ans);
	return 0;
}


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

#define int long long
const int sqrtN = 512;
struct SqrtDecomposition {
  int N, K;
  vector<int> data;
  vector<int> bucketSum;
  SqrtDecomposition(int n) : N(n) {
    K = (N + sqrtN - 1) / sqrtN;
    data.assign(K * sqrtN, 0);
    bucketSum.assign(K, 0);
  }
  void add(int x, int y) {
    int k = x / sqrtN;
    data[x] += y;
    int sum = 0;
    for(int i = k * sqrtN; i < (k + 1) * sqrtN; ++i) {
      sum += data[i];
    }
    bucketSum[k] = sum;
  }
  // [x, y)
  int getSum(int x, int y) {
    int sum = 0;
    for (int k = 0; k < K; ++k) {
      int l = k * sqrtN, r = (k + 1) * sqrtN;
      if (r <= x || y <= l)
        continue;
      if (x <= l && r <= y) {
        sum += bucketSum[k];
      } else {
        for (int i = max(x, l); i < min(y, r); ++i) {
          sum += data[i];
        }
      }
    }
    return sum;
  }
};

signed main() {
  ios::sync_with_stdio(false);
  int N, Q; cin >> N >> Q;
  SqrtDecomposition decomp(N);
  while(Q--) {
    int c, x, y; cin >> c >> x >> y;
    if(c == 0) {
      decomp.add(x, y);
    }
    else {
      cout << decomp.getSum(x, y + 1) << endl;
    }
  }
}

Measured memory_bytes: 3528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;
//vector<ll> dp(N+1,INF);

int main(){

  ll N;
  cin>>N;
  vector<ll> M;
  ll nin=9;
  ll six=6;
  M.push_back(1);
  for(ll i=1;six<=100000;i++){
    M.push_back(six);
    six=six*6;
  }
  for(ll i=1;nin<=100000;i++){
    M.push_back(nin);
    nin=nin*9;
  }
  sort(M.rbegin(),M.rend());
  
  
  vector<vector<ll>> dp((ll)M.size()+2,vector<ll>(N+2,INF));
  dp[0][0]=0;
  
  for(ll i=0;i<=(ll)M.size();i++){
   for(ll j=0;j<=N;j++){
     
     dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
     
     if(j+M[i]<=N)dp[i+1][j+M[i]]=min(dp[i+1][j+M[i]],dp[i][j]+1);
     
     if(j+M[i]<=N)dp[i+1][j+M[i]]=min(dp[i+1][j+M[i]],dp[i+1][j]+1);
  	}
  }
  cout<<dp[(ll)M.size()][N]<<endl;
}


Measured memory_bytes: 15052
#include <bits/stdc++.h>
 
using namespace std;
typedef  long long ll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
#define REP(i,n) for(ll i = 0; i < (n); ++i)
 
int main(){
    int n, k;
    cin >> n >> k;
    vector<int> x(n),y(n);
    REP(i,n)
        cin >> x[i] >> y[i];
 
    REP(i,n){
        map<pair<int,int>, int> m;
        for(int j = i + 1; j < n; ++j){
            int xdiff = x[j] - x[i];
            int ydiff = y[j] - y[i];
 
            if(xdiff < 0){
                xdiff *= -1;
                ydiff *= -1;
            }
 
            int g = __gcd(abs(xdiff), abs(ydiff));
            xdiff /= g;
            ydiff /= g;
 
 
            ++m[make_pair(xdiff, ydiff)];
 
            if(m[make_pair(xdiff,ydiff)] >= k - 1){
                cout << 1 << endl;
                return 0;
            }
        }
    }
    cout << 0 << endl;
 
 
}


Measured memory_bytes: 3300
package main

import "fmt"
import "bufio"
import "os"
import "strconv"
import "sort"

var _sw = bufio.NewScanner(os.Stdin)

func main() {
	N := NextInt()
	A := NextInts(N)

	total := 0
	for _, a := range A {
		total += a
	}

	min := total
	curr := 0
	for _, a := range A {
		v := total - curr*2
		if v < 0 {
			v = -v
		}
		min = Min(v, min)
		curr += a
	}
	fmt.Println(min)
}

func init() {
	_sw.Split(bufio.ScanWords)
}

func NextInt() int {
	if _sw.Scan() == false {
		panic(_sw.Err())
	}
	i, e := strconv.Atoi(_sw.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func NextInts(n int) []int {
	a := make([]int, n)
	for i := range a {
		a[i] = NextInt()
	}
	return a
}

func NextString() string {
	if _sw.Scan() == false {
		panic(_sw.Err())
	}
	return _sw.Text()
}

func Max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func Min(x, y int) int {
	if x > y {
		return y
	}
	return x
}

func Bounded(lower, n, upper int) int {
	return Min(upper, Max(lower, n))
}

func SortInts(xs []int) {
	sort.Sort(sort.IntSlice(xs))
}

func ReverseSortInts(xs []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(xs)))
}


Measured memory_bytes: 4992
MOD = 10**9 + 7
def solve(n, a):
    dp = [3] + [0] * n
    res = 1
    for x in a:
        res = res * dp[x] % MOD
        if res == 0:
            break
        dp[x] -= 1
        dp[x+1] += 1
    return res

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

Measured memory_bytes: 20836
N = int(input())
H = list(map(int,input().split()))
dp = [float('inf') for i in range(N)]
dp[0]=0
for i in range(N):
    if i+1 < N:
        dp[i+1] = min(dp[i+1],dp[i]+abs(H[i]-H[i+1]))
    if i+2 < N:
        dp[i+2] = min(dp[i+2],dp[i]+abs(H[i]-H[i+2]))
print(dp[N-1])

Measured memory_bytes: 13928
def ABC143B_TakoyakiFes():
    N = int(input())
    d = [int(i) for i in input().split()]

    sum = 0
    for i in range(0, N - 1):
        for j in range(i + 1, N):
            sum += d[i] * d[j]

    print(sum)

def main():
    ABC143B_TakoyakiFes()

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A == B) {
		if (A != C)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else if (A == C) {
		if (A != B)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else if (B == C) {
		if (A != B)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else
		cout << "No" << endl;
}

Measured memory_bytes: 256
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 03/28/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int N,K; cin>>N>>K;
  for (int i = 0; i < N; i++) {
    int a; cin>>a;
  }
  int ans = ceil(double(N-1)/(K-1));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)
#define REP(i,a) FOR(i,0,(int)(a)-1)
#define reset(a,b) memset(a,b,sizeof(a))
#define all(x) x.begin(), x.end()
#define uni(x) x.erase(unique(all(x)), x.end());
#define BUG(x) cout << #x << " = " << x << endl
#define BUGP(x) cout << #x << " = " << x._1 << ", " << x._2 << endl
#define PR(x,a,b) {cout << #x << " = "; FOR (_,a,b) cout << x[_] << ' '; cout << endl;}
#define CON(x) {cout << #x << " = "; for(auto i:x) cout << i << ' '; cout << endl;}
#define mod 1000000007
#define pi acos(-1)
#define eps 1e-9
#define pb push_back
#define sqr(x) (x) * (x)
#define _1 first
#define _2 second

int h, w, H, W, ans[555][555];

int main() {
	ios::sync_with_stdio(false);
	cin >> H >> W >> h >> w;
	bool cr = (H % h);
	bool cc = (W % w);
	if (!cr && !cc) {
		cout << "No";
		return 0;
	}
	cout << "Yes" << endl;
	REP (i, H) REP (j, W) ans[i][j] = 2000;
	if (cc) {
		REP (j, H) for (int i = w - 1; i < W; i += w) ans[j][i] = - 2000 * w + 1999;
	} else REP (j, W) for (int i = h - 1; i < H; i += h) ans[i][j] = - 2000 * h + 1999;
	// if (W < 2 * w && W > w) {
	// 	REP (i, H) ans[i][W / 2] = - w * 2 + 1;
	// } else REP (j, W) ans[H / 2][j] = - h * 2 + 1;
	REP (i, H) {
		REP (j, W) cout << ans[i][j] << ' ';
		cout << endl;
	}
}

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

const int N = 1000005;

int k;
bool vis[N];

int solve() {
  scanf("%d", &k);

  int cur = 0;
  int ans = 0;
  do {
    ++ans;
    cur = (cur * 10 + 7) % k;
    if (vis[cur]) return 0 * printf("-1\n");
    vis[cur] = true;
  } while (cur % k != 0);

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

int main() {
  int t = 1;
  // scanf("%d", &t);
  while (t--) solve();
  return 0;
}


Measured memory_bytes: 4788
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > using vec = std::vector< T >;
template < class T > void print(T &x) { cout << x << "\n"; }
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  string S;
  cin >> S;
  int N=S.size();

  string ans = "AC";
  if (S[0]!='A'){
      ans="WA";
  }else{
      int cnt=0;
      REPS(i,N-1){
          if ( i!=1 && i!=N-1 && S[i]=='C'){
              cnt++;
          }
          else if (isupper(S[i])){
              ans="WA";
          }
      }
      if (cnt!=1)ans="WA";
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    N = int(input())

    if N % 10 in [2, 4, 5, 7, 9]:
        print("hon")
    elif N % 10 in [0, 1, 6, 8]:
        print("pon")
    else:
        print("bon")


if __name__ == '__main__':
    main()

Measured memory_bytes: 72764
h, w = gets.chomp.split(" ").map(&:to_i)

m = []

h.times do 
  m << gets.chomp.split("")
end

h.times do |i|
  w.times do |j|
    next if m[i][j] == "."
    flag = true
    [[-1, 0], [1, 0], [0, 1], [0, -1]].each do |dh, dw|
      if i + dh >= 0 && i + dh < h && j + dw >= 0 && j + dw < w && m[i + dh][j + dw] == "#"
        flag = false
      end
    end
    if flag
      puts "No"
      exit
    end
  end
end
puts "Yes"

Measured memory_bytes: 2172
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt(), b= sc.nextInt(), c=sc.nextInt();
   double sum = a;
    int i=1;
    int result=0;
    while(i<100){
     if(sum%b==c){
       result=1;
       break;
     }else{
       i++;
       sum +=a;
     }
   }
    if(result==1){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}



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


int main(){
    int n;
    while(std::cin >> n){
        if(n == 0) break;

        int dp[n][n], ans = 0;

        for(int i = 0; i < n; i++){
            std::string str;
            std::cin >> str;

            for(int j = 0; j < n; j++){
                if(str[j] == '*'){
                    dp[i][j] = 0;
                }else{
                    if(i > 0 && j > 0){
                        dp[i][j] = std::min(dp[i - 1][j], std::min(dp[i][j - 1], dp[i - 1][j - 1])) + 1;
                    }else{
                        dp[i][j] = 1;
                    }
                    ans = std::max(ans, dp[i][j]);
                }
            }
        }

        std::cout << ans << std::endl;

    }
    return 0;
}

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

int main (int argc,char **argv)
{
	char moji[4][4];
	scanf("%s\n %s\n %s",moji[0],moji[1],moji[2]);

	printf("%c%c%c\n",moji[0][0],moji[1][1],moji[2][2]);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n;
  cin >> n;
  long double ans=0;
  rep(i,n){
    long double y;
    cin >> y;
    ans+=1/y;
  }
  cout << fixed << setprecision(10);
  cout << 1/ans << endl;
}  


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

using ll = long long;
using P = pair<int, int>;

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int n;
  cin >> n;
  if (n == 1) {
    cout << "Hello World" << endl;
  } else {
    int a, b;
    cin >> a >> b;
    cout << a + b << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) (c.find(x) != c.end())
#define cpresent(c,x) (find(all(c),x) != c.end())
#define REP(i,a,b) for(int i =a;i<b;i++)
typedef vector <ii> vii;

int main(){
	
	int size;
	cin >> size;
	
	vi B(size);
	REP(i,0,size-1){
		cin >> B[i];
	}
	
	int ans=0;
	ans+=B[0]+B[size-2];

	REP(i,0,size-2){
		ans+=min(B[i],B[i+1]);
	}
	
	cout << ans;
		return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <fstream>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}

};
typedef vector<vector<Edge>> Graph;

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

ll factorial(ll n) {//階乗
	ll ret = 1;
	rep(i, 1, n + 1)
		ret = (ret *i) % MODU;

	return ret;
}

ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x %mod;
		x = x * x%mod;
		n >>= 1;
	}
	return res;
}
ll divmod(ll a, ll b, ll m) { // a/b(mod m)
								  // a/b (mod m)
								  // a*b^-1
								  // b^-1 * b = 1
								  // b^(m-1) = 1 
								  // b^(m-2) * b = 1
								  // b^-1 = b^(m-2)

								  // a/b = a * b^(m-2)

	return (a * 1LL * mod_pow(b, m - 2, m)) % m;
}
ll ncr(ll n, ll r) {
	return divmod(factorial(n), (factorial(r) * (factorial(n - r))) % MODU, MODU);
}


signed main() {
	ll a, b;
	cin >> a >> b;
	cout << a * b / gcd(a, b) << endl;
	return 0;
}


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

int main() {
	long long N, K, V[50], ANS = 0;
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> V[i];
	for (int A = 0; A <= K; A++) {
		for (int B = 0; A + B <= K && A + B <= N; B++) {
			vector<int> X;
			long long COUNT = 0;
			for (int i = 0; i < A; i++) {
				X.push_back(V[i]);
			}
			for (int i = 0; i < B; i++) {
				X.push_back(V[N - 1 - i]);
			}
			sort(X.begin(), X.end());
			for (int i = 0; i < K - A - B && i < X.size(); i++) {
				if (X[i] < 0) X[i] = 0;
			}
			for (int P : X) COUNT += P;
			ANS = max(ANS, COUNT);
		}
	}
	cout << ANS << endl;
}

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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

struct node {
    ll w, from, to;
};

int main() {
    ll n, m, i, j, k;
    cin >> n;
    ll g[n][n];
    vector<node> v;
    for(i = 0; i < n; i++) {
        for(j = 0; j < n; j++) {
            cin >> g[i][j];
            if(i < j) {
                node x = {g[i][j], i, j};
                v.push_back(x);
            }
        }
    }
    ll ret = 0;
    ll result_g[n][n];
    for(i = 0; i < n; i++) {
        for(j = 0; j < n; j++) {
            if(i == j)
                result_g[i][j] = 0;
            else {
                result_g[i][j] = INF;
            }
        }
    }
    sort(v.begin(), v.end(), [](const node &a, const node &b) {
        return a.w < b.w;
    });
    for(node x : v) {
        bool flag = false;
        for(i = 0; i < n; i++) {
            if(x.w > result_g[x.from][i] + result_g[i][x.to]) {
                cout << -1 << endl;
                return 0;
            } else if(x.w == result_g[x.from][i] + result_g[i][x.to]) {
                flag = true;
                break;
            }
        }
        result_g[x.from][x.to] = x.w;
        result_g[x.to][x.from] = x.w;
        if(!flag){
            ret += x.w;
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 2804
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i,n) for (ll i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define vvl vector<vector<ll>> //a(縦行,vector<ll>(横列));
#include<algorithm>//__gcd(a,b)
#include <iostream>
#include <vector>
#include <cstdlib>
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

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

    if(S=="SSS")cout<<0<<endl;
  else  if(S=="RRS"||S=="SRR")cout<<2<<endl;
  else  if(S=="RRR")cout<<3<<endl;
    else cout<<1<<endl;

}

Measured memory_bytes: 3620
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);

		String str = sc.next();
		int a[] = new int[3];
		int max = 0;
		for(int i=0;i<str.length();i++) {
			switch (str.charAt(i)) {
			case 'J':
				if( (a[1]|a[2]) == 0 )
					a[0]++;
				else {
					a[0] = 1;
					a[1] = a[2] = 0;
				}
				break;
			case 'O':
				if( a[2] == 0 && a[0] > a[1] ) a[1]++;
				else a[0] = a[1] = a[2] = 0;
				break;
			case 'I':
				if(a[1]-1 > a[2]) a[2]++;
				else {
					max = max(a[1], max);
					a[0] = a[1] = a[2] = 0;
				}
			}
//			debug(a);
		}
		System.out.println(max);
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 16000
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template <typename T>
void max_self(T& a, T b) {
	a = max(a, b);
}
int main()
{
	long long n, w;
	cin >> n >> w;
	vector<pair<long long, long long>> v;
	vector<long long> dp(w + 1, 0);
	for (int i = 0; i < n; i++) {
		long long a, b;
		cin >> a >> b;
		v.push_back({ a,b });
		
	}
	long long mx = 0;
	for (auto item : v) {
		for (long long i = w; i >=0; i--) {
			if (i - item.first >= 0)
				max_self(dp[i],dp[i-item.first]+item.second);
			max_self(mx, dp[i]);
		}
	}
	
	cout << mx;
}


Measured memory_bytes: 3608
N = gets.to_i
A = []
B = []

N.times do
  a, b = gets.split.map(&:to_i)
  A << a
  B << b
end

num = 0
(N - 1).downto(0) do |i|
  if B[i] == 1
    next
  end

  a = A[i] + num
  if a % B[i] == 0
    next
  end

  num += B[i] - a % B[i]
end

puts num


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

typedef long long int ll; 
#define MOD 1000000007
#define ON 200000
#define rep(i,n) fp(i,0,n)  
#define fp(i,a,b) for(ll i=(a);i<(b);++i)
#define fn(i,a,b) for(ll i=(a);i>(b);i--)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define FF first
#define SS second
typedef pair<ll, ll> pll; 
typedef vector<pll> vpll;
typedef vector<ll> vll;
#define rs(t) string t;cin>>t
#define ri(t) int t;cin>>t
#define rll(t) long long int t;cin>>t
#define MK make_pair
#define PB push_back
#define PO pop_back
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
///// This part below is only for debug, not used /////
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
///// END /////



int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  rll(x);
  rll(y);
  rll(a);
  rll(b);
  rll(c);
  vll p(a);
  vll q(b);
  vll r(c);

  cin >> p >> q >> r;

  sort(p.begin(),p.end());
  sort(q.begin(),q.end());
  sort(r.begin(),r.end());
  reverse(p.begin(),p.end());
  reverse(q.begin(),q.end());
  reverse(r.begin(),r.end());


  vll v;

  rep(i,x){
  	v.push_back(p[i]);
  }
  rep(i,y){
  	v.push_back(q[i]);
  }
  rep(i,c){
  	v.push_back(r[i]);	
  }

  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  ll ans = 0;
  rep(i,x+y){
  	ans += v[i]; 
  }
  cout << ans << endl;


  return 0;
  
}

Measured memory_bytes: 8688
import java.io.*;
class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        String s[]=bu.readLine().split(" ");
        int n=Integer.parseInt(s[0]),i,c=0; double x,y,d=Double.parseDouble(s[1]);
        for(i=0;i<n;i++)
        {
            s=bu.readLine().split(" ");
            x=Double.parseDouble(s[0]); y=Double.parseDouble(s[1]);
            x=Math.sqrt(x*x+y*y);
            if(x<=d) c++;
        }
        System.out.print(c);
    }
}

Measured memory_bytes: 56576
/*..........mango is luv..........*/
#include<bits/stdc++.h>
using namespace std;
#define fk(i,start,end) for(ll i=start;i<ll(end);i++)
typedef long long int ll;
string A="YES";
string B="NO";
int main()
{ 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll d,t,s;
  cin>>d>>t>>s;
  if(d<=t*s)
  {
  	cout<<"Yes";
  }
  else
  {
  	cout<<"No";
  }
  return 0;

}

Measured memory_bytes: 3580
#include <stdio.h>
 
int main(void){
  char s[101],p[101];
  int i,j,sn=0,pn=0,t;
 
  scanf("%s %s",s,p);
 
//文字数カウント
  while(s[sn] != '\0') sn++;
  while(p[pn] != '\0') pn++;
 
  for(i=0;i<sn;i++){
    t=1;
    for(j=0;j<pn;j++)
      if(s[(i+j)%sn] != p[j]) t=0;
    if(t) break;
  }
 
  if( t )
    printf("Yes\n");
  else
    printf("No\n");
 
  return 0;
}


Measured memory_bytes: 2112
#include <stdio.h>

int main(void){
	int n, a[100], i, j;
	char c, s[53] = {"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"};
	while(1){
		scanf("%d",&n);
		if(!n) break;
		for(i = 0;i < n;i++)
			scanf("%d",&a[i]);
		getchar();
		for(i = 0;(c = getchar()) != '\n';i++){
			for(j = 0;j < 52;j++){
				if(s[j] == c)
					printf("%c",s[(52 + j - a[i % n]) % 52]);
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1004
n = int(input())
d = list(map(int, input().split()))
h = [0]*13
for i in d:
    h[i] += 1

ans = 0
def rec(now, state):
    global ans
    if now == 13:
        state.sort()
        m = float("Inf")
        for i in range(len(state)):
            m = min(m, min(abs(state[i-1]-state[i]), 24-abs(state[i-1]-state[i])))
        ans = max(ans, m)
    elif now == 0:
        if h[now]:
            return
        rec(now+1, state)
    elif now == 12:
        if h[now]==0:
            rec(now+1, state)
        elif h[now]==1:
            state.append(now)
            rec(now+1, state)
    else:
        if h[now]==0:
            rec(now+1, state)
        elif h[now]==1:
            s = state[:]
            s.append(now)
            rec(now+1,s)
            s = state[:]
            s.append(24-now)
            rec(now+1, s)
        elif h[now]==2:
            state.append(now)
            state.append(24-now)
            rec(now+1, state)
rec(0, [0])
print(ans)

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

int main(){
  int N;cin>>N;
  if(N<600) cout<<8<<endl;
  else if(N<800) cout<<7<<endl;
  else if(N<1000) cout<<6<<endl;
  else if(N<1200) cout<<5<<endl;
  else if(N<1400) cout<<4<<endl;
  else if(N<1600) cout<<3<<endl;
  else if(N<1800) cout<<2<<endl;
  else cout<<1<<endl;
}


Measured memory_bytes: 3632
N  = gets.to_i
ss = N.times.map{ gets.rstrip }.map{ |s| s.chars.sort!.join }

ans_h = {}
ss.each do | s |
  if ans_h[s]
    ans_h[s] += 1
  else
    ans_h[s] = 0
  end
end

ans = 0
ans_h.each do | k, v |
  ans += (v+1)*v/2
end
p ans

Measured memory_bytes: 37116
#include<stdio.h>

int main(){
    int a,b,i;
    scanf("%d %d", &a, &b);

    for(i = 0;i<=1000;i++){
        if(a == i * 8 / 100 && b == i * 10 / 100){
            printf("%d\n", i);
            break;
        }
    }
    if(i > 1000)printf("-1\n");
    return 0;
}

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

#define MOD 1000000007
Int extgcd(Int a,Int b,Int& x,Int& y){
  Int d=a;
  if(b!=0){
    d=extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }else{
    x=1;y=0;
  }
  return d;
}
Int mod_inverse(Int a,Int mod){
  Int x,y;
  extgcd(a,mod,x,y);
  return (mod+x%mod)%mod;
}

//INSERT ABOVE HERE
const Int MAX = 2.6e4;
Int dp[MAX][404];
Int dp2[MAX][404];

signed main(){
  Int n,k,m;
  cin>>n>>k>>m;
  vector<Int> a(m);
  for(Int i=0;i<m;i++) cin>>a[i];

  vector<Int> po(MAX,1);
  for(Int i=1;i<MAX;i++) po[i]=po[i-1]*k%MOD;
  
  Int res=(n-m+1)*po[n-m]%MOD;
  Int ans=0;
  memset(dp,0,sizeof(dp));
  dp[1][1]=k;
  for(Int i=1;i<n;i++){
    Int res=0;
    for(Int j=k-1;j>0;j--){
      dp[i+1][j+1]+=dp[i][j]*(k-j)%MOD;
      dp[i+1][j+1]%=MOD;

      res+=dp[i][j];
      res%=MOD;
      
      dp[i+1][j]+=res;
      dp[i+1][j]%=MOD;
    }
  }
  
  Int tmp=0;
  vector<Int> cnt(k+1);
  auto add=[&](Int x){tmp+=++cnt[x]==1;};
  auto sub=[&](Int x){tmp-=--cnt[x]==0;};

  if(m>=k){
    for(Int i=0;i<k;i++) add(a[i]);
    if(tmp==k){cout<<res<<endl;return 0;}
    for(Int i=k;i<m;i++){
      add(a[i]);sub(a[i-k]);
      if(tmp==k){cout<<res<<endl;return 0;}
    }
    tmp=0;
    fill(cnt.begin(),cnt.end(),0);
  }
  for(Int i=0;i<m;i++) add(a[i]);

  if(tmp==m){
    memset(dp2,0,sizeof(dp2));
    for(Int i=1;i<=n;i++){
      Int res=0;
      for(Int j=k-1;j>0;j--){
	dp2[i][j]+=(j>=m)*dp[i][j];
	dp2[i][j]%=MOD;
	
	dp2[i][j]+=dp2[i-1][j-1]*(k-j+1)%MOD;
	dp2[i][j]%=MOD;
	
	res+=dp2[i-1][j];
	res%=MOD;
	dp2[i][j]+=res;
	dp2[i][j]%=MOD;
      }
    }
    Int mul=1;
    for(Int i=k-m+1;i<=k;i++) mul=mul*i%MOD;
    for(Int j=0;j<k;j++) ans=(ans+dp2[n][j])%MOD;
    ans=ans*mod_inverse(mul,MOD)%MOD;
  }else{
    tmp=0;
    fill(cnt.begin(),cnt.end(),0);
    Int x=0,y=0;
    while(tmp==x) add(a[x++]);
    tmp=0;
    fill(cnt.begin(),cnt.end(),0);
    while(tmp==y) add(a[m-++y]);
    x--;y--;
    //cout<<x<<" "<<y<<endl;
    Int p=1,q=1;
    for(Int i=k-x+1;i<=k;i++) p=p*i%MOD;
    for(Int i=k-y+1;i<=k;i++) q=q*i%MOD;
    //cout<<p<<" "<<q<<endl;
    p=mod_inverse(p,MOD);
    q=mod_inverse(q,MOD);
    for(Int i=0;i+m<=n;i++){
      Int j=n-(i+m);
      Int g=0,h=0;
      for(Int z=x;z<k;z++) g=(g+dp[i+x][z])%MOD;
      for(Int z=y;z<k;z++) h=(h+dp[j+y][z])%MOD;
      //cout<<g<<":"<<h<<endl;
      ans+=g*h%MOD;
      ans%=MOD;
    }
    ans*=p*q%MOD;
    ans%=MOD;
  }
  
  ans=res+MOD-ans;
  ans%=MOD;
  cout<<ans<<endl;
  return 0;
}


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

int main(int argc, char const *argv[]) {

  int N,K;
  scanf("%d %d", &N, &K);
  if(N%2 == 0) {
    if(K > N/2) {
      printf("NO");
    } else {
      printf("YES");
    }
  } else {
    if(K > N/2+1) {
      printf("NO");
    } else {
      printf("YES");
    }
  }

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(){
	int n, read, min, max;
	scanf("%d", &n);
	scanf("%d", &read);
	min = max = read;
	for(int i = 1; i < n; ++i){
		scanf("%d", &read);
		if(min > read) min = read;
		if(max < read) max = read;
	}
	printf("%d\n", max - min);
	return 0;
}


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

int main() {
    
    int not_match = 0;
    string s;
    
    cin >> s;
    
    string pat[4] = { "dreamer", "eraser", "dream", "erase" };
    
    for ( long long i = 0; i < s.length(); ) {
        
        int index;
       
        not_match++;
        
        for ( int j = 0; j < 4; j++ ) {
            if ( s.substr( i, pat[j].length() ) == pat[j] ) {
                index = j;
                not_match = 0;
                break;
            }
        }
       
        if ( not_match == 1 ) {
            i -= 2;
            continue;
        }
        else if ( not_match == 2 ) {
            cout << "NO" << endl;
            return 0;
        }
        
        i += pat[index].length();
    }
    
    cout << "YES" << endl;
    
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;


void solve(){
    int a, b, c;
    cin >> a >> b >> c;
    for(int k = 0; k <= 1e6; k++){
        if((c + k * b) % a == 0){
            cout << "YES";
            return;
        }
    }
    cout << "NO";
}
int main(){
    int q = 1;
    //cin >> q;}
    while(q--) solve();
}


Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val x, y = sc.nextInt()
  val g = List(
    Set(1,3,5,7,8,10,12),
    Set(4,6,9,11),
    Set(2)
  )
  val gx = g.find(_(x))
  val gy = g.find(_(y))
  println(if (gx == gy) "Yes" else "No")
}


Measured memory_bytes: 55720
#include <stdio.h>
#include <math.h>
int main(){
	int r, r2;
    float a;
    int s;
	r2 = 1;
	double area, area2;
	if(scanf("%d", &r)== 1);
    area = M_PI * r * r;
	area2 = M_PI * r2 * r2;
	a =(double)area/(double)area2;
    s = (int)a;
	printf("%d", s);
    return 0;
}

Measured memory_bytes: 128
n = int(input())
input_list = list(map(int, input().split()))

i = 0
c = 1
cnt = 0
while i < n:
    if input_list[i] == c:   
        c += 1
    else:
        cnt += 1     
        
    i += 1

print(cnt if c > 1 else '-1')

Measured memory_bytes: 24744
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int W[3] = {0};
    int K[3] = {0};
    int Wsub = 0;
    int Ksub = 0;
    int ws,ks;
    for(int i = 0;i < 10;i++){
        cin >> ws;
        if(ws > W[0]){
            W[0] = ws;
            sort(W,W+3);
        }
    }
    for(int i = 0;i < 10;i++){
        cin >> ks;
        if(ks > K[0]){
            K[0] = ks;
            sort(K,K+3);
        }
    }
    for(int i = 0;i < 3;i++){
        Wsub+=W[i];
        Ksub+=K[i];
    }
    cout << Wsub << " " << Ksub << endl;
    return 0;
}

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

int main(void) {
  int a,b,c,count=0;
  cin >> a >> b >> c;
  for(int i=a; i <= b; i+=a){
    count++;
    if(count == c){
      break;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
//Author : Ayush Jain

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define mod 1000000007

int main()
{
	ios_base::sync_with_stdio(false);
	ll q,h,s,d,n;
	cin>>q>>h>>s>>d;
	cin>>n;
	if(n%2==0){
		ll ans=min(8*q,4*h);
		ans=min(ans,2*s);
		ans=min(ans,d);
		ans=(n/2)*ans;
		cout<<ans<<endl;
	}
	else{
		ll ans1=min(4*q,2*h);
		ans1=min(ans1,s);
		ll foo=ans1;
		ans1=n*ans1;
		n--;
		ll ans2=min(8*q,4*h);
		ans2=min(ans2,2*s);
		ans2=min(ans2,d);
		ans2=(n/2)*ans2;
		ans2+=foo;
		cout<<min(ans1,ans2)<<endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n,x;
    cin>>n;

    map<int,int> m;

    while(n--){

        x = n+1;

        while(x%2==0){
            x/=2;
            m[2]++;
        }

        for(int i=3; i<=sqrt(x); i+=2){
            while(x%i==0){
                x/=i;
                m[i]++;
            }
        }
        if(x>1)
            m[x]++;
    }

    long long ans=1;

    for(auto it: m){
        ans*=(it.second+1);
        ans%=mod;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()

#define N 100

int min(int weight[],int n){
    int i, min_num = 0, min_weight = weight[0];

    for(i=0; i<n; i++){
        if(min_weight > weight[i]){
            min_num = i;
            min_weight = weight[i];
        }
    }

    return min_num;
}


int main(void){
    int weight[N];
    int n=0;
    int x=0;
    int i;
    int min_num=0;
    int donuts=0;

    //input
    std::cin >> n >> x;
    for(i=0; i<n; i++){
        std::cin >> weight[i];
    }

    min_num = min(weight, n);

    for(i=0; i<n; i++){
        x -= weight[i];
        donuts++;
    }

    while(x >= weight[min_num]){
        x -= weight[min_num];
        donuts++;
    }

    std::cout << donuts << std::endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <numeric>


int main()
{
	int a, b;

	std::cin >> a >> b;

	std::cout << std::max(a - b, 0) << std::endl;

	return 0;
}

Measured memory_bytes: 256
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

//for A以上B未満でI探索 for (int I = A; i <= B; i++)
//string s = to_string(i);
int a = 0, b = 0, x = 0, y = 0, z = 0, n = 0;
string s = ""; asas; cncn;

int main(void) {
	cin >> x >> y;
	ans += x - 1;
	if (y >= x)ans++;
	cout << ans << rt;
	please AC;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int n;
  cin >> n;
  vector<ll>a(n),ans(n);
  rep(i,n) cin >> a[i];
  if(n%2==0){
    rep(i,n){
      if(i%2==0){
        ans[n/2+i/2]=a[i];
      }
      else{
        ans[n/2-1-(i/2)]=a[i];
      }
    }
  }
  else{
    rep(i,n){
      if(i==0){
        ans[n/2]=a[0];
        continue;
      }
      if(i%2==1){
        ans[n/2+(i+1)/2]=a[i];
      }
      else{
        ans[n/2-i/2]=a[i];
      }
    }      
  }
  rep(i,n){
    if(i!=0)cout<< " ";
    cout << ans[i];
  }
  
}


Measured memory_bytes: 5376
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    int X, N;
    cin >> X >> N;
    map<int, bool> P;
    for(int i = 0; i < N; i++){
        int p;
        cin >> p;
        P[p] = true;
    }
    int min_x;
    for(int i = X; i >= 0; i--){
        if(P[i] == false){
            min_x = i;
            break;
        }
    }
    int min_x2;
    for(int i = X; i <= 101; i++){
        if(P[i] == false){
            min_x2 = i;
            break;
        }
    }
    if(X - min_x > min_x2 - X) cout << min_x2 << endl;
    else if(X - min_x < min_x2 - X) cout << min_x << endl;
    else cout << min_x << endl;
}


Measured memory_bytes: 3648
// ?????????????????? compareTo
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		
		Scanner scan = new Scanner(System.in);
		// ?????°??????????????°???
		int n = scan.nextInt();
		// ???????????????????´????????????°
		int taro = 0;
		int hanako = 0;
		// ?????????????????????????????§??°?????????
		for(int i = 0; i<n; i++) {
			// ??????????????????
			String taroCard = scan.next();
			String hanakoCard = scan.next();
			// ??????????????????????????????
			int x = taroCard.compareTo(hanakoCard);
			
			if (x > 0) taro = taro +3;
			else if (x < 0) hanako = hanako +3;
			else{
				taro = taro + 1;
				hanako = hanako +1;
			}
		}
		// ??????
		System.out.println(taro + " " + hanako);

	}

}

Measured memory_bytes: 29256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main(){

    input!{
        n: usize,
        a: [usize;n],
    }

    let mut a_tmp: Vec<usize> = Vec::new();
    for i in a{
        a_tmp.push(i);
    }

    a_tmp.sort();
    let mut cnt = 0;
    let mut dp: Vec<bool> = vec![true; a_tmp[n-1]+1];
    let mut tmp = 0;
    for &i in &a_tmp {
        if dp[i]==true {
            for j in (i*2..a_tmp[n-1]+1).step_by(i) {
                dp[j] = false;
            }
            
            if i==tmp {
                dp[i] = false;
            }
            tmp = i;
            // println!("{}", i);
            // println!("{}", dp[i]);
        }
    }

    for &i in &a_tmp {
        if dp[i]==true {
            cnt += 1;
        }
    }

    println!("{}", cnt);

}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define fre freopen("in.txt","r",stdin)
#define IO ios::sync_with_stdio(false)
#define mem(a,n) memset(a,n,sizeof(a))
#define rep(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
typedef long long ll;
const int INF=0x3f3f3f3f;
const double PI=3.1415926;
const int MOD=1e9+7;
const int N=1e2+5;
int n;
int dp[3][N],a[3][N];
int dfs(int x,int y)
{
    if(x>1||y>=n) return -1;
    int& ret=dp[x][y];
    if(x==1&&y==n-1) return a[x][y];
    if(ret!=-1) return ret;
    ret=max(dfs(x+1,y),dfs(x,y+1))+a[x][y];
    return ret;
}
int main()
{
    //fre;
    scanf("%d",&n);
    rep(i,0,2)
    rep(j,0,n) scanf("%d",&a[i][j]);
    mem(dp,-1);
    printf("%d\n",dfs(0,0));
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from itertools import accumulate
from collections import defaultdict
def inpl(): return map(int, input().split())
N = int(input())
A = inpl()
ans = 0
S = list(accumulate(A))
D = defaultdict(int)

for s in S:
    ans += D[s] + (s==0)
    D[s] += 1

print(ans)


Measured memory_bytes: 34196
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <bitset>
#include <set>

using ll = long long;
using namespace std;
constexpr ll MOD = ll(1e9) + 7;

int main(void) {
	int h, n;
	cin >> h >> n;
	
	vector<int> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	sort(a.begin(), a.end(), greater<int>());
	
	for(int i = 0; i < n; ++i) {
		h -= a[i];
	}
	
	if( h <= 0 ) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main() {
    string s, t;
    int a;
    int ans = 0;

    cin >> s >> t;

    for (int i = 0; i < (int)(s.length()); i++) {
       if (s[i] == t[i]) ans++; 
    }

    

    cout << ans << endl;
}



Measured memory_bytes: 256
X,N = map(int,input().split())
p = list(map(int,input().split()))
if p == []:
    print(X)
    exit()
for i in range(100):
    if not X-i in p:
        print(X-i)
        exit()
    if not X+i in p:
        print(X+i)
        exit()

Measured memory_bytes: 9176