akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static Scanner;

class Program
{
    static void Main() => new Program().Solve();

    public void Solve()
    {
        Console.WriteLine(Read()[0] <= 'Z' ? "A" : "a");
    }
}


static class Scanner
{
    static Queue<string> que = new Queue<string>();

    public static string Read()
    {
        if (!que.Any()) foreach (var s in Console.ReadLine().Split()) que.Enqueue(s);
        return que.Dequeue();
    }
    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());
    public static decimal ReadDecimal() => decimal.Parse(Read());

    public static IEnumerable<string> Read(long n)
    {
        for (long i = 0; i < n; i++) yield return Read();
    }
    public static IEnumerable<int> ReadInt(long n) => Read(n).Select(int.Parse);
    public static IEnumerable<long> ReadLong(long n) => Read(n).Select(long.Parse);
    public static IEnumerable<double> ReadDouble(long n) => Read(n).Select(double.Parse);
    public static IEnumerable<decimal> ReadDecimal(long n) => Read(n).Select(decimal.Parse);
}

Measured memory_bytes: 26592
import java.math.*;
// import java.util.*;
data class Edge(val from:Int,val to:Int,val cost:Long)

object MainKt {
  @JvmStatic fun main(args:Array<String>) {
   val (N,M)=readLine()!!.split(" ").map(String::toInt)
   val graph=(1..M).map{
     val (a,b,c)=readLine()!!.split(" ").map(String::toLong)
     Edge(a.toInt(),b.toInt(),-c)
   }
   val inf=1000000001L*N*M
   var dist=Array(N) {inf}
  //  var is_closed=false


   dist[0]=0
   var dist_n = 0L
   for(j in 0.until(N)) {
      for(node in graph) {
        val (u,v,c)=node
        
        if(dist[u-1] +c < dist[v-1]) {
          dist[v-1]=dist[u-1]+c
        }
      }
      if(j==N-1) {
            dist_n=dist[N-1]
          }
   }
   for(j in 0.until(N)) {
      for(node in graph) {
        val (u,v,c)=node
        
        if(dist[u-1] +c < dist[v-1]) {
          dist[v-1]=dist[u-1]+c
        }
      }
   }  
   println(if(dist_n==dist[N-1]) {-dist[N-1]} else {"inf"} )
  }
}


Measured memory_bytes: 48520
#include <bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)


void solve(long long N, std::string S){
  for(auto c:S){
    cout<<(char)(((c-'A')+N)%26+'A');
  }
  cout<<endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::string S;
  std::cin >> S;
  solve(N, S);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#define max_c 50
using namespace std;

int n;
char S[51];
int num_of_alphabet[26], min_num_of_alphabet[26];

void getMinNum(){
	for(int i = 0; i < 26; i++){
		num_of_alphabet[i] = 0;
	}
	for(int i = 0; i < strlen(S); i++){
		num_of_alphabet[S[i] - 'a']++;
	}
	for(int i = 0; i < 26; i++){
		//cout << i << " " << num_of_alphabet[i] << endl;
		if(num_of_alphabet[i] < min_num_of_alphabet[i]){
			min_num_of_alphabet[i] = num_of_alphabet[i];
		}
	}
}

void printMax(){
	//cout << "come into printMax" << endl;
	for(int i = 0; i < 26; i++){
		for(int j = 0; j < min_num_of_alphabet[i] ;j++){
			printf("%c", i + 'a');
		}
	}
}

int main(void){
	for(int i = 0; i < 26; i++){
		min_num_of_alphabet[i] = max_c + 1;
		//cout << min_num_of_alphabet[i] ;
	}
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> S;
		getMinNum();
	}

	printMax();

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep2(i, i0, n) for (int i = i0; i < n; ++i)
 
int main() {
  double r;
  cin >> r;
  cout << fixed << setprecision(15);
  cout << 2 * 3.14159265 * r << endl;
  return 0; 
}

Measured memory_bytes: 3776
from math import factorial
from collections import Counter

def prime(n):
    a = [0] * (n + 1)
    a[0] = 1
    a[1] = 1
    i = 2
    while n // i >= i:
        if a[i] != 0:
            i += 1
            continue
        j = 2 * i
        while j <= n:
            a[j] = 1
            j += i
        i += 1
    return [i for i, ai in enumerate(a) if ai == 0]


n = int(input())
f = factorial(n)
primes = prime(n)
counter = Counter()

while f > 1:
    for p in primes:
        if f % p == 0:
            counter[p] += 1
            f = f // p

ans = 1
for val in counter.values():
    ans *= (val + 1)

print(ans % (10**9 + 7))

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

int main(void) {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int ans = 0;
  ans += min(K, A);
  K -= min(K, A);
  K -= min(K, B);
  ans -= min(K, C);
  K -= min(K, C);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
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();
    int C = scanner.nextInt();
    for (int i = 1; i <= B; i++) {
      if (A * i % B == C) {
        System.out.println("YES");
        return;
      }
    }
    System.out.println("NO");
  }
}


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

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<vector<char>>;
using vin= vector<int>;
using ll=long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using pinin=pair<int ,int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sort(x) sort(x.begin(), x.end());
#define rese(x) reverse(x.begin(), x.end());

