akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int N; cin >> N;
  //vector<int> vec(N);
  //rep(i, N) cin >> vec[i];

  if(N >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;

}

Measured memory_bytes: 3620
import java.util.*;

public class Main {
	public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int a = num / 100;
		int b = (num - a*100) / 10;
		int c = (num - a*100 - b*10);

        if(a < b){
            a++;
        }else if(a == b){
             if(b < c){
                 a++;
             }
        }
        
        System.out.println(a*100 + a*10 + a);
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


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

    return 0;
}


Measured memory_bytes: 3576
#include<iostream>
#include<vector>
#include<tuple>
#include<map>
#include<algorithm>
using namespace std;

enum {FLOOR = -3, WALL, ICE};

enum {Y, X};
const int NEXT[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};

const int NIL = -1;
const int INF = 1000000000;

int h, w;
vector<vector<int>> field;
vector<int> durability;
int sy, sx, gy, gx;
vector<vector<int>> visited;

int flood_fill(int y, int x, int id) {
    int result = 1;
    field[y][x] = id;
    for(const auto& d: NEXT) {
        int ny = y + d[Y];
        int nx = x + d[X];
        if(field[ny][nx] != ICE) continue;
        result += flood_fill(ny, nx, id);
    }
    return result;
}

int dfs(int y, int x, int step) {
    if(y == gy && x == gx) return step;
    if(step == 0) return NIL;
    if(abs(y - gy) + abs(x - gx) > step) return NIL;        // 枝刈り１
    int count = 0;                                                              // 枝刈り４
    for(const auto& d: NEXT) if(visited[y + d[Y]][x + d[X]]) ++count;           //
    if(count >= 2) return NIL;                                                  //
    int result = NIL;
    for(const auto& d: NEXT) {
        int ny = y + d[Y];
        int nx = x + d[X];
        if(field[ny][nx] == WALL) continue;
        if(field[ny][nx] == FLOOR) {
            if(visited[ny][nx]) continue;
            visited[ny][nx] = 1;
            result = max(result, dfs(ny, nx, step - 1));
            visited[ny][nx] = 0;
        } else {
            if(durability[field[ny][nx]] <= 0) continue;
            if(visited[ny][nx]) continue;
            visited[ny][nx] = 1;
            --durability[field[ny][nx]];
            result = max(result, dfs(ny, nx, step - 1));
            ++durability[field[ny][nx]];
            visited[ny][nx] = 0;
        }
    }
    return result;
}

int solve() {
    visited = vector<vector<int>>(h + 2, vector<int>(w + 2, 0));
    for(int i = 1; i <= INF; ++i) {
        int result = dfs(sy, sx, i);
        if(result != NIL) return i - result;
    }
    return NIL;
}

int main() {
    while(cin >> w >> h, w | h) {
        field = vector<vector<int>>(h + 2, vector<int>(w + 2, WALL));
        for(int i = 1; i <= h; ++i) for(int j = 1; j <= w; ++j) {
            char c;
            cin >> c;
            if(c == '#') field[i][j] = WALL;
            else if(c == 'X') field[i][j] = ICE;
            else {
                field[i][j] = FLOOR;
                if(c == 'S') {sy = i; sx = j;}
                if(c == 'G') {gy = i; gx = j;}
            }
        }

        durability.clear();
        for(int i = 1; i <= h; ++i) for(int j = 1; j <= w; ++j) if(field[i][j] == ICE) durability.push_back(flood_fill(i, j, durability.size()) / 2);

        cout << solve() << endl;
    }
}

Measured memory_bytes: 1220
#include <stdio.h>
 
int main(void)
{
    int a[11][11];
    int n, i, j;
 
    scanf("%d", &n);
    while (n != 0)
    {
        for (i = 0; i < n; i++)
            for (j = 0; j < n; j++)
                scanf("%d", &a[i][j]);
 
        a[n][n] = 0;
        for (i = 0; i < n; i++)
        {
            a[i][n] = 0;
            for (j = 0; j < n; j++)
                a[i][n] += a[i][j];
            a[n][n] += a[i][n];
        }
 
        for (j = 0; j < n; j++)
        {
            a[n][j] = 0;
            for (i = 0; i < n; i++)
                a[n][j] += a[i][j];
        }
 
        for (i = 0; i <= n; i++)
        {
            for (j = 0; j <= n; j++)
                printf("%5d", a[i][j]);
            printf("\n");
        }
         
        scanf("%d", &n);
    }
 
    return 0;
}

Measured memory_bytes: 1044
A, B, C = map(int, input().split())
l = [A, B, C]
l = sorted(l)
d1 = l[1] - l[0]
d2 = l[2] - l[1]

