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

struct node
{
    vector<int> child;
    bool visited = false;
    int parent;
};

void solve(std::istream &ist, std::ostream &ost)
{
    /* ------- 宣言と入力 ------- */

    int N, M;
    ist >> N >> M;

    vector<int> A;
    vector<int> B;

    for (int i = 0; i < M; i++)
    {
        int input1, input2;
        ist >> input1 >> input2;
        A.emplace_back(input1);
        B.emplace_back(input2);
    }

    /* ------- 計算 ------- */

    vector<struct node *> room;

    for(int i = 0; i < N; i++) {
        struct node *tmp = new struct node();
        room.emplace_back(tmp);
    }

    for (int i = 0; i < M; i++)
    {
        room.at(A.at(i) - 1)->child.emplace_back(B.at(i) - 1);
        room.at(B.at(i) - 1)->child.emplace_back(A.at(i) - 1);
    }

    queue<int> q;
    int now;
    q.push(0);
    room.at(0)->visited = true;

    while (!q.empty())
    {
        now = q.front();
        
        for (auto it = room.at(now)->child.begin(); it != room.at(now)->child.end(); it++)
        {
            if (!room.at(*it)->visited)
            {
                q.push(*it);
                room.at(*it)->parent = now;
                room.at(*it)->visited = true;
            }
        }
        q.pop();
    }

    for (int i = 1; i < N; i++)
    {
        if (!room.at(i)->visited)
        {
            ost << "No" << endl;
            return;
        }
    }

    ost << "Yes" << endl;

    for (int i = 1; i < N; i++)
    {
        ost << room.at(i)->parent + 1 << endl;
    }
}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif


Measured memory_bytes: 14492
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll=long long;  
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
	int W,H,N;
	cin >> W >> H >> N;
	int x1=0,x2=W,y1=0,y2=H;
	for(int i=0;i<N;++i){
		int x,y,a;
		cin >> x >> y >> a;
		if(a==1){
			x1=max(x1,x);
		}else if(a==2){
			x2=min(x2,x);
		}else if(a==3){
			y1=max(y1,y);
		}else{
			y2=min(y2,y);
		}
	}
	cout << max(0,x2-x1)*max(0,y2-y1) <<endl;
    return 0;
}


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

