akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}
 
ll T1,T2,A1,A2,B1,B2;
ll solve(){
    ll X = T1*(A1-B1), Y = T2*(A2-B2);
    if(X > 0) X *= -1, Y *= -1;
    if(X + Y < 0) return 0;
    if(X + Y == 0) return -1;
    ll ct = 0;

    ll S = (-X) / (X+Y), T = (-X) % (X+Y);

    if(T != 0) ct = 2*S + 1;
    else ct = 2*S;

    return ct;
}
 
int main(){
    cin >> T1 >> T2;
    cin >> A1 >> A2;
    cin >> B1 >> B2;
 
    if(solve() == -1) pr("infinity");
    else pr(solve());
    return 0;
}

Measured memory_bytes: 256
n,s = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
mod = 998244353
dp = [[0 for i in range(s+1)] for j in range(n+1)]
dp[0][0] = 1
for i in range(n):
    for x in range(s+1):
        dp[i+1][x] = 2*dp[i][x]
        if x-a[i] >= 0:
            dp[i+1][x] += dp[i][x-a[i]]
        dp[i+1][x] %= mod

print(dp[n][s])

Measured memory_bytes: 147072
#include<iostream>
using namespace std;
int main(){
	int n,m,l;
	cin>>n>>m>>l;
	long long a[100][100];
	long long b[100][100];
	long c[100][100];

	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>a[i][j];
		}
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<l;j++){
			cin>>b[i][j];
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<l;j++){
			c[i][j]=0;
			for(int k=0;k<m;k++){
				c[i][j]+=a[i][k]*b[k][j];
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<l;j++){
			if(j!=0)cout<<" ";
			cout<<c[i][j];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1404
#include<iostream>
using namespace std;
int main()
{
	for (;;)
	{
		int n=0, x=0,A=0;
		cin >> n >> x;
		if (n == 0 && x == 0)
		{
			break;
		}
		for (int a = 1; a <= n;a++)
		{
			for (int b = a + 1; b <= n;b++)
			{ 
				for (int c = b+1; c <= n; c++)
				{
					if (x == a + b + c){A += 1;}
				}
			}
		}
		cout<< A<<endl;
	}
	return 0;
}

Measured memory_bytes: 3100
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] l = new int[n];
        for(int i = 0; i < n; i++){
            l[i] = Integer.parseInt(sc.next());
        }
        
        Arrays.sort(l);
        int x = 0;
        for(int i = 0; i < n-1; i++){
            x += l[i];
        }
        
        if(l[n-1] < x){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <iostream> 
#include <iomanip>  
#include <string>
#include <sstream>  
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <cstring>
#include <cmath>
#include <cassert>


#define INF              (int)1000000007
#define EPS              1e-9
#define pb               push_back
#define mp               make_pair
#define all(c)           c.begin(), c.end()
#define forall(i,a,b)    for(int i=a;i<(b);++i)
#define trav(a,x)        for(auto & a: x)
#define in(a,b)          ((b).find(a) != (b).end())
#define sz(c)            (int)(c).size()
#define input(a)         for(auto & x : a) cin >> x;

using namespace std;

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

#ifdef DEBUG
#define trace(...)       __f(#__VA_ARGS__, __VA_ARGS__)
#define debug(args...)   {dbg,args; clog<<endl;}
#define print_( a )      for( auto & x : a ) clog << x << ' '; clog << '\n';
#define printPair_( a )  for( auto & x : a ) clog << '(' << x.first << ',' << x.second << ')' << ' '; clog << '\n';
#else
#define trace(...)       
#define debug(args...)            
#define print_( a )               
#define printPair_( a )           
#endif

struct debugger {
  template<typename T> debugger& operator , (const T& x) {    
    clog << x << " ";    return *this;    
  }
}dbg;

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " | ";
    __f(comma + 1, args...);
}

auto ____ =[]() { std::ios::sync_with_stdio(0); cin.tie(0); return nullptr; }();

auto modadd = [](ll & x, ll  y){
  if( y < 0 ) y += INF;
  x += y;
  x %= INF;
};

auto modsub = [](ll & x, const ll & y){
  if( y > x ) x += INF;
  x -= y;
  x %= INF;
};

int main( int argc, char * argv[] ){
  int n, m; cin >> n >> m; 
  vi v(n); input(v);
  vector<ll> dp(m+1, 0), u(m+1, 0);
  dp[0] = 1;
  for (auto x : v) {
    trace(x);
    u.assign(sz(u), 0);
    for (int i = m; i >= 0; --i) {
      ll tmp = dp[i]; if( tmp == 0 ) continue;
      modadd( u[i], tmp);
      if( i+x+1 < m+1 ) modsub(u[i+x+1], tmp);
    }
    debug("u");
    print_(u);
    ll run = 0;
    forall(i,0,m+1){
      modadd(run, u[i]);
      dp[i] = run;
    }
    debug("dp");
    print_(dp);
  }
  cout << dp[m] << endl;

  return 0;
}


Measured memory_bytes: 1792
n=int(input())
t,a = map(int, input().split())
H = list(map(int, input().split()))

min_abs = float("inf")

for i in range(n):
    if abs((t-H[i]*0.006)-a)< min_abs:
        min_abs = abs((t-H[i]*0.006)-a)
        ans = i+1
print(ans)

Measured memory_bytes: 9184
import sys
from itertools import chain

n, k, *a = map(int, sys.stdin.read().split())
*a, = map(lambda x: min(k, x), a)
# bitsが大きくなりすぎないように前処理
a.sort()

mask = (1 << k) - 1
def is_needed(i):
    res = 1
    for j in chain(a[:i], a[i+1:]):
        res |= res << j
        res &= mask
    return res >> (k - a[i]) 
    # k - a[i]番目以降のbitが1つでも立っていれば、a[i]はneeded

def main():
    lo = 0
    hi = n - 1
    while lo <= hi:
        i = (lo + hi) // 2
        if is_needed(i):
            hi = i - 1
        else:
            lo = i + 1
    
    # hi: neededとなる最小のindex
    return hi + 1
    
if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3572
x = int(input())

dp = [0 for _ in range(100001)]
dp[0] = 1
dp[100] = 1
dp[101] = 1
dp[102] = 1
dp[103] = 1
dp[104] = 1
dp[105] = 1
for i in range(200, 100001):
    if dp[i - 100] or dp[i - 101] or dp[i - 102] or dp[i - 103] or dp[i - 104] or dp[i - 105]:
        dp[i] = 1

if dp[x]:
    print(1)
else:
    print(0)


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

#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000001

using namespace std;
#define prime 1000000007

const ll N = 300005;

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";

using namespace std;

string s;

int main(){
	cin >> s;


	int sum = 0;
	for (int i = 0; i < (int)s.size(); ++i){
		if(s[i]=='x') sum++;
	}

	if(sum < 8) printf("YES\n");
	else printf("NO\n");

	return 0;
}

Measured memory_bytes: 256
// Vicfred
// https://atcoder.jp/contests/abc159/tasks/abc159_b
// string manipulation

import std.stdio;
import std.string;

bool palindrome(string s) {
    long n = s.length;
    for(long i = 0; i < n/2; i++)
        if(s[i] != s[$-i-1])
            return false;
    return true;
}

void main() {
    string s = readln.chomp;
    long n = s.length;
    if(s[0..(n-1)/2].palindrome &&
            s[(n+1)/2..$].palindrome &&
            s.palindrome)
        "Yes".writeln;
    else
        "No".writeln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, wt;
long long int dp[101][100001];

long long int f(int i, int iw, int w[], long long int v[]) {
	if(iw>wt || i>=n)
	return 0;
	if(dp[i][iw]!=-1)
	return dp[i][iw];
	
	long long int ans;
	if(iw+w[i]>wt)
	ans = f(i+1, iw, w, v);
	else {
		if(v[i]+f(i+1, iw+w[i], w, v) > f(i+1, iw, w, v))
		ans = v[i]+f(i+1, iw+w[i], w, v);
		else
		ans = f(i+1, iw, w, v);
	}
	dp[i][iw] = ans;
	return ans;
	//ans = max(v[i]+f(i+1, iw+w[i], w, v) , f(i+1, iw, w, v))
}

int main() {
	cin>>n>>wt;
	int w[n];
	long long int v[n];
	for(int i=0; i<n; ++i) {
		cin>>w[i]>>v[i];
		for(int j=0; j<wt; ++j)
		dp[i][j]=-1;
	}
	cout<<f(0, 0, w, v);
	return 0;
}

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

using namespace std;

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif*/
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;

    int n;cin>>n;
    vector<pair<int,int>> v(n);
    for(int i=0;i<n;i++){
        int a,b;cin>>a>>b;
        v[i]={a,b};
    }
    sort(v.begin(),v.end(),[&](pair<int,int> a,pair<int,int> b){
        return a.second<b.second;
    });
    int time=0;
    for(auto x:v){
        time+=x.first;
        if(time>x.second){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    
    /*#ifndef ONLINE_JUDGE
        cout << "\nTime Elapsed : " << 1.0 * clock() << " ms\n";
    #endif*/
    return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

#define mod 1000000007

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int H,W,N,now=0;

int main(){
    cin>>H>>W>>N;
    int a[N],color[H][W];
    rep(i,N){
        cin>>a[i];
    }
    rep(i,H){
        if(i%2==0){
            rep(j,W){
                // out(now);
                // out(a[now]);
                color[i][j]=now+1;
                a[now]--;
                if(a[now]==0){
                    now+=1;
                }
            }
        }
        else{
            for(int j=W-1;j>=0;j--){
                color[i][j]=now+1;
                a[now]--;
                if(a[now]==0){
                    now+=1;
                }
            }
        }
    }
    rep(i,H){
        rep(j,W){
            if(j==W-1){
                cout<<color[i][j];
            }
            else{
                cout<<color[i][j]<<" ";
            }
        }
        out("");
    }
}

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

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

Measured memory_bytes: 256
n,c=gets.split.map &:to_i
x,v=($<.map{|l|l.split.map(&:to_i)}).transpose
y=[];x.each{|e|y.unshift(c-e)}
x.unshift(0);y.unshift(0)
r=[0];l=[0]
v.each{|e|r<<r[-1]+e}
(v.reverse).each{|e|l<<l[-1]+e}
f=[0];g=[0]
for k in 1..n
  f<<[f[-1],r[k]-x[k]].max
  g<<[g[-1],r[k]-2*x[k]].max
end
m=0
for i in 0..n
  m=[l[i]-y[i]+g[n-i],l[i]-2*y[i]+f[n-i],m].max
end
p m

Measured memory_bytes: 17644
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

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:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        x: i64
    }

    let mut find = false;

    for i in -501..501 {
        for j in i + 1..501 {
            if x == (j as i64).pow(5) - (i as i64).pow(5) {
                println!("{} {}", j, i);
                find = true;
            }

            if find {
                break;
            }
        }

        if find {
            break;
        }
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 2236
N,x=gets.split.map &:to_i
if x==1 || x==2*N-1
  puts :No
  exit
end
a=(1..2*N-1).to_a
a[x-1],a[N-1]=a[N-1],a[x-1]
a[0],a[N-2],a[N],a[-1]=a[N-2],a[0],a[-1],a[N]
puts :Yes,a


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

int main(){
  int N;
  cin >> N;
  vector<int> W(N);
  int Sum=0;
  for(int i=0; i<N; i++){
    cin >> W.at(i);
    Sum+=W.at(i);
  }
  int Sumd=Sum/2;
  int subSum=0;
  int k=0;
  for(int i=0; i<N; i++){
    subSum+=W.at(i);
    if(subSum>=Sumd){
      k=i;
      break;
    }
  }
  cout << min(abs(Sum-2*subSum), abs(Sum-2*subSum+2*W.at(k)));
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node *NODE;
#define NIL NULL
NODE root;
NODE min(NODE);
NODE max(NODE);
int search(NODE,int);
NODE successor(NODE);
void delete(int);
void insert(int);
void inorder(NODE);
void preorder(NODE);
int main(){
  int n,i,x,t;
  char com[20];
  scanf("%d", &n);

  for (i=0;i<n;i++){
    scanf("%s", com);
    if (com[0]=='f'){
      scanf("%d", &x);
      t = search(root, x);
      if (t==x) printf("yes\n");
      else printf("no\n");
    } else if (com[0]=='i'){
      scanf("%d", &x);
      insert(x);
    } else if (com[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if (com[0]=='d'){
      scanf("%d", &x);
      delete(search(root, x));
    }
  }
  free(root);
  return 0;
}
NODE min(NODE x){
}
NODE max(NODE x){
}
int search(NODE x,int k){
  if(x==NIL)return -1;
  if(x->key==k)return k;
  else if(x->key < k) search(x->right,k);
  else if(x->key > k) search(x->left,k);
}
NODE successor(NODE x){
}
void delete(int x){
}
void insert(int k){
  NODE y = NIL;
  NODE x = root;
  NODE z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  while(x!=NIL){
    y=x;
    if(z->key < x->key)x=x->left;
    else x=x->right;
  }
    z->parent=y;
    if(y==NIL)root=z;
    else if(z->key < y->key)y->left=z;
    else y->right=z;
}
void inorder(NODE x){
if(x->left!=NIL && x->right!=NIL){
    inorder(x->left);
    printf(" %d",x->key);
    inorder(x->right);
  
  }
  if(x->left!=NIL && x->right==NIL){
   inorder(x->left);
     printf(" %d",x->key);  
  }
  
  if(x->right!=NIL && x->left==NIL){
  printf(" %d",x->key);
  inorder(x->right); 
  
  }
  if(x->left==NIL && x->right==NIL)printf(" %d",x->key);
}
void preorder(NODE x){
printf(" %d",x->key);
  if(x->left!=NIL){
    preorder(x->left);
  }
  if(x->right!=NIL){
    preorder(x->right);
  }
}



Measured memory_bytes: 20484
#include<iostream>
using namespace std;
int main() {
	int m, f, r;
	while (true) {
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1) {
			break;
		}
		else if (m == -1 || f == -1) {
			cout << "F" << endl;
		}
		else if (m + f >= 80) {
			cout << "A" << endl;
		}
		else if (65 <= m + f&&m + f < 80) {
			cout << "B" << endl;
		}
		else if ((50 <= m + f&&m + f < 65)||(30 <= m + f&&m + f < 50&&r >= 50)) {
			cout << "C" << endl;
		}
		else if (30 <= m + f&&m + f < 50 && r < 50) {
			cout << "D" << endl;
		}
		else if (m + f < 30) {
			cout << "F" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int count = 0;
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			if(a[i]>=h&&b[i]>=w) {
				int plus = Math.min(a[i]/h, b[i]/w);
				count++;
			}
		}
		System.out.println(count);
	 }
}

Measured memory_bytes: 25684
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

char str[205];

void solve()
{
    scanf("%s", str);
    int n = strlen(str);
    int i;
    for (i = 1; i <= n / 2; i++) {
        if (strncmp(str + 0, str + (n / 2 - i), (n / 2 - i)) == 0) {
            break;
        }
    }
    printf("%d\n", n - i * 2);
    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


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

int main() {
    int n;
    int64_t k;
    cin >> n >> k;
    vector<vector<int>> to(62, vector<int>(n));
    for(int i = 0; i < n; ++i) {
        cin >> to[0][i];
        to[0][i]--;
    }
    for(int x = 0; x < 61; ++x) {
        for(int i = 0; i < n; ++i) to[x + 1][i] = to[x][to[x][i]];
    }
    int now = 0;
    for(int i = 0; i < 62; ++i) {
        if(k & (1LL << i)) {
            now = to[i][now];
            k ^= (1LL << i);
        }
    }
    cout << now + 1 << '\n';
    return 0;
}


Measured memory_bytes: 52628
x = int(input())
a = []
b = []
c = []
for i in range(200):
    a.append(i**5)
    b.append(i**5)
    a.append((-i)**5)
    b.append((-i)**5)
    c.append(i)
    c.append(-i)

ans_1=0
for i in range(len(a)):
    for j in range(len(b)):
        if a[i] - b[j] == x:
            ans_1 = c[i]
            ans_2 = c[j]
            break
    if ans_1 != 0:
        break
print(str(ans_1) + ' ' + str(ans_2))

Measured memory_bytes: 9228
from itertools import combinations
N, M, X = map(int, input().split())

A = [[] for _ in range(N)]
C = [0] * N

for i in range(N):
  ca = list(map(int, input().split()))
  C[i], A[i] = ca[0], ca[1:]

ans = float("INF")
p = [i for i in range(1, N+1)]

for k in range(1, N+1):
  for v in combinations(p, k):
    smart = [0] * M
    cost_sum = 0
    for i in v:
      cost_sum += C[i-1]
      for j in range(M):
        smart[j] += A[i-1][j]
    ok = True
    for j in range(M):
      if smart[j] < X:
        ok = False
    if ok:
      ans = min(ans, cost_sum)

if ans == float("INF"):
  ans = -1
print(ans)

Measured memory_bytes: 9252
import heapq

n,m = list(map(int,input().split()))
a = list(map(int,input().split()))
a = list(map(lambda x:x*(-1),a))
heapq.heapify(a)

for i in range(m):
  mx = heapq.heappop(a)
  mx= -(-mx//2)
  heapq.heappush(a,mx)

a = list(map(lambda x:x*(-1),a))
print(sum(a))

Measured memory_bytes: 14180
#include <bits/stdc++.h>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#include <bitset>

using namespace std;

#define rep(i,n,m) for(ll (i)=(n);(i)<(m);(i)++)
#define rrep(i,n,m) for(ll (i)=(n);(i)>(m);(i)--)
using ll = long long;
const ll mod = 998244353;

struct LazySegmentTree {
private:

        int n;
        vector<ll> node, lazy;
        ll inf = 10000000;

public:
    LazySegmentTree(vector<ll> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        rep(i,0,2*n-1) node[i] = inf;
        lazy.resize(2*n-1, 0);

        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = min(node[i*2+1] , node[i*2+2]);
    }

    void eval(int k, int l, int r) {

        if(lazy[k] != 0) {
            node[k] += lazy[k];

            if(r - l > 1) {
                lazy[2*k+1] += lazy[k];
                lazy[2*k+2] += lazy[k];
            }
            lazy[k] = 0;
        }
    }

    void add(int a, int b, ll x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;

        eval(k, l, r);

        if(b <= l || r <= a) return;
        
        if(a <= l && r <= b) {
            lazy[k] += x;
            eval(k, l, r);
        }

        else {
            add(a, b, x, 2*k+1, l, (l+r)/2);
            add(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = min(node[2*k+1] , node[2*k+2]);
        }
    }

    ll rmq(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(b <= l || r <= a) return INT_MAX;

        // 関数が呼び出されたら評価！
        eval(k, l, r);
        if(a <= l && r <= b) return node[k];
        ll vl = rmq(a, b, 2*k+1, l, (l+r)/2);
        ll vr = rmq(a, b, 2*k+2, (l+r)/2, r);
        return min(vl , vr);
    }

    ll getind(int index){
        return rmq(index,index+1);
    }

    void updind(int index , ll newnum){
        ll oldnum = getind(index);
        ll difference = newnum - oldnum;
        add(index,index+1,difference);
    }

};

int main(){

    int N,Q,l,r;
    scanf ("%d" , &N);
    vector<int> b(N,0);
    rep(i,0,N) scanf("%d",&b[i]);
    scanf ("%d" , &Q);
    vector<vector<int>> rlis(N+1,vector<int> (0));

    rep(i,0,Q){
        scanf ("%d %d",&l,&r);
        rlis[l].push_back(r);
    }

    vector<ll> tmp(N+1,10000000);
    tmp[0] = 0;

    LazySegmentTree lst(tmp);
    rep(i,1,N+1){

        rep(j,0,rlis[i].size()){
            r = rlis[i][j];
            ll newnum = lst.rmq(0,r);
            ll oldnum = lst.getind(r);
            if (newnum < oldnum) lst.updind(r,newnum);
        }

        if (b[i-1] == 0){
            lst.add(i,N+1,1);
        }else{
            lst.add(0,i,1);
        }
    }

    cout << lst.rmq(0,N+1) << endl;
}

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

long long int n,k;
long long int A[100000];
int sum=0;

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

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

if((n-1)%(k-1)==0){
    sum=(n-1)/(k-1);
}
else{
    sum=(n-1)/(k-1)+1;
}

cout<<sum<<endl;

return 0;

}

Measured memory_bytes: 1024
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

def gcd_list(a):
    l = len(a)
    if l == 1:
        return a[0]
    ans = gcd(a[0], a[1])
    for i in range(2, l):
        ans = gcd(ans, a[i])
    return ans

N,X=map(int,input().split())
x=list(map(int,input().split()))
x2=[abs(t-X) for t in x]
print(gcd_list(x2))


Measured memory_bytes: 14480
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#define rep(i, a, n) for(int i = a;i < n;++i)
#define repe(i, a, n) for(int i = a;i <= n;++i)
#define repr(i, a, n) for(int i = a;i > n;--i)
#define reper(i, a, n) for(int i = a;i >= n;--i)
#define size(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define EPS (1e-20)
#define INF 999999999
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using namespace std;


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

	sort(all(S));

	if(S == "abc") cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {
    
    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[] seq = new int[n];
      for(int i=0; i!=n; i++)
        seq[i] = Integer.parseInt(br.readLine());

      System.out.println( shellSort(seq, n) );

      StringBuilder str = new StringBuilder(n*6);
      for (int i : seq)
        str.append(i).append("\n");

      str.setLength(str.length()-1);
      System.out.println(str);
    }
  }

  public static int shellSort(int a[], int n) {
    int cnt=0;
    int m = 0;
    int[] aG = new int[100];
    for (int g=1,max=n+1; g < max; g=(g*3+1)) {
      aG[m++] = g;
    }
    StringBuilder str = new StringBuilder(m*5);
    str.append(m).append("\n");

    for(int i=(m-1); i!=-1; i--){
      cnt += insertionSort(a, n,aG[i]);
      str.append(aG[i]).append(" ");
    }

    str.setLength(str.length()-1);
    System.out.println(str);

    return cnt;
  }
  
  public static int insertionSort(int a[], final int max, final int g) {
    int cnt=0;

    for (int i=g,j=0,v=0; i < max; i++) {
      for( j=(i-g), v=a[i]; j>=0 && a[j]>v; j-=g ) {
        a[j+g] = a[j];
        cnt++;
      }
      a[j+g] = v;
    }

    return cnt;
  }
}


Measured memory_bytes: 94068
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();

		int sum = 0;

		sum += a>b?a--:b--;
		sum += a>b?a--:b--;

		// 出力
		System.out.println(sum);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <map>
#include <vector>
//#include <unordered_map>
//#include <unordered_set>
#include <stack>
#include <set>
#include <queue>
#include <list>

using namespace std;
bool ju[10];
int main()
{
    int n,k,co=0;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d",&k);
        if(k<400) ju[0]=true;
        else if(k<800) ju[1]=true;
        else if(k<1200) ju[2]=true;
        else if(k<1600) ju[3]=true;
        else if(k<2000) ju[4]=true;
        else if(k<2400) ju[5]=true;
        else if(k<2800) ju[6]=true;
        else if(k<3200) ju[7]=true;
        else ++co;
    }
    int f=0;
    for(int i=0;i<8;++i)
        if(ju[i]) ++f;
    if(f==0) cout<<1<<' '<<co<<endl;
    else cout<<f<<' '<<f+co<<endl;
    return 0;
}


Measured memory_bytes: 256
//https://arc099.contest.atcoder.jp/tasks/arc099_c

#include<bits/stdc++.h>
const int N = 705;
using namespace std;

typedef pair <int, int> ii;
vector <ii> mv;
int n, m, E[N][N], d[N];
int dp[N], Max;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= m; i++){
        int x, y; cin >> x >> y;
        E[x][y] = E[y][x] = 1;

    }
    for (int i = 1; i <= n; i++) d[i] = -1;
    for (int i = 1; i <= n; i++){
        if (d[i] != -1) continue;
        queue <int> mq;
        mq.push(i); d[i] = 0;
        int cnt[2] = {0, 0};
        while (mq.size()){
            int u = mq.front(); mq.pop();
            cnt[d[u]]++;
            for (int v = 1; v <= n; v++){
                if (v == u || E[u][v]) continue;
                if (d[v] != -1 && d[u] == d[v]) return cout << "-1", 0;
                if (d[v] == -1){
                    d[v] = d[u] ^ 1;
                    mq.push(v);
                }
            }
        }
        mv.push_back(ii(cnt[0], cnt[1]));
    }
    dp[0] = 1;
    for (auto x : mv){
        for (int i = n; i >= 0; i--){
            int cur = 0;
            if (i >= x.first) cur |= dp[i-x.first];
            if (i >= x.second) cur |= dp[i-x.second];
            dp[i] = cur;
        }
    }
    for (int i = 0; i <= n/2; i++) if (dp[i]) Max = i;
    cout << Max * (Max - 1) / 2 + (n - Max) * (n - Max - 1) / 2;
}


Measured memory_bytes: 2176
import math
import bisect

def get_lis(S):
    dp = [float('inf')] * len(S)
    for i, (x, y) in enumerate(S):
        a = S[i][1]
        j = bisect.bisect_right(dp, a)
        dp[j] = a
    return bisect.bisect_left(dp, float('inf'))

x_1, y_1, x_2, y_2 = map(int, input().split())
N = int(input())

if x_1 <= x_2:
    x_s = x_1
    y_s = y_1
    x_t = x_2
    y_t = y_2
else:
    x_s = x_2
    y_s = y_2
    x_t = x_1
    y_t = y_1

x_min = min(x_1, x_2)
x_max = max(x_1, x_2)
y_min = min(y_1, y_2)
y_max = max(y_1, y_2)

S = []
for i in range(N):
    X, Y = map(int, input().split())
    if X < x_min or X > x_max or Y < y_min or Y > y_max:
        continue
    S.append((X, Y))

dist = 0
s_num = len(S)

S.sort()
if y_s > y_t:
    S.reverse()
    start_y = y_t
    end_y = y_s
else:
    start_y = y_s
    end_y = y_t

round_count = get_lis(S)
dist = (abs(x_t - x_s) + abs(y_t - y_s)) * 100 + (math.pi * 20 / 4 - 20) * round_count

if min(abs(x_t - x_s), abs(y_t - y_s)) + 1 == round_count:
    dist += math.pi * 5

print(dist)

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

using namespace std;

double n, t, a;

int main()
{
  cin >> n >> t >> a;
  double h;
  double d = DBL_MAX;
  int m = -1;
  for (int i = 0; i < n; i++) {
    cin >> h;
    if (d > abs(a - (t - 0.006*h))) {
      d = abs(a - (t - 0.006*h));
      m = i+1;
    }
  }
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 256
# B
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0]*n
def db(x): 
    global debug
    if debug: print(x)
debug = True
N = getInt()
A = input()
B = input()
C = input()
count = 0
for i in range(N):
    if A[i]==B[i] and B[i]==C[i]: continue
    elif A[i]==B[i] and B[i]!=C[i]: count += 1
    elif A[i]!=B[i] and B[i]==C[i]: count += 1
    elif A[i]==C[i] and B[i]!=C[i]: count += 1
    else: count += 2
print(count)        

Measured memory_bytes: 3064
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);cout<<fixed<<setprecision(16);
#define ll long long int
#define ld long double
#define el '\n'
#define El '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < n; i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << t<<" "; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << v.first << " " << v.second ; }

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)

      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}


