akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,x,cnt;
ll sum=0;
ll pow(int x)
{
    ll ans=1;
    for(int i=1;i<x;i++)
    {
        ans*=10;
    }
    return ans;
}
void dfs(ll now,int w)  // 现在加的数，位数
{
    if(w>x) return;
    //cout<<now<<" "<<w<<" "<<cnt<<" "<<sum<<endl;
    if(w==x)
    {
        cnt++;
    }
    if(cnt==n)
    {
        cout<<sum;
        exit(0);
    }
    for(ll i=0;i<=9;i++)
    {
        if(abs(i-now)<=1)
        {
            ll su=sum;
            sum=sum+i*(ll)pow(x-w);
            dfs(i,w+1);
            sum=su;
        }
    }
}
int main()
{
    cin>>n;
    for(x=1;x<=10;x++)   // 位数
    {
        for(ll i=1;i<=9;i++)
        {
            sum=i*pow(x);
            dfs(i,1);
        }
    }
    return 0;
}


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

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define INF (1 << 29)

using namespace std;

/*class Point{
	public:
		double x, y;

		Point(double x = 0, double y = 0): x(x), y(y) {}

		Point operator + (Point p){ return Point(x + p.x, y + p.y); }
		Point operator - (Point p){ return Point(x - p.x, y - p.y); }
		Point operator * (double a){ return Point(a * x, a * y); }
		Point operator / (double a){ return Point (x / a, y / a); }

		double abs(){ return sqrt(norm()); }
		double norm(){ return x * x + y * y; }

		bool operator < (const Point &p) const{
			return x != p.x ? x < p.x : y < p.y;
		}

		bool operator == (const Point &p) const{
			return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
		}
};

class Segment{
	public:
		Point p1, p2;
		Segment(Point p1 = Point(), Point p2 = Point()): 
			p1(p1), p2(p2) {}
};

class Circle{
	public:
		Point c;
		double r;
		Circle(Point c = Point(), double r = 0.0): c(c) , r(r) {}
};

typedef Segment Line;
typedef vector<Point> Polygon;
typedef Point Vector;

double dot(Vector a, Vector b){
	return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b){
	return a.x * b.y - a.y * b.x;
}
*/

int main(){
	int R; cin >> R;
	cout << 2 * M_PI * R << endl; 

	return 0;
}


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

using namespace std;

int main() 
{
    int n, i;
    scanf("%d", &n);
    
    vector<int> v1;
    vector<int> v2;
    vector<vector<int> > vs;
    
    for(i = 1; i <= n; i++)
        v1.emplace_back(i);
    
    do
    {
        for(i = 0; i < n; i++)
            v2.emplace_back(v1[i]);
        vs.emplace_back(v2);
        v2.clear();
    } while(next_permutation(v1.begin(), v1.end()));
    
    sort(vs.begin(), vs.end());
    
    for(i = 0; i < (int)vs.size(); i++)
    {
        auto it = vs[i].begin();
        for(; it != --vs[i].end(); it++)
            printf("%d ", *it);
        printf("%d\n", *it);
    }
    
    return 0;
}


Measured memory_bytes: 28184
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include <limits>
#include <numeric>
#include <type_traits>

int gcd(int a,int b)
{
	if (a%b==0)
	{
		return(b);
    }
	else
	{
		return(gcd(b,a%b));
    }
}

using namespace std;
typedef long long ll;

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

int main(){
int K,N;
ll ans = 0;
cin>>K;
for(int i = 1;i <= K;i++){
        for(int j = 1;j <= K;j++){
            for(int k = 1;k <= K;k++){
                N = gcd(j,k);
                ans+=gcd(i,N);
             }
        }


}
cout<<ans<<endl;


return 0;
}

Measured memory_bytes: 3596
def examA():
    K, X = LI()
    if K*500>=X:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)
    return

def examB():
    N = I()
    S = SI()
    ans = 0
    for i in range(N-2):
        if S[i:i+3]=="ABC":
            ans +=1
    print(ans)
    return

def examC():
    N = I()
    P = LI()
    Q = LI()
    Cp = [i for i in itertools.permutations(P,N)]; Cp.sort()
    Cq = [i for i in itertools.permutations(Q, N)]; Cq.sort()
#    print(Cp)
#    print(Cq)
    for k,i in enumerate(Cp):
        flag = True
        for j in range(N):
            if P[j]!=i[j]:
                flag = False
                break
        if flag:
            a = k
            break
    for k,i in enumerate(Cq):
        flag = True
        for j in range(N):
            if Q[j]!=i[j]:
                flag = False
                break
        if flag:
            b = k
            break
    ans = abs(a-b)
    print(ans)
    return

def gcd(x,y):
    if y==0:
        return x
    while(y!=0):
        x, y = y,x%y
    return x
def lcm(x, y):
    return x * y // gcd(x, y)
def examD():
    N, M = LI()
    A = LI()
    flag = 0
    for i in range(1,32):
        if A[0]%(2**i)==0:
            flag +=1
        else:
            break