typedef long double ld;									// XD
#define int long long
#define PB push_back
#define all(x) (x).begin(),(x).end()
#define ii pair <int,int>
#define mii map <int,int>
#define vi vector<int>
#define vii vector< ii >
#define F first
#define S second
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a; i>=b; --i)
#define sz(x) (int)((x).size())
const double pi=2*acos(0.0);
inline void io(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int mod = 1e9+7;
const int INF = 1e18;
const int maxn = 5e5+5;

// MO's algo 
 
int ar[maxn];
int freq[maxn];
int BLOCK;
int cnt[maxn];
int ans[maxn];

struct Mo{
  int l,r,idx;
}Q[maxn];

int dis = 0;
inline void Add(int pos){
  cnt[ar[pos]]++;
  if(cnt[ar[pos]]==1)dis++;
  
}
inline void Remove(int pos){
  cnt[ar[pos]]--;
  if(cnt[ar[pos]]==0)dis--;
}
bool comp(Mo a, Mo b){
    if(a.l / BLOCK != b.l / BLOCK)
        return a.l < b.l;
    return a.l / BLOCK % 2 ? a.r < b.r : a.r> b.r;
}
void solve(){
	int n, q; cin>>n>>q;
	rep(i, 1, n+1) cin>>ar[i];
	BLOCK = 1201;
	int lt,rt;
	rep(i, 0, q){
		cin>>lt>>rt; 
		Q[i].l = lt;
		Q[i].r = rt;
		Q[i].idx = i;
	}
	sort(Q, Q+q, comp);
	int lb, rb, cl = 0, cr = 0;
	
	rep(i, 0, q){
		lb = Q[i].l;
		rb = Q[i].r;
		while(cl < lb)
			Remove(cl), cl++;
			
		while(cl > lb)
			Add(cl-1), cl--;
			
		while(cr <= rb)
			Add(cr), cr++;
			
		while(cr > (rb+1))
			Remove(cr-1), cr--;	
			
		ans[Q[i].idx] = dis;
	}
	rep(i, 0, q) cout<<ans[i]<<"\n";
}
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0); //io();
    cout<<setprecision(6);
    int tc=1; //cin>>tc;
    while(tc--){
        solve();//cout<<'\n';
    }
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	string s[n];
	for (int i = 0;i<n;i++)cin >> s[i];
	for (int i = 0;i<n;i++) {
		for (int j = 0;j<i;j++) {
			if (s[i] == s[j]) {
				cout << "No" << endl;
				return 0;
			}
		}
		if (i + 1 < n) {
			if (s[i][s[i].size() - 1] != s[i + 1][0]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char in[210000];
int bit[210000];
int sum(int a,int b){
	if(a)return sum(0,b)-sum(0,a-1);
	int ret=0;
	for(;b>=0;b=(b&(b+1))-1)ret+=bit[b];
	return ret;
}
void add(int a,int b){
	for(;a<210000;a|=a+1)bit[a]+=b;
}
vector<int>pos[26];
pair<int,int> p[110000];
int main(){
	scanf("%s",in);
	int n=strlen(in);
	for(int i=0;i<n;i++){
		pos[in[i]-'a'].push_back(i);
	}
	int ki=0;
	for(int i=0;i<26;i++)if(pos[i].size()%2)ki++;
	if(ki>1){
		printf("-1\n");return 0;
	}
	for(int i=0;i<n;i++)add(i+1,1);
	int sz=0;
	for(int i=0;i<26;i++){
		for(int j=0;j<pos[i].size()/2;j++){
			p[sz++]=make_pair(pos[i][j],pos[i][pos[i].size()-1-j]);
		}
	}
	std::sort(p,p+sz);
	long long ret=0;
	for(int i=0;i<sz;i++){
		int L=p[i].first;
		int R=p[i].second;
		ret+=sum(0,L);
		ret+=sum(R+2,n);
		add(L+1,-1);
		add(R+1,-1);
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 3064
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

############
############
############


N, K = l_inpl()
S = input()

nums = []
now = 1 # 今見ている数
cnt = 0
for i in range(N):
    if S[i] == str(now):
        cnt += 1
    else:
        nums.append(cnt)
        now = 1 - now
        cnt = 1

if cnt != 0:
    nums.append(cnt)

if len(nums) % 2 == 0:
    nums.append(0)

ruiseki = [0]

for i in range(1, len(nums)+1):
    ruiseki.append(ruiseki[i-1] + nums[i-1])

ans = 0

for i in range(0, len(nums), 2):
    left = i
    right = min(i+2*K+1, len(nums))
    ans = max(ans, ruiseki[right] - ruiseki[left])

print(ans)

Measured memory_bytes: 48156
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <stack>

using namespace std;

struct Info{
	Info(){ left = height = 0;}
	Info(int arg_left,int arg_height){
		left = arg_left;
		height = arg_height;
	}
	int left,height;
};

int main(){

	int H,W,max_s,tmp,tmp_h;

	scanf("%d %d",&H,&W);

	int** table = new int*[H+1];
	for(int i = 0; i < H+1; i++){
		table[i] = new int[W+1];
	}

	for(int i = 0; i < W+1; i++)table[0][i] = 0;
	for(int i = 0; i < H+1; i++)table[i][W] = 0;

	stack<Info> S;
	Info work;

	max_s = 0;

	for(int i = 1;i <= H; i++){
		for(int k = 0; k < W; k++){
			scanf("%d",&table[i][k]);
			if(table[i][k] == 0){
				table[i][k] = table[i-1][k] + 1;
			}else{
				table[i][k] = 0;
			}
		}

		tmp_h = table[i][0];
		S.push(Info(0,tmp_h));

		for(int k = 1; k < W+1; k++){
			if(table[i][k] > tmp_h){
				S.push(Info(k,table[i][k]));
				tmp_h = table[i][k];
			}else if(table[i][k] == tmp_h){

			}else{
				while(S.empty() == false && S.top().height >= table[i][k]){
					work = S.top();
					S.pop();
					tmp = (k - work.left)*work.height;
					max_s = (max_s >= tmp)?max_s:tmp;
				}
				tmp_h = table[i][k];
				S.push(Info(work.left,table[i][k]));
			}
		}
	}

	printf("%d\n",max_s);

	return 0;
}



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


#define mod                1000000000000000007
#define pi                 3.1415926535897932384626433832795
#define ll                 long long
#define pb                 push_back
#define pii                pair < int , int >
#define vecsort(v)         sort(v.begin(),v.end())
#define lcm(x,y)           (x/__gcd(x,y))*y
#define forn(i,n)          for(i = 0 ; i < n ; i++)
#define deb(x)             cout << #x << " " << x << endl;
#define vecsum(v)          accumulate(v.begin(), v.end(), 0)
#define T(t)               cout << "Case " << t <<": ";
#define fast_cin           ios_base::sync_with_stdio(false);cin.tie(NULL)

int mark[1000005];
int main()
{


        fast_cin;
        ll k ;
        cin >> k ;
        ll curr = 0;
        for( int i = 1 ; i <= k+100 ; i++ ){
            curr *= 10 ;
            curr+=7;
            curr = curr%k;
            if( curr == 0 ){
                cout << i << endl;
                break;
            }
            else if(mark[curr]==1) {
                cout <<  -1 << endl;
                break;
            }
            mark[curr] =1;
        }






}

Measured memory_bytes: 7468
import java.util.Scanner;

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

		if (a == b)
			System.out.println("a == b");
		else if (a > b)
			System.out.println("a > b");
		else
			System.out.println("a < b");
	}
}



Measured memory_bytes: 26084
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp3
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			var q = from p in Console.ReadLine().Split(' ')
					orderby int.Parse(p) descending
					select int.Parse(p);
			var vList = new List<int>(q);

			double value = 0;
			for (int i = 0; i < n - 1; i++)
			{
				value += vList[i] / Math.Pow(2, i + 1);
			}
			value += vList[n - 1] / Math.Pow(2, n - 1);

			Console.WriteLine(value);
		}
	}
}


