akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, W;
    cin >> n >> W;
    vector<ll> w(n), v(n);
    REP(i,n) cin >> w[i] >> v[i];

    vector<vector<ll>> dp(n+1,vector<ll>(W+1));
    ll ans = 0;
    REP(i,n) {
        REP(j,W+1){
            dp[i+1][j] = dp[i][j];
            if (j - w[i] >= 0) {
                dp[i+1][j] = max(dp[i][j-w[i]]+v[i],dp[i+1][j]);
                ans = max(ans,dp[i+1][j]);
            } else continue;
        }
        //cerr << ans << endl;
    }

    cout << ans << '\n';


    return 0;
}

Measured memory_bytes: 80256
import math
from collections import deque
import itertools

[H, W] = map(int, input().rstrip().split(" "))
S = []


for h in range(H):
    Ss = input().rstrip()
    S.append(Ss)

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

max_cost = 0

for h in range(H):
    for w in range(W):
        if S[h][w] == "#":
            continue
        que = deque()
        history = [ [-1 for w in range(W)] for h in range(H)]
        que.append([h, w])
        history[h][w] = 0
        current_max_cost = 0
        while len(que) != 0:
            [x, y] = que.pop()
            for i in range(4):
                newx = x + dx[i]
                newy = y + dy[i]
                if 0 <= newx and newx < H and 0 <= newy and newy < W and S[newx][newy] != "#" and (history[newx][newy] > history[x][y] + 1 or history[newx][newy] == -1):
                    history[newx][newy] = history[x][y] + 1
                    que.append([newx, newy])
        current_max_cost = max(list(itertools.chain.from_iterable(history)))
        if max_cost < current_max_cost:
            max_cost = current_max_cost

print(max_cost)


Measured memory_bytes: 50404
////////////////////////////////////////////    _LeMur_
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <chrono>
#include <random>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <ctime>
#include <stack>
#include <queue>
#include <cmath>
#include <list>
#include <map>
#include <set>

using namespace std;

const int N = 100005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int n;

int main(){
	mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());
    cin >> n;
    int answ = 0;
    for(int i=1;i<=n;i++){
        int x = i;
        int z = 0;
        while(x){
            ++z;
            x /= 10;
        }
        if(z % 2) ++answ;
    }
    cout << answ << endl;
    return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  ll ans = 1;
  ll mod = 1e9 + 7;
  for(int i = 1; i <= N; i++) {
    ans = (ans * i) % mod;
  }
  cout << ans << endl;

  return 0;
}

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

public class Main {
  public static void main(String[] args) {
    try (PrintWriter out = new PrintWriter(System.out);
        Scanner sc = new Scanner(System.in)) {
      Task task = new Task();
      task.solve(sc, out);
      out.flush();

    } catch (Exception e) {
      // DO NOT USE
      e.printStackTrace();
    }
  }

  private static class Task {
    private void solve(Scanner sc, PrintWriter out) {
      // TODO

      int N = nint(sc);
      int x = nint(sc);

      List<Integer> list = getIntegerList(sc, N);

      Collections.sort(list);

      int count = 0;
      for (int i = 0; i < list.size(); i++) {
        x = x - list.get(i);

        if (x < 0) {
          break;
        }


        count++;
      }

      if (x > 0){
          count--;
      }

      out.println(count);
    }
  }

  // method
  private static int nint(Scanner sc) {
    return Integer.parseInt(sc.next());
  }

  private static long nlong(Scanner sc) {
    return Long.parseLong(sc.next());
  }

  private static double ndouble(Scanner sc) {
    return Double.parseDouble(sc.next());
  }

  private static float nfloat(Scanner sc) {
    return Float.parseFloat(sc.next());
  }

  private static String nstr(Scanner sc) {
    return sc.next();
  }

  private static long[] longLine(Scanner sc, int size) {
    long[] lLine = new long[size];
    for (int i = 0; i < size; i++) {
      lLine[i] = nlong(sc);
    }
    return lLine;
  }

  private static int[] intLine(Scanner sc, int size) {
    int[] iLine = new int[size];
    for (int i = 0; i < size; i++) {
      iLine[i] = nint(sc);
    }
    return iLine;
  }

  private static String[] strLine(Scanner sc, int size) {
    String[] strLine = new String[size];
    for (int i = 0; i < size; i++) {
      strLine[i] = nstr(sc);
    }
    return strLine;
  }

  private static long maxFromList(List<Long> longList) {
    return longList.stream().max(Comparator.naturalOrder()).get();
  }

  private static long minFromList(List<Long> longList) {
    return longList.stream().min(Comparator.naturalOrder()).get();
  }

  private static int sumDigits(int n) {
    int sum = 0;
    while (n != 0) {
      sum += n % 10;
      n /= 10;
    }
    return sum;
  }

  private static long sumDigits(long n) {
    long sum = 0;
    while (n != 0) {
      sum += n % 10;
      n /= 10;
    }
    return sum;
  }