#    print(flag)
    for a in A:
        cur = 0
        for i in range(1, 32):
            if a % (2 ** i) == 0:
                cur += 1
            else:
                break
        if cur!=flag:
            print(0)
            return
    cur = A[0]
    for i in range(1,N):
        cur = lcm(cur,A[i])
        if cur>2*M:
            print(0)
            return
    ans = 1 + (M-cur//2)//cur
    print(ans)
    return

def examE():
    N = I()
    C = LI()


    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examD()


Measured memory_bytes: 59872
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C = MAP()
print(B//A if B//A < C else C)

Measured memory_bytes: 5332
# -*- coding utf-8 -*-

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())


if k >= b-a and k >= c-a and k >= d-a and k >= e-a and k >= c-b and k>= d-b and k >= e-b and k >= d-c and k >= e-c and k>= e-d:
    print("Yay!")
else:
    print(":(")


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        try(Scanner sc = new Scanner(System.in)){
            int w = sc.nextInt();
            int n = sc.nextInt();
            int[] values = new int[w];
            for(int i=0 ; i< values.length; i++) values[i] = i+1;
            for(int j=0 ; j< n ; j++){
                String str = sc.next();
                String[] ab = str.split(",");
                int a = Integer.parseInt(ab[0]) - 1;
                int b = Integer.parseInt(ab[1]) - 1;
                int z;
                z = values[a];
                values[a] = values[b];
                values[b] = z;
            }
            for(int i=0; i<w; i++){
                System.out.println(values[i]);
            }
        }
    }
}


Measured memory_bytes: 26180
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
// using namespace __gnu_pbds;
// template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long int
#define ull unsigned long long int
 
#define lp(i,n) 	    for(int i=0;i<(int)(n);i++)
#define lpi(i, j, n)    for(int i=(j);i<(int)(n);i++)
#define lpd(i, j, n)    for(int i=(j);i>=(int)(n);i--)
 
#define all(v)  	 ((v).begin()), ((v).end())
#define sz(v)    	 ((int)((v).size()))
#define clr(v, d)    memset(v, d, sizeof(v))
#define PB           push_back
#define MP           make_pair
#define N 100005
 
#define PI 3.14159265359
 
 
ll nChooseR(int n,int k);
ll gcd(ll a, ll b);
vector<string> split(string target,unsigned char c );


int n,k,t,m,x,y;

bool isPrime(ll h);
string s;

 

ll ans;

ll mod=1e9 +7;




int main() {
// freopen("pyramid.in","r",stdin); 
  //freopen("output.txt","w",stdout); 
cout.precision(10);
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin>>n>>m;
cout<<(n+m-1)/m;
}
 
	
ll nChooseR( int n, int k )
{
    if (k > n) return 0;
    if (k * 2 > n) k = n-k;
    if (k == 0) return 1;
   	ll result = n;
    for( int i = 2; i <= k; ++i ) {
        result *= (n-i+1);
        result /= i;
    }
    return result;
}
 
ll gcd(ll a, ll b){
	return b==0?a:gcd(b,a%b);
	}
 
 
vector<string> split(string target,unsigned char c ){
	string d="";
	vector<string>arr;
	for(auto n:target)
	{
		if(n!=c)
		d+=n;
		else if(d!="")
		arr.push_back(d),d="";
	}
	if (d!="")
	arr.push_back(d),d="";
	return arr;
}
// bool isPrime(ll h){
//      for(ll i=0;primes[i]*primes[i]<= h;i++)
//      if (h%primes[i]==0)
//      	return 0;
//      return h!=1;
//  }
 bool isPrime(ll g){
   if((g%2==0 && g>2) || g==1)return 0;
   for(ll i=3;i*i<=g;i+=2)if(g%i==0)return 0;
   return 1;   
 
 }

Measured memory_bytes: 256
from math import ceil
N,K = map(int,input().split())
A=list(map(int,input().split()))


low=0
high=10**9+1

while low<=high:
    mid=(low+high)//2
    if mid==0: #0-div errorを消す
        print(1)
        exit()

    cnt=0
    for a in A:
        v=ceil(a/mid)
        cnt+=v-1

    if cnt<=K:
        high=mid-1
    else:
        low=mid+1
print(low)


Measured memory_bytes: 93940
#include<iostream>
#include<algorithm>

int calc(int a, int b){
	if (!b)return a;
	else return calc(b, a%b);
}

int main(){
	int a, b;
	std::cin >> a >> b;
	std::cout << calc(std::max(a, b), std::min(a, b)) << std::endl;
	return 0;
}

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

using namespace std;

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

#define INF 2<<29
#define F first
#define S second

int main(){
  int n;
  int cnt[10005]={};

  while(1){
    scanf("%d",&n);
    if(n==0) break;

    for(int i=0;i<n;i++){
      int c;
      scanf("%d",&c);
      cnt[c]++;
    }
    
    for(int i=0;i<10;i++){
      for(int j=0;j<cnt[i];j++){
	printf("*");
      }
      if(cnt[i]==0) printf("-");
      printf("\n");
    }
    fill(cnt,cnt+n,0);
  }
	       
  return (0);
}