Measured memory_bytes: 13396
n = int(input())
a = ([list(map(int, input().split())) for _ in range(n)])
a.insert(0,[0,0,0])

dp = [[0,0,0] for _ in range(n+1)]

for i, a in enumerate(a):
  dp_1 = dp[i-1]
  dp[i][0] = max(dp_1[1], dp_1[2]) + a[0]
  dp[i][1] = max(dp_1[0], dp_1[2]) + a[1]
  dp[i][2] = max(dp_1[0], dp_1[1]) + a[2]

print(max(dp[n]))


Measured memory_bytes: 47280
import math

n,k = map(int,input().split(" "))
ret = 0
for i in range(1,n+1):
    if i > k:
        fraq = 0.0
    else:
        fraq = math.ceil(math.log2(k/i))
    ret += (1/n) * (1/2)**fraq

print(ret)



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

int Binary_Search(int kye,int a[],int n);

const int NOT_FOUND=-1;

int main(){
  int n,q;
  int s[100001];
  int t[50001];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s[i];
  }
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>t[i];
  }
  int ans=0;
  for(int i=0;i<q;i++){
    if(Binary_Search(t[i],s,n)!=NOT_FOUND)ans++;
  }
  cout<<ans<<endl;
}

int Binary_Search(int kye,int a[],int n){
  int left,right,mid;
  left=0;
  right=n-1;
  while(1){
    if(left>right)break;
    mid=(left+right)/2;
    if(a[mid]==kye)return mid;
    else if(a[mid]<kye)left=mid+1;
    else if(a[mid]>kye)right=mid-1;
  }
  return NOT_FOUND;
}
  

Measured memory_bytes: 1744
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val H, W, K = in.next().toInt
  val S = new Array[String](H+1)
  for (i <- 1 to H) {
    S(i) = "#" + in.next()
  }

  //
  var ans = Int.MaxValue
  for (_bit <- 0 to 1<<(H-1)) {
    breakable {
      var rowCnt = new Array[Int](H+1)
      var res = 0

      for (w <- 1 to W) {
        var bit = _bit

        val tmpRowCnt = new Array[Int](H+1)
        var row = 1

        for (h <- 1 to H) {
          if (S(h)(w) == '1')
            tmpRowCnt(row) += 1

          if (bit % 2 == 1) {
            row += 1
          }
          bit /= 2
        }

        var flag = false
        for (i <- 1 to H) {
          val now = tmpRowCnt(i)
          if (now > K)
            break()
          else {
            if (rowCnt(i) + now > K)
              flag = true
          }
        }

        if (flag) {
          res += 1
          rowCnt = tmpRowCnt
        }
        else {
          for (i <- 1 to H) {
            rowCnt(i) += tmpRowCnt(i)
          }
        }
      }

      //println(_bit.toBinaryString, res)
      //println(rowCnt.toList)
      ans = ans min (res + _bit.toBinaryString.count(_ == '1'))
    }
    
  }

  println(ans)
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.toList))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 56772
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn permutations(size: usize) -> Permutations {
    Permutations {
        idxs: (1..size + 1).collect(),
        swaps: vec![0; size],
        i: 0,
    }
}
pub struct Permutations {
    idxs: Vec<usize>,
    swaps: Vec<usize>,
    i: usize,
}

