akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using pi = pair<int, int>;
const int MAXT = 1050000;

struct seg{
	int tree[MAXT], lim;
	void init(int n){
		memset(tree, 0x3f, sizeof(tree));
		for(lim = 1; lim <= n; lim <<= 1);
	}
	void upd(int x, int v){
		x += lim;
		tree[x] = v;
		while(x > 1){
			x >>= 1;
			tree[x] = min(tree[2*x], tree[2*x+1]);
		}
	}
	int query(int s, int e){
		s += lim;
		e += lim;
		int ret = 1e9;
		while(s < e){
			if(s % 2 == 1) ret = min(ret, tree[s++]);
			if(e % 2 == 0) ret = min(ret, tree[e--]);
			s >>= 1;
			e >>= 1;
		}
		if(s == e) ret = min(ret, tree[s]);
		return ret;
	}
}seg;

int solve(int h, int w, vector<pi> v){
	if(v.empty()) return h + w;
	sort(v.begin(), v.end());
	int ret = 0;
	seg.init(v.size() + 5);
	for(int i=0; i<2; i++){
		for(auto &j : v) j.second = w - j.second;
		vector<pi> stk;
		vector<pi> aux;
		aux.emplace_back(0, w / 2);
		v.emplace_back(h, w / 2);
		auto query = [&](int d, int u, int r){
			if(aux.empty() || aux.back().first < u) return d - u + r;
			int ret = d - aux.back().first + r;
			int ptr = lower_bound(aux.begin(), aux.end(), pi(u, -1)) - aux.begin();
			if(ptr != aux.size()){
				ret = max(ret, d - u + r - aux[ptr].second);
			}
			ret = max(ret, d + r - seg.query(ptr, (int)aux.size() - 2));
			return ret;
		};
		for(auto &j : v){
			if(j.second >= w / 2){
				int b = (stk.empty() ? 0 : stk.back().first);
				ret = max(ret, query(j.first, b, w));
				while(!stk.empty() && stk.back().second >= j.second){
					auto r = stk.back().second;
					stk.pop_back();
					auto u = (stk.empty() ? 0 : stk.back().first);
					ret = max(ret, query(j.first, u, r));
				}
				stk.push_back(j);
			}
			else{
				while(!aux.empty() && aux.back().second <= j.second){
					if(aux.size() >= 2) seg.upd(aux.size() - 2, 1e9);
					aux.pop_back();
				}
				aux.push_back(j);
				if(aux.size() >= 2) seg.upd(aux.size() - 2, aux[aux.size()-2].first + aux[aux.size()-1].second);
			}
		}
		v.pop_back();
	}
	return ret;
}

int find_best_stages(int H, int W, int N, std::vector<int> X, std::vector<int> Y){
	H <<= 1;
	W <<= 1;
	for(auto &i : X) i <<= 1;
	for(auto &i : Y) i <<= 1;
	vector<pi> punk1, punk2;
	for(int i=0; i<N; i++){
		if(X[i] == 0 || Y[i] == 0 || X[i] == H || Y[i] == W) continue;
		punk1.emplace_back(X[i], Y[i]);
		punk2.emplace_back(Y[i], X[i]);
	}
	return max(solve(H, W, punk1), solve(W, H, punk2));
}

int main(){
	int H, W, N;
	scanf("%d %d %d",&H,&W,&N);
	vector<int> X(N), Y(N);
	for(int i=0; i<N; i++) scanf("%d %d",&X[i],&Y[i]);
	cout << find_best_stages(H,W,N,X,Y) << endl;
}

Measured memory_bytes: 27060
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int N;
  string ans="";
  cin >> N;

  if(N < 1000){
    ans = "ABC";
  } else {
    ans = "ABD";
  }
  print(ans);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int r=gi();
	    int d=gi();
	    int x=gi();
        
        for (int i=0; i<10; i++) {
        	x=r*x-d;
        	System.out.println(x);
        }

        //System.out.print(v);

//        if (b>=1 && b<=12) {
//        	if(a>=1 && a<=12) {
//        	    System.out.println("AMBIGUOUS");
//        	} else {
//        		System.out.println("MMYY");
//        	}
//        }else {
//        	if(a>=1 && a<=12) {
//        	    System.out.println("YYMM");
//        	} else {
//        		System.out.println("NA");
//        	}
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35624
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    n: usize,
    a: usize,
    b: usize,
    s: chars
    }
    calc(n, a, b, s);
}