Measured memory_bytes: 3196
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
#define ll long long
//ll a[20005],dp[20005],s[100];//这里需要定义为2倍，不然会内存不够，出现runtime
int main()
{
	int a,b,c,i,n;
	cin>>a>>b;
	cout<<100<<' '<<100<<endl;
	int j;
	for(i = 0;i < 50;i++){
        for(j = 0;j < 100;j++){
            if(i%2&&j%2&&a>1){
                cout<<'.';
                a--;
            }
            else{
                cout<<'#';
            }
        }
        cout<<endl;
	}
	for(i = 0;i < 50;i++){
        for(j = 0;j < 100;j++){
            if(i%2&&j%2&&b>1){
                cout<<'#';
                b--;
            }
            else{
                cout<<'.';
            }
        }
        cout<<endl;
	}
}


Measured memory_bytes: 256
#include<cstdio>
int vis[10];
int record[10];
int edge[5][5];

int find = 0;

void dfs(int p,int n){
    if(p==n+1){
        int ok = 1;
        for(int i = 1; i <= 3; i++){
            if(edge[record[i]][record[i+1]]==0) ok = 0;
        }
        find |= ok;
    }
    else{
        for(int i = 1; i <= 4; i++){
            if(!vis[i]){
                vis[i] = 1, record[p] = i;
                dfs(p+1,n);
                vis[i] = 0;
            }
        }
    }
}