impl Iterator for Permutations {
    type Item = Vec<usize>;
    fn next(&mut self) -> Option<Self::Item> {
        if self.i > 0 {
            loop {
                if self.i >= self.swaps.len() {
                    return None;
                }
                if self.swaps[self.i] < self.i {
                    break;
                }
                self.swaps[self.i] = 0;
                self.i += 1;
            }
            self.idxs.swap(self.i, (self.i & 1) * self.swaps[self.i]);
            self.swaps[self.i] += 1;
        }
        self.i = 1;
        Some(self.idxs.clone())
    }
}

fn main() {
    let n: usize = read();
    let ps: Vec<usize> = read_vec();
    let qs: Vec<usize> = read_vec();

    let mut perms = permutations(n).collect::<Vec<_>>();
    perms.sort();

    let mut a: i32 = 0;
    let mut b: i32 = 0;
    for (i, perm) in perms.iter().enumerate() {
        if ps == *perm {
            a = i as i32;
        }
        if qs == *perm {
            b = i as i32;
        }
    }

    println!("{}", i32::abs(a - b));
}


Measured memory_bytes: 8444
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std ;
int main()
{
    long long sum=0;
    int n,k,c=0;
    cin >> n >> k ;
    vector < int > v;
    vector < int > :: iterator it;
    for(int i=0;i<n;i++)
    {
        int x ;
        cin >> x ;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    it=v.begin();
    if(k>=n){cout << "0" << endl;return 0;}
    c=n-k;
    while(c--)
    {
        sum+=*it;
        it++;
    }
    cout << sum << endl;
    return 0 ;
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

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

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll h, w;
    cin >> h >> w;
    vector<string> s(h);
    REP(i, h) cin >> s[i];

    vector<ll> sx, sy;
    REP(i, h) REP(j, w) {
        if(s[i][j] == '#') {
            sx.push_back(j);
            sy.push_back(i);
        }
    }

    vector<vector<ll>> dist(h, vector<ll>(w, LLINF));
    queue<PII> que;
    REP(i, sx.size()) {
        dist[sy[i]][sx[i]] = 0;
        que.push({sx[i], sy[i]});
    }
    while(que.size()) {
        PII v = que.front(); que.pop();
        REP(i, 4) {
            ll nx = v.first + dx[i], ny = v.second + dy[i];
            if(IN(0LL,h,ny) && IN(0LL,w,nx) && dist[ny][nx]==LLINF) {
                dist[ny][nx] = dist[v.second][v.first] + 1;
                que.push({nx, ny});
            }
        }
    }

    ll ret = 0;
    REP(i, h) REP(j, w) chmax(ret, dist[i][j]);
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 41512
n, x, m = map(int, input().split())
def am(a, b):
    return (a * a) % b
l = [x]
u = []
now = x
for i in range(n):
    s = am(now, m)
    if(s in l):
        break
    l.append(s)
    now = s
c = l.index(s)
k = 0
if(0 in l):
    print(sum(l))
else:
    for i in range(c):
        u.append(l.pop(0))
    a = (n-len(u)) // len(l)
    b = (n-len(u)) % len(l)
    print(sum(u) + a * sum(l) + sum(l[:b]))


Measured memory_bytes: 69920
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

using static Input;
using static Util;
class Program
{
    static int N;
    static string S;
    static void INPUT()
    {
        N = NextInt();
        S = NextString();
    }
    static void OUT()
    {
        long r_count = S.Count(__ => __ == 'R');
        long g_count = S.Count(__ => __ == 'G');
        long b_count = S.Count(__ => __ == 'B');

        var omit = 0;
        for (var i = 0; i < S.Length; i++)
        {
            for (var ii = 1; i + ii * 2 < S.Length; ii++)
            {
                if (S[i] != S[i + ii] && S[i + ii] != S[i + ii * 2] && S[i] != S[i + ii * 2]) omit++;
            }
        }

        Console.WriteLine((r_count * g_count * b_count) - omit);
    }
    static void Main(string[] args)
    {
#if DEBUG  
        //TESTINPUT();
        INPUT();

#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{        
}




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

int main(){
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int ans = 0;
    //お得
    if(a+b >= c*2){
        //余りなし
        int ans1 = 0;
        ans1 += min(x, y) * 2 * c;
        if(x > y) ans1 += (x-y) * a;
        else ans1 += (y-x) * b;

        //cのみ
        int ans2 = 0;
        ans2 += 2 * c * max(x, y);

        //統合
        ans = min(ans1, ans2);
    }

    //単品のみ
    else{
        ans += a * x + b * y;
    }

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


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

int main(){
	int x, y, z;
	cin >> x >> y >> z;
	if(x == 7){
		if (y == 5 && z ==5){
			cout << "YES" << endl;
		}
			else{
			cout << "NO" << endl;
		}
	}
	else if (y == 7){
		if (x == 5 && z == 5){
			cout << "YES" << endl;
		}
			else{
				cout << "NO" << endl;
		}
	}
	else if (z == 7) {
		if (x == 5 && y == 5){
			cout << "YES" << endl;
		}
			else{
			cout << "NO" << endl;
		}
	}
	else{
		cout << "NO" << endl;
	}
}


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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	int n ;
	cin >> n ;
	vector<string> s(n);
	rep(i,n) cin >>s[i];
	map<string,int> MAP;
	rep(i,n){
		MAP[s[i]] ++ ;
	}
	//これらをpairに押し込む
	vector<pair<int,string>> p(0);
	for(auto x: MAP){
		//firstが文字列
		p.push_back(make_pair(x.second,x.first));
	}
	SORT(p);
	rSORT(p);//大きい順担っている。
	int num = p[0].first;
	int i = p.size() - 1;
	while(i+1){
		if(p[i].first == num){
			cout << p[i].second << endl;
			i--;
		} else{
			i--;
		}
		
	}

}


Measured memory_bytes: 30704
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m; cin >> n >> m;
    vvll a(n, vll(m, 0));
    REP(i, n) REP(j, m) {cin >> a[i][j]; a[i][j]--;}

    ll ans = HIGHINF;
    V<bool> use_sports(m, true);
    REP(_, m-1) {
        vll num_sports(m, 0);
        REP(i, n) REP(j, m) {
            if (use_sports[a[i][j]]) {
                num_sports[a[i][j]]++;
                break;
            }
        }
        ll maxa=0, maxi=-1;
        REP(i, m) {
            if (num_sports[i] > maxa) {
                maxa = num_sports[i]; maxi = i;
            }
        }
        chmin(ans, maxa);
        use_sports[maxi] = 0;
    }
    if (n==1) cout << 1 << endl;
    else if (m==1) cout << n << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc139_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] kazu = Console.ReadLine().Split(' ');
            int A = int.Parse(kazu[0]);
            int B = int.Parse(kazu[1]);
            int consent = 1;
            int tap = 0;

            for(int i = 0; consent <= B; i++)
            {
                if(consent < B)
                {
                    consent = consent - 1 + A;
                    tap = tap + 1;

                    if(consent > B)
                    {
                        Console.WriteLine(tap);
                    }
                    
                }
                else if(consent == B)
                {
                    Console.WriteLine(tap);
                    break;
                }
            }
            Console.Read();
        }
    }
}