fn calc(n: usize, a: usize, b: usize, s: Vec<char>) {
    let mut domestic: usize = 0;
    let mut ex: usize = 0;
    for c in s {
        match c {
            'a' => {
                let ok = domestic + ex < a + b;
                if ok {
                    println!("Yes");
                    domestic += 1;
                } else {
                    println!("No");
                }
            }
            'b' => {
                let ok = (domestic + ex < a + b) && (ex < b);
                if ok {
                    println!("Yes");
                    ex += 1;
                } else {
                    println!("No");
                }
            }
            _ => println!("{}", "No"),
        }
    }
}

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

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

	if(s >= 'A' && s <= 'Z'){
		cout << "A" << endl;
	}else if(s >= 'a' && s <= 'z'){
		cout << "a" << endl;
	}

	

	return 0;
}

Measured memory_bytes: 3620
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let n:usize = read();
    let s:String = read();
    let mut c = s.chars().collect::<Vec<char>>();
    c.dedup();
    println!("{}", c.len());
}

Measured memory_bytes: 2704
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>
#include <set>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d\n",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

//最大公約数
ll gcd(ll a, ll b) {
	if (a%b == 0)
		return b;
	return gcd(b, a%b);
}

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

	m = max({a,b,c});

	int answer = (m - a) / 2 + (m - b) / 2 + (m - c) / 2;

	int t = (m - a) % 2 + (m - b) % 2 + (m - c) % 2;

	if (t == 1)
		answer += 2;
	else if (t == 2)
		answer += 1;

	cout << answer << endl;

	return 0;
}


Measured memory_bytes: 256
class BIT:
            
    def __init__(self, L):
        self.N = len(L)
        self.bit = [0]*self.N
        for i,l in enumerate(L):
            self.add(i,l)

    def add(self, a, w):
        x = a + 1
        for i in range(1000):
            self.bit[x-1] += w
            x += x & -x
            if x > self.N:
                break

    def sum(self, a):
        x = a+1
        ret = 0
        for i in range(1000):
            ret += self.bit[x-1]
            x -= x & -x
            if x <= 0:
                break        
        return ret



N,K = list(map(int,input().split()))

A = list(map(int,input().split()))

S_tag = [0]*2001

for i in range(N):
        S_tag[A[i]]+=1

bit=BIT([0]*2001)

bit.add(A[0],1)
count = 0

for i in range(1,N):
        count+=bit.sum(2000)-bit.sum(A[i])
        bit.add(A[i],1)

mod = 10**9 + 7

ans = 0
for i in range(1,2001):
        ans += bit.sum(i-1)*S_tag[i]

ans *= (K*(K-1))//2
ans %= mod

ans += K*count
ans %= mod

print(ans)

Measured memory_bytes: 43244
import numpy as np
N = int(input())

coin = [6**n for n in range(10) if 6**n <= N]
coin += [9**n for n in range(10) if 9**n <= N]

dp = np.zeros(N+1, dtype=np.int32)
dp += 10**9
dp[0] = 0

for c in coin:
  for _ in range(9):
    dp[c:] = np.minimum(dp[:-c] + 1, dp[c:])

answer = dp[-1]
print(answer)


Measured memory_bytes: 13636
#!/usr/bin/env python3
from collections import deque

n, m = map(int, input().split())
ab = [input() for _ in range(m)]
# print(ab)
edge = [[] for _ in range(n)]  # 頂点n が辺を持つ頂点 かつ、へんの番号を入れる
for i in range(m):
    a, b = map(int, ab[i].split())
    a, b = a - 1, b - 1
    # print(a, b, edge)
    edge[a].append((b, i))
    edge[b].append((a, i))
ans = 0
for i in range(m):  # 全ての辺を消してみる
    visit = [0] * n
    visit[0] = 1
    stack = deque()
    stack.append(0)
    while stack:
        pos = stack.popleft()
        for j in edge[pos]:
            if j[1] == i or visit[j[0]]:  # その辺は使えない or すでに頂点に行っている
                pass
            else:
                stack.append(j[0])
                visit[j[0]] = 1
    # print(visit)
    if sum(visit) != n:
        ans += 1
print(ans)


Measured memory_bytes: 3316
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main{
    private static final Map<Integer, String> MAPPING = new HashMap<Integer, String>() {{
        put(22, "Christmas Eve Eve Eve");
        put(23, "Christmas Eve Eve");
        put(24, "Christmas Eve");
        put(25, "Christmas");
    }};

    public static String process(TestCase testCase) {
        final int D = testCase.D;
        return MAPPING.get(D);
    }

    // Util func

    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final String result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        int D = sc.nextInt();

        sc.close();
        return new TestCase(D);
    }

    private static void output(String result) {
        System.out.println(result);
    }

    public static class TestCase {
        final int D;

        public TestCase(int D) {
            this.D = D;
        }
    }
}


Measured memory_bytes: 22868
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, m = sc.nextInt()
  val e = List.fill(m)((sc.nextInt()-1, sc.nextInt()-1))
  val adj = Array.fill(n)(List[Int]())
  for ((a, b) <- e) {
    adj(a) ::= b
    adj(b) ::= a
  }

  println(if (adj(0).flatMap(adj).contains(n-1)) "POSSIBLE" else "IMPOSSIBLE")
}