ll kv;
ll t,n,x,y,h,k,z,p,q,w,r;
string s,s1,s2;
//vvl v;
//vl vis,d;

int main() {
    IOS;
    cin>>n;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            x=i;y=n/i;
        }
    }
    cout<<x+y-2;
    return 0;
}



Measured memory_bytes: 256
import itertools

N, C = map(int, input().split())
D = [tuple(map(int, input().split())) for _ in range(C)]
L = [tuple(map(int, input().split())) for _ in range(N)]

lst = [[0] * 3 for _ in range(C)]
for y in range(N):
    for x in range(N):
        for c in range(C):
            lst[c][(x + y) % 3] += D[L[y][x] - 1][c]

ans = float('inf')
for t in itertools.permutations(range(C), 3):
    ans = min(ans, sum(lst[t[i]][i] for i in range(3)))
print(ans)


Measured memory_bytes: 48860
package main

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

var sc = bufio.NewScanner(os.Stdin)

func b2i(a []byte) (n int) {
	for _, v := range a {
		n = n*10 + int(v-48)
	}
	return
}

func ri() (n int) {
	sc.Scan()
	b := sc.Bytes()
	if b[0] == 45 {
		return -b2i(b[1:])
	} else {
		return b2i(b)
	}
}

func diff(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()

	cumSum := make([]int, n)
	sum := 0
	for i := 0; i < n; i++ {
		sum += ri()
		cumSum[i] = sum
	}

	minDiff := 2100000000
	for i := 0; i <= n-2; i++ {
		d := diff(cumSum[i], sum-cumSum[i])
		if d < minDiff {
			minDiff = d
		}
	}
	fmt.Println(minDiff)
}


