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 rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin>>N;
    string S;
    cin>>S;
    string T = "";
    rep(i,(int)S.size()){
        T.push_back(char((S[i]-'A' + N)%26 + 'A'));
    }

    cout<<T<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;


int main() {
	while (1) {

		int R, N; cin >> R >> N;
		if (!R)break;
		vector<int>heights(42,0);
		
		for (int i = 0; i < N; ++i) {
			int l, r, h; cin >> l >> r >> h;
			l += 21; r += 21;
			for (int i = l; i < r; ++i) {
				heights[i] = max(heights[i], h);
			}
		}
		vector<ld>times(41, 99999);
		for (int i = 0; i < 41; ++i) {
			int dx = abs(i - 20);
			if (dx < R) {
				ld dy = R-sqrtl(R*R - dx*dx);
				times[i] = min(heights[i+1],heights[i]) +dy;
			}
		}
		ld ans = *min_element(times.begin(), times.end());
		cout << fixed<<setprecision(5)<<ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3236
s = list(input())
a = s[:len(s)//2]
b = s[len(s)//2+1:]
res = 0
if s[::-1] == s: res+=1
if a[::-1] == a: res+=1
if b[::-1] == b: res+=1
print("Yes" if res == 3 else "No")

Measured memory_bytes: 9032
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>

using namespace std;

int N;
int X;
vector<int> a;

int main()
{
	cin >> N;
	cin >> X;
	for (int i=0; i < N; ++i) {
		int tmp;
		cin >> tmp;
		a.push_back(tmp); //価格のvector
	}

	sort(a.begin(), a.end()); //昇順ソート
	int sum = accumulate(a.begin(), a.end(), 0);

	int scp = X - sum; //一個ずつの合計を全部から引く
	int cnt = scp / a.at(0); //最小値で割る

	printf("%d", cnt + N);


	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    for (int ii = 0; ii < n; ii++) {
      int f = scanner.nextInt();
      int t = scanner.nextInt();
      if (f < t) {
        for (int jj = f; jj <= t; jj++) {
          System.out.print(jj);
          if (jj != t) {
            System.out.print(" ");
          } else {
            System.out.print("\n");
          }
        }
      } else if (f > t) {
        if (f <= 5 && t <= 5) {
          for (int jj = f; jj >= t; jj--) {
            System.out.print(jj);
            if (jj != t) {
              System.out.print(" ");
            } else {
              System.out.print("\n");
            }
          }
          continue;
        }
        String out = "";
        for (int jj = f;;) {
          out += jj + " ";
          if (jj == t) {
            break;
          }
          if (5 < jj) {
            jj++;
          } else {
            jj--;
            if (jj == 0) {
              jj += 6;
              out += "0 1 2 3 4 5 ";
            }
          }
          if (jj == 10) {
            jj = 5;
          }
        }
        System.out.print(out.trim() + "\n");
      }
    }
  }
}

Measured memory_bytes: 17180
<?php
fscanf(STDIN, '%d %d', $daysCnt, $worksCnt);
$workDays = array_map('intval', explode(' ', trim(fgets(STDIN))));
$ans = $daysCnt - array_sum($workDays);
if ($ans < 0) {
    $ans = -1;
}
echo $ans;

Measured memory_bytes: 17092
N, T = gets.chomp.split(" ").map(&:to_i)
inputs = gets.chomp.split(" ").map(&:to_i)
ans = 0
time_lag = []
(N-1).times do |i|
    time_lag << inputs[i+1] - inputs[i]
end
 
time_lag.each do |i|
    ans += T > i ? i : T
end
 
puts ans+T

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

int gcd(int a,int b){return (a%b?gcd(b,a%b):b);};

int main()
{
	int n,x;
	cin >> n >> x;
	vector<int> a(n);
	for(int i = 0;i<n;i++)
	cin >> a[i];
	int ans = abs(x-a[0]);
	for(int i =0;i<n-1;i++)
	{
		ans = gcd(ans,abs(a[i]-a[i+1]));
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x,a,b; cin>>x>>a>>b;
	int xx=abs(x-a);
	int yy=abs(x-b);
	if(xx<yy){
		cout<<"A";
	}
	else if(yy<xx)
	{
		cout<<"B";
	}
	else
	{
	    cout<<min(a,b);
	}
}

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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define INFTY 999999

//char型のポインタ(=配列と意味は同じ)をString型と定義
typedef char* String;

//文字列の長さを求める関数
int string_len(String str){
    int len=0;
    while(str[len]!=0){
        len++;
    }
    return len;
}

//str[0]~str[n-1]まで
//文字列を標準入力から読み込み、それをString型のメモリを確保し直してくれる関数
String string_input(void){
    int i,len;
    char buf[200];
    String str;
    scanf("%s",buf);//buf=入力した文字列が入るchar型の配列
    //ここまでは文字列の長さがわからなかったから、一旦1000個分のメモリを用意しそこに入力させる
    
    len=string_len(buf);//len=文字列の長さを表すint型変数
    NEW(str,len+1);//strはただのポインタだから、ここでNEWを使ってメモリを確保しなくちゃいけない
    for(i=0;i<len;i++){
        str[i]=buf[i];
    }
    str[len]=0;
    
    return str;
}

int count_match(char a, char b, char c){
    int ans;

    if(a==b){
        if(b==c){
            ans=0;
        }
        else{
            ans=1;
        }
    }
    else{
        if(a==c){
            ans=1;
        }
        else if(b==c){
            ans=1;
        }
        else{
            ans=2;
        }
    }

    return ans;
}

int main(void){
    int N;
    String A,B,C;

    scanf("%d", &N);
    A=string_input();
    B=string_input();
    C=string_input();

    int ans=0;

    for(int i=0;i<N;i++){
        ans+=count_match(A[i],B[i],C[i]);
    }

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


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

int main(){
	int a,b;
	cin>>a>>b;
	
	int m=a+b;
	int n=a-b;
	int c=a*b;
	
	int d=max(m,n);
	
	cout<<max(c,d);
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int i,j,sa,downmax,upmax,n,m,b[1000];


  scanf("%d",&m);
  for(j=0;j<m;j++){
    downmax = 0;
    upmax = 0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
      scanf("%d",&b[i]);
      if(i>0){
	if (b[i-1]<b[i] && upmax<(b[i]-b[i-1])){
	  upmax = b[i]-b[i-1];
	}
	if( b[i-1]>b[i] && downmax<(b[i-1]-b[i])){
	  downmax = b[i-1]-b[i];
	}
      }
    }
  printf("%d %d\n",upmax,downmax);
  }
  return 0;
}

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

int main() {
    int S;
    cin >> S;
    int count;
    if (S / 100 == 1) {
        count++;
    }
    S %= 100;
    if (S / 10 == 1) {
        count++;
    }
    S %= 10;
    if (S / 1 == 1) {
        count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  
#define lli long long 
using namespace std; 
long long mod=1e9+7;
lli power(lli x, lli y,lli m=mod) 
{
    lli res = 1;  
   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x)%m; 
        y = y>>1; 
        x = (x*x)%m;  
    }
    if(res<0)
       res+=m; 
    return res; 
}
// lli fact[2000009];
// lli ncr(lli n,lli r){
//     lli ans=fact[n];
//     if(r>n)return 1;
//     if(r<0)return 0;
//     if(n<0)return 0;
//     ans=(ans*power(fact[n-r],mod-2))%mod;
//     ans=(ans*power(fact[r],mod-2))%mod;
//     return ans;
// }
int main() 
{ 
    // fact[0]=1;
    // for(int i=1;i<=2000005;i++)fact[i]=(i*fact[i-1])%mod;
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        long long s;cin>>s;
        long long dp[s+5];memset(dp,0,sizeof dp);
        dp[0]=1;
        dp[3]=1;
        for(int i=4;i<=s;i++){
            for(int j=3;j<=i;j++)dp[i]=(dp[i]+dp[i-j])%mod;
        }
        cout<<dp[s]<<"\n";
    }
    return 0; 
} 

Measured memory_bytes: 3592
import java.util.*
import java.math.*

fun main(args: Array<String>) {
    var (N,K) = readLine()!!.split(" ").map { it.toInt() }
//    var N = readLine()!!.toInt()
//    val S = readLine()!!
//    val D = readLine()!!.split(" ").map { it.toLong() }
    println(if (N < K) 0 else 10)
}


Measured memory_bytes: 36152
//package src.com.jetman.atcoder;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * @description:
 * @author: Jetman
 * @create: 2020-08-29 14:39
 **/
public class Main {

    Scanner sc = new Scanner(System.in);

    long MOD = 1000000000 + 7;


    private void slove() {

        int h = sc.nextInt();
        System.out.println(h^1);





    }

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


Measured memory_bytes: 35624
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
cd = [list(map(int, input().split())) for _ in range(M)]

for a, b in ab:
    ans = -1
    m = 10**9
    i = 1
    for c, d in cd:
        t = abs(c-a)+abs(d-b)
        if t < m:
            m = t
            ans = i
        i += 1
    print(ans)


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

int h[100000][3];
int dp[100001][3];

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 3; j++)
      cin >> h[i][j];
  fill_n((int*)dp, n*3, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++)
	if (j != k)
	  dp[i+1][k] = max(dp[i+1][k], dp[i][j]+h[i][k]);
    }
  }
  int ans = 0;
  for (int j = 0; j < 3; j++)
    ans = max(ans, dp[n][j]);
  cout << ans << endl;
}


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