if d1 % 2 == 0:
    print(d1//2 + d2)
else:
    print((d1-1)//2 + d2 + 2)

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

int main(){
  int h, w, i;
  cin >> h >> w;
  string a;
  
  cout << string(w+2, '#') << endl;
  for (i=0; i<h; i++) {
    cin >> a;
    cout << "#" << a << "#" << endl;
  }
  cout << string(w+2, '#') << endl;  
      
  return 0;  
}

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

using namespace std;

int main(){
  int d,t,s;
  cin >> d >> t >> s;
  if(d%s == 0){
    if(d/s <= t) cout << "Yes";
    else cout << "No";
  }
  else{
    if(d/s+1 <=t) cout << "Yes";
    else cout << "No";
  }
  return 0;
}


Measured memory_bytes: 3620
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (ll i = ll(a); i <= ll(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end

// 下から桁DP
// dp[桁数][13の倍数で作ることができるか]
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    in >> s;
    ll l = s.size();
    ll dp[l+1][13] = {};
    dp[0][0] = 1;

    ll c;
    REP(i, l){
        if(s[i] == '?') c = -1;
        else c = s[i] - '0';

        REP(j, 10){
            if(c != -1 && c != j) continue;
            REP(k, 13){
                dp[i+1][(k * 10 + j) % 13] += dp[i][k];
            }
        }
        REP(j, 13) dp[i+1][j] %= MOD;
    }
    out << dp[l][5] << endl;
}


Measured memory_bytes: 10704
#include <stdio.h>

int main(){
  char s[2048];
  int i;
  fgets(s, sizeof(s), stdin);
  for(i = 0;s[i] != '\0';i++){
    if('a' <= s[i] && s[i] <= 'z') s[i] += 'A' - 'a';
    else if('A' <= s[i] && s[i] <= 'Z') s[i] += 'a' - 'A';
  }

  printf("%s",s);
  return 0;
}

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

int main () {
  long long N , X , pre = 0;
  cin >> N >> X ;
  vector<int> line(N) ;
  for(int i = 0 ; i < N ; i++ ) {
    cin >> line[i] ;
    pre += line[i] ;
  }
  sort(line.begin(),line.end()) ;
  cout << (X-pre)/line[0] + N << endl ;
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
q = int(input())
bc = [list(map(int, input().split())) for _ in range(q)]
suma = sum(a)
counter = Counter(a)
for i in range(q):
    suma -= bc[i][0] * counter[bc[i][0]]
    suma += bc[i][1] * counter[bc[i][0]]
    counter[bc[i][1]] += counter[bc[i][0]]
    counter[bc[i][0]] = 0
    print(suma)


Measured memory_bytes: 40380
N,M=map(int, input().split())
bad=[0]*(N+1)
for i in range(M):
    bad[int(input())]=1
dp=[0]*(N+1)
mod=10**9+7
dp[0]=1
if bad[1]==0:
    dp[1]=1
for i in range(2,N+1):
    if bad[i]==0:
        dp[i]=(dp[i-2]+dp[i-1])%mod
print(dp[N])

Measured memory_bytes: 7668
n, k = gets.chomp.split(" ").map(&:to_i)
h = gets.chomp.split(" ").map(&:to_i)

dp = Array.new(n, 0)
dp[0] = 0
dp[1] = (h[1] - h[0]).abs

for i in 2..n - 1
  min = Float::INFINITY
  for j in 1..k
    break if i - j < 0

    cost = dp[i - j] + (h[i] - h[i - j]).abs

    if cost < min
      min = cost
    end
  end
  dp[i] = min
end

puts dp[n - 1]

Measured memory_bytes: 12044
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;

namespace ConsoleApp1AtCoder_Beginner_Contest_132
{
    class Program
    {
        //配列にする
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        //Listにする
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static void Main(string[] args)
        {
            var S = ReadLine();
            var d = new Dictionary<char, int>();
            foreach(var c in S)
            {
                if (!d.ContainsKey(c))
                    d[c] = 1;
                else
                    d[c]++;
            }

            if (d.Count == 2)
            {
                foreach(KeyValuePair<char, int> kv in d)
                {
                    if (kv.Value != 2)
                    {
                        WriteLine("No");
                        return;
                    }
                }
                WriteLine("Yes");
            }
            else
            {
                WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 13152
N = int(input())
A = list(map(int,input().split(' ')))

def myGCD(a,b):
    if a == 0:
        return b
    while b!=0:
        a,b = b,a%b
    return a

L=[]
R=[]
for i in range(N):
    L.append(0)
    R.append(0)

for i in range(N-1):
    L[i+1]=myGCD(L[i],A[i])

for i in range(N-2,-1,-1):
    #print(i)
    R[i] = myGCD(R[i+1],A[i+1])

M=[]
for i in range(N):
    M.append(myGCD(R[i],L[i]))
#print(L)
#print(R)

print(max(M))

Measured memory_bytes: 14436
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr = (input.trim()).split("\n");

const binarySearch = (key, arr, N) => {
  let mid;
  let left = 0;
  let right = N;
  if (key < arr[0] || arr[N-1] < key) return 0;
  while (left < right) {
    mid = Math.floor((left + right) / 2);
    if (key < arr[mid]) right = mid;
    else if (key > arr[mid]) left = mid + 1;
    else return 1;
  }
  return 0;
}


(function() {
  const N1 = Number(Arr[0]);
  const arr1 = Arr[1].split(" ").map(Number);
  // const N2 = Number(Arr[2]);
  const arr2 = Arr[3].split(" ").map(Number);
  console.log(arr2.map(e => binarySearch(e, arr1, N1)).reduce((a, b) => a + b, 0));
})();



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

using namespace std;

const int N = 1e5 + 5;
int n;
int arr[N] ;
long long memo[N][2];

long long solve (int i , bool flipped) {
    if (i == n)
        return 0;

    long long &ret = memo[i][flipped];
    if (~ret)
        return ret;

    int cur = flipped ? -arr[i] : arr[i];
    int ncur = -cur;
    ret = solve(i + 1 , 0) + cur;
    if (i != n - 1)
        ret = max(ret , solve(i + 1 , 1) + ncur);
    return ret;
}

int main() {
    scanf("%d" , &n);
    for (int i = 0 ;i < n ;i++)
        scanf("%d" , arr + i);

    memset(memo , -1 , sizeof memo);
    printf("%lld" , solve(0 , 0));
}

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


int main()
{
    int h,w,n;
    scanf("%d %d", &h,&w);
    scanf("%d",&n);
    int num[n];
    int town[h][w];
    for(int i=0; i<n; i++)scanf("%d", &num[i]);

    for(int i=0; i<h; i++)for(int j=0; j<w; j++)town[i][j]=0;

    int hnow=0,wnow=0;



    for(int i=0; i<n; i++){
      for(int j=0; j<num[i]; j++){
        //printf("%d %d\n",hnow,wnow);
        town[hnow][wnow]=i+1;

        if(hnow%2==0&&wnow==w-1){
          hnow++;
        }
        else if(hnow%2==1&&wnow==0){
          hnow++;
        }
        else if(hnow%2==0)wnow++;
        else wnow--;
      }
    }

    for(int i=0; i<h; i++){
      for(int j=0; j<w; j++){
        printf("%d", town[i][j]);
        if(j<w-1)printf(" ");
      }
      printf("\n");
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

a_cnt = {}
for ai in A:
    if ai in a_cnt:
        a_cnt[ai] += 1
    else:
        a_cnt[ai] = 1
from operator import itemgetter
a_cnt = sorted(a_cnt.items(), key=itemgetter(0), reverse=True)
tate = 0
yoko = 0
for i in range(len(a_cnt)):
    if a_cnt[i][1] >= 2:
        tate = a_cnt[i][0]
        #a_cnt[i][1] -= 1
        a_cnt[i] = (a_cnt[i][0], a_cnt[i][1] - 2)
        break
for i in range(len(a_cnt)):
    if a_cnt[i][1] >= 2:
        yoko = a_cnt[i][0]
        #a_cnt[i][1] -= 1
        a_cnt[i] = (a_cnt[i][0], a_cnt[i][1] - 2)
        break
#if tate == 0 or yoko == 0:
#    print(0)
print(tate * yoko)

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

//defines
#define openin freopen("input.txt","r",stdin)
#define openout freopen("output.txt","w",stdout)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define int long long
#define mod 1000000007
#define repr(i,x,y) for (__typeof(x) i=x;i>=y;i--)
#define rep(i,x,y) for (__typeof(x) i=x;i<=y;i++)
#define all(c) (c).begin(),(c).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

/* Print pair */
template <typename T,typename S>
ostream & operator << (ostream &os , const pair<T,S> &v) {
    os << "(" ;
    os << v.first << "," << v.second << ")" ;
    return os ;
}
/* Print vector */
template <typename T>
ostream & operator << (ostream &os , const vector<T> &v) {
    os << "[" ;
    int sz = v.size() ;
    for(int i = 0 ; i < sz ; ++i) {
        os << v[i] ;
        if(i!=sz-1)os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print set */
template <typename T>
ostream & operator << (ostream &os , const set<T> &v) {
    T last = *v.rbegin() ;
    os << "[" ;
    for(auto it : v) {
        os << it  ;
        if(it != last) os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print Map */
template <typename T,typename S>
ostream & operator << (ostream &os , const map<T,S> &v) {
    for(auto it : v) {
        os << it.first << " : " << it.second << "\n" ;
    }
    return os ;
}
int power(int a , int b)
{
    int res = 1 ;
    while(b)
    {
        if(b%2) {
            res = (res * a) % mod ;
        }
        b/=2 ;
        a = (a*a) % mod ;
    }
    return res ;
}

//debug
#define TRACE

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

const int N = 3e5 + 5 ; 

int arr[N] ; 
int cnt[N] ; 
int present[N] ; 

int32_t main()
{
    fast;
    int n , m ; cin >> n >> m ; 
    rep(i,0,n-1) cin >> arr[i] ; 
    rep(i,0,n-1) cnt[arr[i]] ++ ; 
    int ans = 0 ; 
    rep(i,1,n) {
        int temp = max(0LL,i-cnt[i]) ;
        rep(j,temp,i-1) present[j]++;
    }
    rep(i,0,n-1) if(!present[i]) ++ans ;
    rep(i,1,m) {
        int x , y ; cin >> x >> y ; --x ;
        if(y != arr[x]) {
            if(y > cnt[y]) {
                if(present[y-cnt[y]-1] == 0) --ans ;
                present[y-cnt[y]-1]++ ;
            }
            if(arr[x] >= cnt[arr[x]]) {
                if(present[arr[x]-cnt[arr[x]]] == 1) ++ans ;
                present[arr[x]-cnt[arr[x]]]-- ; 
            }
            cnt[arr[x]]-- ; 
            cnt[y]++ ; 
            arr[x] = y ;
        }
        cout << ans << endl ;
    }
    return 0;
}


Measured memory_bytes: 7296
#include <stdio.h>

int main(void){

    int a,b,k,key;

    scanf("%d\n%d %d",&k,&a,&b);

    for(;a<=b;a++){
        key = a%k;
        if(key == 0){
            printf("OK\n");
            return 0;
        }
    }
    printf("NG\n");

    return 0;

}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
int main(){
    CIN(N);CIN(A);CIN(B);
    SCIN(str);
    int ins = 0;
    int kai = 1;
    for(int a = 0;a < str.size();a++){
        if(str.at(a) == 'a'){
            if(ins < A + B){
                ins++;
                Yes(true);
            }else{
                Yes(false);
            }
        }else if(str.at(a) == 'b'){
            if(ins < A+B && kai <= B){
                Yes(true);
                ins++;
                kai++;
            }else{
                Yes(false);
            }
        }else{
            (Yes(false));
        }
    }
    return 0;
}


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

int main()
{
    string  s;
    string  s1;
    string  s2;
    string  rs;
    string  rs1;
    string  rs2;

    cin >> s;
    rs = s;
    s1 = s.substr(0, ((s.size() - 1) / 2));
    s2 = s.substr((s.size() + 2) / 2, s.size() - 1);
    rs1 = s1;
    rs2 = s2;
    //cout << rs1 << " " << rs2 << endl;
    reverse(rs1.begin(), rs1.end());
    reverse(rs2.begin(), rs2.end());
    reverse(rs.begin(), rs.end());
    if (s.compare(rs) == 0 && s1.compare(rs1) == 0 && s2.compare(rs2) == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int h = int.Parse(input[0]);
		int n = int.Parse(input[1]);
		long[,] dp = new long[n+1,h+1];

    long[,] vertexes = new long[n,2];
    for(int i = 0; i < n; i++)
    {
      long[] numsa = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
      vertexes[i,0] = numsa[0];
      vertexes[i,1] = numsa[1];
    }

    for(int i = 0; i <= n; i++)
    {
      for(int j = 0; j <= h; j++)
      {
        dp[i,j] = 999999999;
      }
    }
    dp[0,0] = 0;
    

    for(int i = 1; i <= n; i++)
    {
      for(int j = 0; j <= h; j++)
      {
        dp[i,j] = Math.Min(dp[i,j],dp[i-1,j]);
        if(j-vertexes[i-1,0] >= 0)
        {
          dp[i,j] = Math.Min(dp[i,j], dp[i,j-vertexes[i-1,0]]+vertexes[i-1,1]);
          dp[i,j] = Math.Min(dp[i,j], dp[i-1,j-vertexes[i-1,0]]+vertexes[i-1,1]);
        }else
        {
          dp[i,j] = Math.Min(dp[i,j], dp[i,0]+vertexes[i-1,1]);
          dp[i,j] = Math.Min(dp[i,j], dp[i-1,0]+vertexes[i-1,1]);
        }

        //Console.WriteLine(i+" "+j+" "+dp[i,j]);
      }
    }

		Console.WriteLine(dp[n,h]);
	}
}

Measured memory_bytes: 89176
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let n = input::<usize>();
    let k = input::<usize>();
    let h = {
        let mut temp = (0..n).map(|_| input()).collect::<Vec<i64>>();
        temp.sort();
        temp
    };

    let ans = h.windows(k).map(|i| i[k - 1] - i[0]).min().unwrap();
    println!("{}", ans);
}


Measured memory_bytes: 4352
//   /$$$$           /$$                 /$$$$  /$$$$$$            /$$
//  | $$_/          | $$                |_  $$ /$$__  $$          | $$
//  | $$    /$$$$$$$| $$$$$$$   /$$$$$$   | $$|__/  \ $$ /$$$$$$$ | $$   /$$
//  | $$   /$$_____/| $$__  $$ |____  $$  | $$  /$$$$$$/| $$__  $$| $$  /$$/
//  | $$  |  $$$$$$ | $$  \ $$  /$$$$$$$  | $$ /$$____/ | $$  \ $$| $$$$$$/
//  | $$   \____  $$| $$  | $$ /$$__  $$  | $$| $$      | $$  | $$| $$_  $$
//  | $$$$ /$$$$$$$/| $$  | $$|  $$$$$$$ /$$$$| $$$$$$$$| $$  | $$| $$ \  $$
//  |____/|_______/ |__/  |__/ \_______/|____/|________/|__/  |__/|__/  \__/
//
//
//






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


#define ll long long int
#define ull unsigned long long int
#define po2(z) 1<<(ll)z
#define fr(i,x,n) for(ll i=(ll)(x);i<(ll)(n);++i)
#define rf(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);--i)
#define modinv(x) powah(x,mod-2)
#define ncr(n,r) (((fact[n]*modinv(fact[n-r]))%mod*modinv(fact[r]))%mod)
#define factorial fact.pb(1);sidha(i,1,MAX)fact.pb((fact[i-1]*i)%mod)
#define tej ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod (ll)1000000007
#define MAX 100005
#define Vii  vector<ll>
#define pb  push_back
#define pii pair<ll,ll>
#define ff  first
#define ss second
#define vpii vector<pii >
#define endl '\n'

ll n,W;
ll wt[110];
ll val[110];
ll dp[110][100005];
//--------------------------------------------------//
ll KS(ll n,ll W){
	if(n==0||W==0){
		return 0;
	}
	
	if(dp[n][W]!=-1) return dp[n][W];
	
	if(wt[n]>W){
		return dp[n-1][W] = KS(n-1,W);
	}
	else{
		return dp[n][W]=max(val[n]+KS(n-1,W-wt[n]),KS(n-1,W));
	}

}

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


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

	
	cin>>n>>W;
	memset(wt,0,sizeof(wt));
	memset(val,0,sizeof(val));
	memset(dp,-1,sizeof(dp));
	for(ll i=1;i<=n;i++){
		cin>>wt[i]>>val[i];
	}
	cout<<KS(n,W);

}


Measured memory_bytes: 89592
#include <stdio.h>

int main(void) {
  /* this is comment */
  int num[2];
  scanf("%d %d", &num[0], &num[1]);

  int ans;
  if ( num[0] - 2*num[1] >0) {
    ans = num[0] - 2*num[1];
  } else {
    ans = 0;
  }

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

Measured memory_bytes: 128
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.stream.Stream;

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

        System.out.printf("%.6f", Math.PI * r * r );
        System.out.print(" ");
        System.out.printf("%.6f", Math.PI * 2 * r);
    }
}



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

int main()
{
    int bell1, bell2, bell3;
    int sum1, sum2, sum3;
    int mini_sum;

    cin >> bell1 >> bell2 >> bell3;

        sum1 = bell1 + bell2;
        sum2 = bell2 + bell3;
        sum3 = bell3 + bell1;

        mini_sum = sum1;

        if(mini_sum > sum2){
            mini_sum = sum2;
        }
        if(mini_sum > sum3){
            mini_sum = sum3;
        }

        cout << mini_sum << "\n";

    return 0;
}

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

#define vec(v) vector<int>(v)
#define be(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define mapci(mp) map<char*,int>(mp)
#define mapcc(mp) map<char*,char*>(mp)
typedef long long ll;
using namespace std;

int main() {
    ll a,b,c;
    cin>>a>>b>>c;
    if(a%2==0||b%2==0||c%2==0){
        cout << 0<<endl;
    }
    else{
        cout << min(min(a*b,c*a),b*c)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
using namespace std;

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

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

ll d(ll d) {
  ll cnt = 0;
  while (d) cnt++, d /= 10;
  return cnt;
}

int main() {
  ll n, a, keta, ans = INF;
  cin >> n;

  for (ll i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      a = n / i;
      keta = max(d(a), d(i));
    }
    ans = min(ans, keta);
  }
  cout << ans << endl;
  return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    int cnt0 = 0;
    int cnt1 = 0;
    int cnt2 = 0;

    rep(i, N) {
        int a;
        cin >> a;
        if (a % 4 == 0) {
            cnt0++;
        } else if (a % 2 == 0) {
            cnt1++;
        } else {
            cnt2++;
        }
    }

    if (!cnt1) cnt2--;

    if (cnt0 >= cnt2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;

    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int64_t H,x,sum=0,count=0,y=0;
  vector<pair<int,int64_t>> A(41);
  for(int i=0;i<41;i++){y+=pow(2,i);A.at(i)=make_pair(i,y);}
  cin>>H;
  sum=H;x=H;
  while(x>=2){x/=2;sum+=x;count++;}
  cout<<A.at(count).second<<endl;
}

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

int64_t powmod(int x, int pow)
{
  int64_t total = 1;
  while(pow > 0)
  {
    total = total * x % 1000000007;
    pow--;
  }
  return total;
}

int main()
{
  int N;
  cin >> N;
  
  int mod = 1000000007;
  
  if(N == 1){cout << "0" << endl;}
  else
  {
    int64_t T = 0;
    T += (powmod(10,N) - powmod(9,N)) % mod;
    if(T < 0) T += mod;
    T -= powmod(9,N);
    if(T < 0) T += mod;
    T = T % mod;
    T += powmod(8,N);
    if(T < 0) T += mod;
    T = T % mod;
    cout << T << endl;
  }
}

Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = True

def main():
    S = input().strip()
    P = [-1] * len(S)
    ans = [0] * len(S)
    numl = 0
    numr = 0
    prevIsR = True if S[0] == 'R' else False
    for i in range(len(S)):
        if S[i] == 'R':
            numr += 1
        else:
            ans[i-1] += numr - numr // 2
            ans[i] += numr // 2
            numr = 0
    for i in range(len(S)-1,-1,-1):
        if S[i] == 'L':
            numl += 1
        else:
            ans[i+1] += numl - numl // 2
            ans[i] += numl // 2
            numl = 0
    for a in ans:
        print(a)



        






    pass
if __name__ == '__main__':
    main()

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

int main(){
  int h,w;
  int han=0;
  cin >> h >> w; char cam[h][w];
  for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin >> cam[i][j];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(cam[i][j]=='#'){
        if(i==0&&j==0){ if(cam[i+1][j]!='#'&&cam[i][j+1]!='#') han=1;}
        else if(i==h-1&&j==w-1) {if(cam[i-1][j]!='#'&&cam[i][j-1]!='#') han=1;}
        else if(j==0) {if(cam[i+1][j]!='#'&&cam[i][j+1]!='#'&&cam[i-1][j]!='#') han=1;}
        else if(i==0) {if(cam[i][j-1]!='#'&&cam[i+1][j]!='#'&&cam[i][j+1]!='#') han=1;}
        else if(j==w-1) {if(cam[i-1][j]!='#'&&cam[i][j-1]!='#'&&cam[i+1][j]!='#') han=1;}
        else if(i==h-1){if(cam[i-1][j]!='#'&&cam[i][j-1]!='#'&&cam[i][j+1]!='#') han=1;}
        else if(cam[i-1][j]!='#'&&cam[i+1][j]!='#'&&cam[i][j-1]!='#'&&cam[i][j+1]!='#') han=1;
      }
    }
    if(han==1) {
      cout << "No" << endl;
      exit(0);
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  string s;
  cin>>s;
  int firone=0,firzero=0;
  rep(i,s.size() ){
    if(i%2==0){
      if(s[i]=='0') firone++;
      else firzero++;
    }else{
       if(s[i]=='0') firzero++;
      else firone++;
    }
  }
  cout<<min(firone,firzero)<<endl;
  return 0;
}


Measured memory_bytes: 512
package main

import (
	"fmt"
	"sort"
)

type K struct {
	V int
	N int
}

type ByV []K

func (ks ByV) Len() int { return len(ks) }
func (ks ByV) Swap(i, j int) { ks[i], ks[j] = ks[j], ks[i] }
func (ks ByV) Less(i, j int) bool { return ks[i].V < ks[j].V }

func main() {
	var n, k int // 64bitになるかしらん。
	fmt.Scan(&n, &k)
	var ks = make([]K, n, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&ks[i].V, &ks[i].N)
	}
	sort.Sort(ByV(ks))
	for i := 0; i < n; i++ {
		if k <= ks[i].N {
			fmt.Println(ks[i].V)
			break
		} else {
			k -= ks[i].N
		}
	}
}


Measured memory_bytes: 5504
#include <stdio.h>
#include <vector>
#include <limits.h>
#include <algorithm>

using namespace std;

int main()
{
    int n,m;
    int x,y;
    scanf("%d %d",&n,&m);
    scanf("%d %d",&x,&y);
    vector<int> a(n+1);
    vector<int> b(m+1);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    for(int i=0;i<m;i++) scanf("%d",&b[i]);
    a[n]=x;
    b[m]=y;
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    printf("%sWar\n",a[n]<b[0]?"No ":"");
    

}

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

string getResult(vector<uint> &apples){
  for(uint apple : apples){
    if(apple % 2 != 0) return "first";
  }
  return "second";
}

int main(){
  uint N;
  cin >> N;
  
  vector<uint> a(N);
  for(uint i = 0; i < N; i++){
    cin >> a[i];
  }

  string result = getResult(a);
  cout << result;
  return 0;
}

Measured memory_bytes: 3764
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;


	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);

			int n = sc.nextInt();
			int[] d = new int[n];
			int maxd = 0;
			for(int i=0;i<n;i++) {
				d[i] = sc.nextInt();
				maxd = Math.max(maxd, d[i]);
			}
			
			int m = sc.nextInt();
			int[] t = new int[m];
			int maxt = 0;
			for(int i=0;i<m;i++) {
				t[i]= sc.nextInt();
				maxt = Math.max(maxt, t[i]);
			}
			
			int maxi = Math.max(maxd, maxt);
			
			Map<Integer,Integer> difd = new HashMap<Integer,Integer>(); 
			
			
			for(int i=0;i<n;i++) {
				if(!difd.containsKey(d[i])) {
					difd.put(d[i], 1);
				}else {
					difd.put(d[i], difd.get(d[i])+1);
				}
			}
			
			for(int i=0;i<m;i++) {
				if(!(difd.containsKey(t[i]))){
					System.out.println("NO");
					return;
				}
				if(!(difd.get(t[i])>0)){
					System.out.println("NO");
					return;
				}
				
				difd.put(t[i], difd.get(t[i])-1);
			}
			
			System.out.println("YES");
			
		}
		
		
		
	}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int a , b , c;

int main()
{
    _FastIO;
    cin >> a >> b >> c;
    string ans = "win";
    if((a + b + c) >= 22)
        ans = "bust";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int N,M;

int main() {
  cin >>N >>M;
  vector<vector<int>> A(N, vector<int>(M, 0));
  rep(i, N) rep(j, M) cin >>A[i][j];
  vector<int> B(M, 0);
  rep(j, M) cin >>B[j];
  rep(i, N){
    int sum = 0;
    rep(j, M) sum += A[i][j] * B[j];
    cout <<sum <<endl;
  }
}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

vector<int> ans;

int main(){
	int n; cin >> n;
	ans.resize(n+10, 0);
	int x, y; cin >> x >> y;
	for( int node = 1; node <= n; ++node ){
		for( int trg = node+1; trg <= n; ++trg ){
			++ans[min( trg-node, abs(x-node)+abs(y-trg)+1 )];
		}
	}
	for( int i = 1; i <= n-1; ++i ){
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template <class T>
class CuSum {
private:
	vector<T> cusum;

public:
	CuSum(vector<T> const &vec) : cusum(vec.size() + 1) {
		for (int i = 0; i < (int)vec.size(); i++) cusum[i + 1] = cusum[i] + vec[i];
	}
	CuSum(const int N) : cusum(N + 1) {}
	void add(const int i, const T &x) { cusum[i + 1] += x; }
	void build() { for (int i = 0; i < (int)cusum.size() - 1; i++) cusum[i + 1] += cusum[i]; }

	// partial sum of 0-indexed [l, r)
	T operator()(int l, int r) {
		if (r < l || r < 0) {
			assert(0);
			return T(0);
		}
		else return cusum[r] - cusum[l];
	}
	// 0-indexed
	const T &operator[](int i) { return cusum[i + 1]; }
	T back() { return cusum.back(); }
};

int main() {

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

	int N, K;
	cin >> N >> K;

	vector<lint> a(N);
	for (int i = 0; i < N; i++) cin >> a[i];

	CuSum<lint> A(a);
	vector<lint> sum_a;
	sum_a.reserve(N*(N + 1) / 2);
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j <= N; j++) {
			sum_a.emplace_back(A(i, j));
		}
	}
	DMP(sum_a);

	for (int i = 60; i >= 0; i--) {

		vector<lint> tmp;
		for (int j = 0; j < sum_a.size(); j++) {
			if (sum_a[j] & (1LL << i)) tmp.emplace_back(sum_a[j]);
		}
		DMP(tmp);
		if (tmp.size() >= K) sum_a = tmp;
	}

	lint ans = LINF - 1;
	for (int i = 0; i < sum_a.size(); i++) ans &= sum_a[i];
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 5368
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;
#define INF 0x3f3f3f3f
const int maxn=30;
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
int n,m,ans,vis[maxn][maxn];
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
char s[maxn][maxn];
struct Node
{
    int x,y,dis;
};

int bfs(int x,int y)
{    
    int ans=0;
    memset(vis,0,sizeof(vis));
    vis[x][y]=1;
    queue<Node> Q;
    Q.push(Node{x,y,0});
    while(!Q.empty())
    {
        Node now=Q.front();
        Q.pop();
        ans=max(ans,now.dis);
        for(int i=0;i<4;i++)
        {
            int nx=now.x+dx[i];
            int ny=now.y+dy[i];
            if(nx<1||nx>n||ny<1||ny>m||s[nx][ny]=='#') continue;
            if(!vis[nx][ny])
            {
                vis[nx][ny]=1;
                Q.push(Node{nx,ny,now.dis+1});
                //cout<<nx<<" "<<ny<<" "<<now.dis+1<<endl;
            }    
        }
    }
    return ans;
}

int main()
{
    #ifdef __LOCAL__
        freopen("1.in","r",stdin);
        freopen("1.out","w",stdout);
    #endif
    cin>>n>>m;
    _rep(i,1,n)
        scanf("%s",s[i]+1);
    _rep(i,1,n)
        _rep(j,1,m)
        {
            if(s[i][j]=='#')  continue;
            ans=max(ans,bfs(i,j));
        }
    cout<<ans<<endl;
    return 0;
}

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



int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> V(N+1, vector<int>(0));
  
  for(int i = 0; i<M; i++){
    int A, B;
    cin >> A >> B;
    V[A].push_back(B);
    V[B].push_back(A);
  }
  
  //BFSの準備
  vector<bool> visited(N+1, false);
  queue<int> que;
  
  int ans = 0;
  
  for(int i = 1; i<N+1; i++){
    if(!visited[i]){
      
      int sum = 1;
      
      visited[i] = true;
      que.push(i);
      
      while(!que.empty()){
        int v = que.front();
        que.pop();
        
        for(int nv : V[v]){
          if(visited[nv]) continue;
          
          sum++;
          visited[nv] = true;
          que.push(nv);
        }
      }
      
      ans = max(ans, sum);
    }
  }
  
  cout << ans << endl;       
}





Measured memory_bytes: 14860
#include<stdio.h>
#include<math.h>
int main()
{
	int n,an=0;
	scanf("%d",&n);
	int a[n],b[n]={},c[n];
	for(int i=0;i<n;i++)
		scanf("%d",a+i);
	for(int i=n;i>0;i--)
		if(a[i-1]!=b[i-1])
		{
			c[an++]=i;
			for(int j=1;j<sqrt(i);j++)
				if(i%j==0)
				{
					b[j-1]=!b[j-1];
					b[i/j-1]=!b[i/j-1];
				}
			int t=sqrt(i);
			if(t*t==i)
				b[t-1]=!b[t-1];
		}
	printf("%d\n",an);
	for(int i=an-1;i>=0;i--)
		printf("%d ",c[i]);
	return 0;
}

Measured memory_bytes: 4084
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define mod 1000000007

int main() {
	long long int n;
	cin >> n;
	long long int a[200000];
	long long int cnt[200001] = {};
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	long long int allpair = 0;
	for (int i = 1; i <= n; i++) {
		allpair += cnt[i] * (cnt[i] - 1) / 2;
	}
	for (int i = 0; i < n; i++) {
		long long int tmp = cnt[a[i]];
		long long int ans = allpair;
		ans -= tmp * (tmp - 1) / 2;
		tmp--;
		ans += tmp * (tmp - 1) / 2;
		cout << ans << endl;
	}
}

Measured memory_bytes: 5760
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
r+=[0]
del p[x:]
del q[y:]
p.reverse()
q.reverse()
i,j,k=0,0,0
while min(p[i],q[j])<r[k] and k<c:
  if p[i]<=q[j]:
    p[i]=r[k]
    i+=1
  else:
    q[j]=r[k]
    j+=1
  k+=1
  if i==x or j==y:
    break

if i==x:
  while q[j]<r[k] and k<c:
    q[j]=r[k]
    j+=1
    k+=1
    if j==y:
      break
elif j==y:
  while p[i]<r[k] and k<c:
    p[i]=r[k]
    i+=1
    k+=1
    if i==x:
      break
print(sum(p)+sum(q))

Measured memory_bytes: 22720
#include<iostream>
#include<cstdio>'
#include<cmath>
#define rg register
#define il inline
#define ll long long
#define maxn 500005
using namespace std;
il int read(){rg int x = 0 ,w = 1;char ch = getchar();while (ch < '0' || ch > '9'){if (ch == '-') w = -1;ch = getchar();}while (ch >= '0' && ch <= '9'){x = (x<<3) + (x<<1) + ch - '0';ch = getchar();}return x * w;}
struct edge{
	int to,next;	
}e[maxn << 1];
ll a[maxn];
int main(){
	rg int n = read() , m = read();
	for (rg int i = 1;i <= n;++i) {scanf("%lld",&a[i]);if (!a[i]) --m;}
	rg ll res = 99999999999999 , k = 0;
	if (!m) {cout<<'0';return 0;}
	for (rg int i = 1;i <= n;++i){
		if (a[i] < 0) ++k;
		else break;	
	}
	for (rg int i = 1;i <= n;++i){
		if (a[i] < 0) {
			if (k - i + 1 >= m) res = min (res , -a[i]);
			else if (i + m - 1 <= n) res = min (res , ((-a[i]) << 1) + a[i + m - 1] );
		}
		else if (a[i] > 0){
			if (i - k >= m) res = min(res , a[i]);
			else if (i - m + 1 >= 1) res = min (res , (a[i] << 1) - a[i - m + 1]) ;
		}
	}
	cout<<res;
	return 0;	
}

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

#include <cstdio>

using namespace std;

int main(int argc, char *argv[])
{
    string s,ans;
    
    for(int i=0;i<3;++i)
    {
        cin >> s;
        ans+=toupper(s[0]);
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	ll n,a,b,c=0,s=0;
	cin>>n;
	ll arr[n]={0};
	for(int j=0;j<n;j++)
	{
		cin>>a>>b;
		if(a==b)
		{
			arr[c]++;	
		}
		c++;
	}
	for(int i=0;i<n-2;i++)
	{
		if(arr[i]==1)
			if(arr[i+1]==1)
				if(arr[i+2]==1)
				{	
				    s=1;
				    break;
				}
	}
	if(s==1)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef long double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define cerr if(true)cerr
void print(){cout<<endl;}
template<typename T,typename... Args>
void print(T a, Args... args) {cout<<a<<" ";print(args...);}
lli llipowerp(lli x, lli y, lli p=LLONG_MAX)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1) res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
template <typename T>
inline void printvec(vector<T> inp){
    for(auto it:inp) cout<<it<<" ";
    cout << endl;
}
//---------------------------------------------------------------------------------
int n;
lld dp[3010][3010];
vector<lld> p(3010);


lld fill(int i,int j){
    if(i+j>n) return 0;
    
    if(i<0 || j<0) return 0;
    if(dp[i][j]!=-1) return dp[i][j];
    

    dp[i][j]=fill(i-1,j)*p[i+j]+fill(i,j-1)*(1-p[i+j]);
    return dp[i][j];

}

int main()
{   
    cin>>n;
    fori(n+1){
        forj(n+1) dp[i][j]=-1;
    }
    fori(n) cin>>p[i+1];
    dp[0][0]=1;
    lld ans=0;

    for(int tails=0;tails<=n;tails++){
        if(n-tails>tails) ans+=fill(n-tails,tails);
        
    }
    cout<<fixed<<setprecision(12)<<ans<<endl;
    
}

Measured memory_bytes: 141824
#include <bits/stdc++.h> 
using namespace std ;
int main () {
	string s ;
	cin >> s ;
	string t ;
	cin >> t ;
	for (int i = 0 ; i < s.length() ; ++i) {
		if (s[i] != t[i]) {
			cout << "No\n" ;
			return 0 ;
		}
	}
	cout << "Yes\n" ;
	return 0 ;
}

Measured memory_bytes: 3604
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  int a, b, t;

  cin >> a >> b >> t;

  cout << (t / a * b) << endl;
  return 0;
}



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

using namespace std;

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

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


int main()
{
    int n,x,l;
    int d=0;
    int ans=1;
    cin >> n >> x;
    rep(i,n){
        cin >> l;
        d=d+l;
        if(d<=x) ans++;
        else break;
    }
    cout << ans << endl;

    return 0;
}

    

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

int main()
{
  int N,T;
  pair<int,int> pr[100];
  cin >> N >> T;
  
  for(int i=0;i < N;i++){
    cin >> pr[i].first >> pr[i].second;
  }
  sort(pr,pr+N);
  //reverse(pr,pr+N);

  int mini=99999;
  
  for(int i=0;i < N;i++){
    if(T >= pr[i].second){
      mini = min(mini,pr[i].first);
    }
  }
  if(mini == 99999){
    cout << "TLE" << endl;
  }
  else cout << mini << endl;
  return 0;
}

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

using namespace std;
 
int main(void)
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if( min(b,d) - max(a,c)<= 0)
        cout << 0 << endl;
    else
        cout << min (b,d) - max(a,c) << endl;
    
}

Measured memory_bytes: 256