Measured memory_bytes: 85988
N, A, B, C, D = map(int, input().split())
S = input()

def check() :
    if '##' in S[A-1:C] or '##' in S[B-1:D] :
        return 'No'

    if C < D or '...' in S[B-2:D+1] :
        return 'Yes'

    return 'No'
        

print(check())

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

using namespace std;
using ll = long long;
constexpr ll mod = 1e9+7;
constexpr ll md = mod;
constexpr ll inf = 1e15;
int main(){
    int a,x;
    cin>>x>>a;
    if(a > x) cout << 0 << endl;
    else if(a <= x) cout << 10 << endl;
    return 0;
}



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

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define boost ios::sync_with_stdio(0); cin.tie(0)

#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

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

const int N = 1e6 + 5;

/***************************************************************************/

int dp[N];
int H[N];

int main() {

	boost;
	int n; cin>>n;
	for(int i=1; i<=n; i++) {
		cin>>H[i];
	}
	dp[n] = 0;
	dp[n-1] = abs(H[n-1]-H[n]);
	for(int i=n-2; i>=1; i--) {
		dp[i] = min(abs(H[i]-H[i+1]) + dp[i+1], abs(H[i]-H[i+2]) + dp[i+2]);
	}
	cout<<dp[1]<<"\n";
	return 0;
}

Measured memory_bytes: 4736
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String S= sc.next();
        String[] SArray = new String[S.length()];
        long K=sc.nextLong();
        long num=0;
        for (int i = 0; i < S.length(); i++) {
            SArray[i] = String.valueOf(S.charAt(i));
            int a=Integer.parseInt(SArray[i]);
            if(a!=1)num +=K+1;
            else num++;
            if(num>=K){
                System.out.println(SArray[i]);
                return;
            }
        }
        
    }
}


Measured memory_bytes: 22868
def num_paths(trail, num_all_nodes, edges):
    if len(trail) == num_all_nodes:
        return 1

    count = 0
    for dest in edges[trail[len(trail)-1]]:
        if dest in trail:
            continue
        count += num_paths(trail + [dest], num_all_nodes, edges)
    return count


def main():
    n, m = [int(x) for x in input().split()]
    edges = [set() for i in range(n)]
    for i in range(m):
        a, b = [int(x) - 1 for x in input().split()]
        edges[a].add(b)
        edges[b].add(a)
    print(num_paths([0], n, edges))


main()


Measured memory_bytes: 41564
#include <vector>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <string.h>
using namespace std;

int main()
{
  int i;
  string s, tomorrow;
  cin >> s;
  tomorrow.clear();
  if (s[0] == 'S')
  {
    tomorrow += "Cloudy";
  }
  if (s[0] == 'C')
  {
    tomorrow += "Rainy";
  }
  if (s[0] == 'R')
  {
    tomorrow += "Sunny";
  }
  
  cout << tomorrow;

  return 0;  
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
	int N; cin >> N;
	cout << pow(N,3) << endl;
}



Measured memory_bytes: 256
def main():
    H, W = map(int, input().split())
    C = list(list(map(int, input().split())) for _ in range(10))
    A = list(list(map(int, input().split())) for _ in range(H))
    for k in range(10):
        for i in range(10):
            for j in range(10):
                C[i][j] = min(C[i][j], C[i][k] + C[k][j])

    ans = 0
    for h in range(H):
        for w in range(W):
            if A[h][w] != -1:
                ans += C[A[h][w]][1]

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 40540
#!/usr/bin/env python3
import sys

INF = float('inf')

def solve(n: int, A: "List[int]"):
    dp = [[INF] * 5  for _ in range(n + 1)]
    dp[0][0] = 0
    dp[0][1] = 0
    dp[0][2] = 0
    for i in range(n):
        for j in range(5):
            if j == 0 or j == 4:
                extra = A[i]
            elif j == 1 or j == 3:
                extra = A[i] % 2 if A[i] > 0 else 2
            else:
                extra = (A[i] + 1) % 2
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + extra)
            for k in range(j + 1, 5):
                dp[i + 1][k] = min(dp[i + 1][k], dp[i][j] + extra)
        #print(dp[i + 1])
    print(min(dp[n]))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    L = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(L) ]  # type: "List[int]"
    solve(L, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 67804
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int [] valu = new int[1000];
        for (int i = 1; i <= 999; i++) {
            valu[i] = (i * (i+1)) / 2;
        }
        int a = input.nextInt();
        int b = input.nextInt();
        for (int i = 1; i < 1000; i++) {
            if ( valu[i] >= a   &&  valu[i+1] >= b  ){
                if ((a - valu[i]) == (b - valu[i+1])){
                    System.out.println( valu[i] - a);
                    break;
                }
            }
        }

    }
}