Measured memory_bytes: 13140
n=int(input())
t,a=tuple(map(int,input().split()))
h=list(map(int,input().split()))

k=[t-h[i]*0.006 for i in range(n)]
l=10000
p=0
for i in range(n):
    if abs(a-k[i])<l:
        l=abs(a-k[i])
        p=i+1
print(p)

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

int main() {
	// 0-ind
	int N, Q; cin >> N >> Q;
	dsu d(N);
	while(Q--) {
		int t, u, v; cin >> t >> u >> v;
		if (t == 0) {
			d.merge(u, v);
		} else {
			cout << d.same(u, v) << endl;
		}
	}
}

Measured memory_bytes: 4064
h,w = map(int,input().split())
table = [0]*h
for i in range(h):
    table[i] = list(input())

for i in range(h):
    for j in range(w):
        if table[i][j] == "#":
            if i - 1 >= 0 and table[i-1][j] == "#":
                ok = True
            elif i + 1 <= h-1 and table[i+1][j] == "#":
                ok = True
            elif j - 1 >= 0 and table[i][j-1] == "#":
                ok = True
            elif j + 1 <= w-1 and table[i][j+1] == "#":
                ok = True
            else:
                ok = False
            if ok == False:
                 print("No")
                 exit()
print("Yes")

Measured memory_bytes: 39152
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define pii pair<int,int>
#define prec(n) fixed<<setprecision(n)
#define MOD 1000000007
#define eps 1e-8
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

int f(int n){
    int ans=0;
    while(n){
        n=n/10;
        ans++;
    }
    if(ans%2==1)return 1;
    return 0;
}