Measured memory_bytes: 2176
#include<stdio.h>
int main(){
  int N,T,c,t,flag=0,cost=1145;
  scanf("%d %d",&N,&T);
  for(int i=0;i<N;i++){
    scanf("%d %d",&c,&t);
    if(t<T+1){
      flag=1;
      if(c<cost){
        cost=c;
      }
    }
  }
  if(flag==0) printf("TLE");
  else printf("%d",cost);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;

using ll = long long;
using Bint = mp::cpp_int;
ll mod = 1000000007;

int main() {
source:
    ll n;
    cin >> n;
    string s[n];
    rep(i, n) { cin >> s[i]; }

    map<string, ll> m;
    rep(i, n) {
        if (m[s[i]] == 0) {
            m[s[i]] = 1;
        } else {
            m[s[i]]++;
        }
    }

    ll num = 0;
    for (auto iter = m.begin(); iter != m.end(); iter++) {
        num = max(num, iter->second);
    }

    vector<string> ans;
    for (auto iter = m.begin(); iter != m.end(); iter++) {
        if (iter->second == num) {
            ans.push_back(iter->first);
        }
    }

    sort(ans.begin(), ans.end());
    for (auto str : ans) {
        cout << str << endl;
    }
    return 0;
}



Measured memory_bytes: 30196
def int_raw():
    return int(raw_input())
 
def words_raw():
    return raw_input().split()

BTC_TO_JPY = 380000.0
N = int_raw()
sum = 0.0
for _ in range(N):
	present, currency = words_raw()
	if currency == 'JPY':
		sum += int(present)
	else:
		sum += float(present) * BTC_TO_JPY
print sum


Measured memory_bytes: 2568
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>

#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;


/* 2倍しても桁溢れしない最大数

   almost_max<uint64_t>() とか
*/
template<typename T>
constexpr T almost_max() {
    return std::numeric_limits<T>::max() / 2 - 1;
}

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

    struct E {
        int a;
        int b;
        int c;
    };

    std::vector<E> e;
    for (size_t i = 0; i < N; ++i) {
        E t;
        std::cin >> t.a >> t.b >> t.c;
        e.push_back(t);
    }

    boost::multi_array<int, 3> memo(boost::extents[N+1][N*10+1][N*10+1]);
    std::fill(memo.data(), memo.data() + memo.num_elements(), -1);


    // 現在a, b, cであって、i以降を選択した時に 比がMa, Mbになる最小の価格
    auto f = [&e, &memo, N, Ma, Mb](auto F, int i, int a, int b) -> int {
        int ret = 0;

        if (memo[i][a][b] != -1) {
            return memo[i][a][b];
        }

        if (a != 0 && b != 0 && a * Mb == b * Ma) {
            ret = 0;
        }
        else if (i == N) {
            ret = almost_max<int>();
        }
        else {
            ret = std::min(F(F, i+1, a, b),
                           F(F, i+1, a + e[i].a, b + e[i].b) + e[i].c);
        }

        return memo[i][a][b] = ret;
    };

    auto ret = f(f, 0, 0, 0);
    if (ret == almost_max<int>()) {
        std::cout << -1 << std::endl;
    }
    else {
        std::cout << ret << std::endl;
    }

    return 0;
}


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