string yes="Yes",no="No";

int main() {
   string s;
   cin>>s;
   int n=s.size();
   rep(i,n) cout<<"x";
   cout<<endl;
    

}


Measured memory_bytes: 3612
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n;
const int Maxn=1e5+5;
#define pll pair<ll,ll>
pll a[Maxn];
bool comp(const pll &x,const pll &y){
	return x.second<y.second;
}
//bool check(int k){
//	vector<pll>v;
//	v.push_back(a[1]);
//	int cnt=0;
//	for(int i=2;i<=n;i++){
//		if(a[i].first>=v.back().second){
//			cnt++;
//			v.push_back(a[i]);
//		}
//	}
//	return cnt>=k;
//}
//void solve(){
//	int l=1,r=n+1;
//	while(r-l>1){
//		int mid=l+r>>1;
//		if(check(mid))l=mid;
//		else r=mid;
//	}
//	cout<<l<<endl;
//}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		ll x,len;
		cin>>x>>len;
		a[i].first=x-len;
		a[i].second=x+len;
	}
	sort(a+1,a+n+1,comp);
	vector<pll>v;
	v.push_back(a[1]);
	int cnt=1;
	for(int i=2;i<=n;i++){
		if(a[i].first>=v.back().second){
			cnt++;
			v.push_back(a[i]);
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3956
import java.util.Scanner;

public class Main{

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

	private Scanner scan;

	private int n,id,value;
	private void mainrun() {
		scan = new Scanner(System.in);

		n = scan.nextInt();

		id = -1;
		value = Integer.MIN_VALUE;

		for(int i = 0;i < n;i++) {
			int a = scan.nextInt();
			int v = scan.nextInt();

			if( v > value || (v == value && a < id)) {
				id = a;
				value = v;
			}
		}

		System.out.println(id + " " + value);

		scan.close();
	}
}

class Data{
	public Data(int id) {
		this.id = id;
		value = 0;
	}
	int id;
	int value;
}


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

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

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

int main(){
    int N, L; cin >> N >> L;
    string S[N];
    for (int i=0; i<N; i++){
        cin >> S[i];
    }
    sort(S, S+N);
    for (int i=0; i<N; i++){
        cout << S[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	m500 := []float64{35.5, 37.5, 40.0, 43.0, 50.0, 55.0, 70.0, 1000.0}
	m1000 := []float64{71.0, 77.0, 83.0, 89.0, 105.0, 116.0, 148.0, 1000.0}
	classes := []string{"AAA", "AA", "A", "B", "C", "D", "E", "NA"}
	for scanner.Scan() {
		input := strings.Split(scanner.Text(), " ")
		t500, _ := strconv.ParseFloat(input[0], 64)
		t1000, _ := strconv.ParseFloat(input[1], 64)
		for i := 0; i < len(m500); i++ {
			if t500 < m500[i] && t1000 < m1000[i] {
				fmt.Println(classes[i])
				break
			}
		}
	}
}


Measured memory_bytes: 1080
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N;
  bool ok = true;

  cin >> N;

  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    ok &= A % 2 || A % 3 == 0 || A % 5 == 0;
  }

  if (ok)
    cout << "APPROVED" << endl;
  else
    cout << "DENIED" << endl;

  return 0;
}


Measured memory_bytes: 256
<?php
ini_set('memory_limit', '1024M');
$sc = new Scanner();
$N = $sc->nextInt();
$P = $sc->nextInt();
 
if ($N == 1) {
    echo $P . PHP_EOL;
    exit;
}
if ($P == 1) {
    echo 1 . PHP_EOL;
    exit;
}
 
$result = [];
 
while ( $P != 1 ) {
    $i = 2;
    while ($i * $i <= $P) {
        if ($P % $i == 0) {
            while($P % $i == 0) {
                $result[$i]++;
                $P /= $i;
            }
            break;
        }
        $i++;
    }
    if ($i * $i > $P) {
        $result[$P]++;
        $P /= $P;
    }
}
$ans = 1;

foreach($result as $k => $v) {
    $ans *= pow($k, (int)($v/$N));
}
 
echo $ans . PHP_EOL;
 
class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}


Measured memory_bytes: 5112
#include <iostream>

int main()
{
	int n,sum = 0;
	std::cin >> n;

	int *pdeli = new int[n];
	for (int i = 0; i < n; i++) {
		std::cin >> pdeli[i];
		for (int j = i - 1; j >= 0; j--) {
			sum += pdeli[i] * pdeli[j];
		}
	}

	std::cout << sum << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
using P = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
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; }
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() {
	string s;
	cin >> s;
	int i;
	for (i = 0; i < s.size(); i += 2) {
		if (s[i] != 'h' || s[i + 1] != 'i') {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

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


int main()
{
    int h,n;
    cin>>h>>n;
    vector<int>dp(h+1,1e9+7);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        int val,cost;
        cin>>val>>cost;
        for(int j=0;j<=h;j++)
        {
            int k = min(h,j+val);
            dp[k]=min(dp[k],dp[j]+cost);
            //cout<<dp[k]<<endl;
        }
    }
    cout<<dp[h]<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int c1,c2,c3;
	while(cin>>c1>>c2>>c3){
		int ct=0;
		rep(i,1,11){
			if(i==c1 || i==c2 || i==c3) continue;
			if(c1+c2+i<=20) ct++;
		}
		o((ct>=4?"YES":"NO"));
	}
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0;i<n;i++)
int mx=90001;
int a,h,w,d,q,l,r,y[90001],x[90001],s[90001];

int main() {
	cin >> h >> w >> d;
	REP(i,h)REP(j,w){
    cin >> a; y[a]=i,x[a]=j;
  }
  REP(i,h*w-d+1) {
		s[i+d] = s[i] + abs(x[i+d]-x[i]) + abs(y[i+d]-y[i]);
  }

	cin >> q;
  REP(i,q) {
    cin >> l >> r;
    cout << s[r]-s[l] << endl;
  }
  return 0;
}

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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n >> m;
    cout << 6-n-m << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
 
int main()
{
    double a,b,c,d,e,f;
    while(cin>>a>>b>>c>>d>>e>>f){
        printf("%.3f ",(c-b*(f-d*c/a)/(e-d*b/a))/a);
        printf("%.3f\n",(f-d*c/a)/(e-d*b/a));
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
    ll n, k, res = 0;
    scanf("%lld%lld", &n, &k);
    for (int i = k; i <= n + 1; i++) {
        res += (1ll * i * (2ll * n - i + 1) / 2)  - (1ll * (i - 1) * i / 2) + 1;
        res = (res % MOD + MOD) % MOD;
    }
    printf("%lld\n", res % MOD);
    return 0;
}

Measured memory_bytes: 3748
#include <iostream>
using namespace std;
typedef long long ll;

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

  ll cs[n];
  cs[0] = a[0];
  for (int i = 1; i < n; i++) cs[i] = cs[i-1] + a[i];
  
  ll ans = abs(cs[0] * 2 - cs[n-1]);
  for (int i = 1; i < n-1; i++) {
    ans = min(ans, abs(cs[i] * 2 - cs[n-1]));
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

int main(){
	
	string s;
	cin >> s;
	ll n = s.size();
	int ans = 0;
	for(int i = 0; i < n; ++i){
		int x = s[i] - '0';
		ans = (ans % 9 + x % 9) % 9;
	}
	if(ans == 0){
		cout << "Yes";
	}
	else{
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n,m;
  cin>>n>>m;
  int a[n+1];
  for(int i=1;i<=n;i++){
  	cin>>a[i];
  }
  vector<vector<int> > ans(n+1);
  for(int i=0;i<m;i++){
      int s,b;
      cin>>s>>b;
    ans[s].push_back(b);
	ans[b].push_back(s);   
  }
  int count=0;
  for(int i=1;i<=n;i++){
  	int flag=0;
  	for(int j=0;j<ans[i].size();j++){
  		 if(a[ans[i][j]]>=a[i]){
  		 	flag++;
		   }
	  }
	  if(flag==0)
	  count++;
  }
  cout<<count<<"\n";
}

Measured memory_bytes: 8804
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;

int main() {
  int N;
  cin >> N;
  double total=0,x;
  string u;
  for (int i = 0; i < N; i++) {
    cin >> x >> u;
    total += u=="BTC" ? x*380000 : x;
  }
  cout << total << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int ant[5];
	int i, j, k;
	cin >> ant[0] >> ant[1] >> ant[2] >> ant[3] >> ant[4] >> k;
	for(i = 0; i < 4; i++){
		for(j = i + 1; j < 5; j++){
			if(ant[j] - ant[i] > k) {
				cout << ":(";
				exit(0);
			}
		}
	}
	cout << "Yay!";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <valarray>
#include <queue>

using namespace std;

typedef long long LL;

bool bm_augment(const vector<vector<int>> &graph, int v, vector<int> &match_to, vector<bool> &visited) {
    if(v == -1) return true;
    if(visited[v]) return false;
    visited[v] = true;
    for(int n : graph[v]) {
        if(bm_augment(graph, match_to[n], match_to, visited)) {
            match_to[n] = v;
            return true;
        }
    }
    return false;
}

int bipartite_matching(const vector<vector<int>> &graph) {
    const int N = graph.size();
    vector<int> match_to(N, -1);
    int cnt = 0;
    for(int i = 0; i < N; ++i) {
        vector<bool> visited(N, false);
        if(bm_augment(graph, i, match_to, visited)) ++cnt;
    }
    return cnt;
}

bool solve() {
    int N, M, L;
    if(!(cin >> N >> M >> L)) return false;
    if(!N && !M && !L) return false;

    vector<vector<int>> dist(N, vector<int>(N, -1));
    for(int i = 0; i < M; ++i) {
        int u, v, d;
        cin >> u >> v >> d;
        dist[u][v] = dist[v][u] = d;
    }
    for(int i = 0; i < N; ++i) {
        dist[i][i] = 0;
    }
    for(int k = 0; k < N; ++k) {
        for(int i = 0; i < N; ++i) {
            for(int j = 0; j < N; ++j) {
                if(dist[i][k] == -1 || dist[k][j] == -1) continue;
                const int d = dist[i][k] + dist[k][j];
                if(dist[i][j] == -1 || dist[i][j] > d) dist[i][j] = d;
            }
        }
    }

    vector<vector<int>> graph(L);
    vector<pair<LL,int>> queries(L);
    for(int i = 0; i < L; ++i) {
        cin >> queries[i].second >> queries[i].first;
    }
    sort(queries.begin(), queries.end());
    for(int i = 0; i < L; ++i) {
        const auto &qi = queries[i];
        for(int j = i+1; j < L; ++j) {
            const auto &qj = queries[j];
            if(dist[qi.second][qj.second] != -1 && qj.first - qi.first >= dist[qi.second][qj.second]) {
                graph[i].push_back(j);
            }
        }
    }
    int cnt = bipartite_matching(graph);
    cout << L-cnt << endl;
    return true;
}

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

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 3900
x,n = list(map(int,input().split()))
ans = 0
if n != 0:
  p_list = list(map(int,input().split()))
  for i in range(0,102):
    if i not in p_list:
      if abs(x - i) < abs(x - ans):
        ans = i
      elif abs(x - i) == abs(x - ans) and i < ans:
        ans = i
else:
  ans = x
print(ans)

Measured memory_bytes: 9108
while True:
    h, w = [int(x) for x in input().split()]
    if h == w == 0:
        break
    bool_ = [[0 for x in range(w)] for y in range(h)]
    tile = []
    for i in range(h):
        tile.append(list(input()))
    x, y = 0, 0
    while True:
        if bool_[y][x]:
            print('LOOP')
            break
        else:
            bool_[y][x] = 1
            if tile[y][x] == '>':
                x += 1
            elif tile[y][x] == '<':
                x -= 1
            elif tile[y][x] == '^':
                y -= 1
            elif tile[y][x] == 'v':
                y += 1
            elif tile[y][x] == '.':
                print(x, y)
                break

Measured memory_bytes: 7896
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

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

    // 素数である
    return 1;
}
lint lcm(lint a,lint b){
      return a/__gcd(a,b)*b;
  }

lint x[200000];
  int main(){
      lint N;
      cin>>N;
      lint G[N];
      rep(i,N)cin>>G[i];

      repm(i,N){
          lint sum=0;
          lint k=1;
          while((i+1)*k<=N){
              if(x[(i+1)*k-1]==1)sum++;
              k++;
          }
          if(sum%2!=G[i])x[i]++;
      }
      lint count=0;
      rep(i,N){
          if(x[i]==1)count++;
      }
      cout<<count<<endl;
      rep(i,N){
         if(x[i]==1) cout<<i+1<<endl;
      }
  }
  

Measured memory_bytes: 3968
N = int(input())
h = [0] + list(map(int, input().split()))

dp = [int(1e18)]*(N+1)
dp[1] = 0
for i in range(1, N):
    dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]))
    if i+2 <= N:
        dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]))