int main(){
  int n;
  cin>>n;
  double a[100]={};
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  
  int ans[6]={};
  double h=165;
  int i=0,cnt=0;
  while(i<n){
    if(a[i]>=h)h+=5,cnt=min(5,cnt+1);
    else ans[cnt]++,i++;
  }
  
  for(int i=0;i<6;i++){
    cout << i+1<<":";
    for(int j=0;j<ans[i];j++) cout << "*";
    cout <<endl;
  }
  
  return 0;
}

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

using namespace std;

int main(){
    long N ;
    string S;
    cin >> N >> S;
    long e, w;
    e = w = 0;
    long a = 3 * 100000;
    for(int i = 0; i < N; i++) {
        //if(S.at(i) == 'E')e++;
        if(S.at(i) == 'W')
        w++;
    }
    for(int i = N-1; i >= 0; i--){
        if(S.at(i) == 'W'){
            w--;
            a = min(w + e , a);
        }
        if(S.at(i) == 'E') {
            e++;
            a = min(w + e -1, a);
        }
    }
    cout << a << endl;
    return 0;
}

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

typedef long int lint;
typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(t, c) for (auto&& t : c)
#define ALL(c) begin(c), end(c)
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define fk first
#define sv second

const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

  cin >> s;

  int cost = 700;
  REP(i, 3) {
    if (s[i] == 'o') {
      cost += 100;
    }
  }

  cout << cost << endl;
}

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