signed main(){
    FASTER;
    int n,ans=0;cin>>n;
    for(int i=1;i<=n;i++){
        ans+=f(i);
    }
    cout<<ans;
}






Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

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

  if(b%a == 0){
    cout << a + b << endl;
  } else {
    cout << b - a << endl;
  }

  return 0;
}

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

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;


const int MOD = 998244353;

void sadd(int &a, int b)
{
    a += b;
    if (a >= MOD) a -= MOD;
}
int add(int a, int b)
{
    sadd(a, b);
    return a;
}
int mul(int a, int b)
{
    return (a * 1LL * b) % MOD;
}
void smul(int &a, int b)
{
    a = mul(a, b);
}

const int N = (int) 3e5 + 100;
int fact[N], rfact[N], ri[N];


int getC(int n, int k)
{
    if (k < 0 || k > n) return 0;
    return mul(fact[n], mul(rfact[n - k], rfact[k] ) );
}

int solve(int a, int c, int d)
{
    if (a == 0 && c == 0 && d == 0) return 1;
    return getC(a + c + d - 1, c + d);
}

int solve(int n, int m, char sa[], char sb[], char sc[], char sd[] )
{
    int a = 0, b = 0;
    int c = 0, d = 0;
    for (int i = 0; i < n; i++)
    {
        a += sa[i] - '0';
        b += sb[i] - '0';
    }
    for (int i = 0; i < m; i++)
    {
        c += sc[i] - '0';
        d += sd[i] - '0';
    }

    if (a == 0 && b == 0 && c == 0 && d == 0)
    {
        printf("1\n");
        exit(0);
    }

    int _c = 0, _d = 0;

    int ans = 0;
    int sumDown = 0;
    for (int i = m - 1; i >= 0; i--)
    {
        if (sc[i] == '0' && sd[i] == '0') continue;

        c -= (sc[i] - '0');
        d -= (sd[i] - '0');

        eprintf("b = %d, _c = %d, _d = %d\n", b, _c, _d);
        sadd(sumDown, solve(b, _c, _d) );
        if (sc[i] == '1' && sd[i] == '1')
            smul(sumDown, 2);

        _c += (sc[i] - '0');
        _d += (sd[i] - '0');
    
        int cur = solve(a, c, d);
        eprintf("%d) up = %d, sumDown = %d\n", i, cur, sumDown);
        
        smul(cur, sumDown);

        sadd(ans, cur);
    }
    return ans;
}


void init()
{
    fact[0] = 1;
    rfact[0] = 1;
    ri[1] = 1;

    for (int i = 1; i < N; i++)
    {
        if (i >= 2) ri[i] = MOD - mul(ri[MOD % i], MOD / i);
        fact[i] = mul(fact[i - 1], i);
        rfact[i] = mul(rfact[i - 1], ri[i] );

        if (mul(i, ri[i] ) != 1) throw;
    }
}


char a[N], b[N], c[N], d[N];
int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    init();

    int n, m;
    scanf("%d%d", &n, &m);
    scanf("%s%s%s%s", a, b, c, d);

    int ans = 0;
    sadd(ans, solve(n, m, a, b, c, d) );
    sadd(ans, solve(m, n, c, d, a, b) );
    printf("%d\n", ans);


	return 0;
}



Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*
ユニオンみつけて、一番大きいユニオン数
*/
vector<vector<ll>> G;
vector<bool> seen;
struct UnionFind{
  vector<ll> par,siz;
  
  UnionFind(ll N):par(N+1),siz(N+1,1){
    for(int i=0; i<=N; i++)
      par[i]=i;
  }
  
  void mkpar(ll n, ll set){
    for(auto next_n: G[n]){
      if(seen[next_n]) continue;
      seen[next_n]=true;
      par[next_n]=set;
      mkpar(next_n, set);
    }
  }
  
  ll root(ll x){
    if(par[x]==x)
      return x;
    return par[x]=root(par[x]);
  }
  
  void unite(ll x, ll y){
    ll rx=root(x), ry=root(y);
    if(rx==ry)
      return;
    par[ry]=rx;
    siz[rx]+=siz[ry];    
  }
  
  bool issame(ll x, ll y){
    return root(x)==root(y);
  }
  
  ll size(ll x){
    return siz[root(x)];
  }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
 