print(dp[N])


Measured memory_bytes: 13928
n = int(input())
problems = [int(input()) for _ in range(n)]
sum_all = sum(problems)
not_multi_of_10 = [x for x in problems if x % 10 != 0]
not_multi_of_10.sort()

if sum_all % 10:
    print(sum_all)
else:
    if len(not_multi_of_10) == 0:
        print(0)
    else:
        print(sum_all - not_multi_of_10[0])

Measured memory_bytes: 9144
import java.io.{BufferedReader, InputStreamReader}

import scala.collection.mutable

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val n = in.readLine().toInt

    val memo = new mutable.HashMap[(Char, Char), Int]()

    for {
      i <- 1 to n
    } {
      val s = i.toString
      val head = s.head
      val last = s.last

      if (last != '0') {
        val key = (head, last)
        memo.update(key, memo.getOrElseUpdate(key, 0) + 1)
      }
    }

    var count = 0
    for {
      i <- '1' to '9'
      j <- '1' to '9'
    } {
      count += memo.getOrElse((i, j), 0) * memo.getOrElse((j, i), 0)
    }

    System.out.println(count)
  }
}


Measured memory_bytes: 36664
#include <stdio.h>

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

int main() {
	int n;
	scanf("%d", &n);
	rep(q, n) {
		double x[4], y[4];
		rep(i, 4) scanf("%lf%lf", x+i, y+i);
		double x1=x[1]-x[0], x2=x[3]-x[2], y1=y[1]-y[0], y2=y[3]-y[2];
		if(x1*y2-x2*y1==0) printf("YES\n");
		else printf("NO\n");
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

ll pow_mod(ll n, ll k, ll mod) {
    if(k == 0) {
        return 1;
    } else if(k % 2 == 1) {
        return pow_mod(n, k - 1, mod) * n % mod;
    } else {
        ll t = pow_mod(n, k / 2, mod);
        return t * t % mod;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> cnt;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    bool ok = true;
    if(n % 2 == 1) {
        for(auto p : cnt) {
            if(p.first == 0 && p.second != 1) {
                ok = false;
            }
            if(p.first != 0 && p.second != 2) {
                ok = false;
            }
        }
    } else {
        for(auto p : cnt) {
            if(p.second != 2) {
                ok = false;
            }
        }
    }
    if(!ok) {
        cout << 0 << endl;
    } else {
        cout << pow_mod(2LL, n / 2, MOD) << endl;
    }
}

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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	int A, B, C;
	
	cin >> A >> B >> C;
	
	for(int i=1; i<=B; i++){
		if((i*A)%B == C){
			cout << "YES";
			return 0;
		}
	}
	
	cout << "NO";
	
	return 0;
}

Measured memory_bytes: 256
import std;

alias Book = Tuple!(int, "cost", int[], "ss");

int calc(int x, Book[] books) {
    auto n = books.length;
    auto m = books[0].ss.length;

    int ans = int.max;
    foreach (es; subsets(n.iota)) {
        int cost = 0;
        auto ss = new int[m];
        foreach (e; es) {
            cost += books[e].cost;
            foreach (k, s; books[e].ss) ss[k] += s;
        }
        if (ss.all!(e => e >= x)) {
            ans = min(ans, cost);
        }
    }
    return ans == int.max ? -1 : ans;
}

void main() {
    int n, m, x; scan(n, m, x);
    Book[] books;
    foreach (_; 0..n) {
        auto t = readints;
        books ~= Book(t[0], t[1..$]);
    }
    writeln(calc(x, books));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readints = reads!int;

Subsets!R subsets(R)(R range)
if (isInputRange!R)
{
    return Subsets!R(range);
}

struct Subsets(R) {
    alias E = ElementType!R;
    private E[] _source;

    private E[] _current;
    private int _state;

    this(R source) {
        _source = source.array;
        assert(!_source.empty);
        _state = 0;
        next();
    }

    private void next() {
        _current = null;
        if (_state < (1 << _source.length)) {
            for (int i = 0; i < _source.length; i++) {
                if (_state & (1 << i)) _current ~= _source[i];
            }
            _state++;
        }
    }

    @property E[] front() { return _current; }
    @property bool empty() { return _current == null && _state >= (1 << _source.length); }
    void popFront() { next(); }
}


Measured memory_bytes: 4424
import sys

def main():
  s = input()
  n = len(s)
  x, y = map(int, input().split())
  
  move = [0]
  for i in range(n):
    if s[i] == "F":
      move[-1] += 1
    else:
      move.append(0)
  
  move_x = move[2::2]
  move_y = move[1::2]
  move_a = move[0]
  
  for start, lis in zip([x-move_a, y], [move_x, move_y]):
    move_range = sum(lis)
    if abs(start) > move_range:
      print("No")
      sys.exit()
    
    dp = 2**move_range
    for value in lis:
      dp = (dp >> value)|(dp << value)
    if not (dp>>(move_range+start))&1:
      print("No")
      sys.exit()
  
  print("Yes")
  
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 71480
n=int(input())
S=[0 if i=='.' else 1 for i in input()]
if sum(S)==0 or sum(S)==n:
    print(0)
    exit()
sS=sum(S)
allblack=n-sum(S)
allwhite=sum(S)
bw=10**6
from itertools import accumulate
accS=list(accumulate(S))
for i in range(n):
    bw=min(bw,accS[i]+(n-(i+1))-(sS-accS[i]))
print(min(bw,allblack,allwhite))

Measured memory_bytes: 56500
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

N, X = map(int, input().split())
Xs = list(map(int, input().split()))

Ys = Xs[::-1]
Y_sum = [0] * N
Y_sum[0] = Ys[0]
for i in range(1, N):
    Y_sum[i] = Y_sum[i-1] + Ys[i]
ans = 1e100
for rep_num in range(1, N+1):
    local_ans = X * rep_num
    local_ans += 5 * Y_sum[rep_num - 1]
    i = 2 * rep_num - 1
    n = 1
    while i <= N-1:
        local_ans += (2 * n + 3) * (Y_sum[i] - Y_sum[i - rep_num])
        n += 1
        i += rep_num
    local_ans += (2 * n + 3) * (Y_sum[N - 1] - Y_sum[i - rep_num])
    ans = min(ans, local_ans)
print(ans + N * X)


Measured memory_bytes: 28800
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;

// types - only for stuff used a lot 
using ll = long long;
using pll = pair<ll,ll>;
using ordered_set = tree<
	pll,
	null_type,
	less<pll>,
	rb_tree_tag,
	tree_order_statistics_node_update>;
// insert, find_by_order, and order_of_key
#define vv vector
#define Pp pair

// IO
#define get(x) scanf("%d",&x)
#define getl(x) scanf("%lld",&x);

// Operations
#define pb push_back
#define pob pop_back
#define sz(a) int(a.size()) 
#define re(a,b) a=max(a,b) // relax
#define ri(a,b) a=min(a,b) // relaxi

// Debugging

#ifndef LOCAL
#define cerr if (0) cerr
#else
#define cerr cout
#endif

#define print(arr,n) {for (int _ = 0; _ < n; _++) cerr<<arr[_]<<" "; cerr << endl; }
#define printv(vec)  {for (int _ : vec) cerr<<_<<" "; cerr<<endl;}

const int mod = 1e9+7, oo = 1e9;
const ll loo = 1e18;

// Functions 
ll modpow(ll a, ll b) {
	ll ans = 1; // faster modpow than recursive
	for (; b; b/=2,a=a*a%mod)
		if (b&1) ans = (ans*a)%mod;
	return ans;
}
ll gcd(ll a, ll b) {
	while (a) b%=a,swap(a,b);
	return b;
}
#define bitcount __builtin_popcountll
#define f(i,a,b) for (int i = a; i < b; i++)
#define fr(i,a,b) for (int i = b-1; i >= a; i--)


/* 

   ALRIGHT HACKERS, THIS IS WHERE THE ACTUAL CODE BEGINS
   Time to get demoted :)

 */

const bool DEBUG = 1;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	if (DEBUG) freopen("input.txt", "r", stdin);
	if (DEBUG) freopen("output.txt", "w", stdout);
	clock_t start = clock();
#endif

	string s,t; cin>>s>>t;
 	int N = s.length(), M = t.length();
  	s += s;
  	int nxt[2*N][26];
  	fr(i,0,2*N) {
    	if (i == 2*N-1)
        	f(c,0,26) nxt[i][c] = oo;
      	else f(c,0,26) nxt[i][c] = nxt[i+1][c];
      	nxt[i][s[i]-'a'] = i;
    }
  	int cur = -1;
  	int reserve = 0;
  	f(j,0,M) {
    	if (nxt[cur+1][t[j]-'a'] == oo) {
          	cout << "-1" << endl;
          	return 0;
        } else cur = nxt[cur+1][t[j]-'a'];
      	if (cur >= N)
        	reserve++,cur -= N;
    }
  	cout << cur+1LL+(long long)reserve*N << endl;

#ifdef LOCAL
	cout << setprecision(12) << (long double)(clock()-start) / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}

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

const int N = 100005;
const long long LIM = 1000000000000000000LL;
const __int128 ONE = 1;

int n;
long long a[N];

int solve() {
  scanf("%d", &n);
  long long ans = 1;

  for (int i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
    if (a[i] == 0) return 0 * printf("0\n");
  }

  for (int i = 0; i < n; ++i) {
    if (ONE * ans * a[i] > LIM) return 0 * printf("-1\n");
    ans *= a[i];
  }

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

int main() {
  int t = 1;
  // scanf("%d", &t);
  for (int tc = 0; tc < t; ++tc) {
    // printf("Case #%d: ", tc+1);
    solve();
  }
  return 0;
}


Measured memory_bytes: 4592
import sys
input = sys.stdin.readline
N = int(input().strip())
A = [int(x) for x in input().strip().split()] + [0]
totalcost = 0
a_ = 0
for a in A:
    totalcost += abs(a - a_)
    a_ = a

C = [totalcost] * N
a_ = 0
for i, a in enumerate(A):
    if i == len(A)-1:
        break
    C[i] += -abs(a - a_) -abs(A[i+1] - a) + abs(A[i+1] - a_)
    a_ = a

for c in C:
    print(c)


Measured memory_bytes: 14048
from sys import stdin
N, M, C = map(int, input().split())
B = list(map(int, input().split()))

A = [stdin.readline().rstrip().split() for _ in range(N)]

ans = []
for i in range(N):
    L = []
    for j, v in enumerate(B):
        L.append(int(A[i][j]) * B[j])
    ans.append(sum(L) + C)


count = 0
for i in ans:
    if (i > 0):
        count += 1
# print(ans)
print(count)


Measured memory_bytes: 3064
/*
	Copyright: razouq (c)
	Author: Anass BENDARSI
	Date: 20/08/2017 13:07:46
	flamers will **** you
*/
#include<bits/stdc++.h>
//#include<flamers.h>
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define POB pop_back
#define dist(a, b) sqrt(a*a + b*b)
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vipi;
bool compare(pi p1, pi p2){
	 if(1) return true;
	 return false;
}

int main(){
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie();
	ll n;
	cin>>n;
	vector<ll> vect(n);
	for(int i = 0; i < n; i++ ){
		cin>>vect[i];
	}
	vector<ll> v;
	sort(vect.begin(), vect.end());
	
	
	for(ll i = n-1; i > 0; i--){
		if(vect[i] == vect[i-1]) {
			v.PB(vect[i]);
			i--;
		}
	}
	if(v.size() >= 2) cout<<v[0]*v[1]<<endl;
	else cout<<0<<endl;
	return 0;
}


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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	string T = "";
	for (int i = 1; i < 10; i++) {
		T = T + "hi";
		if (S == T) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
import * as fs from 'fs';

namespace AtCoder.abc105 {

    class ProgramA {
        args: string[];

        constructor(args: string[]) {
            this.args = args;
        }

        /**
         * in
         *  7 3
         * out
         *  1
         */
        main(): void {
            const [n, k]: number[] = this.args[0].split(' ').map(x => +x);
            (n % k === 0) ? console.log(0) : console.log(1);
        }
    }

    const args = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
    const prg = new ProgramA(args);
    prg.main();
}




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

int main(){
    int n;
    cin >> n;
    int num[n];
    vector<int>ans;
    
    for(int i = 0;i < n;i++){
        cin >> num[i];
    }
    
    for(int i = 0;i < n;i++){
        if(i%2 == 0){
            ans.push_back(num[i]);
            
        }else{
            ans.insert(ans.begin(),num[i]);
        }
    }
    

    if((ans.size() % 2) == 0){
        for(int i = 0; i < ans.size(); i++){
            cout << ans[i];
            if(i != ans.size()-1){
                cout << " ";
            }
        }
    }else{
        for(int i = (int)ans.size()-1; i >= 0; i--){
            cout << ans[i];
            if(i != 0){
                cout << " ";
            }
        }
    }
    
    cout << "\n";
    return 0;
}

Measured memory_bytes: 3828
import java.util.*;

public class Main{
	public static void main(String args[]){
	  Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      double v[] = new double[n];
      double temp;
      for(int i = 0; i < n; i++){
        v[i] = sc.nextDouble();
      }
      for(int j = 0; j < n-1; j++){
        for(int k = 0; k < n-1; k++){
          if(v[k] > v[k+1]){
            temp = v[k];
            v[k] = v[k+1];
            v[k+1] = temp;
          }
        }
      }
      for(int l = 0; l < n-1; l++){
        v[l+1] = (v[l]+v[l+1])/2;
      }
      System.out.println(v[n-1]);
	}
}


Measured memory_bytes: 23380
#A - Candy Distribution Again
N,x = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)

tmp = 0
A_1  = x
for i in range(N):
    A_1 = A_1 - a[i]
    if A_1 > 0:
        if i == N-1:
            print(tmp)
            exit()
        else:
            tmp += 1
    elif A_1 == 0:
        tmp += 1
        print(tmp)
        exit()

    else:
        print(tmp)
        exit()
print(tmp)

Measured memory_bytes: 38384
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int getketa(long long int n)
{
	int ans = 1;
	while(n >= 10){
		ans++;
		n = n / 10;
	}
	return ans;
}

int main()
{
	long long int n;
	cin >> n;
	long long int ans = 1;
	for(long long int i = 2; i * i <= n; i++){
		if(n % i == 0){
			ans = max(ans, i);
		}
	}
	cout << max(getketa(ans), getketa(n / ans)) << endl;
	return 0;
}

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

int main()
{
  int a, b;
  cin >> a >> b;
  if (a >= b)
  {
    for (int i = 0; i < a; i++)
    {
      string Sb = to_string(b);
      cout << Sb;
    }
  }
  if (a < b)
  {
    for (int j = 0; j < b; j++)
    {
      string Sa = to_string(a);
      cout << Sa;
    }
  }
  cout << endl;
}
    

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

int main() {
    int N, K;
    std::cin >> N >> K;

    std::vector<int> V(N);
    for (int i = 0; i < N; i++)
        std::cin >> V[i];

    int ans = 0;
    for (int i = 0; i <= N; i++) {
        for (int j = i; j <= N; j++) {
            if (i + (N - j) > K) continue;
            int res = 0;
            std::vector<int> v;
            for (int k = 0; k < N; k++) {
                if (k >= i && k < j) continue;
                res += V[k];
                if (V[k] < 0)
                    v.push_back(V[k]);
            }
            sort(v.begin(), v.end());

            int L = std::min((int)v.size(), K - i - (N - j));
            for (int k = 0; k < L; k++)
                res -= v[k];

            ans = std::max(ans, res);
        }
    }
    std::cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const int mod = 1000000007;

ll modPow(ll x, ll n){
    ll res = 1;
    if(n > 0){
        res = modPow(x, n/2);
        if(n%2 == 0) res = (res*res)%mod;
        else res = ((res*res)%mod)*x%mod;
    }

    return res;
}

int main(){
    int x, n; cin >> x >> n;
    cout << modPow(x, n) << endl;
}


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

bool is_odd(long n){
  return n%2;
}

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

  while(true){
    for(i = 0; i < n; i++){
      if(is_odd(a[i])){
        cout << count << endl;
        return 0;
      }
      a[i] /= 2;
    }
    count++;
  }
}


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

long long n,ans,tmp;

int main(){

	cin>>n;
	
	for(long long i=1;(i*i)<=n;i++){
	    
	    if(n%i==0){
    	    if(n/i < i-1ll)ans+=(i-1ll);
    	    
    	    if(n/i!=i){
    	        
    	        tmp=n/i;
    	        if(n/tmp < tmp-1ll)ans+=(tmp-1ll);
            }
	    }
    }

    cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll  long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pb push_back
#define Max(x,y,z) max(x,max(y,z))
#define f first
#define s second
#define lbd lower_bound
#define sz(x)       (ll)x.size()
#define pi 3.1415926536
#define mod 1000000007
using namespace std;
void solve()
{
    ll n,m,k,x,y=0,res=0,l,cnt=0,sum=0,z,sum1=0,cnt1=0,h,res1;
   cin>>n>>m;
ll   ans=(n-m+1);
   cout<<ans;
}
int main()
{   speed_up
    ll t;
   // cin>>t;
    t=1;
    while(t--)
        solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    if(n==1){
        cout << 1 << endl;
        return 0;
    }
    else if(n==2){
        cout << 3 << endl;
        return 0;
    }
    long ans=0;
    long a=2;
    long b=1;
    long c=0;
    for(int i=0;i<=n-2;i++){
        c=a+b;
        a=b;
        b=c;
    }
    cout << c << endl;
    return 0;
}

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

int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0&&c>0){
        c-=b;
        a-=d;
    }
    if(c<1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
ll INF = pow(10,10);

int main(){
	ll n,W;
	cin >> n >> W;
	vector<ll> w(n),v(n);
	rep(i,n) cin >> w[i] >> v[i];
	int V(pow(10,5));
	vector<vector<ll>> dp(n+10,vector<ll>(V+10, INF));
	dp[0][0] = 0;
	for(ll i(1);i<=n;++i){
		for(ll j(0);j<=V;++j){
			if(j - v[i-1]>= 0){
				if(dp[i-1][j-v[i-1]] + w[i-1] < dp[i-1][j]){
					dp[i][j] = dp[i-1][j-v[i-1]] + w[i-1];
				}else{
					dp[i][j] = dp[i-1][j];
				}
			}else{
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	for(ll i(V);i>=0;--i){
		for(ll j(1);j<=n;++j){
			if(dp[j][i] <= W){
				cout << i << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 87296
from math import log
n,k=map(int,input().split())
if n<k:
    p=0
    for i in range(1,n+1):
        po=int(log(k/i,2))
        if i*(2**po)!=k:
            po+=1
        p+=(1/n)*((1/2)**po)
    print(p)
else:
    p=(n-k+1)/n
    for i in range(1,k):
        po=int(log(k/i,2))
        if i*(2**po)!=k:
            po+=1
        p+=(1/n)*((1/2)**po)
    print(p)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <bitset>
using namespace std;
using ll = long long int;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll mod = 1000000007;

int check[100];

int main() {
    int n;
    cin >> n;
    vector<vector<int>> d(n, vector<int>(2));
    rep(i,n) cin >> d[i][0] >> d[i][1];
    rep(i,n) {
        if(d[i][0] == d[i][1]) check[i] = 1;
        else check[i] = 0;
    }
    int res = 0;
    rep(i,n) {
        if(check[i] == 1) {
            res++;
        }else res = 0;
        if(res == 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3632
/**
 *      ABC 67 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-04 23:27:50
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int A, B; cin >> A >> B;
    if ((A % 3 == 0 || B % 3 == 0) || (A + B) % 3 == 0){
        cout << "Possible" << endl; 
    }
    else {
        cout << "Impossible" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    H, W, D = [int(x) for x in input().strip().split()]
    M = [0] * H
    C = {}
    revM = {}
    for h in range(H):
        M[h] = [int(x) for x in input().strip().split()]
        for i, w in enumerate(M[h]):
            revM[w] = (h, i)
    Q = int(input())
    HW = H * W
    ans = [0] * (HW + 1)
    for i in range(1, D+1):
        cur = i
        while cur + D <= HW:
            ans[cur+D] += ans[cur] + abs(revM[cur][0] - revM[cur+D][0]) + abs(revM[cur][1] - revM[cur+D][1])
            cur += D

    for q in range(Q):
        l, r = [int(x) for x in input().strip().split()]
        print(ans[r]-ans[l])

if __name__ == '__main__':
    main()

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int D; cin >> D;
	vint C = makeVector(26, 0); cin >> C;
	vvint S = makeVector(D, 26, 0); cin >> S;
	vint T = makeVector(D, 0); cin >> T;
	vint last(26, -1);	
	ll score = 0;
	for (int i = 0; i < D; i++) {
		T[i]--;
		score += S[i][T[i]];
		last[T[i]] = i;
		for (int j = 0; j < 26; j++) {
			score -= (i-last[j])*C[j];
		}
		cout << score << el;
	}

}

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


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

using namespace std;

bool is_palindrome(int N)
{
    string s = to_string(N);
    int n = s.size();
    for (int i = 0; i < n/2; i++) {
        if (s[i] != s[n-1-i]) return 0;
    }
    return 1;
}

int main()
{
    int N;
    cin >> N;
    int l = -1, r = -1;
    for (int i = N; ; i--) {
        if (is_palindrome(i)) {
            l = i;
            break;
        }
    }

    for (int i = N; ; i++) {
        if (is_palindrome(i)) {
            r = i;
            break;
        }
    }

    if (N - l <= r - N) {
        cout << l << endl;
    } else {
        cout << r << endl;
    }    
    return 0;
}

Measured memory_bytes: 3248