  private static List<Integer> getIntegerList(Scanner sc, int size) {
    List<Integer> list = new ArrayList<>();
    for (int i = 0; i < size; i++) {
      list.add(nint(sc));
    }
    return list;
  }

  private static List<Long> getLongList(Scanner sc, int size) {
    List<Long> list = new ArrayList<>();
    for (int i = 0; i < size; i++) {
      list.add(nlong(sc));
    }
    return list;
  }

  private static long gcd(long m, long n) {
    if (m < n) return gcd(n, m);
    if (n == 0) return m;
    return gcd(n, m % n);
  }

  private static long lcm(long m, long n) {
    return m * n / gcd(m, n);
  }
}


Measured memory_bytes: 23124
#include <iostream>

using namespace std;

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

	if (a + b == 15) {
		cout << "+" << endl;
	}
	else if (a * b == 15) {
		cout << "*" << endl;
	}
	else {
		cout << "x" << endl;
	}

	return 0;
}

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

int s[2001][1001];

#define calc(x, y, w, h) (s[(x)+(w)][(y)+(h)] - s[(x)+(w)][(y)] - s[(x)][(y)+(h)] + s[(x)][(y)])

int main(void){
    long n, k;
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n >> k;
    for(long i=0; i<n; i++){
        long x, y;
        char c;
        cin >> x >> y >> c;
        y %= 2*k;
        if(c=='W'){
            x += k;
        }
        if(y>=k){
            y-=k;
            x+=k;
        }
        x %= 2*k;
        s[x+1][y+1]++;
    }
    for(long x=0; x<2*k; x++){
        for(long y=0; y<k; y++){
            s[x+1][y+1] = s[x+1][y+1] + s[x][y+1] + s[x+1][y] - s[x][y];
        }
    }
    long max = 0;
    for(long x=0; x<k; x++){
        for(long y=0; y<k; y++){
            long t = calc(x, y, k, k-y)+calc(0, 0, x, y)+calc(x+k, 0, k-x, y);
            t = t<n/2 ? n-t : t;
            max = t>max ? t : max;
        }
    }
    cout << max;
    return 0;
}


Measured memory_bytes: 8064
def main():
  S = input()
  argc = len(S)
  result = 0
  flg = 0
  for i in range(argc):
    if (flg == 0):
      leng = 0
      flg = 1
    if (S[i]=='A')or(S[i]=='C')or(S[i]=='G')or(S[i]=='T'):
      leng = leng + 1
      if leng > result:
        result = leng
    else:
      flg = 0
  print(result)
main()

Measured memory_bytes: 3064
table = [[[0]*10 for i in range (0,3)] for k in range (0,4)]

N = int(input())

for loop in range(N):
    house_id,floor,room,add = map(int,input().split())
    table[house_id-1][floor-1][room-1] += add


x = 0

for i in range(4):
    if x != 0:
        print("#"*20)
    x += 1

    for a in range(3):
        for b in range(10):
            print(" %d"%(table[i][a][b]),end = "")
        print()


Measured memory_bytes: 5624
#include<bits/stdc++.h>
using namespace std;
const int N=1005;
const int mod=1000000007;
char a[N][N];
int dp[N][N];
int main()
{
	int h,w;
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++)
		scanf("%s",a[i]+1);
	dp[1][1]=1;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++)
			if(a[i][j]!='#'&&(i!=1||j!=1))
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
	printf("%d\n",dp[h][w]);
	return 0;
}


Measured memory_bytes: 5120
#include <stdio.h>

int main(void){
	int n,x,i,j,k;
	while(1){
	int c=0;
	scanf("%d %d",&n,&x);
	if(n==0 && x==0){
		break;
	}
	for(i=1;i<=n;i++){
		for(j=i+1;j<=n;j++){
			for(k=j+1;k<=n;k++){
				if(i+j+k==x){
					c++;
				}
			}
		}
	}
	printf("%d\n",c);
	}
	return 0;
}

Measured memory_bytes: 600
def main():
    n = int(input())
    s = {}
    for _ in range(n):
        string = input()
        if string in s:
            s[string] += 1
        else:
            s[string] = 1
    s = sorted(list(s.items()), key=lambda x: (x[1], x[0]), reverse=True)
    lst = []
    max_num = s[0][1]
    if n == len(s):
        for string, num in reversed(s):
            print(string)
    else:
        for string, num in s:
            if num != max_num:
                break
            lst.append(string)
    for l in reversed(lst):
        print(l)


if __name__ == "__main__":
    main()


Measured memory_bytes: 110176
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

