akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{ min, max };

macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

#[allow(dead_code)]
const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let x: i32 = sc.cin();
    let ls: Vec<i32> = (0..n).map(|_| sc.cin()).collect();
    let mut ac = 0;
    let mut ans = 0;
    for i in 0..n {
        ac += ls[i];
        if ac <= x { ans = i + 1; }
    }
    put!(ans + 1);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
#define mod 1000000007
#define PI 3.14159265358979323846
#define inf 100000000000000000
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define sz(V) (int)V.size()
#define _ <<" "<<
#define forn(i, n) for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long int ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;

map< ii ,int > mp;
vector<int >v[5005];
signed main() {
    SPEED;
  	//freopen("test.txt","r",stdin);
    int n;cin>>n;

    int b[n-1];
    forn(i,n-1)cin>>b[i];

    int a[n];
    forn(i,n)a[i] = INT_MAX;

    a[0] = b[0];
    a[1] = b[0];
    for(int i=1;i<n-1;i++)
    {	
    	a[i] = min(a[i] , b[i]);
    	a[i+1] = min(a[i+1] , b[i]);
    }

    ll sum = 0;
    forn(i,n)sum += a[i];

    cout<<sum;

}	
 
 

Measured memory_bytes: 384
fn b() {
    input!{
        n: u32,
        d: f64,
        xy: [(f64, f64); n]
    }

    let mut ans = 0;
    for p in xy {
        if (p.0.powf(2.0) + p.1.powf(2.0)).sqrt() <= d {
            ans += 1;
        }
    }
    println!("{}", ans);
}

use proconio::{input, marker:: Chars};

fn main() {
    b();
}


Measured memory_bytes: 7832
#include<bits/stdc++.h>
#define int long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repr(i,x,y) for(int i=x;i>=y;i--) 
#define mod 1000000007
#define ff first
#define ss second
using namespace std;
long long pow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
void Onigiri()
{
  int n;
  cin>>n;
  int ok=0;
  map<pair<int,pair<int,int>>,int>mpp;
  int za=0,zb=0,zab=0;
  rep(i,0,n)
  {
    int x,y;
    cin>>x>>y;
    
    if(x==0&&y==0){zab++;continue;}
    if(x==0){za++;continue;}
    if(y==0){zb++;continue;}

    int g=__gcd(abs(x),abs(y));
    x/=g;
    y/=g;
    if((x<0&&y<0)||(x>0&&y>0))
      mpp[{abs(x),{abs(y),1}}]++;
    else mpp[{abs(x),{abs(y),-1}}]++;
  }

  int tot=0;

  for(auto x:mpp)
    tot+=x.ss;
  tot+=za;
  tot+=zb;
  int ans=1;
  set<pair<int,pair<int,int>>>s;
  for(auto x:mpp)
  {
    if(s.find(x.first)!=s.end())continue;
    int a=x.ff.ff;
    int b=x.ff.ss.ff;
    int sign=x.ff.ss.ss;
    int num1=x.ss;
    int tot2=tot;
    if(mpp.find({b,{a,sign*(-1)}})!=mpp.end()){

      int num2=mpp[{b,{a,sign*(-1)}}];
      int p2=(pow(2LL,num2,mod));
      int p1=(pow(2LL,num1,mod));
      ans=(ans*((p1+p2-1+mod)%mod))%mod;
      s.insert({b,{a,sign*(-1)}});
      s.insert({a,{b,sign}});
    
    }
    else {
      int p1=(pow(2LL,num1,mod));
      ok=1;
      ans=(ans*(p1)%mod)%mod;
    }
  }

  int p1=(pow(2LL,za,mod));
  int p2=(pow(2LL,zb,mod));
  if(za>0&&zb>0)ans=(ans*((p1+p2-1+mod)%mod))%mod;
  else if(za>0||zb>0){ok=1;ans=((ans*p1)%mod*p2)%mod;}
  cout<<(ans+(zab-1)+mod)%mod;
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifdef Zoro
   freopen("in", "r", stdin);freopen("out", "w", stdout);
   #endif  
 
   int t=1; 
    //cin>>t;
 
   while(t--)
   {Onigiri();cout<<"\n";}

   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;
   return 0;
}

Measured memory_bytes: 19416
use std::cmp::min;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:u32 = read();
    let m:usize = read();
    let x:usize = read();
    // let mut c:usize = 0;
    // let mut l:Vec<u32> = (0..m).map(|_| read()).collect();
    // l.sort();
    // for i in &l {
    //     if i > &x {
    //         break
    //     }
    //     c += 1;
    // }
    // println!("{}", min(c, m-c));
    let l:Vec<usize> = (0..m).map(|_| read()).collect();
    let ans:Vec<&usize> = l.iter().filter(|&i| *i > x).collect();
    println!("{}", min(ans.len(), m-ans.len()));
}


Measured memory_bytes: 4352
MOD = 1000000007

S = input()
N = len(S)

dp = [[0 for j in range(13)] for i in range(N + 1)]
dp[0][0] = 1

rem = [[0 for k in range(10)] for j in range(13)]

for j in range(13):
    for k in range(10):
        rem[j][k] = (10 * j + k) % 13

for i in range(N):
    for j in range(13):
        if S[i] == '?':
            for k in range(10):
                dp[i + 1][rem[j][k]] += dp[i][j]
                dp[i + 1][rem[j][k]] %= MOD
        else:
            k = int(S[i])
            dp[i + 1][rem[j][k]] += dp[i][j]
            dp[i + 1][rem[j][k]] %= MOD

print(dp[N][5])