#define  flash ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  int long long
#define  double long double
#define  endl "\n"
#define  ff first
#define  ss second
#define  mem(ar)  memset(ar,0,sizeof ar)
#define  mod 1000000007
#define  time    cerr << "\nTime elapsed: " << clock() / (double) CLOCKS_PER_SEC << "s\n";

template<typename x,typename y> x max(x a,y b){return (a>b)?a:b;}
template<typename x,typename y> x min(x a,y b){return (a<b)?a:b;}

template<typename T> ostream& operator<<(ostream &os, const vector<T> &V) {
    os << '{'; string sep; for (const auto &x : V) os << sep << x, sep = ", "; return os << '}';
}
template<typename T> ostream& operator<<(ostream &os, const vector<pair<T,T>> &V) {
    os << '{'; string sep; for (const auto &x : V) os << sep << '(' << x.ff << "," << x.ss << ')', sep = ", "; return os << '}';
}

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#define DEBUG
#ifdef  DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

inline int power(int x,int y){int ans=1;while(y){if (y&1) ans=(ans*x)%mod;x=(x*x)%mod;y>>=1;}return ans;}
inline int inv(int x){return power(x,mod-2);}

int32_t main(){
flash;
int n; cin>>n;
vector<vector<int>> v(n,vector<int>(3,0));

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

vector<vector<int>> dp(n,vector<int>(3,0));
for(int i=0;i<3;i++)
    dp[n-1][i]=v[n-1][i];

for(int i=n-2;i>=0;i--){
    for(int j=0;j<3;j++){
        for(int k=0;k<3;k++){
            if(j!=k)
                dp[i][j] = max( dp[i][j] , v[i][j]+dp[i+1][k] );
        }
    }
}

cout << max( dp[0][0] , max(dp[0][1],dp[0][2]) ) << endl;

return 0;
}



Measured memory_bytes: 14212
using System.Collections.Generic;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	public const int MOD = 1000000007;
	public K()
	{
		var N = F();
		var S = ReadLine();
		var T = ReadLine();
		var same = new List<bool>();
		for (var i = 0; i < N; i++)
			if (S[i] == T[i]) same.Add(true);
			else { same.Add(false); i++; }
		N = same.Count;
		var dp = same[0] ? 3L : 6;
		for (var i = 1; i < N; i++) dp = dp * (same[i - 1] ? 2 : same[i] ? 1 : 3) % MOD;
		WriteLine(dp);
	}
}


Measured memory_bytes: 13140
N = int(input())

travels = []
for i in range(N):
    t, x, y = map(int, input().split())
    travels.append((t, x, y))

def is_possible(travels):
    current = (0, 0, 0)

    for t, x, y in travels:
        prev_t, prev_x, prev_y = current

        dt = t - prev_t
        dx = x - prev_x
        dy = y - prev_y
        dxy = dx + dy
        if dt < dxy:
            return False
        if dt == dxy:
            continue
        if (dt - dxy) % 2 != 0:
            return False

        current = (t, x, y)

    return True


if is_possible(travels):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 17320
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

class Team{
public:
  int tid,correct,penalty;
  map<int,int> wrongs;
  set<int> solved;
  bool operator<(const Team &a)const{
    if(correct!=a.correct) return correct>a.correct;
    else if(penalty!=a.penalty) return penalty<a.penalty;
    else return tid<a.tid;
  }
};

int main(void){
  int t,p,r;
  while(cin>>t>>p>>r,t||p||r){
    vector<Team> teams(t);
    for(int i=0;i<t;++i)teams[i].tid=i+1;
    for(int i=0,tid,pid,time;i<r;++i){
      string message;
      cin>>tid>>pid>>time>>message;
      if(teams[tid-1].solved.count(pid-1))continue;
      if(message=="CORRECT"){
        ++teams[tid-1].correct;
        teams[tid-1].penalty+=teams[tid-1].wrongs[pid-1]*1200+time;
      }else ++teams[tid-1].wrongs[pid-1];
    }
    sort(teams.begin(),teams.end());
    for(int i=0;i<t;++i)cout<<teams[i].tid<<" "<<teams[i].correct<<" "<<teams[i].penalty<<endl;
  }
  return 0;
}

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

