akhauriyash/Code-Regression huggingface dataset:
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin >> N;

	vector<int> A(N);
	vector<map<pii, int>> memo(N);

	rep(i, 0, N)
	{
		cin >> A[i];
	}

	int ans = -INF;
	memo[0][mp(2,1)] = A[0];
	memo[1][mp(1,1)] = A[1];
	if (N <= 3)
	{
		chmax(ans, max(A[0], A[1]));
	}
	if (N > 2)
	{
		memo[2][mp(0, 1)] = A[2];
		if (N <= 3)
		{
			chmax(ans, max(A[0], A[1]));
		}
	}

	rep(i, 0, N - 1)
	{
		for (auto p : memo[i])
		{
			rep(j, 0, p.first.first + 1)
			{
				if (i + 2 + j >= N)break;
				if (memo[i + 2 + j].find(mp(p.first.first - j, p.first.second + 1)) == memo[i + 2 + j].end())
				{
					memo[i + 2 + j][mp(p.first.first - j, p.first.second + 1)] = p.second + A[i + 2 + j];
				}
				else
				{
					chmax(memo[i + 2 + j][mp(p.first.first - j, p.first.second + 1)], p.second + A[i + 2 + j]);
				}
				if (p.first.second + 1 == N / 2)
				{
					chmax(ans, p.second + A[i + 2 + j]);
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 33032
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<numeric>
#include<map>
#include<math.h>

using namespace::std;

int main(void)
{

  int h[2],m[2],s[2];

  for(int i = 0; i < 3; i++)
    {
      cin >> h[0] >> m[0] >> s[0] >> h[1] >> m[1] >> s[1];

      int ans_s = 0;
      int ans_m = 0;
      int ans_h = 0;

      ans_s = ( (60 - s[0]) + s[1] ) % 60;

      if( s[0] > s[1] )
	{
	  m[0]++;
	}

      ans_m = ( ( 60 - m[0] ) + m[1] ) % 60;
      if( m[0] > m[1] )
	{
	  h[0]++;
	}
      
      ans_h = h[1] - h[0];
      
      cout << ans_h << " " << ans_m << " " << ans_s << endl;
    }
  
  return 0;
}

Measured memory_bytes: 1160
def cost(i,k,j):
 return m[i][k] + m[k+1][j] + p[i][0] * p[k][1] * p[j][1]

n = input()
p = []
m = [[0 for i in xrange(n)] for j in xrange(n)]
for i in xrange(n):
 p.append(map(int, raw_input().split()))

N = len(p)
for l in xrange(2,N+1):
 for i in xrange(0,N-l+1):
   j = i+l-1
   m[i][j] = min(cost(i,k,j) for k in xrange(i,j))

print m[0][N-1]

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

const bool DEBUG = false;

int main(int argc, char const *argv[]) {
  int N;
  cin >> N;
  vector<double> A(N);
  for (size_t i = 0; i < N; i++) cin >> A[i];

  double total = 0;
  for (size_t i = 0; i < N; i++) total += 1.0 / A[i];
  cout << setprecision(10) << 1.0 / total << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(){
    double a[1010];
    int n;
    double m=0;
    double ans=0;
    int i;
    while(scanf("%d",&n),n!=0){
        m=0;
        ans=0;
        for(i=0;i<n;i++){
            scanf("%lf",&a[i]);
            m+=a[i];
        }
        m/=(double)n;
        for(i=0;i<n;i++){
            ans+=pow(a[i]-m,2.0);
        }
        ans/=(double)n;
        printf("%lf\n",sqrt(ans));
    }
    return 0;
}

Measured memory_bytes: 664
package main

import "fmt"

func main() {
	var x, y int
	fmt.Scan(&x, &y)
	for i := 0; i <= x; i++ {
		if i*4+(x-i)*2 == y {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 1752
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
const ll INF = 1LL << 60;
ll d[205][205];

void warshall_floyd(int n) {
  for (int k = 0; k < n; k++){       // 経由する頂点
    for (int i = 0; i < n; i++) {    // 始点
      for (int j = 0; j < n; j++) {  // 終点
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main(){
  int n,m,r; cin >> n >> m >> r;
  
  rep(i,205)rep(j,205){
    if(i == j) d[i][j] = 0;
    else d[i][j] = INF;
  }
  
  vector<int> need(r);
  rep(i,r){
    cin >> need[i];
    need[i]--;
  }
  
  //グラフ入力
  rep(i,m){
    int a,b,c; cin >> a >> b >> c;
    a--;b--;
    d[a][b] = c;
    d[b][a] = c;
  }
  
  //最短距離計算
  warshall_floyd(n);
  
  //順列で全ての行き方で最短距離計算
  sort(need.begin(),need.end()); //permutationを使う前はソートする。
  
  ll ans = INF;
  do{
    int from, to;
    ll tmp_cost = 0;
    rep(i,r){
      if(i==0){
        from = need[i];
      }else{
        to = need[i];
        tmp_cost += d[from][to];
        from = to;
      }
    }
    chmin(ans,tmp_cost);
  }while(next_permutation(need.begin(),need.end()));
  
  cout << ans << endl;
  return 0;
}

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

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
	int n; cin >> n;

    while(true) {
        bool res = IsPrime(n);
        if(res == true) {
            cout << n << endl;
            break;
        }
        n++;
    }
}

Measured memory_bytes: 256
#A
N, M = map(int,input().split())
eve=[2*i for i in range(N)]
odd=[2*i+1 for i in range(M)]

from itertools import combinations
comb_eve=len(list(combinations(eve,2)))
comb_odd=len(list(combinations(odd,2)))

print(comb_eve+comb_odd)

Measured memory_bytes: 9208
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

const int MAXN = 510;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, m, q;
    cin >> n >> m >> q;
    vector<vector<int>> a(MAXN, vector<int>(MAXN, 0));
    rep(i, m) {
        int l, r;
        cin >> l >> r;
        a[l][r]++;
    }
    rep(i, n) {
        rep(j, n) {
            a[i+1][j+1] += a[i+1][j];
        }
    }
    for (int j = n; j > 0; j--) {
        for (int i = n-1; i > 0; i--) {
            a[i][j] += a[i+1][j];
        }
    }


    rep(i, q) {
        int c, d;
        cin >> c >> d;
        cout << a[c][d] << endl;
    }

    return 0;
}

Measured memory_bytes: 1920
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0 

using namespace std;
using ll = long long;

void testcase() {
    string s, t;
    cin >> s >> t;

    int m = t.length();
    int n = s.length();

    if (m == n+1 && t.substr(0, n) == s)
    	cout << "Yes";
    else
    	cout <<"No";
    
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 3656
import std.stdio;
import std.array;
import std.string;
import std.conv;
import std.algorithm;
import std.typecons;
import std.range;

void main() {
  auto input = readln().split.map!(to!int);
  int H = input[0];
  int W = input[1];
  string[] blocks = new string[](H);
  foreach (i; iota(H))
    blocks[i] = readln().chomp;

  int ans = 0;
  foreach (w; iota(W-1)) {
    int[][] cost = new int[][](H+1, H+1);
    foreach (h1; iota(H, -1, -1)) {
      foreach (h2; iota(H-1, -1, -1)) {
        if (h1 == H || h2 == H) {
          cost[h1][h2] = 0;
        } else if (blocks[H-h1-1][w] == blocks[H-h2-1][w+1]){
          cost[h1][h2] = cost[h1+1][h2+1] + 1;
        } else {
          cost[h1][h2] = cost[h1+1][h2+1];
        }
      }
    }

    int[][] dp = new int[][](H+1, H+1);
    foreach (h1; iota(H+1)) {
      foreach (h2; iota(H+1)) {
        if (h1 == 0 && h2 == 0) {
          continue;
        } else if (h1 == 0) {
          dp[h1][h2] = dp[h1][h2-1] + cost[h1][h2-1];
        } else if (h2 == 0) {
          dp[h1][h2] = dp[h1-1][h2] + cost[h1-1][h2];
        } else {
          dp[h1][h2] = min(dp[h1][h2-1] + cost[h1][h2-1],
                           dp[h1-1][h2] + cost[h1-1][h2]);
        }
      }
    }
    ans += dp[H][H];
  }
  writeln(ans);
}


Measured memory_bytes: 8828
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int ans=0;
    cin>>s;
    if(s[0]=='1')
        ans++;
    if(s[1]=='1')
        ans++;
    if(s[2]=='1')
       ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
 
int main(){
    int N, M;
    scanf("%d %d", &N, &M);
    int s[N];
    int sum = 0;
    for (int i=0; i<N; i++){
        scanf("%d", &s[i]);
        sum += s[i];
    }
    int ans = 0;
    float ness = float(sum)/float(4*M);
    for (int i=0; i<N; i++){
        float x = float(s[i]);
        if (x >= ness) ans += 1;
    }
    if (ans >= M) printf("Yes");
    else printf("No");
    return 0;
}

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

int main() {
  int w, d;
  while(cin >> w >> d && w) {
    int W[30], D[30];
    fill(W, W+30, 0);
    fill(D, D+30, 0);
    int h;
    for (auto i=0; i<w; i++) {
      cin >> h;
      W[h]++;
    }
    for (auto i=0; i<d; i++) {
      cin >> h;
      D[h]++;
    }
    int ans = 0;
    for (auto i=0; i<30; i++) {
      ans += max(D[i], W[i]) * i;
    }
    cout << ans << endl;
  }
}

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

int sumOfEachDigitNum (int n) {
  int ans = 0, a;
  while (n > 0) {
    a = n % 10;
    ans += a;
    n /= 10;
  }
  return ans;
}

int main() {
  int n, a, b, cnt = 0;
  cin >> n >> a >> b;
  for (int i = 1; i <= n; i++) {
    int k = sumOfEachDigitNum(i);
    if ((a <= k) && (k <= b)) {
      cnt += i;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
//
//  main.cpp
//  CoderWork
//
//  Created by Minoru Hayashi on 2020/02/29.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//

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

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

template<class T> inline bool chmin(T& a, T b){ if(a>b){a=b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b){ if(a<b){a=b; return 1;} return 0;}

const int INF = 1LL<<29;

//#define __DBG__

int A,B;


void solve(void){
  
  cin >> A >> B;

  int C = 6-A-B;
  
  cout << C << endl;
  
  
  return;
}

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



    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    solve();
 
    return 0;
}





Measured memory_bytes: 256
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from functools import reduce

from collections import deque, Counter, defaultdict
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7

def main():
  n, k = map(int, readline().split())
  x = list(map(int, readline().split()))
  ans = INF
  for i in range(n-k+1):
    if x[i]<0 and x[i+k-1]<0:
      ans = min(ans, abs(x[i]))
    elif x[i]<=0 and x[i+k-1]>=0:
      ans = min(ans, 2*abs(x[i])+x[i+k-1],abs(x[i])+2*x[i+k-1])
    else:
      ans = min(ans, x[i+k-1])
  print(ans)
  
  
  
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 24060
from itertools import permutations
n = int(input())
xy = [[int(i) for i in input().split()] for _ in range(n)]

l = list(permutations(range(1,n+1), n))
ans = 0
for i in l:
  for j in range(n-1):
    x1,y1 = xy[i[j]-1]
    x2,y2 = xy[i[j+1]-1]
    ans += ((x1-x2)**2 + (y1-y2)**2)**0.5
print(ans/len(l))

Measured memory_bytes: 8052
#include <stdio.h>
#include <stdlib.h>
//#include <string.h>
#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

//昇順
int acs(const void *a, const void *b)
{
  return *(int *)a - *(int *)b;
}

int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  for (int i = 0; i < n; i++)
    scanf("%d", a + i);
  qsort(a, n, sizeof(int), acs);
  int pr = 0;
  bool check = true;
  for (int i=0; i<n; i++) {
    if (pr == a[i]) {
      check = false;
      break;
    } else {
      pr = a[i];
    }
  }
  if (check) printf("YES\n");
  else printf("NO\n");
  return 0;
}


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dy[4]={1,0,-1,0};
int dx[4]={0,1,0,-1};
vector<vector<int>> graph;

bool sort_sec(const pair<int,int> &a,const pair<int,int> &b){
   if(a.second<b.second){
      return true;
   }
   return false;
}

void swap(int *a,int *b){
   int temp=*a;
   *a=*b;
   *b=temp;
}

int main(void){
   int x[5];
   for(int i=0;i<5;i++){
      cin>>x[i];
   }
   int temp=0;
   for(int i=0;i<5;i++){
      if(x[i]==0){
         temp=i+1;
      }
   }
   cout<<temp<<endl;
   return 0;
}


Measured memory_bytes: 3620
// https://twitter.com/toshiki_tesla/status/1160188174548660226
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
 
int main() {
  long long counter=0;
  int N;
  cin >> N ;
  map<string, int> DB;
  
  for(int i=0; i<N; i++){
    std::vector<char> buf(10);
    string hoge = "";
    for(int k=0; k<10; k++)
      cin >> buf.at(k);
    sort(buf.begin(), buf.end());
    for(int k=0; k<10; k++)
      hoge += buf.at(k);
    if(DB.count(hoge))
      DB[hoge]++;
    else
      DB[hoge]=1;
  }
  
  string name;
  for(auto p : DB){
    long long val = p.second;
    counter += ((val-1)*val/2);
  }
  
  cout << counter <<endl;
  
  return 0;
}//endmain


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N;
	cin >> N;
	
	vector<int> A(N);
	REP(i, N) {
		int d1, d2;
		scanf("%d %d", &d1, &d2);
		A[i] = d1 == d2;
	}
	
	bool ans = false;
	REP(i, N - 2) {
		if (A[i] && A[i + 1] && A[i + 2]) ans = true;
	}
	if (ans) puts("Yes");
	else puts("No");
	return 0;
}


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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

int main() {
	int n;
	cin >>n;
	bool ok = true;
	for (int i=0 ; i<n ; i++) {
		int x;
		cin >>x;
		if (x%2 == 0) {
			if (!(x%3 == 0 or x%5 == 0)) {
				ok = false;
			}
		}
	}
	if (ok) printf("APPROVED\n");
	else printf("DENIED\n");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		    long X = sc.nextLong();
		    long Y = sc.nextLong();
		    
		    long ans = 0;
		    
		    for(long i=X; i<=Y; i*=2) {
		    	ans++;
		    }
		    System.out.println(ans);
	 }

}

Measured memory_bytes: 35856
# 2019-11-11 18:30:26(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    d = int(sys.stdin.readline().rstrip())
    ans = 'Christmas' + ' Eve' * (25 - d)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    long long n;
    cin >> n;
    vector<long long> v(n);
    REP(i, n) cin >> v[i];

    unordered_map<long long, long long> mp;
    for(auto &x : v){
        mp[x]++;
    }

    vector<long long> a;
    for(auto &x : mp){
        if(x.second >= 2) a.push_back(x.first);
        if(x.second >= 4) a.push_back(x.first);
    }
    
    if(a.size() < 2) cout << 0 << endl;
    else{
        sort(a.begin(), a.end(), greater<int>());
        long long ans;
        ans = a[0] * a[1];
        cout << ans << endl;
    }

    /*
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        cout << "key = " << itr -> first << " ";
        cout << "value = " << itr -> second << endl;
    }

    REP(i, a.size()) cout << a[i] << " ";
    cout << endl;
    */


    return 0;
}

Measured memory_bytes: 5156
N,K = map(int,input().split())
A = [int(i) for i in input().split()]

#ビット全探索
ans=1000000000*N
for i in range(1<<N):
    bitlist=[]
    for j in range(N):
        bitlist.append((i >> j) & 1)
    if sum(bitlist) < K:
        continue

    tmp_max=0
    nedan=0
    for j in range(N):
        if bitlist[j]==1:
            if tmp_max >= A[j]:
                nedan+=(tmp_max-A[j]+1)
                tmp_max=tmp_max+1
            elif tmp_max < A[j]:
                tmp_max=A[j]
        elif bitlist[j]==0:
            if tmp_max < A[j]:
                tmp_max=A[j]
    ans=min(ans,nedan)
print(ans)


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

int main() {
  int n;

  cin >> n;

  int a;

  // vector<int> a(n);

  vector<int> buka(n,0);

  rep(i,n-1){
    cin >> a;
    buka.at(a-1) += 1;

  }

  rep(i,n){
    cout << buka.at(i) << endl;

  }

}

Measured memory_bytes: 3944
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iomanip>
using namespace std;
 
typedef long long ll;
 
int main(){
    int N;
    cin >> N;
  	vector<int> h(N+1);
  	vector<int> cost(N+1);
    h[0] = 0;
 
    for (int i=1;i<=N;i++){
        cin >> h[i];
    }
    cost[0] = cost[1] = 0;
    cost[2] = cost[1] + abs(h[2]-h[1]);
    int pos = 3;
    while (pos != N+1){
        cost[pos] = min(cost[pos-1] + abs(h[pos-1] - h[pos]),cost[pos-2]+abs(h[pos-2] - h[pos]));
        // cout << cost[pos] << endl;
        // cout << pos << endl;
        pos ++;
 
    }
    cout << cost[N];
 
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){

  int i, j, N;
  int A[100];
  int temp, min, c=0;

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

  for (i = 0; i < N-1; i++) {
    min = i;
    for (j = i; j < N; j++) {
      if(A[j] < A[min]) min = j;
    }
    temp = A[i];
    A[i] = A[min];
    A[min] = temp;
    if(i != min) c++;
  }


  for (i = 0; i < N-1; i++) {
    printf("%d ", A[i]);
  }
  printf("%d\n", A[N-1]);
  printf("%d\n", c);

  return 0;
}



Measured memory_bytes: 2088
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#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>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int N; cin >> N;
    vector<int> v(N+1);
    for(int i=0; i<N; i++) cin >> v[i];

    int ans = 0;
    while(1) {
        int cons = 0, sum = 0;
        for(int i=0; i<=N; i++) {
            if(v[i] == 0) {
                ans += (cons > 0);
                sum += (cons > 0);
                cons = 0;
            }
            else {
                v[i]--;
                cons++;
            }
        }
        if(sum == 0) break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX_V 1000
typedef pair<int,int> P;
struct edge{ int to,cap,cost,rev; };

int V;
vector<edge> G[MAX_V];
int h[MAX_V];
int dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];

void add_edge(int from,int to,int cap,int cost){
  
  G[from].push_back( (edge){to,cap,cost,(int)G[to].size()} );
  G[to].push_back((edge){from,0,-cost,(int)G[from].size()-1});
}

int min_cost_flow(int s,int t,int f){
  
  int INF=1e9;
  int res=0;
  fill(h,h+V,0);
  while(f>0){

    priority_queue< P , vector<P> , greater<P> > que;
    fill(dist,dist+V,INF);
    dist[s]=0;
    que.push(P(0,s));
    
    while(!que.empty()){
      P p=que.top();que.pop();
      int v=p.second;
      if(dist[v]<p.first)continue;
      for(int i=0;i<(int)G[v].size();i++){
        edge &e=G[v][i];
        if(e.cap>0&&dist[e.to]>dist[v]+e.cost+h[v]-h[e.to]){
          dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
          prevv[e.to]=v;
          preve[e.to]=i;
          que.push(P(dist[e.to],e.to));
        }
      }
    }

    if(dist[t]==INF)return -1;

    for(int v=0;v<V;v++)h[v]+=dist[v];
    int d=f;
    for(int v=t;v!=s;v=prevv[v]){
      d=min(d,(int)G[prevv[v]][preve[v]].cap);
    }
    f-=d;
    res+=d*h[t];
    for(int v=t;v!=s;v=prevv[v]){
      edge &e=G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }

  return res;
}

int N,M,K;
int a[100];
int b[100][100];
int T[100];

int main(){

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

  for(int i=0;i<M;i++)
    for(int j=0;j<N;j++)
      cin>>b[i][j];

  for(int i=0;i<M;i++)
    cin>>T[i];


  V=2+M+N+2;
  int si=V-2;
  int ti=V-1;
  //  cout<<si<<' '<<ti<<endl;
  
  int X=1000000;
  
  add_edge(si,0,N,0);
  add_edge(si,1,N-K,0);

  for(int i=0;i<N;i++){
    add_edge(0,2+i,1,X-a[i]);
    add_edge(2+i,ti,1,0);
  }

  for(int i=0;i<M;i++){
    add_edge(1,2+N+i,T[i],0);
  }

  for(int i=0;i<M;i++){
    for(int j=0;j<N;j++){
      add_edge(2+N+i,2+j,1,X-b[i][j]);
    }
  }

  int ans=min_cost_flow(si,ti,N);
  ans-= X*N;
  ans=-ans;

  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3436
#include <iostream>

using namespace std;

int main(){
  int c1, c2, c3, c4, n;
  c1 = 0;
  c2 = 0;
  c3 = 0;
  c4 = 0;
  string str = "";

  cin >> n;

  for(int i = 0; i < n; i++){
    cin >> str;
    if(str=="AC"){
      c1 += 1;
    }else if(str=="WA"){
      c2 += 1;
    }else if(str=="TLE"){
      c3 += 1;
    }else if(str=="RE"){
      c4 += 1;
    }
  }

  cout << "AC x " << c1 << endl;
  cout << "WA x " << c2 << endl;
  cout << "TLE x " << c3 << endl;
  cout << "RE x " << c4 << endl;

  return 0;
}

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

using namespace std;

int main(){

int n, i, s, jud;

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

s = 0;
jud = 0;

while(1){
    for(i = 0; i < n; i++){
        if((a[i] % 2) == 0){
            a[i] = a[i] / 2;
        }else{
            jud = 1;
            break;
        }

        if(i == (n-1)){
            ++s;
        }
    }


    if(jud == 1){
        break;
    }

}

cout << s << endl;

}

Measured memory_bytes: 256
#include <cstdio>

const double kProbability = 1.0f / 6.0f;
const int kMaxSquare = 128;
const int kMaxTurn = 128;	//30?§s?±????????????\W?¨???126??^??[???¬????¢?\???¬x

enum BoardState{
	BLANK, LOSE, BACK
};

BoardState board[kMaxSquare];

double bp(const int N, const int T){
	double prob[kMaxTurn][kMaxSquare];
	for (int i = 0; i <= T; i++)
		for (int j = 0; j <= N; j++)
			prob[i][j] = 0.0f;
	prob[0][0] = 1.0f;

	for (int t = 0; t < T; t++){
		for (int n = 0; n < N; n++){
			if (prob[t][n] == 0.0f) continue;
			for (int dice = 1; dice <= 6; dice++){
				int pos = (n + dice <= N) ? n + dice : N - (n + dice - N);
				switch (board[pos]){
				case BLANK:
					prob[t + 1][pos] += prob[t][n] * kProbability;
					break;
				case LOSE:
					prob[t + 2][pos] += prob[t][n] * kProbability;
					break;
				case BACK:
					prob[t + 1][0] += prob[t][n] * kProbability;
				}
			}
		}
	}

	double res = 0.0f;
	for (int i = 1; i <= T; i++)
		res += prob[i][N];
	return res;
}

int main(){
	while (1){
		int N, T, L, B;
		scanf("%d %d %d %d", &N, &T, &L, &B);
		if (N == 0) return 0;
		for (int i = 0; i <= N; i++) 
			board[i] = BLANK;
		for (; L > 0; L--){
			int l;
			scanf("%d", &l);
			board[l] = LOSE;
		}
		for (; B > 0; B--){
			int b;
			scanf("%d", &b);
			board[b] = BACK;
		}
		printf("%.6f\n", bp(N, T));
	}
}

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

int main(){
  string s;
  cin >> s;
  int n=s.size();
  char a[26];
  for(int i=0;i<26;i++) a[i]='a'+i;
  if(n<26){
    char ans='0';
    for(int i=25;i>=0;i--){
      bool check=true;
      for(int j=0;j<n;j++){
        if(s[j]==a[i]) check=false;
      }
      if(check) ans=a[i];
    }
    cout << s << ans << endl;
  }
  else{
    int count=1;
    for(int i=25;i>=1;i--){
      if(s[i]<s[i-1]){
        count++;
      }
      else{
        break;
      }
    }
    if(count==26){
      cout << -1 << endl;
    }
    else{
      for(int i=0;i<25-count;i++){
        cout << s[i];
      }
      for(int i=25;;i--){
        if(s[i]>s[25-count]){
          cout << s[i] << endl;
          break;
        }
      }
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a = 0, b = 0, c = 0;
    cin >> a >> b >> c;
    
    if( ( a < b ) && ( b < c ) ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
 
#define M 1000000007
 
#define mp make_pair
#define pb push_back
#define tri pair<int, pair<int, int> >
#define TRI(a,b,c) (make_pair(a,make_pair(b,c)))
 
typedef long long ll;
typedef long double ld;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, x, tot=0, mn = M; cin>>n>>x;
    int arr[n];
    for(int i=0; i<n; i++)
    {
    	cin>>arr[i];
    	tot++;
    	x-=arr[i];
    	mn = min(mn, arr[i]);
    }
    tot+=x/mn;
    cout<<tot<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
lst = [0] * 1000
for i in range(1000):
    if len(str(i)) == 1:
        tmp = '00' + str(i)
        lst[i] = tmp
    elif len(str(i)) == 2:
        tmp = '0' + str(i)
        lst[i] = tmp
    else:
        lst[i] = str(i)

cnt = 0
for v in lst:
    id_1 = s.find(v[0])
    if id_1 == -1:
        continue
    id_2 = s.find(v[1], id_1 + 1)
    if id_2 == -1:
        continue
    id_3 = s.find(v[2], id_2 + 1)
    if id_3 == -1:
        continue
    cnt += 1

print(cnt)


Measured memory_bytes: 3064
#include<iostream>
#include <bits/stdc++.h>
#include<string>
#include<algorithm>
using namespace std;
typedef pair<int,int> P;


int main(){
    int N;
    cin >> N;
    int Nminus2=1, Nminus1 = 1,ans =0;
    if(N==0) cout <<1 <<endl;
    else if(N==1) cout <<1 <<endl;
    else {
        for(int i=1; i<N; ++i){
           ans = Nminus2 + Nminus1;
           Nminus2 =Nminus1;
           Nminus1 = ans;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>
#include <iomanip>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;
typedef pair<int,int> P;

int main()
{

    int A,B,C;
    cin >> A >> B >> C;


    string ans="NO";

    FOR(i,1,101){
    	if(A*i%B==C){
    		ans="YES";
    		break;
    	}
    }


    cout << ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<pair<int, int>> vec;

int main(){
	int N, a, b; cin>>N;
  	while(N--){
      	cin>>a>>b;
    	vec.push_back(make_pair(b,a));
    }
  	sort(vec.begin(), vec.end());
  	int total = 0;
  	for(auto elem: vec){
    	total+=elem.second;
      	if(total>elem.first){
        	cout<<"No"<<endl; return 0;
        }
    }
  	cout<<"Yes"<<endl;
  	return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
#define fastio     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x)     (x).begin() , (x).end()
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
typedef long long int ll;
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}


const ll mod = 1e9+7;
const double eps = 1e-9;



void solve(){
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a;
}





int main(){
    fastio
    int test=1;
    while(test--)
        solve();
    return 0;
}


Measured memory_bytes: 3636
c[];main(n,m,i,j,k,f){for(f="%d\n";scanf("%d%d",&n,&m)*n;printf(f,j>m?i:j)){for(i=3;i--;)for(scanf(f,&j);j--;c[n-k]=i)scanf(f,&k);for(i=n;i--;k+=c[i])j-=pow(3,i)*abs(k*2%4-c[i]);j=fmin(~j,pow(3,n)+j);}}

Measured memory_bytes: 644
import sys
n = int(input())
p = list(map(int, input().split()))

mx = 0
for k in range(n):
    pk = p[k]
    mx = max(mx, pk)
    if pk < mx:
        break
else:
    print('YES')
    sys.exit()

for i in range(n):
    for j in range(i+1,n):
        mx = 0
        for k in range(n):
            pk = p[k]
            if k == i: pk = p[j]
            if k == j: pk = p[i]
            mx = max(mx, pk)
            if pk < mx:
                break
        else:
            print('YES')
            sys.exit()
print('NO')

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    int ans=0;
    REP(i,0,3) if(s[i]==t[i]) ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    int h,w;
    cin>>h>>w;
    if(h==1 || w==1){
        cout<<1<<endl;
        return 0;
    }
    cout<<(h*w+1)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func solve(l int) bool {
	return l >= 30
}

func main() {
	var N int
	fmt.Scan(&N)
	
	result := solve(N)
	if result {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1768
n=int(input())
a=[0]+list(map(int,input().split()))
b=[]
c=[0]*(n+1)
for i in range(n,0,-1):
  cnt=0
  t=i
  while t<=n:
    cnt+=c[t]
    t+=i
  if cnt%2!=a[i]:
    c[i]=1
    b.append(i)
b.sort()
if len(b)>0:
  print(len(b))
  print(*b)
else:
  print(0)
  


Measured memory_bytes: 14032
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	m := nextInt()
	h := make([]int, n)
	good := make([]bool, n)
	for i := 0; i < n; i++ {
		h[i] = nextInt()
		good[i] = true
	}
	for i := 0; i < m; i++ {
		ai := nextInt() - 1
		bi := nextInt() - 1
		if h[ai] > h[bi] {
			good[bi] = false
		} else if h[ai] < h[bi] {
			good[ai] = false
		} else {
			good[ai] = false
			good[bi] = false
		}
	}
	ans := 0
	for i := 0; i < n; i++ {
		if good[i] {
			ans++
		}
	}
	fmt.Println(ans)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 5528
#include <bits/stdc++.h>
#define ll long long
#define _for(a,b,i) for(int i=a;i<=b;i++)
#define for1(a,b,i) for(int i=a;i<b;i++)
using namespace std;
int ma=0x80000000;
int mi=0x7fffffff;
const ll zfc=0xffffffff;
const int mod=1e9+7;
inline void input(ll &x)
{
    x=0;
    int f=1;
    char ch=getchar();
    while(!isdigit(ch))
	{
		if(ch=='-')f=-f;
		ch=getchar();
	}
    while(isdigit(ch))
	{
		x=x*10+(ch-'0');
		ch=getchar();
	}
    x*=f;
}
inline void output(ll x)
{
	if(x<0)
    {
        x=-x;
        putchar('-');
    }
    if(x/10>0)output(x/10);
    putchar(x%10+'0');
}
ll n,a;
int main()
{
    input(n);
    _for(1,n,i)
    {
    	input(a);
    	if(a>ma)ma=a;
    	if(a<mi)mi=a;
    }
    cout<<ma-mi<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define speed ios_base::sync_with_stdio(0); cin.tie(0);
#define FL(i,a,n) for(ll i=a;i<n;i++)
#define even(x) (((x)%(2))==(0))
#define odd(x) (((x)%(2))==(1))
#define meme(x) memset(x, 0, sizeof(x))

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
	
int main()
{
    speed;
    string s;
    cin>>s;
    ll ans=0;
    for(char c:s)
    {
	    ans=ans+(c-'0');
    }
    if(ans%9==0)
    cout<<"Yes\n";
    else
    {
	    cout<<"No\n";
    }
    


}
	
	


Measured memory_bytes: 3700
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);

	        int H = sc.nextInt();	
	        int W = sc.nextInt();	
	        int[][]m = new int[H][W];
	        for (int i=0 ; i<H; i++) {
	        	String S = sc.next();
	        	char[] c = S.toCharArray();
	            for(int j=0;j<W;j++) {
	            	if(c[j]=='#')m[i][j]=1;
	            }
	        }
	        long ans=0;
	        boolean[][] visited = new boolean[H][W];
    		LinkedList<Integer> q= new LinkedList<Integer>();
	        for (int i=0 ; i<H; i++) {
	            for(int j=0;j<W;j++) {
	            	if(m[i][j]==1&&visited[i][j]!=true) {
	            		q.add(i*W+j);
	            		long cnt1=0;
	            		long cnt2=1;
	            		visited[i][j]=true;
            			int[] dx = {1, -1, 0, 0};
            			int[] dy = {0, 0, 1, -1};
	            		while(!q.isEmpty()) {
	            			int t = q.poll();
	            			int nh = t/W;
	            			int nw = t%W;
	            			int w = m[nh][nw];
	            			for(int k=0;k<4;k++) {
	            				int nx = nh + dx[k];
	            				int ny = nw + dy[k];
	            				if(nx >= 0 && nx < H && ny >= 0 && ny < W) {
	            					if(w==m[nx][ny])continue;
	            					if(visited[nx][ny]==true)continue;
		            				if(m[nx][ny]==0)cnt1++;
		            				else {
		            					cnt2++;
		            				}
		            				visited[nx][ny]=true;
		            				q.add(nx*W+ny);
	            				}
	            			}
	            		}
	            		ans=ans+cnt1*cnt2;
	            	}	
	            }	
	        }
	        
	        
	        System.out.println(ans);
	    }
	}

Measured memory_bytes: 43788
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		System.out.println((x - a) % b);

		sc.close();

	}

}


Measured memory_bytes: 35600
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <vector>
#include <iostream>
#include <ctime>
#include <unistd.h>

using namespace std;

#define TRACE(x) cerr << #x <<  " = " << x << endl
#define _ << " " <<
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)

#define X first
#define Y second

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

int main()
{
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  int da = 0;

  REP(i, n+1) REP(j, m+1)
    if (i * (m - j) + (n - i) * j == k)
      da = 1;
  
  printf("%s\n", da ? "Yes" : "No");

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <utility>
#include <cstdlib>
using namespace std;

int main(){
	int n;
	cin >> n;
	while(n){
		double x[3],y[3];
		cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2];

		double  a[2],b[2],c[2];
		for(int i=0;i<2;i++){
			a[i] = 2*(x[i]-x[i+1]);
			b[i] = 2*(y[i]-y[i+1]);
			c[i] = x[i]*x[i]-x[i+1]*x[i+1]+y[i]*y[i]-y[i+1]*y[i+1];
		}
		double ansx,ansy,r;
		ansx = (c[0]*b[1]-c[1]*b[0])/(a[0]*b[1]-a[1]*b[0]);
		ansy = (a[1]*c[0]-a[0]*c[1])/(a[1]*b[0]-a[0]*b[1]);
		r = hypot(x[0]-ansx,y[0]-ansy);
		cout << fixed << setprecision(3) <<  ansx << " " << ansy << " " << r <<  endl;
		n--;
	}
	return 0;
}

Measured memory_bytes: 1300
s = input()
# AKIHABARA
if (s == "AKIHABARA") or (s == "AKIHABAR") or (s == "AKIHABRA") or (s == "AKIHABR") or (s == "AKIHBARA") or (s == "AKIHBAR") or (s == "AKIHBRA") or (s == "AKIHBR") or (s == "KIHABARA") or (s == "KIHABAR") or (s == "KIHABRA") or (s == "KIHABR") or (s == "KIHBARA") or (s == "KIHBAR") or (s == "KIHBRA") or (s == "KIHBR"):
     print("YES")
else:
    print("NO")

Measured memory_bytes: 9028
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<cmath>
#include<stack>
//#include<stdlib.h>
using namespace std;
int main() {
	int n,m,h,f,p;
	cin >> n >> m;
	h = 1; f = n;
	vector<int>l(m);
	vector<int>r(m);
	for (int a = 0; a < m; a++)
	{
		cin >> l[a] >> r[a];
		if (l[a] > h) { h = l[a]; }
		if (r[a] < f) { f = r[a]; }
	}
	p=(f - h + 1);
	if (p < 0) { p = 0; }
	cout << p;
	return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

ll mod_pow(ll x, ll n)
{
    if (n == 0)
        return 1;
    ll fact = x;
    ll out = 1;
    while (n > 0) {
        if (n & 1) {
            out = out * fact % MOD;
        }
        fact = fact * fact % MOD;
        n >>= 1;
    }
    return out;
}

int main()
{
    ll n, k;
    cin >> n >> k;
    map<ll, ll> d;

    for (ll gcd = k; gcd >= 1; gcd--) {
        d[gcd] = mod_pow(k / gcd, n);
        for (ll i = 2; gcd * i <= k; i++) {
            d[gcd] = (d[gcd] - d[gcd * i]) % MOD;
        }
    }

    ll ans = 0;
    for (ll i = 1; i <= k; i++) {
        ans = (ans + d[i] * i % MOD) % MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 9776
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
#define EPS 1e-6
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64; 
long long const INF = 1e18 + 42;
 
 
int main(){
	fast;
	int n,m;
	cin>>n>>m;
	cout<< (n*(n-1))/2+(m*(m-1))/2<<"\n";
	return 0;
}

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

using namespace __gnu_pbds;
using namespace std;

#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sz(v) (int) (v).size()
#define rep(i,a,b) for(int (i) = (a); (i) < (b); ++(i))
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define funoredered_map __fast_unordered_map

template<class Key, class Value, class Hash = std::hash<Key>>
using funordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdb = pair< double, double >;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vvi = vector<vi>;

constexpr int inf = 0x3f3f3f3f;
constexpr double eps = 1e-8;
constexpr ll MOD = 1000000007LL;

template <typename T>
using ordered_set = 
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll powmod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

void buff() { ios::sync_with_stdio(false); cin.tie(nullptr); }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// END OF TEMPLATE CODE


unordered_map<long long, long long> memo;

long long solve(long long v)
{
    if( memo[v] != 0) return memo[v];
    if( v == 1) return memo[v] = 1;
    return 1 + 2 * solve(v/2);
}

int main()
{
    buff(); 
    long long x;
    cin >> x;
    cout << solve(x) << endl;
    return 0;
}



Measured memory_bytes: 256
//
//  main.cpp
//  B - Round Robin Simulation
//
//  Created by Darklanx on 2018/2/1.
//  Copyright © 2018年 Darklanx. All rights reserved.
//

#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <queue>
using namespace std;
struct process{
    string name;
    int time;
    process(string _name, int _time):name(_name),time(_time){}
    
};
bool sort_time(process p1, process p2){
    return p1.time < p2.time;
}
int main() {
    int n, q;
    queue<process> ps;
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    while(cin >> n >> q){
        int cur_time = 0;
        while(n--){
            string name; int time;
            cin >> name >> time;
            process tmp(name,time);
            ps.push(tmp);
        }
        while(ps.size()>0){
            if(ps.front().time <=q ){
                cur_time += ps.front().time;
                cout << ps.front().name << " " << cur_time << '\n';
                ps.pop();
            }else{
                ps.front().time -= q;
                cur_time += q;
                process tmp(ps.front().name,ps.front().time);
                ps.pop();
                ps.push(tmp);
            }
        }
        /*TLE
         while(ps.size()>0){
         // let them take turns
         for(int token=0;token<ps.size(); ){
         if(ps[token].time <= q){
         cur_time += ps[token].time;
         //printf("%s %d\n",ps[token].name.c_str(),cur_time);
         cout << ps[token].name << " " << cur_time << '\n';
         ps.erase(ps.begin()+token);
         }else{
         ps[token].time -= q;
         cur_time += q;
         token++;
         }
         }
         }
         */
    }
    return 0;
}



Measured memory_bytes: 6376
#include<bits/stdc++.h> 
using namespace std; 
int main(){
 int n, k; 
  cin>>n>>k; 
  int ans=0;
  int p[n]; 
  for(int i=0;i<n;i++) cin>>p[i];
  sort(p, p+n); 
  for(int j=0;j<k;j++) ans+=p[j];
  cout<<ans; 
}

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


int main(){
    int k;
    char s[105];
    scanf("%d %s",&k,s);
    for(int i=0;i<k&&i<strlen(s);i++)
        printf("%c",s[i]);
    if(k<strlen(s))printf("...");
    return 0;
}


Measured memory_bytes: 3720