Measured memory_bytes: 23764
#include<stdio.h>
main()
{
    int A,B,C,d,e,f=0;
    scanf("%d%d%d",&A,&B,&C);
    d=A-B;
    e=C-d;
    if(e>0)
        printf("%d",e);
    else printf("%d",f);
    return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
 class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		Scanner scanner = new Scanner(System.in);
		int num = scanner.nextInt();
		Node root = null;

		for (int i = 0; i < num; i++) {
			String element = scanner.next();
			if (!element.equals("print")) {
				int key = scanner.nextInt();
				Node node = new Node(key);
				if (root == null) {
					root = node;
					continue;
				}
				treeInsert(root, node);
			} else {
				StringBuilder stringBuilder = new StringBuilder();
				root.inorderTreeWalk(stringBuilder);
				System.out.println(stringBuilder);
				stringBuilder = new StringBuilder();
				root.preorderTreeWalk(stringBuilder);
				System.out.println(stringBuilder);
			}
		}

	}

	static void treeInsert(Node root, Node z) {
		Node y = null;
		Node x = root;
		while (x != null) {
			y = x;
			if (z.key < x.key) {
				x = x.leftChild;
			} else {
				x = x.rightChild;
			}
		}
		z.parent = y;

		if (y == null) {
			root = z;
		} else if (z.key < y.key) {
			y.leftChild = z;
		} else {
			y.rightChild = z;
		}
	}
}
 class Node {
	/** ????????????????????§??? */
	public Node parent;
	
	/** ???????????§??? */
	public Node rightChild;
	
	/** ???????????§??? */
	public Node leftChild;
	
	/** ?????????????????§??? */
	public int key;
	
	public Node(int key) {
		this.key = key;
	}
	
	/** ??????????????????????????? */
	public void inorderTreeWalk(StringBuilder stringBuilder) {
		if (leftChild != null) {
			leftChild.inorderTreeWalk(stringBuilder);
		}
		stringBuilder.append(" " + String.valueOf(key));
		if (rightChild != null) {
			rightChild.inorderTreeWalk(stringBuilder);
		}
	}
	
	/** ??????????????????????????? */
	public void preorderTreeWalk(StringBuilder stringBuilder) {
		stringBuilder.append(" " + String.valueOf(key));
		if (leftChild != null) {
			leftChild.preorderTreeWalk(stringBuilder);
		}
		if (rightChild != null) {
			rightChild.preorderTreeWalk(stringBuilder);
		}
	}
}

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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using v2 = vector<vector<int>>;
using vc2 = vector<vector<char>>;
int H;
int W;
v1 mh = {-1, 0, 0, 1};
v1 mw = {0, -1, 1, 0};

void paint(vc2& s, int h, int w){
	if(s.at(h).at(w) == '.') return;
	rep(i, 4){
		int nh = h + mh.at(i);
		int nw = w + mw.at(i);
		if(nh >= H || nw >= W || nh <0 || nw<0) continue;
		if(s.at(nh).at(nw) == '#'){
			s.at(h).at(w) = 'b';
			s.at(nh).at(nw) = 'b';
		}
	}
}