int main() {
    vector<int> vec(3);
    for(int i=0; i<3; i++) cin >> vec[i];

    sort(vec.begin(), vec.end());
    for(int i=0; i<vec.size(); i++) {
        cout << vec[i];
        if (i != vec.size()-1) cout << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

typedef tuple<double, double> res; // time, atlas

int N;
ll L, T;
ll X[100010];
int W[100010];
int ans[100010];

vector<ll> V[2];

int main () {
  cin >> N >> L >> T;
  for (auto i = 0; i < N; ++i) {
    cin >> X[i] >> W[i];
    W[i]--;
    V[W[i]].push_back(X[i]);
  }
  for (auto i = 0; i < N; ++i) {
    if (W[i] == 0) {
      ans[i] = X[i] + T%L;
      ans[i] %= L;
    } else {
      ans[i] = X[i] + L - T%L;
      ans[i] %= L;  
    }
  }
  int branch = 0;
  if (W[0] == 0) {
    int counter = V[1].size();
    branch += (T/L) * 2 * counter;
    branch %= N;
    int nokori = T%L;
    for (auto x : V[1]) {
      int kyori = (x + L - X[0])%L;
      if (kyori <= 2 * nokori) {
        branch++;
      }
      if (kyori + L <= 2 * nokori) {
        branch++;
      }
    }
    branch %= N;
  } else {
    int counter = V[0].size();
    branch += N - ((T/L) * 2 * counter)%N;
    branch %= N;
    int nokori = T%L;
    for (auto x : V[0]) {
      int kyori = (X[0] + L - x)%L;
      if (kyori <= 2 * nokori) {
        branch += (N-1);
        branch %= N;
      }
      if (kyori + L <= 2 * nokori) {
        branch += (N-1);
        branch %= N;
      }
    }
    branch %= N;
  }
  cerr << "branch = " << branch << endl;
  int memo = ans[0];
  cerr << "memo = " << memo << endl;
  sort(ans, ans+N);
  int zahyo = 0;
  if (W[0] == 0) {
    for (auto i = N-1; i >= 0; --i) {
      if (memo == ans[i]) {
        zahyo = (i + N - branch)%N;
        break;
      }
    }    
  } else {
    for (auto i = 0; i < N; ++i) {
      if (memo == ans[i]) {
        zahyo = (i + N - branch)%N;
        break;
      }
    }    
  }
  cerr << "zahyo = " << zahyo << endl;
  for (auto i = 0; i < N; ++i) {
    cout << ans[(zahyo + i)%N] << endl;
  }
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define up(j,k,i) for(i=j;i<k;i++)
#define down(j,k,i) for(i=j;i>k;i--)
#define pp(n) printf("%lld\n",n)
#define ps(s) printf("%s",s)
#define is(n) scanf("%lld",&n)
#define ips(n) scanf("%lld",n)
#define ss(s) scanf("%s",s)
#define cool 0
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define f(i) cout<<i<<endl;
#define pll pair<lld,lld> 
#define pi acos(-1)
#define dg(x) cout<<#x<<' '<<x<<endl;
#define dg2(x,y) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<endl;
#define dg3(x,y,z) cout<<#x<<' '<<x<<' '<<#y<<' '<<y<<' '<<#z<<' '<<z<<endl;
#define ds(n,m) scanf("%lld %lld",&n,&m)
#define ts(n,m,k) scanf("%lld %lld %lld",&n,&m,&k)
typedef long double ld;
typedef long long int lld;
using namespace std;
const lld M =1e5+7;
const lld mod=1e9+7;
const lld infi =LLONG_MAX;
lld i,j,ans,k,n,x,y,m,mymax=LLONG_MIN,mymin=LLONG_MAX,b,c,z,sum;
lld cnt[M];
int main()
{
  is(n);
  is(m);
  while(m--)
  {
    ds(x,y);
    cnt[x]++;
    cnt[y]++;
    
  }
  up(1,n+1,i)
  {
    if(cnt[i]%2==1)
    ans++;
  }
        if(ans>1)
        {
          cout<<"NO\n";
        }
        else
        cout<<"YES\n";
        return 0;
}

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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
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; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007

int n,k;
vector<int> a;
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  cin >> n >> k;
  a.resize(n);
  REP(i,n){
    cin >> a[i];
  }
  cout << (n-1+k-2)/(k-1) << endl;
  return 0;
}


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

using namespace std;


int main(){
    int n;
    cin >> n;
    vector<int> D(n);
    copy_n(istream_iterator<int>(cin), n, D.begin());
    D.push_back(0);

    array<int, 13> cnt = {};
    for (const auto &d: D)
        cnt[d]++;

    for (const auto &c: cnt){
        if (c >= 3){
            cout << 0 << endl;
            return 0;
        }
    }

    int ans = 0;
    for (int bits = 0; bits < 1 << 13; bits++){
        int mi = 13;
        vector<int> A;
        for (int i = 0; i < 13; i++){
            if (cnt[i] == 0)
                continue;
            if (cnt[i] == 2){
                A.push_back(i);
                A.push_back(24 - i);
                continue;
            }
            if (bits >> i & 1){
                A.push_back(i);
            } else {
                A.push_back(24 - i);
            }
        }

        for (int i = 0; i < A.size(); i++){
            for (int j = i + 1; j < A.size(); j++){
                mi = min(mi, min((A[i] - A[j] + 24) % 24, (A[j] - A[i] + 24) % 24));
            }
        }
        ans = max(ans, mi);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int[] a = new int[4];
		char[] c = sc.next().toCharArray();
		for (int i = 0; i < 4; i++) {
			a[i] =Character.getNumericValue(c[i]);
		}
		int[][] op = { { 1, 1, 1 }, { 1, 1, -1 }, { 1, -1, 1 }, { -1, 1, 1 }, { 1, -1, -1 }, { -1, 1, -1 },
				{ -1, -1, 1 },
				{ -1, -1, -1 } };
		String str = "";
		for (int i = 0; i < 8; i++) {
			if (a[0] + a[1] * op[i][0] + a[2] * op[i][1] + a[3] * op[i][2] == 7) {
				str += a[0];
				for (int j = 0; j < 3; j++) {
					if (op[i][j] == 1) {
						str += "+" + a[j + 1];
					} else {
						str += "-" + a[j + 1];
					}
				}
				str += "=7";
				break;
			}
		}
		System.out.println(str);
	}
}


Measured memory_bytes: 21844
A, B, Q = gets.split(' ')

As = A.to_i.times.map { gets.to_i }
Bs = B.to_i.times.map { gets.to_i }
Qs = Q.to_i.times.map { gets.to_i }

INF = 10E18

As = [-INF] + As + [INF]
Bs = [-INF] + Bs + [INF]

def bs(qs)
  qs.each do |q|
    a = As.bsearch_index { |a| a > q }
    b = Bs.bsearch_index { |b| b > q }
    
    puts As[a-1, 2].product(Bs[b-1, 2]).flat_map { |a, b| [(q - a).abs + (a - b).abs, (q - b).abs + (b - a).abs ] }.min
  end
end

bs(Qs)

Measured memory_bytes: 8100
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void solve() throws Exception {
		int n = scanInt();
		long a[] = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = scanInt();
		}
		long min = 2, max = 2;
		for (int i = n - 1; i >= 0; i--) {
			long cur = a[i];
			min = (min - 1) / cur + 1;
			max = max / cur;
			if (max < min) {
				out.print(-1);
				return;
			}
			min *= cur;
			max = max * cur + cur - 1;
		}
		out.print(min + " " + max);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

Measured memory_bytes: 42620
import java.util.*;
import java.util.Map.Entry;

import javax.swing.text.Segment;
import javax.xml.ws.WebEndpoint;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
    static long mod=1000000007;
    
    public static void main(String[] args) {        
        new Thread(null, new Main(), "", 200 * 1024 * 1024).start();        
    }

    public void run() {
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

//        int n=sc.nextInt();
        String s=sc.nextString();
        String t=sc.nextString();
        int x=sc.nextInt();
        int y=sc.nextInt();
        if(sc.nextString().equals(s))x--;
        else y--;
        out.println(x+" "+y);
     	out.flush();
    }
    
    static long rep(long h) {
    	if(h==0)return 0;
    	return 1+rep(h/2)*2;
    }

    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }

    static void ret(long ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

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

//class P {
//	int x,y; double d;
//	P(int  x, int y, double d) {
//	  this.x=x;
//	  this.y=y;
//	  this.d=d;
//	}
//}


class P implements Comparable<P>{
    int p,h,f; long m;
    P(int p,int h, int f, long m) {
    	this.p=p;
    	this.h=h;
    	this.f=f;
    	this.m=m;
    }

    public int compareTo(P p){
    	if(this.p==p.p) {
    		if(this.f==-1) return 1;
    		return -1;
    	}
        return this.p-p.p;
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString()
    {
        while( st==null || !st.hasMoreTokens() )
			try {
				st = new StringTokenizer(x.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        return st.nextToken();
    }
    public int nextInt()
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) {
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) {
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() {
        return this.nextString().toCharArray();
    }    
    public long nextLong()
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


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

using namespace std;

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

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main () {
  int cnt1 = 0,cnt2 = 0;
  string s;
  cin >> s;
  if ((s[2] == '1' || s[2] == '0') && (s[3] >= '0' && s[3] <= '9') && (s[2] != '0' || s[3] != '0')){
    cnt1++;
  }
  if ((s[0] == '0' || s[0] == '2') && (s[1] >= '0' && s[1] <= '9')&& (s[1] != '0' || s[2] != '0')){
    cnt2++;
  }
  if (cnt1 == 1 && cnt2 == 0){
    cout << "YYMM\n";
    return 0;
  }
  if (cnt1 == 0 && cnt2 == 1){
    cout << "MMYY\n";
    return 0;
  }
  if (cnt1 == 0 && cnt2 == 0){
    cout << "NA\n";
    return 0;
  }
  if (cnt1 == 1 && cnt2 == 1){
    cout << "AMBIGUOUS\n";
    return 0;
  }
  return 0;
}

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

#define FOR(i, j, k) for(int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

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 <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for(T &x : vec)
        is >> x;
    return is;
}

#define UNION_FIND_MAX_N 100005

struct union_find {

    int par[UNION_FIND_MAX_N];
    int ran[UNION_FIND_MAX_N];
    int num[UNION_FIND_MAX_N];

    union_find(int __n) { init(__n); }

    void init(int n) {
        for(int i = 0; i < n; i++) {
            par[i] = i;
            ran[i] = 0;
            num[i] = 1;
        }
    }

    int find(int x) {
        if(par[x] == x)
            return x;
        else
            return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if(x == y)
            return;

        if(ran[x] < ran[y]) {
            par[x] = y;
            num[y] += num[x];
            num[x] = 0;
        } else {
            par[y] = x;
            num[x] += num[y];
            num[y] = 0;
            if(ran[x] == ran[y])
                ran[x]++;
        }
    }

    bool same(int x, int y) { return find(x) == find(y); }
};

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n, m;
    cin >> n >> m;

    union_find uf = union_find(n);

    REP(i, m) {
        int x, y, z;
        cin >> x >> y >> z;
        x--;
        y--;

        uf.unite(x, y);
    }

    set<int> s;
    REP(i, n) { s.insert(uf.find(i)); }

    cout << s.size() << endl;

    return 0;
}


Measured memory_bytes: 6144
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
using namespace std;

int main(){
    int N,M,A[100010],B[100010];
    long long sum=0;
    pair<int,int>p[100010];
    cin>>N>>M;
    for(int i=0;i<N;++i){
        cin>>A[i]>>B[i];
        p[i].first=A[i],p[i].second=B[i];
    }
    sort(p,p+N);
    for(int i=0;i<N;++i){
        if(M>p[i].second){
            sum+=(long long)p[i].first*p[i].second;
            M-=p[i].second;
        }
        else{
            sum+=(long long)M*p[i].first;
            goto lol;
        }
    }
    lol:
    cout<<sum<<endl;
    return 0;

}

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

using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x;
	cin >> x;
	for (int i = 1; i <= 100000; i++) {
		if (x <= i * (i + 1) / 2) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}

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

using namespace std;

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

    /* cin >> test_cases; */
    test_cases = 1;

    long long ans = 1;
    while (test_cases > 0)
    {
        int n;
        cin >> n;
        long long a[n];

        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
            if (a[i] == 0)
            {
                cout << 0 << endl;
                return 0;
            }
              
        }
        
        for (int i = 0; i < n; i++)
        {
            if (a[i] <= 1000000000000000000/ans)
            {
                ans *= a[i];
            }
            else
            {
                cout << -1 << endl;
                return 0;
            }
            
        }

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

Measured memory_bytes: 4440
import scala.io.StdIn

object Main extends App {

  val Array(n, m) = StdIn.readLine().split(" ").map(_.toInt)

  val a = (0 until n).map { _ =>
    StdIn.readLine()
  }

  val b = (0 until m).map { _ =>
    StdIn.readLine()
  }

  var im = 0
  var jm = 0
  var judge = false
  for (x <- 0 until n if (x + m) <= n && !judge){ 
    for (y <- 0 until n if (y + m) <= n && !judge) {
      judge = true
      for (z <- 0 until m if (z + m) <= n && judge) {
        //println(a(x + z).substring(y, y + m))
        //println(b(z))
        judge = a(x + z).substring(y, y + m) == b(z)
      }
    }
  }

  println(if (judge) "Yes" else "No")
}

Measured memory_bytes: 27340
N, K = map(int, input().split())

c = [0] * (N+1)
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        c[a] += 1
ans = sum(x == 0 for x in c) - 1
print(ans)

Measured memory_bytes: 9188
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <map>

using namespace std;

int main(){

    int N, M;
    cin >> N >> M;

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

    sort(A.begin(), A.end(), greater<int>());

    vector<pair<int, int>> CB(M);
    int b, c;
    for(int i = 0; i < M; i++){
        cin >> b >> c;
        CB[i] = make_pair(c, b);
    }

    sort(CB.begin(), CB.end(), greater<pair<int, int>>());

    int cnt = 0;
    int long long ans = 0;
    int indexA = 0;
    int indexBC = 0;

    while(cnt < N){
        int tempA = A[indexA];
        pair<int, int> tempCB;
        if(indexBC >= M){
            tempCB = make_pair(-1, 0);
        }
        else{
            tempCB = CB[indexBC];
        } 
        int tempC = tempCB.first;

        if(tempA < tempC){
            for(int i = 0; i < tempCB.second; i++){
                ans += tempC;
                cnt++;
                if(cnt == N){
                    break;
                }
            }
            indexBC++;
        }
        else{
            ans += tempA;
            cnt++;
            indexA++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
#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(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

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

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; }

const ll INF=(ll)1e19;
//const int INF=(1<<30);

int main(){
  ll n;
  cin >> n;
  ll mi=INF;
  REP(i,5){
    ll x;
    cin >> x;
    chmin(mi,x); 
  }

  cout << (n+mi-1)/mi + 4 << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef int ut;
typedef complex<int> cli;
typedef vector<ut> VI;
typedef pair<double,int> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr,Vpr> PQ;
const int SIZE=5+1e5;
const LL INF=1LL<<60;

LL N,K;
LL A[SIZE];
int main(){
	REP(i,7){
		cin >> A[i];
	}
	LL ans=A[1]+A[0]/2*2+A[3]/2*2+A[4]/2*2;
	if((A[0] && A[3] && A[4] )){
	   ans=max(ans,A[1]+(A[0]-1)/2*2+(A[3]-1)/2*2+(A[4]-1)/2*2+3);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

struct edge{int to,cost;};

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

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

	ll ans=0;
	int d;
	for(int i=0;i<n;i++){
		if(a[i]>x){//a[i]からa[i]-x減らす　減らしきれなかったらa[i]からも減らす
			ans+=a[i]-x;
			a[i]=x;
//			d=a[i]-x;
//			ans+=d;
//			if(a[i+1]>=d){
//				a[i+1]-=d;
//			}
//			else{
//				a[i]-=d-a[i-1];
//				a[i+1]=0;
//			}
		}
		if(i!=n-1 && a[i]+a[i+1] > x){//a[i+1]からa[i+1]+a[i]-x減らす　減らしきれなかったらa[i]からも減らす
			d=a[i]+a[i+1]-x;
			ans+=d;
			if(a[i+1]>=d){
				a[i+1]-=d;
			}
			else{
				a[i]-=d-a[i-1];
				a[i-1]=0;
			}
		}	
	}
	cout << ans << "\n";

	return 0;
}

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

using namespace std;

int main() {
	int n;
	while ( cin >> n, n ) {
		vector<int> v(n);
		for (int i = 0; i < n; ++i) {
			cin >> v[i];
		}
		int ans = 0;
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < i; ++j) {
				if (v[j] > v[i]) ++ans;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1196
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    string s;
    cin >> s;
    int N = (int)s.size();
    ll ans = 0;
    ll a = 0;
    rep(i, N) {
        if(s[i] == 'A') a++;
        else {
            if(i < N - 1 && s[i] == 'B' && s[i + 1] == 'C') {
                ans += a;
                i++;
            }
            else a = 0;
        }
    }
    output(ans);
    
    return 0;
}


Measured memory_bytes: 720
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll a[10];
char s[10];
int main(){
	scanf("%s",s);
	rep(i,0,4)a[i]=s[i];
	sortup(a,4);
	puts(a[0]==a[1]&&a[1]!=a[2]&&a[2]==a[3]?"Yes":"No");
}

Measured memory_bytes: 128
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
int n, cnt, ans, a[81][81], b[81][81], c, d, tmp, m, h, w, x, y, sum, k, q;
bool dp[81][81][640 * 80 + 1];

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

  cin >> h >> w;
  rep(i, h) rep(j, w) cin >> a[i][j];
  rep(i, h) rep(j, w) cin >> b[i][j];
  dp[1][1][abs(a[0][0] - b[0][0])] = 1;

  rrep(i, 1, h + 1) {
    rrep(j, 1, w + 1) {
      rep(k, 640 * 80 + 1) {
        tmp = dp[i - 1][j][k + abs(a[i - 1][j - 1] - b[i - 1][j - 1])] +
              dp[i - 1][j][abs(k - abs(a[i - 1][j - 1] - b[i - 1][j - 1]))];
        tmp += dp[i][j - 1][k + abs(a[i - 1][j - 1] - b[i - 1][j - 1])] +
               dp[i][j - 1][abs(k - abs(a[i - 1][j - 1] - b[i - 1][j - 1]))];
        tmp += dp[i][j][k];
        dp[i][j][k] = tmp;
      }
    }
  }

  ans = INF;
  rep(i, 640 * 80 + 1) {
    if (dp[h][w][i]) {
      Cout(i);
      return 0;
    }
  }
  return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int n, m;
  cin >> n >> m;
  cout << (1900 * m + 100 * (n - m)) * pow(2, m);
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

int main()
{
  string c;
  cin >> c;
  
  if (("a" == c) || ("e" == c) || ("i" == c) || ("o" == c) || ("u" == c))
  {
    printf("vowel");
  }
  else
  {
    printf("consonant");
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
int mod =1000000007;
const double PI = acos(-1);
int main(){
    ll a,b,c,n,m;cin>>a>>b>>c>>n>>m;
    ll ans =INFL;
    rep(i,max(n,m)+2){
        ll sum =2*i*c;
        sum+=max(0LL,n-i)*a;
        sum+=max(0LL,m-i)*b;
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3652
mm = ['01','02','03','04','05','06','07','08','09','10','11','12']
s = input()
a,b = s[:2], s[2:]

if a in mm and b in mm:
    print('AMBIGUOUS')   
elif a in mm:
    print('MMYY')
elif b in mm:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3060
//Link : https://atcoder.jp/contests/cf16-final/tasks/codefestival_2016_final_f

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005

int s[N];

void solve() {
  int n;scanf("%d ", &n);
  for(int i=0;i<n;++i) {
    scanf("%d ", &s[i]);
  }
  ll ret = 0;
  for(int d=1;d<n;++d) {
    int l = d, r= n-d-1;
    ll tmp = 0;
    while(l<n && r>=0) {
      tmp += s[l] + s[r];
      if(r<=d) {
        break;
      }
      if(r%d!=0)
        ret = max(ret,tmp);
      if(r%d==0) {
        int a = r;
        int k = (n-1-r)/d;
        if(k*d<a) {
          ret = max(ret,tmp);
        }
      }
      l +=d,r -= d;
    }
  }
  printf("%lld\n", ret);
}

int main() {
    //freopen("input.txt","r",stdin);
    solve();
    return 0;
}


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

using namespace std;

#define int long long

const int mod = 998244353;

void solve() {
    int n, s;
    cin >> n >> s;
    int a[n];
    for (int i = 0; i < n; ++i) cin >> a[i];
    int dp[n][s + 1][3];
    for (int i = 0; i < n; ++i) for (int j = 0; j <= s; ++j) for (int k = 0; k < 3; ++k) dp[i][j][k] = 0;
    dp[0][0][0] = 1;
    dp[0][0][1] = 1;
    dp[0][0][2] = 1;
    if (a[0] <= s) dp[0][a[0]][1] = 1;
    if (a[0] == s) dp[0][s][2] = 1;
    for (int i = 1; i < n; ++i) {
        for (int j = 0; j <= s; ++j) dp[i][j][0] = dp[i - 1][j][0];
        for (int j = 0; j <= s; ++j) dp[i][j][1] = (dp[i - 1][j][1] + dp[i - 1][j][0]) % mod;
        for (int j = 0; j <= s; ++j) dp[i][j][2] = (dp[i - 1][j][1] + dp[i - 1][j][2] + dp[i - 1][j][0]) % mod;
        for (int j = 0; j + a[i] <= s; ++j) {
            dp[i][j + a[i]][1] = (dp[i][j + a[i]][1] + dp[i - 1][j][0] + dp[i - 1][j][1]) % mod;
            dp[i][j + a[i]][2] = (dp[i][j + a[i]][2] + dp[i - 1][j][0] + dp[i - 1][j][1]) % mod;
        }
    }
    cout << dp[n - 1][s][2];
    /*vector <vector <int> > dp(n, vector <int> (s + 1));
    vector <vector <int> > pr(n, vector <int> (s + 1));
    dp[0][0] = 1;
    if (a[0] <= s) dp[0][a[0]] = 1;
    for (int i = 1; i < n; ++i) {
        for (int j = 0; j <= s; ++j) dp[i][j] = dp[i - 1][j];
        for (int j = 0; j <= s - a[i]; ++j) dp[i][j + a[i]] = (dp[i][j + a[i]] + dp[i - 1][j]) % mod;
    }
    for (int i = 0; i <= s; ++i) pr[0][i] = dp[0][i];
    for (int i = 1; i < n; ++i) {
        for (int j = 0; j <= s; ++j) pr[i][j] = (pr[i - 1][j] + dp[i][j]) % mod;
    }
    for (int i = 0; i < n; ++i) for (int j = 0; j <= s; ++j) cout << i << ' ' << j << ' ' << pr[i][j] << endl;
    int ans = 0;
    for (int l = 0; l < n; ++l) {
        for (int r = l; r < n; ++r) {
            cout << ans << ' ' << l << ' ' << r << ' ';
            if (r) ans = (ans + pr[r - 1][s]) % mod;
            if (l) ans = (ans - pr[l - 1][s] + mod) % mod;
            if (a[r] <= s) {
                if (s == a[r]) {
                    ans = (ans + 1) % mod;
                }
                else if (l < r) {
                    if (r) ans = (ans + pr[r - 1][s - a[r]]) % mod;
                    if (r > 1) ans = (ans - pr[r - 2][s - a[r]] + mod) % mod;
                }
            }
            cout << ans << endl;
        }
    }
    cout << ans;*/
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 211328
def main():
    M=10**9+7
    r=tuple(tuple((j-k)*9%13 for j in range(10))for k in range(13))
    d=[1]+[0]*12
    for c in input():
      if c>'9':
        d=[sum(d[j]for j in k)%M for k in r]
      else:
        d=[d[(int(c)-k)*9%13]for k in range(13)]
    print(d[5])
main()

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

int main(){
  int n;
  int tmp;
  int num;
  bool possible = false;
  vector<int> p;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> tmp;
    p.push_back(tmp);
  }
  for(int i=0; i<n; i++){
    for(int j=i; j<n; j++){
      num = 0;
      tmp = p.at(i);
      p.at(i) = p.at(j);
      p.at(j) = tmp;
      for(int k=0; k<n-1; k++){
        if(p.at(k) < p.at(k+1)){
          num++;
        }
      }
      if(num==p.size()-1){
        possible = true;
      }
      tmp = p.at(i);
      p.at(i) = p.at(j);
      p.at(j) = tmp;
    }
  }
  if(possible){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256