Measured memory_bytes: 68324
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	//数値の入力
		int h1 = sc.nextInt();
        int m1 = sc.nextInt();
        int h2 = sc.nextInt();
        int m2 = sc.nextInt();
        int k = sc.nextInt();
        int H = 0;
        int M = 0;
        int sum = 0;

      if(m1<m2){
        H = h2 - h1;
        M = m2 - m1;
      }else{
        H = h2 - h1 - 1;
        M = m2+60 - m1;
     }
      sum = M + 60*H;
      if((sum - k)>0){
        System.out.println(sum-k);
      }else{
        System.out.println(0);
      }
    }
}

Measured memory_bytes: 35684
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

struct Dice
{
	int label[6];

	int getLabel(int id)
	{
		return label[id];
	}

	void create()
	{
		for (int i = 0; i < 6; i++)
		{
			cin >> label[i];
		}
	}

	void roll(string s)
	{
		int buf[6];
		for (int i = 0; i < 6; i++)
		{
			buf[i] = label[i];
		}

		if (s == "E")
		{
			label[0] = buf[3];
			label[2] = buf[0];
			label[3] = buf[5];
			label[5] = buf[2];
		}
		else if (s == "N")
		{
			label[0] = buf[1];
			label[1] = buf[5];
			label[4] = buf[0];
			label[5] = buf[4];
		}
		else if (s == "S")
		{
			label[0] = buf[4];
			label[1] = buf[0];
			label[4] = buf[5];
			label[5] = buf[1];
		}
		else if (s == "W")
		{
			label[0] = buf[2];
			label[2] = buf[5];
			label[3] = buf[0];
			label[5] = buf[3];
		}
	}
};

int main()
{
	Dice dice;
	dice.create();

	string str;
	cin >> str;
	for (int i = 0; i < str.length(); i++)
	{
		dice.roll(str.substr(i, 1));
	}

	cout << dice.getLabel(0) << endl;
}