int main(){
	cin >> H >> W;
	vc2 s(H,vector<char>(W));
	rep(i, H){
		rep(j, W){
			cin >> s.at(i).at(j);
		}
	}
	rep(i, H){
		rep(j, W){
			paint(s, i, j);
		}
	}
	rep(i, H){
		rep(j, W){
			if(s.at(i).at(j)== '#'){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
def main():
    x, y = list(map(int, input().split()))

    for i in range(0, x+1):
        if i * 2 + (x-i) * 4 == y or (x-i) * 4 + i * 2 == y:
            print('Yes')
            exit()
    print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
from fractions import gcd

k=int(input())
count = 0

g = {}
for i in range(1,k+1):
    for j in range(i,k+1):
        x = gcd(i,j)
        if i==j:
            y=1
        else:
            y=2
        if x in g:
            g[x] += y
        else:
            g[x] = y
            
for i in g:
    for j in range(1,k+1):
        x = gcd(i,j)
        count += x*g[i]
        
print(count)

Measured memory_bytes: 10680
import math
n = int(input())
# ans = [0 for _ in range(n)]
ans = [0] * n

for x in range(1, int(math.sqrt(n+1))):
    x2 = x*x
    for y in range(1, int(math.sqrt(n+1))):
        y2 = y*y
        xy = x * y
        tmp = x2 + y2 + xy
        if tmp >= n:
            break
        for z in range(1, int(math.sqrt(n+1))):
            tmp2 = tmp + z*z + y*z + z*x
            if tmp2 > n:
                break
            try:
                ans[tmp2 - 1] += 1
                # print(x, y, z)
            except:
                pass
for i in range(n):
    print(ans[i])


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

int main() {
	int a[3];
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	sort(a, a + 3);
	cout << a[0] << " " << a[1] << " " << a[2] << endl;
	return 0;
}


Measured memory_bytes: 3156
#include<bits/stdc++.h>
#define mod 1000000007
// #define pie 3.141592653589793238
#define mod1 998244353
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int li;
typedef unsigned long long int ull;
using namespace std;
bool sortbysec(const pair<li,li>&a,const pair<li,li>&b)
{
    return (a.second<b.second);
}
li mpow(li x,li y)
{
  li ans=1;
  while(y)
  {
    if(y%2!=0)
    ans=(ans%mod)*(x%mod)%mod;
    y/=2;
    x=((x%mod)*(x%mod))%mod;
  }
  return ans;
}
int main()
{
fast_io
li r;
long double pie=3.141592653589793238;
cin>>r;
cout<<fixed<<setprecision(10)<<2*pie*r;
  return 0;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int a=0,b=0;
  for(int i=0;i<3;i++){
    int input;
    cin >> input;
    if(input==5)a++;
    if(input==7)b++;
  }
  if(a==2&&b==1)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int w,h,n;
string mp[31];
string str[2][31],res[31];

void fall(){
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      if(res[i][j] == '.')
	for(int k=i;k>0;k--) swap(res[k][j],res[k-1][j]);
  for(int i=0;i<h;i++) str[0][i] = str[1][i] = res[i];
}
int es(){
  int flg = 0;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
      if(str[0][i][j] != '.'){
	int cnt=1;
	while(j+cnt<w && str[0][i][j+cnt] == str[0][i][j])cnt++;
	if(cnt>=n)for(int k=0;k<cnt;k++)res[i][j+k] = '.',flg++; 
      }
      if(str[1][i][j] != '.'){
	int cnt =1;
	while(i+cnt<h && str[1][i+cnt][j] == str[1][i][j])cnt++;
	if(cnt>=n)for(int k=0;k<cnt;k++) res[i+k][j] = '.',flg++;
      } 
    }
  return flg;
}
bool check(){
  for(int i=0;i<h;i++) res[i]= mp[i];
  fall();
  while(es() != 0) fall();

  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      if(res[i][j]!='.') return false;
  return true;
}

int main() {
  cin >> h >> w >> n;
  for(int i=0;i<h;i++)cin >> mp[i];
  int ans = check();
  for(int i=0;i<h;i++){
    for(int j=0;j<w-1;j++){
      if(mp[i][j] =='.' && mp[i][j+1] == '.') continue;
      if(ans == true) break;
      swap(mp[i][j],mp[i][j+1]);
      ans = check();
      swap(mp[i][j],mp[i][j+1]);
    }
    if(ans == true) break;
  }
  if(ans) cout << "YES"<<endl;
  else cout <<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 1216
#include <iostream>

int main() {
  int N;
  std::cin >> N;
  int A[1 << 20];
  for (int i = 0; i < N; ++i)
    std::cin >> A[i];

  int count = 1;
  bool pos = false, neg = false;
  for (int i = 1; i < N; ++i) {
    if (A[i - 1] < A[i]) {
      pos = true;
      if (neg) {
        ++count;
        pos = neg = false;
      }
    } else if (A[i - 1] > A[i]) {
      neg = true;
      if (pos) {
        ++count;
        pos = neg = false;
      }
    }
  }

  std::cout << count << std::endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
ll A[5000001],bin[5000001];
vector<ll>v;
map<int,int>myMap;
set<int>mySet;
vector<pair<ll,ll> >vp;
/* Precode Start Here *\


    Integer  to Binary

void bti(ll n)
{
ll k=1;
  while(n!=0)
    {
    bin[k++]=n%2;
    n/=2;
    }
}

     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}


/* Precode Ends */
int main()
{
    ll k,cnt=0,inside=0,mark;
    string s,a;
    cin>>s;
    cin>>k;
    for(int i=0;i<s.size();i++)
    {
        if(s[0]==s[i])
        {
            cnt++;
        }
    }
    if(cnt==s.size())
    {
        cout<<(s.size()*k)/2<<endl;
        return 0;
    }
    else if(s[0]!=s[s.size()-1])
    {
        cnt=0;
        for(int i=0;i<s.size();i++)
        {
            if(s[i]==s[i+1])
            {
                cnt++,i++;
            }
        }
        cout<<cnt*k<<endl;
    }
    else
    {
        cnt=0;
        ll first=0,last=s.size()-1,bac=0;
        for(int i=0;i<s.size();i++)
        {
            if(s[i]==s[i+1])
            {
                cnt++,i++;
            }
        }
        while(s[0]==s[first])
        {
            first++;
        }
        while(s[s.size()-1]==s[last])
        {
            last--,bac++;
        }
        //cout<<cnt<<" "<<first<<" "<<bac<<endl;
        cout<<cnt*k-(first/2+bac/2-(first+bac)/2)*(k-1)<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i, n) for (int i = 0, i##_cond = (n); i < i##_cond; ++i)
#define FOR(i, a, b) for (int i = (a), i##_cond = (b); i < i##_cond; ++i)
#define ROF(i, a, b)                                                           \
  for (int i = (a)-1, i##_cond = (b); i >= i##_cond; --i) // ROF(i,n,0)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend() // sortで降順
#define SUM(a) accumulate(all(a), int(0))
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
constexpr ll inf = 1ll << 61;
constexpr ll mod = 1e9 + 7;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> T add(const T &a, const T &b) { return (a + b) % mod; }

signed main() {
  int a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  if (v <= w and a != b) {
    cout << "NO" << endl;
    return 0;
  }
  int c = abs(a - b), d = abs(v - w);
  if (t * d >= c) {
    cout << "YES" << endl;
    return 0;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3636
n = gets.to_i
h = gets.split.map(&:to_i)

(n-2).downto(0) do |i|
  h[i] -= 1 if h[i] > h[i+1]
end

yes = true
(n-1).times do |i|
  if h[i] > h[i+1]
    yes = false
  end
end
puts yes ? "Yes" : "No"

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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;


const int MX = 1e5 + 5;
int N, M;
string S;
int dp[MX], nxt[MX];


int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	cin >> N >> M >> S;

	set<pii> s;

	s.insert(mp(0, N));

	for (int i = N - 1; i >= 0; --i) {
		db(i, s);
		while (!s.empty() && s.begin()->sc > i + M)
			s.erase(s.begin());
		if (s.empty()) {
			cout << "-1\n";
			return 0;
		}
		if (S[i] == '1')
			dp[i] = OO;
		else {
			dp[i] = 1 + s.begin()->fs;
			nxt[i] = s.begin()->sc;
			s.insert(mp(dp[i], i));
		}
	}

	int curr = 0;

	assert(dp[curr] <= N);


	while (curr != N)
		cout << nxt[curr] - curr << " \n"[nxt[curr] == N], curr = nxt[curr];


	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
    return 0;
}


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

const ll mod=360;
ll mu(ll a,ll b){
  return (ll)a*b%mod;
}
ll ad(ll a,ll b){
  if((a+=b)>=mod)a%=mod;
  return a;
}
ll pw(ll a,ll b,ll c=1LL){
  for(;b;b>>=1,a=mu(a,a))if(b&1)c=mu(c,a);
  return c;
}
ll dv(ll a,ll b){
  return mu(a,pw(b,mod-2));
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x;
  cin >> x;

  ll g = gcd(360,x);

  cout << 360/g << endl;

  
  return 0;
    

}


Measured memory_bytes: 3632
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//                                                                              NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first 
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define debug4(w,x,y,z) cout<<#w<<" "<<w<<" "<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
#define sz(x) (ll)((x).size())
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
	double r;
	cin>>r;
	cout<<setprecision(20)<<(44*r)/7;
	return 0;
}


Measured memory_bytes: 3788
c = [1.1,0.6,0.2,0.0]
r = [[0,0] for i in range(4)]
while True:
    try:
        e = map(float, raw_input().split())
        for i in range(2):
            for j in range(4):
                if e[i] >= c[j]:
                	r[j][i] += 1
                	break
    except:
        break
for i in range(4):
	print r[i][0],r[i][1]

Measured memory_bytes: 4240
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct BINNODE {
	int key;
	BINNODE *parent;
	BINNODE *left;
	BINNODE *right;

	BINNODE (int k) {
		key=k;
		parent=nullptr;
		left=nullptr;
		right=nullptr;
	}
};

void preorderwalk(BINNODE* root) {
	if(root==nullptr) return;
	printf(" %d",root->key);
	preorderwalk(root->left);
	preorderwalk(root->right);
	return;
}

void inorderwalk(BINNODE* root) {
	if(root==nullptr) return;
	inorderwalk(root->left);
	printf(" %d",root->key);
	inorderwalk(root->right);
	return;
}

bool findnode(int v, BINNODE* root) {
	if(root == nullptr) return false;
	if(root->key ==v ) return true;
	return (v< root->key)?findnode(v,root->left) : findnode(v,root->right);
}

int main() {
	int m,v;
	int i;
	string cmd;
	BINNODE* root=nullptr;
	BINNODE* x;
	BINNODE* y;
	BINNODE* z;
	cin >> m;
	for(i=0; i<m; ++i) {
		cin >> cmd;
		if(cmd=="find") {
			cin >> v;
			printf(findnode(v,root) ? "yes\n" : "no\n");
		} else if(cmd=="insert") {
			cin >> v;
			z=new BINNODE(v);
			y=nullptr;
			x=root;
			while(x!=nullptr) {
				y=x;
				if (z->key < x->key) {
					x=x->left;
				} else {
					x=x->right;
				}
			}
			z->parent = y;

			if(y==nullptr) {
				root=z;
			} else if(z->key < y->key) {
				y->left = z;
			} else {
				y->right = z;
			}
		} else {
			inorderwalk(root);
			printf("\n");
			preorderwalk(root);
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 22024
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>
#include <queue>
#include <stack>

using namespace std;



int main() {
	string n;
	cin >> n;
	if (n.size()==3) {
		
		if (n[2] == '2' || n[2] == '4' || n[2] == '5' || n[2] == '7' || n[2] == '9')cout << "hon";
		else if (n[2] == '0' || n[2] == '1' || n[2] == '6' || n[2] == '8')cout << "pon";
		else cout << "bon";
	}
	else if (n.size()==2) {
		
		if (n[1] == '2' || n[1] == '4' || n[1] == '5' || n[1] == '7' || n[1] == '9')cout << "hon";
		else if (n[1] == '0' || n[1] == '1' || n[1] == '6' || n[1] == '8')cout << "pon";
		else cout << "bon";

	}
	else {
		if (n[0] == '2' || n[0] == '4' || n[0] == '5' || n[0] == '7' || n[0] == '9')cout << "hon";
		else if (n[0] == '0' || n[0] == '1' || n[0] == '6' || n[0] == '8')cout << "pon";
		else cout << "bon";
	}


	return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ll N, A, B; cin >> N >> A >> B;
  ll a = N / (A + B);
  ll b = N % (A + B);
  cout << A * a + min(A, b) << endl;
}


Measured memory_bytes: 256
n=int(input())
lst=[input().split() for _ in range(n)]
lst_j=[]
for i in lst:
    if i[1]=='JPY':
        lst_j.append(int(i[0]))
    elif i[1]=='BTC':
        lst_j.append(float(i[0])*380000)
print(sum(lst_j))

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


int main()
{
  int x, y;
  cin >> x >> y;
  rep(i, x + 1)
  {
    if (i * 2 + (x - i) * 4 == y)
    {
      puts("Yes");
      return 0;
    }
  }
  puts("No");
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
#define MODSIZE 1000000007
priority_queue<int, vector<int>, greater<int> > PQ; // 昇順PQ
// priority_queue<int> PQ;

int main(){
  char s[25];
  scanf("%s", s);

  int i;
  for(i = 0;i < 3;i++) printf("%c", s[i]);
  printf("\n");
  return 0;
}


Measured memory_bytes: 3764
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int64 div_ceil(int64 lhs, int64 rhs){ return (lhs-1)/rhs + 1; }

void solve(const int64 C, const int64 S, const int64 F, int64& now){
    int64 diff = now - S;
    if(diff > 0ll){
        now += F * div_ceil(diff, F) - diff;
    }else{
        now += abs(diff);
    }
    now += C;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N; cin >> N;
    vector<int> vC(N-1), vS(N-1), vF(N-1);
    for(int i=0; i<N-1; ++i){
        cin >> vC[i] >> vS[i] >> vF[i];
    }
    
    for(int b=0; b<N-1; ++b){
        int64 now = 0ll;
        for(int i=b; i<N-1; ++i){
            solve(vC[i], vS[i], vF[i], now);
        }
        cout << now << endl;
    }
    cout << '0' << endl;
    
    return 0;
}


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


typedef std::pair<std::string, int> dataType;
typedef std::pair<std::pair<std::string, int>, int> pairDataType;

bool compareStr(const pairDataType& a, const pairDataType& b)
{
    return a.first.first < b.first.first;
}

bool compare(const pairDataType& a, const pairDataType& b)
{
    if(a.first.first == b.first.first)
        return a.first.second> b.first.second;
    else
        return false;
}

int main() {

    int N;
    std::cin >> N;
    std::vector<std::pair<std::pair<std::string, int>, int>> data;

    data.resize(N);

    for(int i=0; i<N; ++i)
    {
        std::cin >> data[i].first.first >> data[i].first.second;
        data[i].second = i;
        data[i].first.second = - data[i].first.second;
    }

    std::sort(data.begin(), data.end());

    for(int i=0; i<N; ++i)
    {
        std::cout << data[i].second+1 << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int h1,h2,w,t,y,a,i,q,wh;
  scanf("%d %d",&w,&a);
  //if(w%2==1)wh=w-1;
  for(i=0;i<a;i++){
    h1=0;
    h2=0;
    scanf("%d %d",&y,&t);
    if(t+y>=w+1)h2=1;
    if(t>=y)h1=1;
    if(h1==0&&h2==0)q=t%3;
    if(h1==1&&h2==0)q=y%3;
    if(h1==0&&h2==1)q=(w-y+1)%3;
    if(h1==1&&h2==1)q=(w-t+1)%3;
    if(q==0)printf("3\n");
    else printf("%d\n",q);
  }
  return 0;
}

Measured memory_bytes: 1036
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,k,c,len,tot;
int l[N],r[N];
char str[N];
int main(){
	scanf("%d%d%d",&n,&k,&c);
	scanf("%s",str+1);
	len=strlen(str+1);
	int i=1;
	while (i<=len)
	{
		if (tot==k) break;
		if (str[i]=='o') l[++tot]=i,i+=c+1;
		else i++;
	}
	i=len;
	tot=0;
	while (i>=1)
	{
		if (tot==k) break;
		if (str[i]=='o') r[++tot]=i,i-=c+1;
		else i--;
	}
	reverse(r+1,r+tot+1);
	for (register int i=1; i<=tot; ++i) if (l[i]==r[i]) printf("%d\n",l[i]);
return 0;
}

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

int main(){
  int ans = 0;
  string s, t;
  cin >> s >> t;
  int n = s.size();
  for(int i = 0;i < n;i++){
    if(t.at(i) == s.at(0)){
      int j = (i + 1) % n;
      int k = 1;
      while(t.at(j) == s.at(k)){
        if(k == n - 1){
          ans = 1;
          break;
        }
        j = (j + 1) % n;
        k++;
      }
      if(ans == 1) break;
    }
  }
  if(ans == 1) cout << "Yes" << endl;
  else cout << "No" <<endl;
  return 0;
}


Measured memory_bytes: 256
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}

int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}
// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
ll _pfact(ll a);
static ll pf[100000000];
static ll pc;

ll _pfact(ll a) {
	long i, r;
	if (a % 2 == 0) {
		pf[pc] = 2; pc++;
		return(_pfact(a / 2));
	}
	r = sqrt(a);
	for (i = 3; i <= r; i += 2) {
		if (a % i == 0) {
			pf[pc] = i; pc++;
			return(_pfact(a / i));
		}
	}
	if (a != 1) {
		pf[pc] = a; pc++;
	}
	return 0;

}


#pragma endregion

//ABC 161 -B
int main(void) {
	int i,n,m,a[101];
	int t = 0;

	scanf("%d %d", &n,&m);

	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		t += (float)a[i];
	}

	int c = 0;
	for(i=0;i<n;i++)
		if (a[i]*4*m >= t) c++;

    if(c>=m) printf("Yes\n");
	else     printf("No\n");
	return 0;
}


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

using namespace std;

#define fi first
#define se second

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    if (b < n*a)
    {
        cout << b;
    }
    else
    {
        cout << a*n;
    }
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    a[i] -= i+1;
  }
  sort(a.begin(),a.end());
  int m = a[a.size()/2];

  long long ans = 0;
  for (int i = 0; i < n; i++)
  {
    a[i]-=m;
    a[i] = abs(a[i]);
    ans+=a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
ll mod=1e9+7;
bool dx[2][18000],dy[2][18000];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string ss;cin>>ss;
    int a,b;cin>>a>>b;
    vector<int> d;
    int p=0;
    rep(i,ss.size()){
        if(ss[i]=='T'){
            d.push_back(i-p);
            p=i+1;
        }
        if(i==ss.size()-1&&ss[i]!='T')d.push_back(ss.size()-p);
    }
    int g=8000;
    rep(i,2)rep(j,18000)dx[i][j]=dy[i][j]=0;
    dx[0][g]=1;
    dy[0][g]=1;
    for(int i=0;i<d.size();i+=2)rep(j,18000){
        int k=i/2;
        if(dx[k&1][j]){
            if(j+d[i]<18000)dx[(k+1)&1][j+d[i]]=1;
            if(i>0)if(j-d[i]>0)dx[(k+1)&1][j-d[i]]=1;
            dx[k&1][j]=0;
        }
    }
    for(int i=1;i<d.size();i+=2)rep(j,18000){
        int k=i/2;
        if(dy[k&1][j]){
            if(j+d[i]<18000)dy[(k+1)&1][j+d[i]]=1;
            if(j-d[i]>0)dy[(k+1)&1][j-d[i]]=1;
            dy[k&1][j]=0;
        }
    }
    if((dx[0][a+g]||dx[1][a+g])&&(dy[0][b+g]==1||dy[1][b+g]==1))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 384