int main(){
    int V, E; cin>>V>>E;
    vector<vector<int>> dist(V, vector<int>(V, 1e9));
    for(int i=0; i<V; i++) dist[i][i] = 0;
    for(int i=0; i<E; i++){
        int s, t; cin>>s>>t;
        dist[s][t] = -1;
    }

    for(int i=0; i<V; i++){
        for(int j=0; j<V; j++){
            for(int k=0; k<V; k++){
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }

    auto pdist = dist;

    for(int i=0; i<V; i++){
        for(int j=0; j<V; j++){
            for(int k=0; k<V; k++){
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }

    bool haveCycle = false;
    for(int i=0; i<V; i++){
        for(int j=0; j<V; j++){
            if(dist[i][j] != pdist[i][j]) haveCycle = true;
        }
    }

    cout << haveCycle << endl;
}


Measured memory_bytes: 3240
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


A = list(map(int, sys.stdin.buffer.readline().split()))
A.sort(reverse=True)
ans = int(str(A[0]) + str(A[1])) + A[2]
print(ans)


Measured memory_bytes: 13436
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    double pi = acos(-1);
    while(cin >> n, n){
        vector<int> v(n-1);
        int s = 360;
        for (auto &&i : v) scanf("%d", &i), s -= i;
        v.emplace_back(s);
        int m;
        cin >> m;
        vector<int> u(m-1);
        s = 360;
        for (auto &&j : u) scanf("%d", &j), s -= j;
        u.emplace_back(s);
        double ans1 = 0, ans2 = 0;
        for (auto &&i : v) {
            ans1 += sin(pi*i/180);
        }
        for (auto &&k : u) {
            ans2 += sin(pi*k/180);
        }
        if(abs(ans1-ans2) < 1e-10) puts("0");
        else if(ans1 < ans2) puts("2");
        else puts("1");
    }

    return 0;
}


Measured memory_bytes: 3336
// {{{ include and macros
#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(a, b) for(int unsafe_cnt=a; unsafe_cnt < b;unsafe_cnt++)
#include <iostream>
// #include <stdio.h>
#include <vector>
// #include <math.h>
// #include <algorithm>
// #include <string>
// #include <map>
// #include <set>
using namespace std;
// }}}

// {{{ put
void newline() {cout << endl;}
template <typename T> void display(T input){cout << input;}
template <typename T> void put(T input){display(input); newline();}
// }}}

int main() {
  int n, step=0;
  cin >> n;
  vector<int> v;
  vector<bool> b(n, false);
  for(int cnt=0; cnt<n; cnt++){
    int in; cin >> in;
    v.push_back(in);
  }
  int next = v[0];
  b[0] = true;
  step = 1;
  while(true){
    if(b[next-1] == true){put(-1);break;}
    if(next==2){put(step);break;}
    step++;
    b[next-1] = true;
    next = v[next-1];
  }
}

Measured memory_bytes: 896
#include <stdio.h>
int r[101];
int DP[101][100];
int main(){
  int len, i, n1, n2,answer;//len-n,ri-n1,ci-n2,ans-answer
    scanf("%d", &len);
    for(i=0; i<len; i++) {
        scanf("%d%d", &n1, &n2);
        r[i]=n1;
    }
    r[i]=n2;
    answer = solve(r,len);
    printf("%d\n", answer);
    return 0;
}



int solve(int m[], int len){
  int j, i, k, t;//s-i,n-len,l-j,r-m,i-k,t-t
    for(i=1; i< len; i++) 
        DP[1][i]=0;
    for(j=2;j<=len; j++){
        for(i=0; i+j<=len; i++){
            DP[j][i] = DP[j-1][i+1] + m[i]*m[i+1]*m[i+j];
            for(k=2; k<j; k++){
                t = DP[k][i] +DP[j-k][i+k] + m[i]*m[i+k]*m[i+j];
                if(t<DP[j][i]) DP[j][i]=t;
            }
        }
    }
    return DP[len][0];
}
 

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

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int N;
    io.read(N);
    auto a = io.read_vec<int>(N);
    sort(a.begin(), a.end());
    cout << a.back() - a.front();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define REP(i,s,N) for (int i=s;i<(N); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

ll ans = 0;

int main(){
	ll N;
	cin >> N;
	
	REP(i,1,sqrt(N)+1){
		if(N%i==0){
			if(N/i-i>=0){
				ans = i + N/i - 2;
			}else{
				break;
			}
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;

struct edge{
    int from, to;
    int64_t cost;
    edge(int a=0, int b=0, int64_t c=0LL):from(a), to(b), cost(c) {}
};


vector<vector<edge> > G; // resizeの必要あり


// サイズ,辺の情報,初期化の必要あり
vector<edge> es;

const int64_t INF = INT64_MAX/10;

vector<ll> bellman(int, int);
bool bell_check(int);

int main() {
    int n, m, s;
    cin >> n >> m >> s;
    es.resize(m);
    rep(i, m) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        es[i] = edge(a, b, c);
    }

    vector<ll> d = bellman(s, n);
    if(d[s] == INF) {
        cout << "NEGATIVE CYCLE" << endl;
    } else {
        rep(i, n) {
            if(d[i] == INF) {
                cout << "INF" << endl;
            } else {
                cout << d[i] << endl;
            }
        }
    }
}







// sは始点,vは頂点数
vector<int64_t> bellman(int s, int v) {
    vector<int64_t> d(v, INF);
    int E = es.size();
    d[s] = 0LL;
    int www=0;
    while(true) {
        bool update = false;
        for(int i=0; i < E; ++i) {
            edge e = es[i];
            if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                update = true;
            }
        }
        if(!update) break;
        if(www == v*2) {
            d[s] = INF;
            break;
        }
        
        www++;
    }
    return d;
}

// vは頂点数, 負の閉路が存在するならtrue
bool bell_check(int v) {
    vector<int64_t> d(v);
    int E = es.size();
    for(int i = 0; i < v; ++i) {
        for(int j = 0; j < E; ++j) {
            edge e = es[j];
            if(d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                if(i == v-1) return true;
            }
        }
    }
    return false;
}


Measured memory_bytes: 3112
using System;

namespace _0555
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int n = int.Parse(Console.ReadLine());
            int x = 0;
            for (int i = 0; i < n; i++)
            {
                string now = Console.ReadLine();
                now = now + now;
                if (0 <= now.IndexOf(s))
                {
                    x++;
                }
            }
            Console.WriteLine(x);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9780
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)	cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
// #define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 200005
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 200005;
const long double epsilon = 1e-9;
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinvfermat(ll a, ll m)
{
	return binexp(a, m - 2, m);
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}

signed main() {

	fast
	ll n, k;
	cin >> n >> k;
	vl a(n);
	ain(a, n);
	FOR(i, k, n - 1)
	{
		if (a[i] > a[i - k])
			cout << "Yes" << END;
		else
			cout << "No" << END;
	}




// #ifndef ONLINE_JUDGE
// 	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
	return 0;
}


Measured memory_bytes: 4780
#include<iostream>
using namespace std;
int main(){
    int n;
    int hanako=0, tarou=0;
    cin>>n;
    for(int i=0; i<n; i++){
        string h,t;
        cin>>t>>h;
        if(h>t) hanako+=3;
        else if(h<t)    tarou+=3;
        else{
            hanako++;
            tarou++;
        }
    }
    cout<<tarou<<" "<<hanako<<endl;
}


Measured memory_bytes: 3204
#include<stdio.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(i=0; i<n; i++)

int main(void)
{
	char s[100], t[100];
	scanf("%s%s", s, t);
	printf("%s%s", t, s);
	return 0;
}

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

using namespace std;

int main() {
  
  int n;
  cin >> n;
  
  int k = n/1000*1000, p = 1000 - n + k;
  
  if (p == 1000) cout << 0;
  else 
  cout << 1000 - n + k;
}

Measured memory_bytes: 3632
read n a b

total=0

for ((i=1 ; i<=$n ; i++));do
    len=${#i}
    sum=0
    for (( j = 0; j < ${#i}; j++ )); do
        (( sum += ${i:j:1} ))
    done

    if [ $sum -le $b -a $sum -ge $a ] ; then
            total=$(($total + $i))
    fi

done

echo $total

Measured memory_bytes: 376
#include <stdio.h>
#include <string.h>
/*
#define disp 51

void printDtoB(long long int n){
	int i, a[disp];
	for(i = disp - 1;i >= 0;i--){
		a[i] = n % 2;
		n /= 2;
	}
	for(i = 0;i < disp;i++){
		printf("%d",a[i]);
	}
	printf("\n");
	return;
}*/

int main(void){
	long long int f[50][31], tmp, flag, n, i, m, x, s[50][31], j;
	while(1){
		scanf("%lld",&n);
		if(!n)
			break;
		memset(f,0,sizeof(f));
		memset(s,0,sizeof(f));
		for(i = 0;i < n;i++){
			scanf("%lld",&m);
			for(j = 0;j < m;j++){
				scanf("%lld",&x);
				s[i][x] = 1;
			}
		}
		for(i = 0;i < n;i++)
			f[i][0] = (long long int)1 << i;
		flag = 0;
		for(i = 1;i <= 30 && !flag;(!flag?i++:0)){
			tmp = 0;
			for(j = 0;j < n;j++){
				if(s[j][i])
					tmp |= f[j][i - 1];
			}
			for(j = 0;j < n;j++){
				if(s[j][i])
					f[j][i] = tmp;
				else
					f[j][i] = f[j][i - 1];
			}
			for(j = 0;j < n;j++){
				if(f[j][i] == ((long long int)1 << n) - 1)
					flag = 1;
			}
		}
		if(flag)
			printf("%lld\n",i);
		else
			printf("-1\n");
//		for(i = 0;i < n;i++)
//			printDtoB(f[i][1]);
	}
	return 0;
}

Measured memory_bytes: 1072
N, K = map(int, input().split())
num = [0] * K
for i in range(1, N + 1):
    num[i % K] += 1
ans = 0
for ma in range(K):
    mb = (K - ma) % K
    mc = (K - ma) % K
    if (mb + mc) % K == 0:
        ans += num[ma] * num[mb] * num[mc]
print(ans)

Measured memory_bytes: 4596
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,maxi=0,f=0,mini=INF,sum=0,q;
	string str,g;
    cin>>n;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    sort(all(v));
    cout<<v[v.size()-1]-v[0]<<endl;
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#include <boost/dynamic_bitset.hpp>

using namespace std;
using namespace boost::adaptors;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n;
  cin>>n;
  using bs = boost::dynamic_bitset<>;
  vector<bs> vb(60, bs(n+1));
  for(auto& v : vb) v.set(n);
  vecint cnt(60);
  for(int i : irange(0, n)) {
    ll a;
    cin>>a;
    for (int j : irange(0, 60)) {
      if (a&1) {
        vb[j].set(i);
        ++cnt[j];
      }
      a >>= 1;
    }
  }
  vector<bs> vc;
  vecint indices;
  ll ans = 0;
  for(auto&& c : index(cnt)) {
    if (c.value() % 2) {
      ans |= 1l << c.index();
    } else if (vb[c.index()].count() > 1) {
      vc.push_back(vb[c.index()]);
      indices.push_back(c.index());
    }
  }
  boost::reverse(vc);
  boost::reverse(indices);
  vector<bs> use;
  for(int j : irange(0, (int)vc.size())) {
    vector<bs> tmp = use;
    tmp.push_back(vc[j]);
    int m = tmp.size();
    bool ok = true;
    for(auto&& k:irange(0,m)) {
      size_t mnffs = n+1;
      int mnffsi = -1;
      for(auto&& l:irange(k,m)) {
        auto ffs = tmp[l].find_first();
        if (ffs == bs::npos) {
          continue;
        }
        if (ffs < mnffs) {
          mnffs = ffs;
          mnffsi = l;
        }
      }
      if (mnffs == n+1) {
        break;
      }
      if (mnffs == n) {
        ok = false;
        break;
      }
      swap(tmp[k], tmp[mnffsi]);
      for(auto&& l:irange(k+1,m)) {
        auto ffs = tmp[l].find_first();
        if (ffs == bs::npos) {
          continue;
        }
        if (ffs == mnffs) {
          tmp[l] ^= tmp[k];
        }
      }
    }
    if (ok) {
      ans += 2l << indices[j];
      use.push_back(vc[j]);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3908
#include<stdio.h>
#include<string.h>
const int N = 1300;
const int M = 256;
int main()
{
	char str1[N], str2[N];
	int ary[M] = {0};
	while(fgets(str1, 1300, stdin))
	{
		int s1 = strlen(str1)-1, go = 0;
		for(int i = s1, j = 0; j < s1; i++, j++)
		{
			//123
			//1231
			//12312
			//123123
			str1[i] = str1[j];
		}
		fgets(str2, 1300, stdin);
		for(int i = 0; i < strlen(str1); i++)
		{
			int k = 0;
			for(int j = 0; j < strlen(str2)-1; j++)
			{
				if(str1[i+j] == str2[j])
				{
					k++;
				}
				else
				{
					break;
				}
			}
			if(k == strlen(str2)-1)
			{
				go = 1;
				break;
			}
		}
		if(go)
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
		return 0;
    } 
}


Measured memory_bytes: 2628
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

static int
solve(int K, int S)
{
  int ret = 0;
  for (int x = 0; x <= K; x++)
  {
    for (int y = 0; y <= K; y++)
    {
      int z = S - (x + y);
      if (0 <= z && z <= K)
      {
        ret++;
      }
    }
  }
  return ret;
}

int
main()
{
  int K, S;
  cin >> K >> S;
  cout << solve(K, S) << endl;
  return 0;
}


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

int main(){
    string s;
    cin >> s;
    while(s[0] != '0'){
        int ret = 0;
        for(auto it : s) ret += (it - '0');
        cout << ret << endl;
        cin >> s;
    }
 return 0;
}


Measured memory_bytes: 3212
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	String a=scan.next();
	for(int i=1;i!=a.length();i++) {
		String str=a.substring(0,a.length()-i);
		if(str.length()%2==1) {
			continue;
		}
		else {
			String str1=str.substring(0,str.length()/2);
			String str2=str.substring(str.length()/2,str.length());
			if(str1.equals(str2)) {
				System.out.println(str.length());
				return;
			}
		}
	}
}
}

Measured memory_bytes: 21844
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

char s[500000];
int ww[500000] , ee[500000];

int main()
{
	int n;
	scanf("%d",&n);
	scanf("%s",s + 1);
	int len = strlen(s + 1);
	ee[0] = 0 , ww[0] = 0;
	for(int i = 1 ; i <= len ; i++){
		if(s[i] == 'W') ww[i] = ww[i - 1] + 1;
		else ww[i] = ww[i - 1];
	}
	for(int i = len ; i >= 1 ; i--){
		if(s[i] == 'E') ee[i] = ee[i + 1] + 1;
		else ee[i] = ee[i + 1];
	}
	int Min = 500000;
	for(int i = 1 ; i <= len ; i++){
		Min = min(Min , ww[i - 1] + ee[i + 1]);
	}
	printf("%d\n",Min);
	return 0;
}

Measured memory_bytes: 3584
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
  
    ll n,x,y,i,j;
    cin>>n>>x>>y;
    ll len = y -x + 1;
    map<ll,ll> ma;
    for(i=1;i<=n;i++)
    {
    	for(j=i+1;j<=n;j++)
    	{
    		if((i>=x and i<=y) and (j>=x and j<=y))
    		{
    			ma[min(j-i, len - (j-i))]++;
    		}
    		else if(j<=x)
    		{
    			ma[j-i]++;
    		}
    		else if(i>=y)
    		{
    			ma[j-i]++;
    		}
    		else if(i<x and ( j > x and j <=y))
    		{
    			ma[x-i + min(j-x, len - (j-x))]++;
    		}
    		else if(i<=x and (j >=y))
    		{
    			ma[x-i + j - y + 1]++;
    		}
    		else
    		{
    			ma[j-y + min(y-i,len - (y-i))]++;
    		}
    	}
    }
    for(i=1;i<=n-1;i++) cout<<ma[i]<<"\n";


}

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

int main() {
  int N, K, x = 1;

  cin >> N;
  cin >> K;

  for(int i = 0; i < N; i++){
    if (2 * x < x + K){ //2x<x+KのときX=2xとする
      x = 2 * x;
    }
    else{
      x = x + K;
    }
  }
  cout << x << endl;


}


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

int main() {
  int64_t n;
  std::cin >> n;
  std::vector<int64_t> a(n);
  for (auto &i : a) {
    std::cin >> i;
  }

  const auto l = *std::max_element(a.cbegin(), a.cend());

  int64_t r = a[0];
  if (l % 2 == 0) {
    for (const auto i : a) {
      if (std::abs(l / 2 - i) <= std::abs(l / 2 - r) && i != l) {
        r = i;
      }
    }
  } else {
    for (const auto i : a) {
      if (std::min(std::abs(l / 2 - i), std::abs(l / 2 + 1 - i))
        <= std::min(std::abs(l / 2 - r), std::abs(l / 2 + 1 - r)) && i != l) {
        r = i;
      }
    }
  }

  std::cout << l << " " << r << std::endl;
  return 0;
}

Measured memory_bytes: 1024
from itertools import product

H, W, K = map(int, input().split())
grid = [input() for _ in range(H)]

ans = 0
for row in product([0, 1], repeat=H):
    for col in product([0, 1], repeat=W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if row[i] and col[j] and grid[i][j] == '#':
                    cnt += 1
        if cnt == K:
            ans += 1

print(ans)


Measured memory_bytes: 9192
#include <iostream>
#include <vector>

using namespace std;

void turn(int& x,int k)
{
	x+=k;
	while(x<0) x+=10;
	while(x>9) x-=10;
}

int solve(vector<int> a,vector<int> b,int i)
{
	int n=a.size();
	if(i==n) return a[i-1]!=b[i-1];
	
	if(i>0 && a[i-1]!=b[i-1]){
		int d=b[i-1]-a[i-1];
		turn(a[i-1],d);
		int res=1+solve(a,b,i+1);
		for(int j=i;j<n;j++){
			turn(a[j],d);
			res=min(res,1+solve(a,b,i+1));
		}
		return res;
	}
	else
		return solve(a,b,i+1);
}

int main()
{
	for(int n;cin>>n,n;){
		string sa,sb; cin>>sa>>sb;
		vector<int> a(n),b(n);
		for(int i=0;i<n;i++){
			a[i]=sa[i]-'0';
			b[i]=sb[i]-'0';
		}
		cout<<solve(a,b,0)<<endl;
	}
}

Measured memory_bytes: 1224
#include<iostream>
#include<queue>

#define P pair<int, int>
using namespace std;

const int INF=1<<30-1;

int h, w, n, gx, gy, times[1009][1009];
char c[1009][1009];

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

int bfs(char cur, int sx, int sy){
  int ret=0;
  queue<P> que;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      times[i][j] = INF;
    }
  }
  que.push(P(sy, sx));
  times[sy][sx] = 0;
  while(que.size()){
    P p = que.front();que.pop();
    for(int i=0;i<4;i++){
      int ny = p.first + dy[i];
      int nx = p.second + dx[i];
      if(0<=ny<=h-1&&0<=nx&&nx<=w-1&&c[ny][nx]!='X'&&times[ny][nx]==INF){
        times[ny][nx] = times[p.first][p.second]+1;
        if(c[ny][nx]==cur+1){
          ret = times[ny][nx];
          sx=nx, sy=ny;
        }
        que.push(P(ny, nx));
      }
    }
  }
  if(ret==0)return 0;
  else return ret + bfs(cur+1, sx, sy);
}

int main(){
  cin >> h >> w >> n;
  int sy,sx;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> c[i][j];
      if(c[i][j]=='S'){
        sy=i;sx=j;
      }
    }
  }
  cout << bfs('0', sx, sy) << endl; 
}


Measured memory_bytes: 8088
#include <bits/stdc++.h>
using namespace std;
int main(){
  int h, w, ct=0;
  queue<string> q;
  cin >> h >> w;
  int a[h][w];
  for(int i=0; i<h; i++)
    for(int j=0; j<w; j++)
      cin >> a[i][j];
  for(int i=0; i<h; i++)
    for(int j=0; j<w; j++){
      if(i==h-1 and j==w-1)
	break;
      if(i%2==0){
	if(a[i][j]%2==0)
	  continue;
	else{
	  int tmpi, tmpj;
	  if(j==w-1){
	    tmpi=i+1;
	    tmpj=j;
	  }
	  else{
	    tmpi=i;
	    tmpj=j+1;
	  }
	  a[tmpi][tmpj]++;
	  q.push(to_string(i+1)+" "+to_string(j+1)+" "+to_string(tmpi+1)+" "+to_string(tmpj+1));
	}
      }
      else{
	if(a[i][w-j-1]%2==0)
	  continue;
	else{
	  int tmpi, tmpj;
	  if(j==w-1){
	    tmpi=i+1;
	    tmpj=j;
	  }
	  else{
	    tmpi=i;
	    tmpj=j+1;
	  }
	  a[tmpi][w-tmpj-1]++;
	  q.push(to_string(i+1)+" "+to_string(w-j)+" "+to_string(tmpi+1)+" "+to_string(w-tmpj));
	}
      }
    }
  cout << q.size() << endl;
  while(!q.empty()){
    cout << q.front() << endl;
    q.pop();
  }
  return 0;
}

Measured memory_bytes: 12160
#include <iostream>
#include <vector>
#include <cmath>

using namespace std ;

int main(void) {

    int n, d ;
    cin >> n >> d ;

    int siya = d * 2 + 1 ;
    int ans = (int)(n/siya) ;
    if (n%siya !=0)
        ans++ ;

    cout << ans << endl ; 

    return 0 ;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		Scanner scan = new Scanner(System.in);
		String answer = "";	
		String temp = "";
		while(true){
			temp = scan.next();
			if(temp.equals("-")){
				break;
			}
			char[] targetChar = temp.toCharArray();
			int targetLength = temp.length();
			int shuffleTimes = scan.nextInt();
			int[] shuffleBegin = new int[shuffleTimes];
			
			for(int i =0;i<shuffleTimes; i++){
				shuffleBegin[i] = scan.nextInt();
			answer = "";
				for(int j=0; j<(targetLength - shuffleBegin[i]) ; j++){
					answer = answer + targetChar[j + shuffleBegin[i]];
				}
				
				for(int j=0; j<shuffleBegin[i]; j++){
					answer = answer + targetChar[j];
				}
				
			targetChar = answer.toCharArray();
			}
			System.out.println(answer);		
		}
	}
}

Measured memory_bytes: 46124
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     setbits(x)  __builtin_popcountll(x)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

signed main(){
    FastIO;
    ll x;
    cin>>x;
    cout<<x/500*1000+(x%500)/5*5;
    return 0;
}


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

using namespace std;

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


  if (a < b) {
    string result = "";
    string char_a = to_string(a);
    for (int i = 0;i < b;i++) {
      result.append(char_a);
    }
    cout << result << endl;
  } else {
    string result = "";
    string char_b = to_string(b);
    for (int i = 0;i < a;i++) {
      result.append(char_b);
    }
    cout << result << endl;
  }
  return 0;
}


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

using namespace std;


int main() {
	int A, B;
	cin >> A >> B;
	for (int tax = 1; ; ++tax) {
		if (int(tax * 0.08) == A && int(tax * 0.1) == B) {
			cout << tax << endl;
			return 0;
		}
		if (100 < int(tax * 0.1)) {
			break;
		}
	}

	cout << -1 << endl;
	return 0;
}

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

using namespace std;

int ask(const string& s) {
    int ans;
    
    printf("? %s\n", s.c_str());
    fflush(stdout);
    
    scanf("%d", &ans);
    
    return ans;
}

int main() {
    int n = 0, i;
    vector<char> v;
    vector<string> w;
    
    for (i = 0; i < 26; i++) v.push_back('a' + i);
    for (i = 0; i < 26; i++) v.push_back('A' + i);
    for (i = 0; i < 10; i++) v.push_back('0' + i);
    
    for (i = 0; i < v.size(); i++) {
        int x = 128 - ask(string(128, v[i]));
        
        if (x > 0) {
            n += x;
            w.push_back(string(x, v[i]));
        }
    }
    
    while (w.size() > 1) {
        string s, t, st = "";
        
        sort(w.begin(), w.end(), [](const string& s1, const string& s2) {return s1.size() > s2.size();});
        
        s = w.back();
        w.pop_back();
        t = w.back();
        w.pop_back();
        
        while (s.size() > 0 && t.size() > 0) {
            int x = n - ask(st + s[0] + t);
            
            if (x == st.size() + t.size() + 1) {
                st += s[0];
                s = s.substr(1);
            } else {
                st += t[0];
                t = t.substr(1);
            }
        }
        
        st += s;
        st += t;
        
        w.push_back(st);
    }
    
    printf("! %s\n", w[0].c_str());
    fflush(stdout);
    
    return 0;
}


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

int n;
char S[311][311];

bool check(int k){
    bool res = true;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i - k < 0)
            if((i - k + n) % n == j) continue;
            if(S[i][j] != S[(j + k) % n][(i - k + n) % n]) res = false;
        }
    }
    return res;
}