using namespace std;

int main(void)
{
    int R, L, d;
    cin >> R >> L >> d;
    int count = 0;
    for(int i = R; i <= L; i++){
        if(i % d == 0){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3616
import sys
from math import factorial
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
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()))

x, y, a, b, c = MAP()
p = LIST()
q = LIST()
r = LIST()

p.sort(reverse = True)
q.sort(reverse = True)

p = p[:x]
q = q[:y]
res = p + q + r
res.sort(reverse = True)
print(sum(res[:x+y]))

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

const int MX = 100005;

vector<P> g[MX];
int x[MX];
bool used[MX];

vector<int> ans;
int dfs(int v) {
  used[v] = true;
  int res = x[v];
  for (P e : g[v]) {
    if (used[e.first]) continue;
    int r = dfs(e.first);
    if (r) ans.push_back(e.second);
    res ^= r;
  }
  return res;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<P> a(n);
  rep(i,n) cin >> a[i].first >> a[i].second;
  sort(a.begin(), a.end());
  x[0] = a[0].second;
  rep(i,n-1) x[i+1] = a[i].second^a[i+1].second;
  x[n] = a[n-1].second;

  rep(i,m) {
    int l, r;
    cin >> l >> r;
    l = lower_bound(a.begin(),a.end(),P(l,0))-a.begin();
    r = upper_bound(a.begin(),a.end(),P(r,1))-a.begin();
    g[l].emplace_back(r,i+1);
    g[r].emplace_back(l,i+1);
  }

  rep(i,n+1) {
    if (used[i]) continue;
    if (dfs(i)) {
      cout << -1 << endl;
      return 0;
    }
  }

  cout << ans.size() << endl;
  sort(ans.begin(), ans.end());
  rep(i,ans.size()) printf("%d ", ans[i]);
  cout << endl;
  return 0;
}

Measured memory_bytes: 15228
sx, sy, tx, ty = map(int, input().split())
first_step = ""
second_step = ""
third_step = "L"
fourth_step = ""

if ty-sy > 0:
  first_step += 'U'*(ty-sy)
elif ty-sy < 0:
  first_step += 'D'*(sy-ty)
if tx-sx > 0:
  first_step += "R"*(tx-sx)
elif tx-sx < 0:
  first_step += "L"+(sx-tx)

for c in list(first_step):
  if c == 'U':
    second_step += 'D'
  elif c == 'D':
    second_step += 'U'
  elif c == 'R':
    second_step += 'L'
  elif c == 'L':
    second_step += 'R'

sx -= 1
ty += 1


if ty-sy > 0:
  third_step += 'U'*(ty-sy)
elif ty-sy < 0:
  third_step += 'D'*(sy-ty)
if tx-sx > 0:
  third_step += "R"*(tx-sx)
elif tx-sx < 0:
  third_step += "L"+(sx-tx)

third_step += 'D'
sy -= 1
tx += 1
for c in list(third_step):
  if c == 'U':
    fourth_step += 'D'
  elif c == 'D':
    fourth_step += 'U'
  elif c == 'R':
    fourth_step += 'L'
  elif c == 'L':
    fourth_step += 'R'

print(first_step+second_step+third_step+fourth_step)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,ans=0;
    vector<int> a(101);
    for (int i=0;i<101;i++){
        a.at(i)=0;
    }
    cin >> n;
    vector<int> b(n);
    for (int i=0;i<n;i++){
        cin >> b.at(i);
    }
    for (int i=0;i<n;i++){
        a.at(b.at(i))=1;
    }
    for (int i=0;i<101;i++){
        ans=ans+a.at(i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
from bisect import bisect_left

def main():
	N, M = map(int, input().split(" "))
	data_org = []
	for _ in  range(M):
		p, y = map(int, input().split(" "))
		data_org.append((y, p))
		
	data_tmp = copy.copy(data_org)
	data_tmp.sort()
	
	counts = [0 for _ in range(N)]
	ans = []
	for i, val in enumerate(data_tmp):
		y, p = val
		p_zero = str(p).zfill(6)
		no = counts[p-1] + 1
		no_zero = str(no).zfill(6)
		counts[p-1] += 1
		
		ans.append(p_zero + no_zero)
		
	for i, val in enumerate(data_org):
		y, p = val
		tmp = bisect_left(data_tmp, (y, p))
		print(ans[tmp])
	
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 27356
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	resolve(parseProblem())
}

func parseProblem() (int, []int) {
	n := scanInt(sc)
	as := nextIntSlice(sc, n)
	return n, as
}

// package: gocom
// packed src of [/Users/masumi/dev/src/github.com/masu-mi/gamemo/lib/gocom/next.go] with goone.

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	return int(a)
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextIntSlice(sc *bufio.Scanner, n int) (a []int) {

	a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt(sc)
	}
	return a
}
func resolve(n int, as []int) {
	diffs := make([]int, n+1)
	diffs[0] = abs(as[0])
	sum := diffs[0]
	for i := 1; i < n; i++ {
		diffs[i] = abs(as[i] - as[i-1])
		sum += diffs[i]
	}
	diffs[n] = abs(as[n-1])
	sum += diffs[n]

	for i := 0; i < len(as); i++ {
		cost := sum - diffs[i] - diffs[i+1]
		if i == 0 {
			cost += abs(as[i+1])
		} else if i == n-1 {
			cost += abs(as[i-1])
		} else {
			cost += abs(as[i+1] - as[i-1])
		}
		fmt.Println(cost)
	}
	return
}

func cost(n int, as, diffs []int, skip int) int {
	min, max := math.MaxInt64, math.MinInt64
	for i := 0; i < n; i++ {
		if i == skip {
			continue
		}
		if as[i] < min {
			min = as[i]
		}
		if max < as[i] {
			max = as[i]
		}
	}
	return abs(min) + abs(max-min) + abs(max)
}
func abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


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

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

const long long MOD = 1000000007;

int main(){
  int n,a;
  bool ans = true;
  set<int> num;
  cin >> n;
  rep(i,n){
    cin >> a;
    if(num.count(a)){
      ans = false;
      break;
    }
    num.insert(a);
  }
  if(ans) cout << "YES" << endl;
  else cout << "NO" << endl;
}


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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second

#ifdef OJ
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#else
#define debug(x)
#define debugv(x)
#endif

#define all(x) (x).begin(), (x).end()
#define rsort(x) sort((x).rbegin(), (x).rend())
#define sz(x) ((int)x.size())
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n, e) for (int i = (int)(n); i >= (int)(e); --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
template<typename T> bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool mmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; }
#define RETURN(x) do{cout << (x) << '\n'; return ;}while(0)