  ll N,M; cin>>N>>M;
  G.assign(N+1, vector<ll>());
  seen.assign(N+1,false);
  for(int i=0; i<M; i++){
    ll a,b; cin>>a>>b;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  UnionFind tree(N);
  seen[1]=true;
  for(int i=1; i<=N; i++) tree.mkpar(i,i);
  map<ll,ll> MP;
  for(ll i=1; i<=N; i++)
    MP[tree.par[i]]++;
  ll ans = 0;
  for (auto v: MP)
    chmax(ans, v.second);
  cout<<ans<<endl;
}


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

#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()  
{ 
    FAST_INP;
    int k;
	string s; 
    cin >> k >> s;
    if(s.size()>k) {
    	for(int i=0;i<k;i++) {
    		cout << s[i];
		}
		cout << "..." << "\n";
	} else {
		cout << s << "\n";
	}
    return 0;
} 

Measured memory_bytes: 3612
import sys
n=int(sys.stdin.readline())
h=list(map(int,sys.stdin.readline().split()))

ma=0
cnt=0
first=1
for i in range(n):
    if first==1:
        pre=h[i]
        first=0
    elif h[i]<=pre:
        cnt+=1
        pre=h[i]
    else:
        ma=max(ma,cnt)
        cnt=0
        pre=h[i]
print(max(ma,cnt))


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  vector<int> v(3);
  scanf("%d %d %d", &v[0], &v[1], &v[2]);
  sort(v.begin(), v.end());
  int ans = v[2] - v[1];
  v[0] += ans;
  v[1] += ans;
  if (v[0] < v[1]) {
    int cnt = (v[1] - v[0] + 1) / 2;
    v[0] += (2 * cnt);
    ans += cnt;
    if (v[0] != v[1]) { ++ans; }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.000001
#define pi 3.141592653589793
#define pii pair<int , int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack <int>
#define stll stack <ll>
#define mseti set <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(20)//use fixed before stp
#define endl '\n'
int main()
{  
    FAST
    ll n;
    cin>>n;
    ll a[n][3],dp[n][3];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    dp[0][0]=a[0][0];dp[0][1]=a[0][1];dp[0][2]=a[0][2];
    for(ll i=1;i<n;i++)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
        dp[i][2]=max(dp[i-1][1],dp[i-1][0])+a[i][2];
    }
    ll ans=max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
    cout<<ans;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

int main()
{
	int A,B;
	cin>>A>>B;
	if((A+B) % 2 == 1)
	{
		cout<<"IMPOSSIBLE"<<endl;
	}
	else
	{
		cout<<(A+B)/2<<endl;
	}
	return 0;
}

Measured memory_bytes: 764
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    x,y = LI()
    s = y-2*x
    if s < 0 or s&1:
        print("No")
        return
    b = s >> 1
    a = x-b
    if a < 0:
        print("No")
    else:
        print("Yes")
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 67428
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fucking interest
*******************************
Higher, higher, even higher, to the point you won’t even be able to see me
https://www.a2oj.com/Ladder16.html
*******************************
300IQ as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int A = Integer.parseInt(st.nextToken());
         int V = Integer.parseInt(st.nextToken());
         st = new StringTokenizer(infile.readLine());
         int B = Integer.parseInt(st.nextToken());
         int W = Integer.parseInt(st.nextToken());
         int T = Integer.parseInt(infile.readLine());
         //solve
         int dist = Math.abs(A-B);
         if(V <= W)
            System.out.println("NO");
         else
         {
            int speed = V-W;
            double time = 1.0*dist/speed;
            if(time <= T)
               System.out.println("YES");
            else
               System.out.println("NO");
         }
      }
   }

Measured memory_bytes: 32772
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
 
using namespace std;
 
void addWordCount(const vector<string>& cards, map<string, int>& wordCount);
void subWordCount(const vector<string>& cards, map<string, int>& wordCount);
int getMaxValue(const map<string, int>& wordCount);
 
 
int main() {
    int numOfBlueCard = 0;
    cin >> numOfBlueCard;
    vector<string> blueCards;
    for (int i = 0; i < numOfBlueCard; ++i) {
        string blueCard;
        cin >> blueCard;
        blueCards.push_back(blueCard);
    }
 
    int numOfRedCard = 0;
    cin >> numOfRedCard;
    vector<string> redCards;
    for (int i = 0; i < numOfRedCard; ++i) {
        string redCard;
        cin >> redCard;
        redCards.push_back(redCard);
    }
    
    map<string, int> wordCount;
    addWordCount(blueCards, wordCount);
    subWordCount(redCards, wordCount);
    
    auto maxValueWord = std::max_element(wordCount.begin(), wordCount.end(),
    [](const pair<string, int>& p1, const pair<string, int>& p2) {
        return p1.second < p2.second; });
    
    int maxValue = 0;
    if(maxValueWord->second >= 0) {
        maxValue = maxValueWord->second;
    }
    cout << maxValue << endl;
}
 