int main(){

cin >> n;

for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
        cin >> S[i][j];
    }
}

int ans = 0;

for(int i = 0; i < n; i++){
    if(check(i)) ans++;
}

cout << n * ans << endl;

return 0;

}


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

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

  string str;
  cin >> str;

  int ans = 0;

  for (int i = 0; i < 4; i++) {
    if (str[i] == '+') {
      ans++;
    } else {
      ans--;
    }
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

int LIS(vector<int> a) {
  vector<int> dp(a.size(), INF);
  for (int i = 0; i < a.size(); i++) {
    *lower_bound(dp.begin(), dp.end(), a[i]) = a[i];
  }
  return lower_bound(dp.begin(), dp.end(), INF) - dp.begin();
}

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int N,A,B;
  cin >> N >> A >> B;
  if (A + B - 1 > N) {
    cout << -1 << endl;
    return 0;
  }
  vector<int> v(A,1);
  N -= A;
  for (int i = 0; N > 0 && i < A; i++) {
    int num = min(B - 1, N);
    v[i] += num;
    N -= num;
  }
  if (N > 0) {
    cout << -1 << endl;
    return 0;
  }
  vector<int> ans;
  int last = 0;
  for (int i = 0; i < A; i++) {
    for (int j = 0; j < v[i]; j++) {
      ans.push_back(last + v[i] - j);
    }
    last += v[i];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 8176
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <string>
#include <queue>

using namespace std;

int main(){
  int n,a,b,c,i,j,k;
  string s;
  bool flag=true;
  cin >> a >> b >> k;
  for(i=0;i<k;i++){
    if(flag){
      if(a%2==1)a--;
      b+=a/2;
      a-=a/2;
      flag = false;
    }
    else{
      if(b%2==1)b--;
      a+=b/2;
      b-=b/2;
      flag = true;
    }
  }
  cout << a << " " << b << endl;
  return 0;
}


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

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

typedef struct {
    int h,p,q;
} Bar;

void solve(int n,int m,int a) {
    vector<Bar> v(m);
    for(auto& i : v) cin>>i.h>>i.p>>i.q;

    rep(i,m) rep(j,m-1) if(v[j].h < v[j+1].h) swap(v[j],v[j+1]);

    for(auto& i : v) {
        if(i.p == a) a = i.q;
        else if(i.q == a) a = i.p;
    }

    cout << a << "\n";
}

int main() {
    int n,m,a;
    while(cin>>n>>m>>a && n) solve(n,m,a);
    return 0;
}

Measured memory_bytes: 3072
// Learn more about F# at http://fsharp.org
// See the 'F# Tutorial' project for more help.


let makeTrioSequence (lst:int array) = 
    if lst.Length < 3 then
        []
    else
        [for i in 1..(lst.Length - 2) -> [|lst.[i-1]; lst.[i]; lst.[i+1]|]]

let isSecondElementSecondBiggest (lst:int array) = 
    [for i in 0..(lst.Length-1) -> (i, lst.[i])]
    |> List.sortBy(fun (index, value) -> value)
    |> List.item 1
    |> fst = 1

[<EntryPoint>]
let main argv = 
    let numOfElements = stdin.ReadLine() |> int

    let elements = stdin.ReadLine().Split(' ') |> Array.map int

    let count = elements
                |> makeTrioSequence
                |> List.filter(fun x -> isSecondElementSecondBiggest x)
                |> List.length

    printfn "%d" count

    0 // return an integer exit code


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


int main()
{
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int sum = 0;

    while (A > 0) {
        if (K == 0) {
            break;
        }
        A--;
        K--;
        sum++;
    }

    while (B > 0) {
        if (K == 0) {
            break;
        }
        B--;
        K--;
    }

    while (C > 0) {
        if (K == 0) {
            break;
        }
        C--;
        K--;
        sum--;
    }

    cout << sum << endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<stdlib.h>
int main(){
  
  int n,i,j,flag=1,hozon,z=0;

  scanf("%d",&n);
  int *A;
  A=(int *)malloc(n*sizeof(int));

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  while(flag){
    flag=0;
    for(j=n-1;j>=1;j--){
      if (A[j]<A[j-1]) {
	
	hozon = A[j];
	A[j]=A[j-1];
	A[j-1]=hozon;
	flag=1;
	z++;
      }
      
    }
  }

    for(i=0;i<n;i++){
      printf("%d",A[i]);
      if(i!=n-1) printf(" ");
      else printf("\n%d\n",z);
    }

    return 0;
  }



Measured memory_bytes: 2124
MOD = 10 ** 9 + 7
INF = 10 ** 11
import sys
sys.setrecursionlimit(100000000)

def main():
    N = int(input())
    A = list(map(int,input().split()))

    dic = {}
    ans = 0
    for i in range(N - 1,-1,-1):
        key = A[i] + i
        if key in dic:
            ans += dic[key]
        key2 = -A[i] + i
        if key2 in dic:
            dic[key2] += 1
        else:
            dic[key2] = 1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 40456