const int MOD = 1e9+7;
const int MAXN = 2e6+3;
const int INF = 1e9;

int solve() {
    int n; cin >> n;
    int c = 0;
    fori(i,n) {
        int a; cin >> a;
        if(i%2 == 0 && a%2) c++;
    }
    cout << c << '\n';
    return 0;
} 

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

    int ntest = 1;
    //cin >> ntest;
    fori(test, ntest) {
        solve();
    }

    return 0;
}



Measured memory_bytes: 3608
import sys


def is_palindrome(s):
    if len(s) % 2:
        a, b = s[:len(s) // 2], s[len(s) // 2 + 1:]
    else:
        a, b = s[:len(s) // 2], s[len(s) // 2:]
    return a == ''.join(reversed(b))


def resolve(in_):
    s = in_.readline().strip()
    ret = is_palindrome(s) and is_palindrome(s[:len(s) // 2]) and is_palindrome(s[len(s) // 2 + 1:])
    return 'Yes' if ret else 'No'


def main():
    answer = resolve(sys.stdin)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    ll n;
    cin >> n;
    vl a(n);
    rep(i, n) cin >> a[i];
    ll sum = 0;
    rep(i, n) sum += a[i];
    ll ans = 1e18;
    ll x = a[0];
    REP(i, 1, n)  {
        chmin(ans, abs(x - (sum-x)));
        x += a[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
l = [a,b,c,d,e]
max = max(l)
min = min(l)
if max - min <= k:
    print('Yay!')
else:
    print(':(')

Measured memory_bytes: 3060