void addWordCount(const vector<string>& cards, map<string, int>& wordCount) {
    for (string card : cards) {
        ++wordCount[card];
    }
}
 
void subWordCount(const vector<string>& cards, map<string, int>& wordCount) {
    for (string card : cards) {
        --wordCount[card];
    }
}
 
int getMaxValue(const map<string, int>& wordCount) {
    int maxValue = 0;
    for (auto word : wordCount) {
        if (word.second > maxValue) maxValue = word.second;
    }
    return maxValue;
} 


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n, K, s;
ll dp[30][100][200];

int main() {
	while (cin >> n >> K >> s&&n + K + s) {
		REP(i, 30)REP(j, 100)REP(k, 200)dp[i][j][k] = 0;
		dp[0][0][0] = 1;
		REP(i, n) {
			REP(j, 100) {
				REP(k, 200) {
					dp[i + 1][j][k] += dp[i][j][k];
					dp[i + 1][j][k] %= INF;
					dp[i + 1][j + 1][k + (i + 1)] += dp[i][j][k];
					dp[i + 1][j + 1][k + (i + 1)] %= INF;
				}
			}
		}
		cout << dp[n][K][s] << endl;
	}
}

Measured memory_bytes: 7696
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <chrono>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;

    cout << (a1 + a2 + a3 >= 22 ? "bust" : "win") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <unordered_map>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

int main()
{
    ll X, K, D;
    scanf("%lld", &X);
    scanf("%lld", &K);
    scanf("%lld", &D);

    ll progress = min(abs(X) / D, K);
    ll ans = abs(X) - D * progress;
    K -= progress;
    if (K % 2 == 1)
    {
        ans = abs(ans - D);
    }

    printf("%lld\n", ans);
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/08  Problem: ABC 094 C / Link: http://abc094.contest.atcoder.jp/tasks/abc094_c  ----- */


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

	LL N; 
	cin >> N;
	
	vector<LL> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	auto b = a;
	SORT(b);
	LL LC = b[N / 2 - 1];
	LL RC = b[N / 2];
	FOR(i, 0, N) {
		int idx = lower_bound(ALL(b), a[i]) - b.begin();
		if (idx <= N / 2 - 1) {
			cout << RC << endl;
		}
		else {
			cout << LC << endl;
		}
	}
	

	return 0;
}


Measured memory_bytes: 5376
import java.util.*;
import java.util.function.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
	Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int W = s.nextInt();
		int[] v = new int[N];
		int[] w = new int[N];
		for(int i = 0; i < N; i++) {
			v[i] = s.nextInt();
			w[i] = s.nextInt();
		}
		
		long[][] dp = new long[N + 1][100 * 1010];
		
		for(int i = 1; i < N + 1; i++) {
			for(int j = 0; j < W + 1; j++) {
				dp[i][j] = Math.max(dp[i - 1][j], dp[i][j]);
				dp[i][j + w[i-1]] = Math.max(dp[i - 1][j] + v[i-1], dp[i][j + w[i-1]]);
			}
		}
		
		System.out.println(dp[N][W]);	
    }
}


Measured memory_bytes: 130660
def main():
    n = int(input())
    
    l = []
    for _ in range(n):
        d1,d2 = tuple(map(int,input().split()))
        l.append(1 if d1==d2 else 0)

    for i in range(n-2):
        if sum(l[i:i+3])==3:
            print("Yes")
            return

    print("No")
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 9064
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

long long mod=1000000007;

int main(){
	long long n;
	cin >> n;
	long long x[1000001]={};
	x[0]=1;
	x[1]=n;
	x[2]=n*n%mod;
	for(int i=3;i<=n;i++){
		x[i]=(2*(x[i-1]+mod)-x[i-2]+x[i-3]-1)%mod;
	}
	cout << x[n] << endl;
	return 0;
}

Measured memory_bytes: 8064
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>


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

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long



double a,b,x;
//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> a >> b >> x;

  double max = a * a * b;

  if(x >= 0.5 * max){
  	cout << setprecision(10) << atan((2*b/a) - ((2 * x)/(a*a*a))) * 180.0 / M_PI << endl;
  }
  else{
  	double tmp = atan((2 * x)/(a * b * b)) * 180.0 / M_PI;
  	cout << setprecision(10) << 90 - tmp << endl;
  }

  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 256