Measured memory_bytes: 3160
s = str(input())
ans = 0
for i in range(len(s)//2 - 1, 0, -1):
  s1, s2 = s[:i], s[i:2*i]
  #print(i, s1, s2)
  if s1 == s2:
    ans = 2*i
    break
print(ans)

Measured memory_bytes: 3060
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

int main(void)
{
    string S;
    cin >> S;

    if(S <= "2019/04/30")
        cout << "Heisei" << endl;
    else
        cout << "TBD" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
#include <iomanip>
#include <fstream>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;
typedef long long ll;
typedef pair<int,int> pii;

int x[3000];
int y[3000];

int main() {
  int n;
  while(cin >> n,n) {
    map<pii, int> mp;
    REP(i,n) {
      cin >> x[i] >> y[i];
      mp[pii(x[i], y[i])] = 1;
    }
    int res = 0;
    REP(i,n) {
      REP(j,i) {
        int dy = x[i]-x[j];
        int dx = -(y[i]-y[j]);
        if (dx == 0 && dy == 0) continue;
        
        
        REP(k,2) {
          if (mp.count(pii(x[j]+dx, y[j]+dy)) &&
              mp.count(pii(x[i]+dx, y[i]+dy))) {
            res = max(res, dx*dx + dy*dy);
          }
          dx = -dx;
          dy = -dy;
        }
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 1404
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS

int main(int argc, char const *argv[])
{
	int cnt = 0;
	char s[7];
	scanf("%s",s);
	for (int i = 0; i < 3; ++i)
	{
		if(s[i] == '1')	++cnt;
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 128
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()

	pt, px, py := 0, 0, 0

	for i := 0; i < n; i++ {
		t, x, y := nextInt(), nextInt(), nextInt()
		dist := abs(x-px) + abs(y-py)
		dt := t - pt

		if dt < dist {
			fmt.Println("No")
			return
		}
		if dt&1 != dist&1 {
			fmt.Println("No")
			return
		}

		pt = t
		px = x
		py = y
	}
	fmt.Println("Yes")
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


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

int main(){
    int X, Y, Z;
    int a = 0;
    cin >> X >> Y >> Z;
    a = Y;
    Y = X;
    X = a;
    a = X;
    X = Z;
    Z = a;
    cout << X << " " << Y << " " << Z << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
using namespace std;
#define limit 1000010

int main(void){
  int* table=(int*)malloc(sizeof(int)*limit);
  for(int i=0;i<limit;i++){
    table[i]=1;
  }
  table[0]=0;
  table[1]=0;
  int k;
  for(int i=0;i<limit;i++){
    if(table[i]==0)continue;
      k=2;
      while(k*i<=limit){
        table[k*i]=0;
        k++;
      }
  }
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    int retval=0;
    for(int i=1;i<=n/2;i++){
      if(table[i]==1 && table[n-i]==1){
        retval++;
      }
    }
    cout<<retval<<endl;
  }

  return 0;
}



Measured memory_bytes: 6908
import java.util.Scanner;

public class Main{
 public static void main(String[] args) {
     Scanner sc = new Scanner(System.in);
     int i =0;
	 while(true){
		 i = i + 1;
		 int x = sc.nextInt();
		 if ( x == 0 ) break;
		 System.out.println(String.format("Case %d: %d",i,x));
	 }
 }
}



Measured memory_bytes: 61476
#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 a;
  string b;
  cin >> a;
  cin >> b;
  if (a == b.substr(0,a.length())) {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3624
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
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; }

int main(){
    int n , ans=0;
    cin >>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];

    rep(i,n){
        if((i+1)%2==0) continue;
        if(a[i]%2==1) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
    int r;
    cin >> r;
    if (r < 1200) {
        cout << "ABC" << "\n";
    } else if (r >= 1200 && r < 2800) {
        cout << "ARC" << "\n";
    } else {
        cout << "AGC" << "\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

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 = 1001001001;
const long long INFL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  int a, b, c, d, e, f;
  int water = 0;
  int sugar = 0;
  double m = 0.0;

  cin >> a >> b >> c >> d >> e >> f;

  for (int i = 0; i <= f / (100 * a); i++) {
    int rem_1 = f - 100 * a * i;
    for (int j = 0; j <= rem_1 / (100 * b); j++) {
      int rem_2 = rem_1 - 100 * b * j;
      int w = 100 * a * i + 100 * b * j;
      if (w == 0 || w > f) continue;
      int max_sugar = min(rem_2, e * w / 100);
      for (int k = 0; k <= max_sugar / c; k++) {
        int rem_3 = max_sugar - k * c;
        for (int l = 0; l <= rem_3 / d; l++) {
          int s = k * c + l * d;
          double n = (100 * s) / double(w + s);
          if (n >= m) {
            m = n; water = w; sugar = s;
          }
        }
      }
    }
  }

  cout << water + sugar << " " << sugar << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
n=int(input())
a_list=list(map(int,input().split()))
a_c=[]
Sum=0
for i in a_list:
    a_c.append(Sum+i)
    Sum+=i
ans_p=0
count=0
for i in range(n):
    if i%2==0:
        if a_c[i]+count<=0:
            ans_p+=1-a_c[i]-count
            count=1-a_c[i]
    else:
        if a_c[i]+count>=0:
            ans_p+=1+a_c[i]+count
            count=-1-a_c[i]
ans_n=0
count=0
for i in range(n):
    if i%2==1:
        if a_c[i]+count<=0:
            ans_n+=1-a_c[i]-count
            count=1-a_c[i]
    else:
        if a_c[i]+count>=0:
            ans_n+=1+a_c[i]+count
            count=-1-a_c[i]
ans=min(ans_p,ans_n)
print(ans)


Measured memory_bytes: 59732
#include<bits/stdc++.h>
using namespace std;
typedef pair< int, int > Pi;
typedef pair< Pi, int > Pii;
#define dp second
const int INF = 1 << 30;

int dist( Pi a, Pi b){
  return abs( a.first - b.first) + abs( a.second - b.second);
}


int main()
{
  int w, h;
  Pi goal;

  while( cin >> w >> h, w){
    vector< Pii > num[2500];
    int size = 0, hoge;

    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
        string str;
        cin >> str;
        if(str != ".") {
          if(str == "S") num[0].push_back( Pii( Pi( i, j), 0));
          else if(str == "G") goal = Pi( i, j);
          else {
            num[hoge = atoi(str.c_str())].push_back( Pii( Pi( i, j), INF));
            size = max( hoge, size);
          }
        }
      }
    }
    num[++size].push_back( Pii( goal, INF));

    for(int idx = 1; idx <= size; idx++){ // 今の位置
      for(int i = num[idx].size() - 1; i >= 0; i--){ // いまどこ
        for(int j = num[idx - 1].size() - 1 ; j >= 0; j--){ // まえどこ
          num[idx][i].dp = min( num[idx][i].dp, num[idx - 1][j].dp + dist( num[idx - 1][j].first, num[idx][i].first));
        }
      }
    }
    cout << num[size][0].dp << endl;
  }
  return(0);
}

Measured memory_bytes: 1392
from collections import defaultdict
import heapq

N = int(input())
INF = float('inf')
edges = [list(map(int, input().split())) for _ in range(N-1)]
nodes = defaultdict(list)

for e in edges:
    nodes[e[0] - 1].append((e[2], e[1] - 1))
    nodes[e[1] - 1].append((e[2], e[0] - 1))


Q, K = map(int, input().split())
queries = [list(map(int, input().split())) for _ in range(Q)]

def dijkstra(x):
    que = []
    heapq.heapify(que)
    dist = [INF for _ in range(N)]
    dist[x] = 0
    heapq.heappush(que, (0, x))

    while que:
        p = heapq.heappop(que)
        v = p[1]
        if dist[v] < p[0]:
            continue
        for e in nodes[v]:
            if dist[e[1]] > dist[v] + e[0]:
                dist[e[1]] = dist[v] + e[0]
                heapq.heappush(que, (dist[e[1]], e[1]))

    return dist

distk = dijkstra(K - 1)

for q in queries:
    x, y = q[0] - 1, q[1] - 1
    print(distk[x] + distk[y])



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

int main(){
  string s;
  int i,judge=0;
  cin>>s;
  if(s[0]!='A'){
    cout<<"WA"<<endl;
    return 0;
  }
  for(i=2;i<s.size()-1;i++){
    if(s[i]=='C'){
      break;
    }
    if(i==s.size()-2){
      cout<<"WA"<<endl;
      return 0;
    }
  }
  for(i=1;i<s.size();i++){
    for(char c='a';c<='z';c++){
      if(s[i]==c){
        judge++;
        break;
      }
    }
  }
  if(judge==(int)s.size()-2){
    cout<<"AC"<<endl;
  }else{
    cout<<"WA"<<endl;
  }
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;

    int ans;

    bool t = true;
    if(N < K) t = false;

    if(t)
        ans = K*X + (N-K)*Y;
    else
        ans = N*X;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define LL long long
LL tate[2000][2000],yoko[2000][2000];
LL N,M,K,ans,r;

string s[2001];


int main() {

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

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			yoko[i][j] = 0;
			tate[i][j] = 0;
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			if (s[i][j] == '.') {
				if(j!=0)yoko[i][j]=yoko[i][j-1]+1;
				else yoko[i][j]++;
			}
		}
	}

	for (int i = 0; i < N; i++) {
		for (int j = M - 1; j > -1; j--) {
			if (s[i][j] == '.') {
				if (j != M-1)yoko[i][j]=max(yoko[i][j], yoko[i][j + 1]);
			}
		}
	}

	for (int j = 0; j < M; j++) {
		for (int i = 0; i < N; i++) {		
			if (s[i][j] == '.') {
				if (i != 0)tate[i][j] = tate[i-1][j] + 1;
				else tate[i][j]++;
			}
		}
	}
	for (int j = 0; j < M; j++) {
		for (int i = N-1; i > -1; i--) {
		
			if (s[i][j] == '.') {
				if (i != N-1)tate[i][j] = max(tate[i][j], tate[i+1][j]);
			}
		}
	}
	ans = -1;

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			ans = max(ans, tate[i][j] + yoko[i][j] - 1);
	}
}

	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 66816
def main():
	N = int(input())
	D, X = map(int,input().split())
	A = [0]*N
	ans = X
	for i in range(N):
		A[i] = int(input())
		ans += ((D-1)//A[i]) + 1

	print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int w,a,b,ABS;
	cin>>w>>a>>b;
	ABS=abs(a-b);
	if(ABS<=w)
	{
		cout<<"0";
	}
	else
	cout<<ABS-w;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

const ll C = 1000000007;

int main(){
    ll x;
    cin >> x;

    ll n = x / 11;
    n *= 2;
    ll m = x % 11;
    if (m > 6) {
        n += 2;
    }
    if(m > 0 && m <= 6) {
        n++;
    }
    cout << n << endl;
}

Measured memory_bytes: 3604
S = input()

#回文かどうかを判定する関数
#回文であれば1を返し、回文でなければ0を返す
def kaibunn_judge(moji):
    if moji==moji[::-1]:
        return 1
    else:
        return 0

n = len(S)
A = S[:(n-1)//2]
B = S[(n+3)//2 - 1:n]

judge = kaibunn_judge(S) + kaibunn_judge(A) + kaibunn_judge(B)

if judge == 3:
    print('Yes')
else:
    print('No')




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

def memoize(f):
	memo = {}
	def func(n):
		if n not in memo:
			memo[n] = f(n)
		return memo[n]
	return func

@memoize
def lucas(n):
	if n < 2:
		return [2, 1][n]
	return lucas(n-1) + lucas(n-2)

print(lucas(N))


Measured memory_bytes: 3060
//
//  main.cpp
//  MST2ND
//
//  Created by Dong Truong on 7/13/19.
//  Copyright © 2019 Dong Truong. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;
#define long long long

const long maxn = 1e6+2 , cm=1e9+7 , ba=31;
struct elem
{
    long id,gt;
};
struct cmp
{
    bool operator () (elem a,elem b)
    {
        return a.gt<b.gt;
    }
};

long n,a[maxn],b[maxn];
priority_queue<elem,vector <elem>,cmp> pq;

void nhap()
{
    cin>>n;
    cin>>a[1];
    pq.push({1,a[1]});
    for (int i=2;i<=n;++i)
        cin>>a[i];
    for (int i=1;i<=n;++i)
    {
        cin>>b[i];
        pq.push({i,b[i]});
    }
}
void sol()
{
    long ans=0;
    while (!pq.empty())
    {
        long o=pq.top().id,u=pq.top().gt;
        pq.pop();
        long kc=u-a[o],l=o-1,z=b[o];
        if (l==0) l=n;
        ans+=kc / (b[l]+b[o%n+1]);
        b[o]=a[o]+kc % (b[l]+b[o%n+1]);
        if (z!=b[o])
            pq.push({o,b[o]});
    }
    bool kt=true;
    for (int i=1;i<=n;++i)
        if (a[i]!=b[i]) kt=false;
    if (kt==true) cout<<ans;
    else cout<<-1;
}
int main(int argc, const char * argv[]) {
   // freopen("a.inp","r",stdin);
    nhap();
    sol();
    return 0;
}


Measured memory_bytes: 11120
/*
AUTHOR: Aman Raj
LANG: C++
*/

using namespace std;

typedef   long long  int ll;
#include <bits/stdc++.h>


//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
#define fast  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
#define all(a) a.begin(),a.end()
//#define mod 998244353


#define mod   1000000007

#define inf 1e18
//#define mod 3
#define flush fflush(stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<ll, ll, hash< ll > > ht;

// find_by_order()  // order_of_key
typedef tree<
    ll,
    null_type,
    less<ll>,
    rb_tree_tag,
    tree_order_statistics_node_update>
    ordered_set;






ll power1(ll a, ll b)//a raised to power b
   {  if(b<=0) return 1; if(b==1) return a;
       ll c=power1(a,b/2);
        c*=c;if(b%2==1) c*=a;
        return c;
   }
   ll mi(ll a,ll m)
   { ll c= power1(a,m-2);

     return c;
   }



 struct less_then_greater {
    template<typename T, typename U>
    bool operator()(T const& lhs, U const& rhs) const {
        if (lhs.first < rhs.first) return true;
        if (rhs.first < lhs.first) return false;
        return lhs.second > rhs.second;
    }
};
 /*std::priority_queue<std::pair<int, int>,
                    std::vector<std::pair<int, int>>,
                    less_then_greater
                   > pq;*/
  /*   #define MAXN 1000001
ll spf[MAXN];
void sieve()
{
    spf[1] = 1;
    for (int i=2; i<MAXN; i++)

        // marking smallest prime factor for every
        // number to be itself.
        spf[i] = i;

    // separately marking spf for every even
    // number as 2
    for (int i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for (int i=3; i*i<MAXN; i++)
    {
        // checking if i is prime
        if (spf[i] == i)
        {
            // marking SPF for all numbers divisible by i
            for (int j=i*i; j<MAXN; j+=i)

                // marking spf[j] if it is not
                // previously marked
                if (spf[j]==j)
                    spf[j] = i;
        }
    }
}
vector<ll> getFactorization(ll x)
{
    vector<ll> ret;
    while (x != 1)
    {
        ret.push_back(spf[x]);
        x = x / spf[x];
    }
    return ret;
}
*/
// take multiset of all edges
// meanwhile for all cc keep record of all edges in multiset too which can be used to digest
// one line or two lines
//


  int main()
{    fast;
      string s,t;cin>>s>>t;
       ll ans=0;
       for(ll i=0;i<s.size();i++)if(s[i]!=t[i])ans++;
        cout<<ans<<endl;
      return 0;
}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    auto ans = 0ll;
    for (int i = 0; i < n; i++) {
        ans += (long long)(i+1) * (n-i);
    }
    for (int i = 0; i < n-1; i++) {
        long long u, v;
        cin >> u >> v;
        ans -= min(u, v) * (n - max(u,v) + 1);
    }
    cout << ans << endl;
}


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

ll n,x;
ll a[55],b[55];

ll dfs(ll N,ll X){
    ll count=0;
    if(N==0) count=1;
    else if(X==1) count+=0;
    else if(X>=2&&X<=a[N-1]+1){
        count+=dfs(N-1,X-1);
    }
    else if(X==a[N-1]+2){
        count+=b[N-1]+1;
    }
    else if(X>=a[N-1]+3&&X<=2*a[N-1]+2){
        count+=b[N-1]+1;
        count+=dfs(N-1,X-a[N-1]-2);
    }
    else if(X==2*a[N-1]+3){
        count += 2*b[N-1]+1;
    }
    return count;
}

int main(){
    cin >> n >> x;
    a[0]=1;
    b[0]=1;
    for(ll i=1;i<=n;i++){
        a[i]=2*a[i-1]+3;
        b[i]=2*b[i-1]+1;
    }
    ll ans=dfs(n,x);
    cout << ans << endl;
    return 0;
}  


Measured memory_bytes: 3612
N = int(input())
B = list(map(int, input().split()))
A = [0 for i in range(N)]
A[0] = B[0]
A[N-1] = B[N-2]
for i in range(1,N-1):
  A[i] = min(B[i-1],B[i])
print(sum(A))

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

namespace AtCoder.Contests.ABC175
{
    /// <summary>
    /// 
    /// </summary>
    static class C
    {
        static void Main(string[] args)
        {
            var x = NextLong();
            var k = NextLong();
            var d = NextLong();

            x = Math.Abs(x);
            if (x / d > k)
            {
                Console.WriteLine(x - d * k);
                return;
            }

            var a = x / d;
            var b = x % d;
            Console.WriteLine(Math.Abs(b - ((k - a) % 2) * d));
        }

        #region Console
        static int _index = 0;
        static string[] _buffer;

        static string Next()
        {
            if (_buffer == null || _index >= _buffer.Length)
            {
                _buffer = Console.ReadLine().Split();
                _index = 0;
            }

            return _buffer[_index++];
        }
        static int NextInt()
        {
            return int.Parse(Next());
        }
        static long NextLong()
        {
            return long.Parse(Next());
        }
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static int[] ReadIntArray(int n)
        {
            var a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadInt();
            }
            return a;
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static long[] ReadLongArray(int n)
        {
            var a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = ReadLong();
            }
            return a;
        }
        static List<T> ReadObjects<T>(int n, Func<int[], T> creator)
        {
            var l = new List<T>(n);

            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                l.Add(creator(a));
            }

            return l;
        }

        static int[,] ReadMatrix(int n, int m)
        {
            var r = new int[n, m];
            for (int i = 0; i < n; i++)
            {
                var a = ReadIntArray();
                for (int j = 0; j < m; j++)
                {
                    r[i, j] = a[j];
                }
            }
            return r;
        }
        #endregion
    }
}


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

int main() {
  int h, w;
  cin >> h >> w;
  vector <vector <int> > a(h, vector <int>(w));
  for (int i = 0; i < h; i++) {
	  for (int j = 0; j < w; j++) {
		  cin >> a[i][j];
		}
	}
  int cnt = 0;
  vector <int> y;
  vector <int> x;
  vector <int> yp;
  vector <int> xp;
  for (int i = 0; i < h; i++) {
	  if (i % 2 == 0) {
		  for (int j = 0; j < w - 1; j++) {
			  if (a[i][j] % 2 == 1) {
				  a[i][j + 1]++;
				  cnt++;
				  y.push_back(i);
				  x.push_back(j);
				  yp.push_back(i);
				  xp.push_back(j + 1);
				}
			}
		  if (i < h - 1 &&  a[i][w - 1] % 2 == 1) {
			  a[i + 1][w - 1]++;
			  cnt++;
			  y.push_back(i);
			  x.push_back(w - 1);
			  yp.push_back(i + 1);
			  xp.push_back(w - 1);
			}
		} else {
		  for (int j = w - 1; j >= 1; j--) {
			  if (a[i][j] % 2 == 1) {
				  a[i][j - 1]++;
				  cnt++;
				  y.push_back(i);
				  x.push_back(j);
				  yp.push_back(i);
				  xp.push_back(j - 1);
				}
			}
		  if (i < h - 1 &&  a[i][0] % 2 == 1) {
			  a[i + 1][0]++;
			  cnt++;
			  y.push_back(i);
			  x.push_back(0);
			  yp.push_back(i + 1);
			  xp.push_back(0);
			}
		}
	}
  cout << cnt << endl;
  for (int i = 0; i < cnt; i++) {
	  printf("%d %d %d %d\n", y[i] + 1, x[i] + 1, yp[i] + 1, xp[i] + 1);
	}
  return 0;
}


Measured memory_bytes: 5224
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
#define PI 3.14159265358979323846
using namespace std;
//
int main(){
  string S;
  cin>>S;
  int i=0,SL=S.size();
  while(i<SL){
    if(S[i]=='d'){
      if(S[i]=='d'&&S[i+1]=='r'&&S[i+2]=='e'&&S[i+3]=='a'&&S[i+4]=='m'){
        if(i+5==SL){
          break;
        }else if(S[i+5]=='d'){
          i+=5;
        }else if(S[i+5]=='e'&&S[i+6]=='r'){
          if(i+7==SL){
            break;
          }else if(S[i+7]=='d'||S[i+7]=='e'){
            i+=7;
          }else if(S[i+7]=='a'){
            i+=5;
          }else{
            YES(0);
            return 0;
          }
        }else{
          YES(0);
          return 0;
        }
      }else{
        YES(0);
        return 0;
      }
    }else if(S[i]=='e'&&S[i+1]=='r'&&S[i+2]=='a'&&S[i+3]=='s'&&S[i+4]=='e'){
      if(i+5==SL){
        break;
      }else if(S[i+5]=='d'||S[i+5]=='e'){
        i+=5;
      }else if(S[i+5]=='r'){
        if(i+6==SL){
          break;
        }else if(S[i+6]=='d'||S[i+6]=='e'){
          i+=6;
        }else{
          YES(0);
          return 0;
        }
      }else{
        return 0;
      }
    }else{
      YES(0);
      return 0;
    }
  }
  YES(1);
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
string s;
int num[6],temp,total,res;
int main(){
    cin>>s;
    num[0] = s[0]-'0';
    num[1] = s[1]-'0';
    num[2] = s[2]-'0';
    num[3] = s[3]-'0';
    for(int i = 0; i < (1<<3); i++){
        temp = i;
        total = num[0];
        for(int j = 0; j < 3; j++){
            if(temp%2){
                total += num[j+1];
            } else{
                total -= num[j+1];
            }
            temp /= 2;
        }
        if(total == 7){
            res = i;
            break;
        }
    }
    for(int i = 0; i < 3; i++){
        printf("%d", num[i]);
        if(res%2)printf("+");
        else printf("-");
        res/=2;
    }
    printf("%d=7\n",num[3]);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
bool judge(string str) {
	if (str.size() == 1) {
		return true;
	}
	for (int i = 0; i < str.size() / 2; ++i) {
		if (str[i] != str[str.size() - 1 - i]) {
			return false;
		}
	}
	return true;
}
int main() {
	int n;
	cin >> n;
	string str;
	int upans, downans;
	int nn = n;
	int nnn = n;
	while (true) {
		str = to_string(nn);
		if (judge(str) == false) {
			nn += 1;
		}
		else {
			upans = nn;
			break;
		}
	}
	while (true) {
		str = to_string(nnn);
		if (judge(str) == false) {
			nnn -= 1;
		}
		else {
			downans = nnn;
			break;
		}
	}
	if (upans - n < n - downans) {
		cout << upans << endl;
	}
	else {
		cout << downans << endl;
	}
	return 0;
}

Measured memory_bytes: 3284
import java.util.*;
import java.io.*;
public class Main {
	public static void main(String args[]){
		Scanner sc=new Scanner(new InputStreamReader(System.in));
		int x,y;
		x=sc.nextInt();
		y=sc.nextInt();
		sc.close();
		if(x>y) System.out.println("a > b");
		else if(x<y) System.out.println("a < b");
		else System.out.println("a == b");
	}
}

Measured memory_bytes: 26296
#include<bits/stdc++.h>
using namespace std;
int n,M;
int f[3005],ans;
int S[3005][3005],C[3005][3005];

int ksm(int x,int y,int mod){
	int res=1;
	while(y){
		if(y&1) res=1ll*res*x%mod;
		x=1ll*x*x%mod,y/=2;
	}
	return res;
}

int main(){
	cin>>n>>M;
	C[0][0]=S[0][0]=1;
	for(int i=1;i<=n+1;i++){
		C[i][0]=1,S[i][0]=0;
		for(int j=1;j<=i;j++){
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%M;
			S[i][j]=(S[i-1][j-1]+1ll*j*S[i-1][j]%M)%M;
		}
	}
	for(int i=0;i<=n;i++){
		int add=ksm(2,ksm(2,n-i,M-1),M);
		int add1=1,add2=ksm(2,n-i,M);
		for(int j=1;j<=i+1;j++){
			(f[i]+=1ll*S[i+1][j]*add1%M*add%M)%=M;
			add1=1ll*add1*add2%M;
		}
		f[i]=1ll*f[i]*C[n][i]%M;
	}
	for(int i=0;i<=n;i++){
		if(i&1) (ans+=M-f[i])%=M;else (ans+=f[i])%=M;
	}
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 69504
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
int main(){
    int n,T;
    cin>>n>>T;
    vector<pair<int,int>> p(n);
    rep(i,n){
        int c,t;
        cin >> c>>t;
        p[i]=make_pair(c,t);
    }
    int mincos = 1000;
    bool ans = false;
    rep(i,n){
        if(p[i].second<=T){
            ans = true;
            if(p[i].first<=mincos){
                mincos = p[i].first;
            }
        }
    }
    if(ans){
        cout<<mincos<<endl;
    }
    else{
        cout<<"TLE"<<endl;
    }
}

Measured memory_bytes: 256
N,M = map(int,input().split())
Nstate = {str(i):0 for i in range(1,N+1)}
WAstate = {str(i):0 for i in range(1,N+1)}
AC = 0
for _ in range(M):
    n,m = map(str,input().split())
    if Nstate[n] == 0:
        if m == 'AC':
            Nstate[n] = 1
            AC += 1
        elif m == 'WA':
            WAstate[n] += 1
WA = 0
for i in range(1,N+1):
    if Nstate[str(i)] == 1:
        WA += WAstate[str(i)]
print(AC,WA)

Measured memory_bytes: 31848
N = int(input())
K = int(input())
x = [int(_) for _ in input().split()]
ans = 0
        
for _ in range(N):
  if abs(x[_]) <= abs(x[_]-K):
        ans += abs(x[_]) * 2
  else:
        ans += abs(x[_]-K) * 2

print(ans)

Measured memory_bytes: 3060
n,a,b=map(int,input().split())
s=input()
w=a+b
for i in range(len(s)):
  if w<1:
    print("No")
  elif s[i]=="a":
    print("Yes")
    w-=1
  elif s[i]=="b" and b>0:
    print("Yes")
    b-=1
    w-=1
  else:
    print("No")

Measured memory_bytes: 4016
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
#include<cstring>
using namespace std;

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

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

long dp[2001];


int main(){

	vector<long> nums;
	long N,move_x;
	cin>>N>>move_x;

	nums.resize(N);
	REP(i,N){
		cin>>nums[i];
		dp[i] = nums[i];
		//cout<<nums[i]<<endl;
	}

	long sum = LONG_MAX/2;

	for(long k = 0; k < N; k++)
	{
		for(long i = 0;i < N;i++)
		{	
			//		cout<<"d"<<dp[i]<<endl;
			dp[i] = min(dp[i],(((i - k) < 0) ? nums[N + i - k]:nums[i-k]));
		//		cout<<"dp "<<dp[i]<<endl;
		}

		long now_sum = 0;
		
		//REP(i,N)cout<<dp[i]<<" ";

		for(long i = 0; i < N; i++){
			now_sum += dp[i];
		}

		now_sum += k * move_x;
		sum = min(now_sum,sum);
		//cout<<now_sum<<endl;
	}

	cout<<sum<<endl;

	return 0;
}



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

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

  int a, b, c; cin >> a >> b >> c;
  int tmp = a-b;
  cout << max(c-tmp, 0) << '\n';
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var (
		a, b, c, d, e int
		cnt           = 0
	)
	// var a string
	fmt.Scan(&a, &b, &c, &d, &e)
	// var cnt int = 0
	if a == 0 {
		cnt = 1
	}
	if b == 0 {
		cnt = 2
	}
	if c == 0 {
		cnt = 3
	}
	if d == 0 {
		cnt = 4
	}
	if e == 0 {
		cnt = 5
	}

	fmt.Println(cnt)
}


Measured memory_bytes: 1748
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int A,B;
  	cin >> A >> B;
  
  	if ((A <= 9) && (B <= 9)){
    	cout << A*B << endl;
    }
    else{
    	cout << -1 << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
/* disini kita akan minta user input angka, yang mana 
angka tersebut bakal di tambah dan dipangkatkan 2*/
int main (){
// sebagai hasil
	int sum = 0;
// sebagai inputan
	int a;
/* disni adalah saat dimana user menginput maka inoutannya akan langsung
dijumlahkan dan dipangkatkan*/
	
	while (scanf("%d", &a) != EOF) {
		sum = a + (a * a) + (a * a *a);
	}	
/* disini kita bakal print hasil penjumlahan dan pemangkatannya*/
	 printf("%d", sum); 
	/*kita pake return 0; utk memberi tahu bahwa program yang kita buat
	sudah selesai dan bisa dijalankan*/
	return 0;
}

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

int main() {
    int h, w;
    cin >> h >> w;
    char c[h][w];
    rep(i, h) {
        rep(j, w) cin >> c[i][j];
    }

    rep(i, h) {
        rep(j, 2) {
            rep(k, w) {
                cout << c[i][k];
              	if(k==w-1) cout << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
/*
hey stop, don't skip the shit till it's solved
*/
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
ll n,m;
cin>>n>>m;
ll a;
priority_queue<ll> pq;
ll ans=0;
for(ll i=0;i<n;i++)
{
cin>>a;
ans+=a;
pq.push(a);
}
for(ll i=0;i<m;i++)
{
ll k=pq.top();
k/=2;
ans-=(pq.top()-k);
pq.pop();
pq.push(k);
}
cout<<ans<<endl;
}

Measured memory_bytes: 4328
from bisect import bisect_right


def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    a.reverse()
    lis = [a[0]]
    for i in range(1, n):
        if a[i] >= lis[-1]:
            lis.append(a[i])
        else:
            lis[bisect_right(lis, a[i])] = a[i]
    print(len(lis))


if __name__ == '__main__':
    main()


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

int main(){
	int n,maxn=-1,maxp,maxn2=-1,maxn2p;
	cin>>n;
	int a[n+1];
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(a[i]>maxn){
			maxn=a[i];
			maxp=i;
		}
		else if(a[i]>maxn2){
			maxn2=a[i];
			maxn2p=i;
		}
	}
	if(maxn2==-1){
		maxn2=maxn;
		maxn2p=maxp;
	}
	for(int i=1;i<=n;i++){
		if(i==maxp){
			cout<<maxn2<<endl;
		}
		else{
			cout<<maxn<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 2432
using System;
using System.Linq;

namespace ABC164_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var param = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var S = param[0];
            var W = param[1];

            Console.WriteLine(W >= S ? "unsafe" : "safe");
        }
    }
}


Measured memory_bytes: 28240
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		long X= keyboard.nextLong();
		int ans = 0;
		long x = 100;

		while(x < X ) {
			x += x/100;
			ans++;
		}
		
		System.out.println(ans);
		keyboard.close();	
		
	}
}


Measured memory_bytes: 35612
import sys
input=sys.stdin.readline
n,a,b=map(int,input().split())
H=[int(input()) for i in range(n)]
H.sort(reverse=True)
h=10**9
l=1
def check(t,a,b):
    c=b*t
    for i in H:
        if(i-c<=0):
            return True
        else:
            t+=(c-i)//(a-b)
            if(t<0):
                return False
    return True
while h!=l:
    t=(h+l)//2
    if(check(t,a,b)):
        h=t
    else:
        l=t+1
print(h)

Measured memory_bytes: 7384
#include <bits/stdc++.h>
#define inf 1000000000 //1E+9
#define mod 1000000007
using std::cin;
using std::cout;
using std::endl;

int main(){
	int n;cin>>n;
	int h[n];for(int i=0;i<n;i++)cin>>h[i];

	int ans=1;
	int flag=0;
	for(int i=1;i<n;i++){
		flag=1;
		for(int j=0;j<i;j++){
			if(h[j]>h[i])flag=0;
		}
		if(flag)ans++;
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	long long N, M;
	cin >> N >> M;

	long long ans = 0;
	if (N > M / 2)
	{
		ans = M / 2;
	}
	else
	{
		ans = ((2 * N + M) / 4);
	}

	cout << ans << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int INF = 10101010;

int main(){
    int cc = 0;
    int n;
    while(cin >>n,n){
        vector<string> s(n);
        vector<int> p(n),l(n);
        rep(i,n){
            cin >>s[i] >>p[i];
            l[i] = s[i].size();
        }

        string t;
        cin >>t;
        int T = t.size();

        vector<int> dp(T+1,-INF);
        dp[0] = 0;
        rep(i,T){
            rep(j,n){
                if(i+l[j] > T) continue;
                if(s[j] == t.substr(i,l[j])){
                    dp[i+l[j]] = max(dp[i+l[j]], dp[i]+p[j]);
                }
            }
        }

        int V = dp[T];
        dp = vector<int>(V+1, INF);
        dp[0] = 0;
        rep(i,V){
            rep(j,n){
                int ni = i+p[j];
                if(ni > V) continue;
                dp[ni] = min(dp[ni], dp[i]+l[j]);
            }
        }

        cout << "Case " << cc+1 << ": " << dp[V] << "\n";
        ++cc;
    }
    return 0;
}



Measured memory_bytes: 3200
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;

int main() {
	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;
	if (s == u)cout << a - 1 << ' ' << b << endl;
	else cout << a << ' ' << b - 1 << endl;

}

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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

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

  ll n, m;
  cin >> n >> m;
  vll x(n);
  rep(i, n) {
    cin >> x[i];
  }

  map<ll, ll> mp;
  rep(i, n) {
    mp[x[i]]++;
  }

  vll md(m);
  vll cnt_same(m);
  for (auto& it : mp) {
    ll idx = it.first % m;
    md[idx] += it.second;
    cnt_same[idx] += it.second / 2;
  }

  // 余り0
  ll ans = md[0] / 2;

  REP(i, (m + 1) / 2) {
    ans += min(md[i], md[m - i]);

    ll amari = abs(md[i] - md[m - i]);
    if (md[i] > md[m - i]) {
      ans += min(cnt_same[i], amari / 2);
    } else {
      ans += min(cnt_same[m - i], amari / 2);
    }
  }

  // e.g. 2 (mod 4)
  if (m % 2 == 0) {
    ans += md[m / 2] / 2;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11900
#include <stdio.h>

int main(void) {
	
	int h,m;
	scanf("%d%d",&h,&m);
	
	if(h>m)
	{
		printf("a > b\n");
	}
	else if(h<m)
	{
		printf("a < b\n");
	}
	
	else if(h==m)
	{
		
	printf("a == b\n");
	}
	
	
	
	
	// your code goes here
	return 0;
}



Measured memory_bytes: 2140
// general helpers
const debug = (message?: any, ...optionalParams: any[]) => {
  if (process.env.LOCAL_DEBUG === '1') console.log(message, ...optionalParams)
}

// helpers
const parseLines = (
  lines: string[]
): { N: number, H: number[] } => {
  const N = +lines[0]
  const H = lines[1].split(' ').map(line => +line)
  const obj = { N, H }
  debug(obj)
  return obj
}
// solver
export const solve = (lines: string[]): string => {
  const { N, H } = parseLines(lines)
  let current = H[0]
  for (let i = 1; i < N; i++) {
    if (current <= H[i] - 1) {
      current = H[i] - 1
    } else if (current <= H[i]) {
      current = H[i]
    } else {
      return 'No'
    }
  }
  return 'Yes'
}

// main
const main = (lines: string[]) => {
  console.log(solve(lines))
}

// exec main function for submit
if (process.env.LOCAL_DEBUG !== '1') {
  const { stdin: input, stdout: output } = process
  input.resume()
  input.setEncoding('utf8')
  const lines: string[] = []
  require('readline')
    .createInterface({ input, output })
    .on('line', (line: string) => lines.push(line))
    .on('close', () => main(lines))
}


Measured memory_bytes: 27724