int main(){
    for(int i = 0; i < 3; i++){
        int a,b;
        scanf("%d%d",&a,&b);
        edge[a][b] = edge[b][a] = 1;
    }   
    dfs(1,4);
    if(find==1) printf("YES\n");
    else printf("NO\n");
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
using namespace std;

typedef struct calc {
    int* top;
    int* data;
} calc_t;

calc_t* init(int size) {
    calc_t* calc = (calc_t*)malloc(sizeof(calc_t));
    calc->top = calc->data = (int*)malloc(sizeof(int) * size);
    return calc;
}

int pop(calc_t* stack) {
    if (stack->top == stack->data) {
        return -1;
    }
    int v = *(stack->data);
    stack->data--;
    return v;
}

int* push(calc_t* stack, int val) {
    int v = val;
    stack->data++;
    *(stack->data) = v;
    return stack->data;
}

int main() {
    calc_t* stack = init(200);
    string line;
    getline(cin, line);
    string buf;
    stringstream ss(line);
    while (ss >> buf) {
        if (buf == "+") {
            int v1 = pop(stack);
            int v2 = pop(stack);
            push(stack, v1 + v2);
        } else if (buf == "-") {
            int v1 = pop(stack);
            int v2 = pop(stack);
            push(stack, v2 - v1);
        } else if (buf == "*") {
            int v1 = pop(stack);
            int v2 = pop(stack);
            push(stack, v1 * v2);
        } else {
            push(stack, stoi(buf));
        }
    }

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

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

int main() {
	string S, T;
	cin >> S >> T;
	if (T.substr(0, S.size()) == S) puts("Yes");
	else puts("No");
	
	return 0;
}


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

using namespace std;
#define print(x) cout << x << endl;
//#define endl "\n"
#define rep(i, r) for(int i = 0; i < r; i++)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long

ll max(ll a, ll b) {
    if (a > b)
        return a;
    return b;
}

ll min(ll a, ll b) {
    if (a < b)
        return a;
    return b;
}

bool palindrome(string s, int l , int r)
{
    while(l < r)
    {
        if(s[l] != s[r])
            return false;
        l++;
        r--;
    }
    return true;
}

int main()
{
    string s;
    cin >> s;

    if(palindrome(s, 0, s.length() - 1))
    {
         if(palindrome(s, 0, (s.length() - 1) / 2 - 1))
            cout << "Yes" << endl;
         else
            cout << "No" << endl;
    }
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int gt(const vector<ll>::iterator &begin, const vector<ll>::iterator &end, ll x) {
    int u = distance(upper_bound(begin, end, x), end);
    auto er = equal_range(begin, end, x);
    int e = distance(er.first, er.second);
    return u + e;
}

int main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;

    vector<ll> xs(x), ys(y), zs(z);
    rep(i, x) cin >> xs[i];
    rep(i, y) cin >> ys[i];
    rep(i, z) cin >> zs[i];


    vector<ll> g;
    for (ll xi : xs) {
        for (ll yi : ys) {
            g.push_back(xi + yi);
        }
    }

    sort(g.rbegin(), g.rend());
    while (g.size() > k) g.pop_back();

    vector<ll> f;
    for (ll gi : g) {
        for (ll zi : zs) {
            f.push_back(gi + zi);
        }
    }

    sort(f.rbegin(), f.rend());


    rep(i, k) cout << f[i] << endl;
}


Measured memory_bytes: 44092
import java.io._
import scala.io.StdIn.{readInt, readLine}

object Main {
  val out:BufferedWriter =
    new BufferedWriter(new OutputStreamWriter(new FileOutputStream(java.io.FileDescriptor.out), "ASCII"), 512)
  var count = 0
  class Node(var key:Int, var left:Node = null, var right:Node = null) { }

  def insert(tree:Node, key:Node) = {
    val keyNode = key
    def getNodeToInsert(node:Node):Node =
      if(node.key > keyNode.key) {
        if(node.left == null) node
        else getNodeToInsert(node.left)
      } else {
        if(node.right == null) node
        else getNodeToInsert(node.right)
      }

    val target = getNodeToInsert(tree)

    if(keyNode.key < target.key) target.left = keyNode
    else target.right = keyNode
  }

  def inOrder(tree:Node):Unit =
    if(tree == null) return
    else {
      inOrder(tree.left)
      out.write(" ")
      out.write(tree.key.toString)
      if(count<50) count += 1
      else {
        out.flush
        count = 0
      }
      inOrder(tree.right)
    }

  def preOrder(tree:Node):Unit =
    if(tree == null) return
    else {
      out.write(" ")
      out.write(tree.key.toString)
      if(count<50) count += 1
      else {
        out.flush
        count = 0
      }
      preOrder(tree.left)
      preOrder(tree.right)
    }

  def main(args:Array[String]) = {
    val n = readInt
    val tree = new Node(-1)

    for(i<-0 until n) {
      val s = readLine.split(" ")
      s(0) match {
        case "insert" =>
          if(tree.key == -1) tree.key = s(1).toInt
          else insert(tree, new Node(s(1).toInt))
        case _ => {
          inOrder(tree)
          out.write("\n")
          out.flush()
          preOrder(tree)
          out.write("\n")
          out.flush()
        }
      }
    }
  }
}

Measured memory_bytes: 290312
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

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

	int n;
	scanf("%d", &n);
	vi a(n), b(n-1);
	for (int i = 0; i < n-1; i++) scanf("%d", &b[i]);
	a[0] = b[0], a[n-1] = b[n-2];
	for (int i = 1; i < n-1; i++) a[i] = min(b[i-1], b[i]);
	int ans = accumulate(all(a), 0);
	printf("%d\n", ans);
}


Measured memory_bytes: 256
i = 0
x = 0
y = 0
pi = Math::PI
while n = gets
  d,a = n.split(",").map(&:to_i)
  break if d==0 && a==0
  y = y + d*Math.cos(i*pi/180)
  x = x + d*Math.sin(i*pi/180)
  i = i + a
end
puts x.to_i
puts y.to_i


Measured memory_bytes: 6952
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
// #define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    ll D, T, S;
    cin >> D >> T >> S;
    if (D <= T * S) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

struct r {
    int i;
    string s;
    int p;
    
    bool operator < (const r& other) const
    {
        if (s == other.s) {
            return p > other.p;
        }
        return s < other.s;
    }
};

int main()
{
    // 整数の入力
    int n;
    cin >> n;
    
    vector<r> vr;
    for (int i = 1; i <= n; i++) {
        string s;
        int p;
        // 文字列と整数の入力
        cin >> s >> p;
        r res;
        res.i = i;
        res.s = s;
        res.p = p;
        vr.push_back(res);
    }
    
    // ソート
    sort(vr.begin(), vr.end());
    
    // 出力
    for (int i = 1; i <= n; i++) {
        cout << vr[i-1].i;
        if (i != n) {
            cout << " ";
        } else {
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
z = [0 for _ in range(n)]
w = [0 for _ in range(n)]

for i in range(n):
    x, y = map(int, input().split())
    z[i], w[i] = x+y, x-y

print(max(max(z)-min(z), max(w)-min(w)))

Measured memory_bytes: 24984
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N; cin>>N;
  int W[N];
  int ttl=0;  
  for (int i=0;i<N;++i){
    cin>>W[i];
    ttl+=W[i];
  }
  int mini=ttl;
  int tmp=0;
  for (int i=0;i<N;++i){
    tmp+=W[i];
    mini=min(mini,abs(tmp-(ttl-tmp)));
  }
  cout<<mini<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl

using namespace std;

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

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

int gcd(int a, int b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

bool compareP(pair<int, int> a, pair<int, int> b) {
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    int s[h][w];
    bool flag = true;
    if (h * (w - a) < b * w)
        flag = false;
    if (w * (h - b) < a * h)
        flag = false;
    if (!flag)
        cout << "No" << endl;
    else {
        rep(i, h) {
            rep(j, w) {
                if (i < b && j < a)
                    s[i][j] = 1;
                else if (i >= b && j >= a)
                    s[i][j] = 1;
                else
                    s[i][j] = 0;
                cout << s[i][j];
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;



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

    int h,w;
    cin >> h >> w;

    int sx,sy,gx,gy;
    cin >> sy >> sx >> gy >> gx;
    sx--;sy--;gx--;gy--;

    pair<int,int> s = make_pair(sx,sy), g = make_pair(gx,gy); 
    vector<vector<int>> ans(h,vector<int>(w,mod));
    string sur[h];

    for(int i = 0; i < h; i++) cin >> sur[i];

    auto inout = [&](int x,int y){
        if(0 <= x && x < w && 0 <= y && y < h) return true;
        else return false;
    };

    auto add = [&](pair<int,int> now,int dx,int dy){
        pair<int,int> ret = make_pair(now.first+dx,now.second+dy);
        return ret;
    };

    auto answer = [&](pair<int,int> now){
        if(now == g){
            cout << ans[now.second][now.first] << endl;
            return true;
        } else return false;
    };

    queue<pair<int,int>> p,q;

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

    p.push(s);
    ans[s.second][s.first] = 0;

    int can = 0;

    while(!p.empty()){
        while(!p.empty()){
            pair<int,int> now = p.front();
            p.pop();
            q.push(now);
            bool first = true;
            for(int i = 0; i < 4; i++){
                pair<int,int> nxt = add(now,dx[i],dy[i]);
                if(inout(nxt.first,nxt.second)){
                    if(sur[nxt.second][nxt.first] == '.'){
                        ans[nxt.second][nxt.first] = can;
                        if(answer(nxt)) return 0;
                        p.push(nxt);
                        sur[nxt.second][nxt.first] = '#';
                    }
                }
            }
        }
        can++;
        while(!q.empty()){
            pair<int,int> now = q.front();
            q.pop();
            for(int i = -2; i < 3; i++){
                for(int j = -2; j < 3; j++){
                    pair<int,int> nxt = make_pair(now.first+i,now.second+j);
                    if(inout(nxt.first,nxt.second)){
                        if(sur[nxt.second][nxt.first] == '.'){
                            ans[nxt.second][nxt.first] = can;
                            p.push(nxt);
                            sur[nxt.second][nxt.first] = '#';
                            if(answer(nxt)) return 0;
                        }
                    }
                }
            }
        }
    }

    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 8648
#include <stdio.h>

int main(){
	
	int a, b, c;
	int cnt;

	cnt = 0;

	scanf("%d %d %d", &a, &b, &c);

	for (int i = a; i <= b; i++){
		if ((c % i) == 0){
			cnt++;
		}
	}

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

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

#define B (1000000007ULL)
using namespace std;
typedef unsigned long long ull;

int h, w, r, c;
char t[1000][1001], p[1000][1001];
ull th[1000][1000], ph[1000];
int st[1001];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>h>>w;
    cin.ignore();
    for(int i=0; i<h; i++) 
        cin.getline(t[i], 1001);
    cin>>r>>c;
    cin.ignore();
    for(int i=0; i<r; i++) 
        cin.getline(p[i], 1001);

    for(int i=0; i<r; i++){
        for(int j=0; j<c; j++){
            ph[i]=ph[i]*B+p[i][j];
        }
    }
    ull bn=B;
    for(int i=1; i<c; i++) bn*=B;
    for(int i=0; i<h; i++){
        for(int j=0; j<c; j++) th[i][0]=th[i][0]*B+t[i][j];
        for(int j=0; j<w-c; j++) th[i][j+1]=th[i][j]*B-t[i][j]*bn+t[i][j+c];
    }
    for(int y=0; y<=h-r; y++){
        for(int x=0; x<=w-c; x++){
            int i;
            for(i=0; i<r&&th[y+i][x]==ph[i]; i++);
            if(i==r) cout<<y<<' '<<x<<'\n';
        }
    }
    return 0;
}

Measured memory_bytes: 12520
/*
 * author :Sadik Hassan
 *
*/
#include "bits/stdc++.h"
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define rep(i,n)      for(int i=0;i<n;i++)
#define repn(i,n)     for(int i=1;i<=n;i++)
#define rrep(i,n)     for(int i=n-1;i>=0;i--)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
#define TSFL(s)       transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSFH(s)       transform(s.begin(),s.end(),s.begin(),::tolower);
/*---------------------------------------------------------------------*/
const int N = 2e5+10;
const int INF = (int)1e9+5;

int main()
{
    _SAD()
    int n;
    bool fl=false;
    cin>>n;
    while(n--)
    {
        int a;
        cin>>a;
        if(a%2==0&&(a%3!=0&&a%5!=0))
        {
            fl=true;
        }
    }
    if(!fl)
    {
        cout<<"APPROVED"<<nl;
    }
    else
    {
        cout<<"DENIED"<<nl;
    }
    return 0;
}


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

using namespace std;
typedef pair<int, int> P;

int N, L;
int length[100000];

bool nobiruka(int x) {
	if (x < 0 || x >= N)return false;
	if (x == 0 && length[0] < length[1])return true;
	else if (x == N - 1 && length[N - 1] < length[N - 2])return true;
	else if (length[x] < length[x + 1] && length[x] < length[x - 1])return true;
	return false;
}

int main() {
	cin >> N >> L;
	for (int i = 0; i < N; i++)
		cin >> length[i], length[i] = L - length[i];
	priority_queue<P, vector<P>, greater<P>> pq;
	for (int i = 0; i < N; i++) {
		if (nobiruka(i))pq.push(P(length[i], i));
	}
	int ans = 0;
	while (pq.size()) {
		auto tmp = pq.top(); pq.pop();

		//cout << tmp.first << "A" << tmp.second << endl;

		ans += (tmp.first - ans);
		//cout << ans << endl;
		length[tmp.second] = 10000000;

		if (nobiruka(tmp.second + 1)) {
			pq.push(P(length[tmp.second + 1] + ans, tmp.second + 1));
		}

		if (nobiruka(tmp.second - 1)) {
			pq.push(P(length[tmp.second - 1] + ans, tmp.second - 1));
		}

	}

	cout << ans << endl;

	return 0;
}

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

long long f(double x){
  int c = x;
  if(x - c != 0){return c + 1;}
  else{return c;}

}

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

  double y;
  y = (pow(1 + 8 * n, 0.5) - 1) /2;
  cout << f(y) << endl;
}       

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main() {
	string s;
	getline(cin, s);
	for (int i = 0; i < s.size(); i++)
		if (s[i] >= 'a' && s[i] <= 'z')
			s[i] += 'A' - 'a';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 0
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限


a,b = input().split()
a = int(a)
b = int(round(float(b) * 100))
temp = str(a * b)[:-2]
if temp == "":
    temp = "0"
print(temp)


Measured memory_bytes: 9212
// #Sazaの1日1AC
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;
const long long INF=9e15;
const double PI=3.14159265358979323846;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
using vvl=vector<vector<long long>>;
using vP=vector<pair<long long, long long>>;
//ショートカット
#define rep(i,n) for(long long i = 0; i < n; i++)
#define rep2(i,k,n) for(long long i = k; i < n; i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mkp make_pair
//入力
#define vin(v,N) for(long long id=0;id<N;id++) cin>>v.at(id)
#define lin(n) long long n;cin>>n
#define chin(x) char x;cin>>x;
#define sin(s) string s;cin>>s;
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

#define max(a,b) max((ll)a,(ll)b)
#define min(a,b) min((ll)a,(ll)b)

//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x, long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//繰り返し二乗法
long long repeat_squaring(long long x, long long n){
  if(n==0) return 1;
  else if(n%2==0){
    long long t=repeat_squaring(x,n/2);
    return t*t%mod;
  }
  else
    return x*repeat_squaring(x,n-1);
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//構造体

/////////////////⊂('ω'⊂ )))Σ≡GO!/////////////////


//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  
  lin(N);lin(M);lin(X);
  vl c(N);
  vvl A(N, vl(M));
  rep(i, N){
      cin >> c[i];
      vin(A[i], M);
  }

  ll res = INF;
  rep(bit, (1<<N)){
    vector<bool> use(N, false);
    rep(i, N){
      if(bit & (1<<i)) use[i] = true;
    }
    vl p(M);
    ll cnt = 0;
    rep(i, N){
      if(use[i]){
        cnt += c[i];
        rep(j, M) p[j] += A[i][j]; 
      }
    }
    bool OK = true;
    rep(i, M){
      //cout << p[i] << " ";
      if(p[i] < X) OK = false;
    }
    //cout << endl;
    if(OK) chmin(res, cnt);
  }


  if(res != INF)
    cout << res << endl;
  else cout << -1 << endl;
}



Measured memory_bytes: 3608
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
typedef long long ll;
int main(void){
    ll n,p,ans=1;
    scanf("%lld%lld",&n,&p);
    for (ll i=1; i*i<=p; i++){
        if (p%i==0){
            if ((ll)p%(ll)(pow(i,n))==0){
                ans=ans>i?ans:i;
            }
            if ((ll)p%(ll)(pow(p/i,n))==0){
                ans=ans>i?ans:p/i;
            }
        }
    }
    printf("%lld\n",ans);
	return 0 ;
}

Measured memory_bytes: 384
import java.io.IOException;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) throws Exception{
		// TODO ?????????????????????????????????????????????
			Scanner sc = new Scanner(System.in);
			int []b = new int[26];
			char e;
			while(sc.hasNext()){
				String a = sc.next();
				a = a.toLowerCase();
				int c = a.length();
				for(int d=0 ; d<c ; d++){
					e = a.charAt(d);
					if((int)e>=97 && (int)e<=122){
						b[(int)e-97] += 1;
					}
				}
			}
			for(char d=97 ; d<123 ; d++){
				System.out.println(d+" : "+b[(int)d-97]);
			}
	}
}

Measured memory_bytes: 25952
#!/usr/bin/env python
# coding: utf-8

# In[1]:


S = input()
T = input()


# In[4]:


for i in range(len(S)):
    tmp = S[i:] + S[:i]
    if tmp == T:
        print("Yes")
        break
else:
    print("No")


# In[ ]:






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

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, s, e) for (int i = (s); i < (e); i++)
#define all(x) x.begin(), x.end()

#define endl "\n"

void use_cio() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}

template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
    os << "[";
    for (auto x : V) os << x << ", ";
    return os << "]";
}
//--------------------------------------------------//

int main() {
    use_cio();
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b) << " " << max(0, a + b - n);
}


Measured memory_bytes: 256
n=int(input())
a = [int(input()) for _ in range(n)]
ans=0
a.sort()
for i in range(n):
    if sum(a)%10 == 0:
        if a[i]%10 == 0:
            pass
        else:
            a[i]=0
    else:
        print(sum(a))
        exit(0)
print(0)

Measured memory_bytes: 9080
def judge(k, N, A):
    p = N - 1
    t = 0
    for i in A:
        while p >= 0 and A[p] + i < k:
            p -= 1
        t += (p + 1)
    return t
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort(reverse=True)
    t = A[0] * 2
    b = 0
    X = None
    while t - b > 1:
        m = (t + b)//2
        i = judge(m, N, A)
        if i == M:
            X = m
            break
        if i > M:
            ip = judge(m + 1, N, A)
            if ip == M:
                X = m + 1
                break
            if ip < M:
                X = m
                break
            b = m + 1
        if i < M:
            im = judge(m - 1, N, A)
            if im >= M:
                X = m - 1
                break
            t = m - 1
    if X is None:
        X = b
    r = 0
    p = N - 1
    k = sum(A)
    for i in A:
        while p >= 0 and A[p] + i < X :
            k -= A[p]
            p -= 1
        r += i * (p + 1) + k
    return r - (judge(X, N, A) - M) * X
print(main())


Measured memory_bytes: 53436
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    ll n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    vector<vector<ll>> dp(50, vector<ll>(2, -1));
    dp[49][0] = 0;
    //cout << "test" << endl;
    for (ll i = 48; i >= 0; --i) {
        ll cnt1 = 0;
        //cout << i << endl;
        rep(j, n) {
            if (a[j]&(1LL<<i)) {
                ++cnt1;
            }
        }
        if (dp[i+1][0] >= 0) {
            if ((k&(1LL<<i))) {
                dp[i][0] = max(dp[i][0], dp[i+1][0] + (n-cnt1) * (1LL<<i));
                dp[i][1] = max(dp[i][1], dp[i+1][0] + cnt1 * (1LL<<i));
            }
            else {
                dp[i][0] = max(dp[i][0], dp[i+1][0] + cnt1 * (1LL<<i));
            }
        }
        if (dp[i+1][1] >= 0) {
            dp[i][1] = max(dp[i][1], dp[i+1][1] + max(n-cnt1, cnt1) * (1LL<<i));
        }
    }
    //rep(i, 50) {
    //    cout << dp[i][0] << " " << dp[i][1] << endl;
    //}
    cout << max(dp[0][0], dp[0][1]) << endl;
    return 0;
}


Measured memory_bytes: 4056
#include<bits/stdc++.h>
using namespace std;
main(){
    int n;
    scanf("%d" , &n);
    int arr[n +100];
    for(int i = 1 ; i<= n ; i++){
        scanf("%d" , &arr[i]);
    }
    sort(arr+1 , arr + n +1);
    int mid = n /2;
    if(arr[mid] == arr[mid+1]){
        cout<<0;
    }
    else{
        cout<<arr[mid+1] - arr[mid];
    }
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
	int time, h, m, s;
	scanf("%d", &time);
	for(h = 0; h <= 24; h++){
		if(time-h*3600 < 3600){
			time = time-h*3600;
			break;
		}
	}
	for(m = 0; m <= 60; m++){
		if(time-m*60 < 60){
			time = time-m*60;
			break;
		}
	}
	s = time;
	printf("%d:%d:%d\n", h, m, s);
	return 0; 
}

Measured memory_bytes: 592
import statistics
N = int(input())
A = []
B = []
for _ in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)

A.sort()
B.sort()

if N % 2 == 1:
  med_min = A[N // 2]
  med_max = B[N // 2]
  print(med_max - med_min + 1)  
else:
  med_min_db = A[N // 2] + A[N // 2 - 1]
  med_max_db = B[N // 2] + B[N // 2 - 1]
  print(med_max_db - med_min_db + 1)





Measured memory_bytes: 27188
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long h,n,a;
  unsigned long long s=0;
  cin>>h>>n;
  for(register int i=0;i<n;i++)
  {
  	cin>>a;
  	s+=a;
  }
  if(s>=h) 
  return cout<<"Yes\n",0;
  else
  return cout<<"No\n",0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
struct PIECE{
  int s,width,depth;
  void init(int a,int b,int c){s=a;width=b;depth=c;}
};
bool operator<(PIECE a,PIECE b){return a.s<b.s;};
 
int main()
{
  int n,w,d,p,s;
  int i,w1,w2,d1,d2;
  vector<PIECE> piece;
  vector<PIECE>::iterator it;
 
  while(cin>>n>>w>>d,n|w|d){
    piece.clear();
    PIECE t={w*d,w,d};
    piece.push_back(t);
 
    for(i=0;i<n;i++){
      cin>>p>>s;
      it=piece.begin();advance(it,p-1);
      s %= 2*it->width + 2*it->depth;

      if(s < it->width){
	w1 = s;
	w2 = it->width - s;
	d1 = d2 = it->depth;
      }else if(s < it->width + it->depth){
	s -= it->width;
	w1 = w2 = it->width;
	d1 = s;
	d2 = it->depth - s;
      }else if(s < 2*it->width + it->depth){
	s -= it->width + it->depth;
	w1 = s;
	w2 = it->width - s;
	d1 = d2 = it->depth;
      }else{
	s -= 2*it->width + it->depth;
	w1 = w2 = it->width;
	d1 = s;
	d2 = it->depth - s;
      }
      if(w1*d1>w2*d2){
	swap(w1,w2);
	swap(d1,d2);
      }
      piece.erase(it);
      t.init(w1*d1,w1,d1);
      piece.push_back(t);
      t.init(w2*d2,w2,d2);
      piece.push_back(t);
    }
    sort(piece.begin(),piece.end());
    it=piece.begin();
    cout<<it->s;
    for(it++;it!=piece.end();it++)cout<<" "<<it->s;
    cout<<endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int H,W;

PII point(int i, int j){
  if(i&1) j = W-j-1;
  return PII(i,j);
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> H >> W;
  int N;cin >> N;
  int v[N];
  rep(i,N) cin >> v[i];
  vector<vector<int> > maze(W,vector<int> (H));
  int index = 0;
  int num = v[0];
  rep(i,H)rep(j,W){
    PII p = point(i,j);
    int y = p.first, x = p.second;
    maze[x][y] = index+1;
    --num;
    if(num==0){
      ++index;
      num = v[index];
    }
  }
  rep(y,H){
    rep(x,W) cout << maze[x][y] SPF;
    cout << endl;
  }
  return 0;
}


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

bool judge_mm(string s){
    if (stoi(s)>=1&&stoi(s)<=12){
        return true;
    }else{
        return false;
    }
}

int main(){
    string s;
    cin>>s;
    bool judged_mm_first_half = judge_mm(s.substr(0,2));
    bool judged_mm_later_half = judge_mm(s.substr(2,4));
    if (judged_mm_first_half && judged_mm_later_half){
        cout<<"AMBIGUOUS"<<endl;
    } else if (judged_mm_first_half && !judged_mm_later_half){
        cout<<"MMYY"<<endl;
    } else if (!judged_mm_first_half && judged_mm_later_half){
        cout<<"YYMM"<<endl;
    } else {
        cout<<"NA"<<endl;
    }
    return 0;
}


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

int main(){
    long long i, K, cnt;
    string S, ans;
    cin >> S >> K;

    cnt = 0;
    for (i = 0; i < min((long long)S.size(), K); i++){
      if(S[i] > '1'){
        cout << S[i] << endl;
        break;
      }
    cnt++;
    }
    if(cnt == min((long long)S.size(), K)){
      cout << 1 << endl;
    }
}

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

int max(int a, int b){
  return a >= b ? a : b;
}
int min(int a, int b){
  return b >= a ? a : b;
}
int sei(int a){
  return a>0 ? a : 0;
}
int factorial(int n) {
    if (n > 0) return n*factorial(n - 1);
		else return 1;
}
int compare_up_int(const void *a, const void *b){
   return *(int*)a - *(int*)b;
}
int compare_down_int(const void *a, const void *b){
   return *(int*)b - *(int*)a;
}
int euclid(int a, int b){
  if(a < b){int tmp = a;a = b;b = tmp;}
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  int N,D,X,count=0;
  scanf("%d",&N);
  scanf("%d %d",&D,&X);
  int num[N];
  for(int i=0;i<N;i++) scanf("%d",&num[i]);
  for(int i=0;i<N;i++){
    for(int j=0;j<100;j++){
      if(1 + j*num[i] <= D)count ++;
    }
  }
  printf("%d",X + count);
  return 0;
}


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

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


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
const ll INF = 1e9 + 7;
typedef pair<int,int> P;// pair型は２つの値の組を表せる

int main(){
    double N; cin >> N; //実数double
    int sum=0;
    vector <int> X(N);
    rep(i,N){
        cin >> X[i];
        sum+=X[i];
    }
    int mid=round(sum/N);
    
    int ans=0;
    rep(i,N) ans+=pow(X[i]-mid,2);
    
    cout << ans << endl;
    return 0;   
}

Measured memory_bytes: 256
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言

void solve();

string s;
string t;
int len;

int main() {
  cin >> s;

  solve();

  return 0;
}

void solve() {
  int flag = 1;

  s.pop_back();

  while((len=(int)(s.length()))>=2) {
    if(len%2!=1) {
      int sparate = len/2;
      for(int i=0; i<sparate; ++i) {
        if(s[i]!=s[i+sparate]) {
          flag = 0;
          break;
        }
      }
      if(flag==1) {
        cout << len << endl;
        break;
      }
      else flag = 1;
    }
    s.pop_back();
  }
}


Measured memory_bytes: 256