akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
typedef pair<int,int> P;
int W,H;
int dist(P p,P q){
  return abs(p.first-q.first) + abs(p.second-q.second);
}

int main(){
  while(cin>>W>>H && W){
    int size = 0;
    vector<P> v[2510];
    REP(y,H)REP(x,W){
      string s;
      cin>>s;
      if(s=="S"){
        v[0].push_back(P(x,y));
      }else if(s=="G"){
        v[2509].push_back(P(x,y));
      }else if(s!="."){
        int n = atoi(s.c_str());
        size = max(size, n);
        v[n].push_back(P(x,y));
      }
    }
    v[size+1] = v[2509];
    static int dp[2500][2500];
    REP(i,2500)REP(j,2500)dp[i][j] = 100000000;
    dp[0][0] = 0;
    for(int i=1;i<=size+1;i++){
      REP(j,v[i].size())REP(k,v[i-1].size()){
        dp[i][j] = min(dp[i][j], dp[i-1][k] + dist(v[i][j],v[i-1][k]));
      }
    }
    cout<<dp[size+1][0]<<endl;
  }
  return 0;
}

Measured memory_bytes: 25788
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr = ds.begin(); itr != ds.end(); ++itr)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define INF 2000000000
#define INFL 9000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;
typedef priority_queue<Edge, vector<Edge>, greater<Edge> > pqlE;

int main() {
	/*
	ifstream ifs(".in");
	ofstream ofs("A1.txt");
	cin.rdbuf(ifs.rdbuf());
	cout.rdbuf(ofs.rdbuf());
	*/
	int A, B, C;
	cin >> A >> B >> C;
	if (C >= A&&C <= B) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef pair<int,int> P;
typedef long long ll;

int main(void){
    string s;
    cin>>s;
    map<char,int>m;
    m[s[0]]++;
    m[s[1]]++;
    m[s[2]]++;
    m[s[3]]++;
    if(m.size()!=2){
        cout<<"No"<<endl;
        return 0;
    }
    else{
        for(auto itr=m.begin();itr!=m.end();++itr){
            if((itr->second)!=2){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if (a + b > c + d){
    cout << "Left" << endl;
  }else if (a + b == c + d){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
a,b,c,d = map(int,input().split())

if abs(a-c) > 2*d:
    print('No')
else:
    if a <= b and b<=c:
        if abs(a-b) <= d and abs(b-c) <= d:
            print('Yes')
        else:
            print('No')
    else:
        if abs(a-c) <= d:
            print('Yes')
        else:
            print('No')



Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
        int n;
        cin >> n;
        int ans=0;
        while(n!=0) {
                ans+=n%10;
                n/=10;
        }
        if(ans==1) {
                cout << 10 << endl;
        }else{
                cout << ans << endl;
        }





        return 0;
}


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

inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}

long long extgcd(long long a, long long b, long long &x, long long &y) {
    for (long long u = y = 1, v = x = 0; a; ) {
        long long q = b / a;
        swap(x -= q * u, u);
        swap(y -= q * v, v);
        swap(b -= q * a, a);
    }
    return b;
}

long long modinv(long long x, long long m) {
    long long s, t;
    extgcd(x, m, s, t);
    return (s + m) % m;
}

int main() {
    const long long m = 999979, n = 999983;
    long long mx = 0, nx = 0;
    int N; cin >> N;
    while (N--) {
        long long op, y; cin >> op >> y;
        if (op == 1) mx = mod(mx + y, m), nx = mod(nx + y, n);
        if (op == 2) mx = mod(mx - y, m), nx = mod(nx - y, n);
        if (op == 3) mx = mx * y % m, nx = nx * y % n;
        if (op == 4) mx = mx * modinv(y, m) % m, nx = nx * modinv(y, n) % n;
    }
    long long s, t;
    extgcd(m, n, s, t);
    long long x = (m * s * nx + n * t * mx) % (m * n);
    if (x >= 1LL << 31) x -= m * n;
    cout << x << endl;
    return 0;
}



Measured memory_bytes: 3104
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int ans = n % 1000;
		
		if(ans == 0) {
			ans = 0;
		}else {
			ans = 1000 - ans;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 35636
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		Console.WriteLine((GetString().IndexOf("AC") != -1) ? "Yes" : "No");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 13280
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {a: [[usize; 3];3], n: usize, b: [usize; n]};

    let mut v = vec![[0, 0, 0], [0, 0, 0], [0, 0, 0]];
    let mut bingo = false;

    for &b_i in b.iter() {
        // println!("{}", b_i);

        for row in 0..3 {
            for col in 0..3 {
                if a[row][col] == b_i {
                    v[row][col] = 1;
                }
            }
        }
    }

    for i in 0..3 {
        if v[i][0] == 1 && v[i][1] == 1 && v[i][2] == 1 {
            bingo = true;
            break;
        }
        if v[0][i] == 1 && v[1][i] == 1 && v[2][i] == 1 {
            bingo = true;
            break;
        }
    }

    if v[0][0] == 1 && v[1][1] == 1 && v[2][2] == 1 {
        bingo = true;
    }
    if v[0][2] == 1 && v[1][1] == 1 && v[2][0] == 1 {
        bingo = true;
    }

    if bingo {
        println!("Yes")
    } else {
        println!("No")
    }
}


Measured memory_bytes: 2168
import java.util.Scanner;

// 提出時にclass Main に書き換え
public class Main {
	public static void main(String[] args)  {
		// 標準入力を受け取る
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(); // int aを受け取る
		int b = sc.nextInt(); // int aを受け取る
		sc.close(); // 標準入力を終了

		if ((a * b) % 2 == 0) {
			// 偶数
			System.out.println("Even");
		} else {
			System.out.println("Odd");
		}
	}

}

Measured memory_bytes: 35680
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 1e6 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  ll n, m, x, y;
  cin >> n >> m >> x >> y;
  bool mul = 0;
  if(n% 2 == 0 && n / 2 == x && m % 2 == 0 && m / 2 == y)
    mul = 1;
  long double area = (n * m);
  cout << area / 2.0 << ' ' << mul;
  return 0;
}


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

int n, m;
int v[100][100];

set<set<int>> mem;

int dfs(set<int> used) {
    int cost = 0;
    for (auto i: used) {
        int min_cost = 1 << 28;
        for (auto j: used) {
            if (i == j) continue;
            min_cost = min(min_cost, v[i][j]);
        }
        if (min_cost == 1 << 28) min_cost = 0;
        cost += min_cost;
    }

    mem.insert(used);

    for (int i = 0; i < n; i++) {
        if (used.find(i) != used.end()) continue;

        bool flag = true;
        for (auto j: used) {
            if (v[i][j] == 0) flag = false;
        }

        if (flag) {
            auto tmp = used;
            tmp.insert(i);
            if (mem.find(tmp) == mem.end())
                cost = max(cost, dfs(tmp));
        }
    }

    return cost;
}

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

    for (int i = 0; i < m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        v[x-1][y-1] = v[y-1][x-1] = z;
    }

    cout << dfs(set<int>()) << endl;

    return 0;
}

Measured memory_bytes: 10060
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(N, Ss):
    for i in range(N):
        Ss[i] = ''.join(sorted(list(Ss[i])))
    Ss.sort()
    ans = 0
    flg = False
    counter = 0
    for i in range(N - 1):
        if Ss[i] == Ss[i + 1]:
            if not flg:
                flg = True
                counter = i
        elif flg:
            ans += (i - counter + 1) * (i - counter) // 2
            flg = False
    if flg:
        ans += ((N - 1) - counter + 1) * ((N - 1) - counter) // 2
    print(ans)


if __name__ == '__main__':
    # S = input()
    N = int(input())
    # N, M = map(int, input().split())
    Ss = [input() for _ in range(N)]
    # As = [int(i) for i in input().split()]
    # Bs = [int(i) for i in input().split()]
    solve(N, Ss)


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

using namespace std;

int main(int argc, char const *argv[]) {
	int N;
	std::cin >> N;
	string s,t;
	std::cin >> s;
	std::cin >> t;
	unsigned long long mod = 1000000007;
	unsigned long long ans = 1;

	std::vector<int> v;
	for (size_t i = 0; i < N; i++) {
		if (s[i] == s[i+1]) {
			v.push_back(2);
			i++;
		}
		else {
			v.push_back(1);
		}
	}
	if (v[0] == 1) {
		ans = 3;
	}
	// v[0] == 2
	else {
		ans = 6;
	}

	for (size_t i = 1; i < v.size(); i++) {
		if (v[i-1] == 1) {
			ans = ans * 2 % mod;
		}
		// v[i-1] == 2
		else {
			if (v[i] == 2) {
				ans = ans * 3 % mod;
			}
		}
	}
	std::cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
//created by missever

#include<bits/stdc++.h>
#define MAX 1000000007
using namespace std;
typedef long long LL;

int a[2005][2005],f[2005][2005],g[2005][2005];
char s[2005][2005];

int lowbit(int t)
{
    return t & (-t);
}

void add(int p[],int n,int x)
{
    while(x <= n)
    {
        p[x] += 1;
        x += lowbit(x);
    }
}

int ff(int p[],int x)
{
    int s = 0;
    while(x > 0)
    {
        s += p[x];
        x -= lowbit(x);
    }
    return s;
}

int main(){
    int n,m,q,i,j;
    int x1,x2,y1,y2;
    scanf("%d%d%d",&n,&m,&q);
    for(i = 1;i <= n; i++) scanf("%s",s[i] + 1);
    for(i = 1;i < n; i++){
        for(j = 1;j <= m; j++){
            if(s[i][j] == s[i + 1][j] && s[i][j] == '1') add(f[i],m,j);
        }
    }
    for(j = 1;j < m; j++){
        for(i = 1;i <= n; i++){
            if(s[i][j] == s[i][j + 1] && s[i][j] == '1') add(g[j],n,i);
        }
    }
    for(i = 1;i <= n; i++){
        for(j = 1;j <= m; j++){
            a[i][j] = a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1];
            if(s[i][j] == '1') a[i][j] += 1 - (s[i - 1][j] == '1') - (s[i][j - 1] == '1');
            //cout<<a[i][j]<<" ";
        }
    }
    for(i = 0;i < q; i++){
        scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
        int ans = a[x2][y2] - a[x1 - 1][y2] - a[x2][y1 - 1] + a[x1 - 1][y1 - 1];
        ans += ff(f[x1 - 1],y2) - ff(f[x1 - 1],y1 - 1);
        ans += ff(g[y1 - 1],x2) - ff(g[y1 - 1],x1 - 1);
        printf("%d\n",ans);
    }
    return 0;
}


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

int main(){
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++)  cin >> a[i];

    vector<vector<int>> c;
    c = vector<vector<int>>(H, vector<int>(W,-1));
    int h = 0, w = 0;
    int dx = 1;
    for(int i=0; i<N; i++){
        while(a[i]>0){
            c[h][w] = i+1;
            a[i]--;
            if((w==W-1 && dx==1) || (w==0 && dx==-1)){
                dx*=-1;
                h++;
            }else{
                w += dx;
            }
        }
    }

    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cout << c[i][j];
            if(j != W-1) cout << " ";
            else cout << endl;
        }
    }
}


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

signed main() {
    int hp1;
    int dmg1;
    int hp2, dmg2;
    cin >> hp1 >> dmg1 >> hp2 >> dmg2;

    int bit = 1;
    while (hp1 > 0 and hp2 > 0) {
        if (bit) {
            hp2 -= dmg1;
        } else {
            hp1 -= dmg2;
        }
        bit = 1 - bit;
    }

    cout << (hp1 > 0 ? "Yes" : "No") << endl;


    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n],b[n],c[n-1],i;
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  for(i=0;i<n;i++){
    cin >> b[i];
  }
  for(i=0;i<n-1;i++){
    cin >> c[i];
  }  
  int sum=0;
  for(i=0;i<n;i++){
    sum+=b[i];
    if(a[i]+1==a[i+1] && i<n-1){
      sum+=c[a[i]-1];
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 384
import numpy as np
from itertools import product

N = int(input())

points = []
non_zero_point = None
for _ in range(N):
    x, y, h = map(int, input().split(' '))
    points.append((x, y, h))
    if non_zero_point is None and h > 0:
        non_zero_point = (x, y, h)

points = np.array(points)
zeros = np.zeros(shape=N, dtype=np.int64)

for cx, cy in product(range(0, 101), repeat=2):
    H = abs(non_zero_point[0] - cx) + abs(non_zero_point[1] - cy) + non_zero_point[2]
    h = np.maximum(H - np.abs(points[:, 0] - cx) - np.abs(points[:, 1] - cy), zeros)
    if np.all(h == points[:, 2]):
        print(cx, cy, H)
        break


Measured memory_bytes: 27164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
int X;
  cin>>X;

  if(X>=30){
     cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}

  
}


Measured memory_bytes: 3632
use std::io;

fn main() {
    let mut line = String::new();
    io::stdin().read_line(&mut line).expect("failed to read line.");
    for c in line.chars() {
        if c == '1' { print!("9"); }
        else if c == '9' { print!("1"); }
        else { print!("{}", c); }
    }
}

Measured memory_bytes: 4352
#include <iostream>

#define INF 10000

using namespace std;

int main(){
  int n; cin >> n;
  int G[n+1][n+1];
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      cin >> G[i][j];
    }
  }
  //prim's algorithm
  int d[n+1],visited[n+1];
  int sum=0;
  for(int i=1;i<=n;i++){
    visited[i]=0;
    d[i]=INF;
  }
  d[1]=0;
  while(1){
    int mincost=INF;
    int u;
    for(int i=1;i<=n;i++){
      if(visited[i]==0 && d[i]<mincost){
        mincost=d[i];
        u=i;
      }
    }
    if(mincost==INF) break;
    visited[u]=1;
    sum=sum+mincost;
    //update d
    for(int v=1;v<=n;v++){
      if(visited[v]==0 && G[u][v]!=-1){
        if(G[u][v]<d[v]){
          d[v]=G[u][v];
        }
      }
    }
  }
  cout << sum << endl;
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i,k,n) for(int i = k; i < n; i++)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define argmax max_element
#define argmin min_element
#define ALL(x) (x).begin(), (x).end()

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

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

template<class T = ll> T in() {
    T _in;
    cin >> _in;
    return _in;
}

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

    string s;
    int num[30] = {0};
    cin >> s;
    rep(i, s.size()) {
        num[s[i]-'a']++;
    }

    bool unique = {true};
    rep(i, 'z'-'a'+1) {
        if(num[i] > 1) {
            unique = false;
        }
    }

    if(!unique) {
        cout << "no" << endl;
    } else {
        cout << "yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<vector>
#define ll long long
using namespace std;

const int N=100005;

int n,m,x,y,cnt;
int a[N],b[N],fa[N],id[N],son[N],vis[N];
ll dp[N],sum[N];
vector<int> lev[N];

bool cmp(int x,int y){
	return a[x]<a[y];
}

int find(int k){
	if (fa[k]!=k) fa[k]=find(fa[k]);
	return fa[k];
}

int main(){
	int i,j;
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++){
		scanf("%d%d",&a[i],&b[i]);
		a[i]=max(a[i]-b[i],0);
		id[i]=i;
	}
	for (i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		lev[x].push_back(y);
		lev[y].push_back(x);
	}
	sort(id+1,id+1+n,cmp);
	for (i=1;i<=n;i++) fa[i]=i;
	for (i=1;i<=n;i++){
		cnt=0; x=id[i]; vis[x]=1; sum[x]=1ll*b[x];
		for (j=0;j<lev[x].size();j++){
			y=lev[x][j];
			if (!vis[y]||find(x)==find(y)) continue;
			son[++cnt]=find(y);
			sum[x]+=1ll*sum[find(y)];
			fa[find(y)]=find(x);
		}
		dp[x]=sum[x]+1ll*a[x];
		for (j=1;j<=cnt;j++) dp[x]=min(dp[x],sum[x]-sum[son[j]]+max(1ll*a[x],dp[son[j]]));
	}
	printf("%lld\n",dp[id[n]]);
	return 0;
}

Measured memory_bytes: 9852
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

void main() {
    while(true) {
        long[] input = readln.split.to!(long[]);
        if (stdin.eof) break;
        long gcd = gcd(input[0], input[1]);
        writeln(gcd, " ", input[0]*input[1]/gcd);
    }
}

Measured memory_bytes: 2504
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}



signed main(){
  int a,b; cin>>a>>b;
  if(a>=b) rep(i,a) cout<<b;
  else rep(i,b) cout<<a;
  cout<<endl;


  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void	ft_swap(long *a, long *b)
{
	long tmp;
	
	tmp = *a;
	*a = *b;
	*b = tmp;
}

void	a_qsort(long *tab, long left, long right)
{
	long Left = left;
	long Right = right;
	long pivot = tab[(left + right) / 2];

	while (1)
	{
		while (tab[Left] < pivot)
			Left++;
		while (tab[Right] > pivot)
			Right--;
		if (Left >= Right)
			break ;
		ft_swap(&tab[Left], &tab[Right]);
		Left++;
		Right--;
	}

	if (Left - 1 > left)
		a_qsort(tab, left, Left - 1);
	if (Right + 1 < right)
		a_qsort(tab, Right + 1, right);
}

void	d_qsort(long *tab, long left, long right)
{
	long Left = left;
	long Right = right;
	long pivot = tab[(left + right) / 2];

	while (1)
	{
		while (tab[Left] > pivot)
			Left++;
		while (tab[Right] < pivot)
			Right--;
		if (Left >= Right)
			break ;
		ft_swap(&tab[Left], &tab[Right]);
		Left++;
		Right--;
	}

	if (Left - 1 > left)
		d_qsort(tab, left, Left - 1);
	if (Right + 1 < right)
		d_qsort(tab, Right + 1, right);
}

int main(void)
{
	long N;
	long x;
	long i;
	scanf("%ld", &N);
	scanf("%ld", &x);
	long a[N + 1];
	long sum = 0;
	long count = 0;
	i = 1;
	while (i <= N)
	{
		scanf("%ld", &a[i]);
		sum += a[i];
		i++;
	}
	if (sum == x)
	{
		printf("%ld", N);
		return 0;
	}
	else if (sum < x)
	{
		count = N - 1;
		// d_qsort(a, 1, N);
		// i = 1;
		// while (i <= N)
		// {
		// 	if (i != N && x >= a[i])
		// 	{
		// 		x -= a[i];
		// 		count++;
		// 	}
		// 	if (i == N)
		// 		break ;
		// 	i++;
		// }
	}
	else if (sum > x)
	{
		a_qsort(a, 1, N);
		i = 1;
		while (i <= N)
		{
			if (x >= a[i])
			{
				x -= a[i];
				count++;
			}
			i++;
		}
	}
	printf("%ld", count);
	return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			int count = 0;
			for(int a=0;a<=9;a++){
				for(int b=0;b<=9;b++){
					for(int c=0;c<=9;c++){
						for(int d=0;d<=9;d++){
							if(a+b+c+d==n)
								count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	}
}

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

int N;
vector<int> x[55],y[55];

bool judge(int now){
    if(x[now].size()!=x[0].size()) return false;
    bool flag=false;
    for(int i=0;i<4;i++){
        swap(x[now],y[now]);
        for(auto &a:x[now]) a*=(-1);
        int dx=x[now][0]-x[0][0];
        int dy=y[now][0]-y[0][0];
        for(auto &a:x[now]) a-=dx;
        for(auto &a:y[now]) a-=dy;

        bool ok=true;
        for(int j=0;j<x[0].size();j++){
            if(x[0][j]!=x[now][j]||y[0][j]!=y[now][j]) ok=false;
        }
        if(ok) flag=true;

        for(auto &a:x[now]) a+=dx;
        for(auto &a:y[now]) a+=dy;
    }
    swap(x[now],y[now]);
    for(auto &a:x[now]) a*=(-1);

    if(flag) return true;
    else return false;
}

int main(){
while(1){
  cin>>N;
  if(N==0) break;
  for(int i=0;i<=N;i++){
      x[i].clear();
      y[i].clear();
  }
  for(int i=0;i<=N;i++){
      int m;
      cin>>m;
      for(int j=0;j<m;j++){
          int a,b;
          cin>>a>>b;
          x[i].push_back(a);
          y[i].push_back(b);
      }
  }

  for(int i=1;i<=N;i++){
      if(judge(i)){
          cout<<i<<endl;
          continue;
      }

      reverse(x[i].begin(),x[i].end());
      reverse(y[i].begin(),y[i].end());
      if(judge(i)) cout<<i<<endl;
  }
  cout<<"+++++"<<endl;
}

  return 0;
}



Measured memory_bytes: 3032
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	Scanner sc = new Scanner(System.in);
	int h, w;
	int[][] map;
	int kaki = 1;
	int ringo = 2;
	int mikan = 3;
	int[] x = {-1, 0, 1, 0};
	int[] y = {0, 1, 0, -1};
	public void run(){
		while(true){
		h = sc.nextInt();
		w = sc.nextInt();
		if(h == 0 && w == 0) break;
		map = new int[h][w];
		for(int i = 0; i < h; i++){
			String line = sc.next();
			for(int j = 0; j < w; j++){
				char s = line.charAt(j);
				if(s == '@') map[i][j] = ringo;
				else if(s == '#') map[i][j] = kaki;
				else map[i][j] = mikan;
			}
		}
		solve();
		}
	}
	public void solve(){
		int ans = 0;
		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				if(map[i][j] != 0){
					ans++;
					dfs(i, j);
				}
			}
		}
		System.out.println(ans);
	}
	
	public void dfs(int i, int j){
		int t = map[i][j];
		map[i][j] = 0;
		for(int k = 0; k < 4; k++){
			int ni = i+x[k];
			int nj = j+y[k];
			
			if(ni >= 0 && ni < h && nj >= 0 && nj < w){
				if(map[ni][nj] == t){
					dfs(ni, nj);
				}
			}
		}
	}
	
	public static void main(String[] args){
		new Main().run();
	}
	
	static class Pair {
        int first,second;
        public Pair(int a,int b) {
            this.first = a;
            this.second = b;
        }
    }	
}

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

int m, k;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> m >> k;
	if((m == 1 && k == 1) || (1<<m) <= k){
		cout << -1 << "\n";
	}else if(k > 0){
		cout << k << " ";
		for(int i=0; i<(1<<m); ++i)
			if(i != k)
				cout << i << " ";
		cout << k << " ";
		for(int i=(1<<m)-1; i>=0; --i)
			if(i != k)
				cout << i << " ";
		cout << "\n";
	}else{
		for(int i=0; i<(1<<m); ++i)
			cout << i << " " << i << " ";
		cout << "\n";
	}
}

Measured memory_bytes: 1792
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons, std.functional;
import std.container;

void main() {
    auto tmp = readln.split.to!(long[]);
    auto N = tmp[0], K = tmp[1];

    long[][long] sushiList;
    foreach (i; 0..N) {
        tmp = readln.split.to!(long[]);
        auto t = tmp[0], d = tmp[1];
        if (t !in sushiList) sushiList[t] = [];
        sushiList[t] ~= d;
    }
    foreach (key; sushiList.keys) {
        sushiList[key] = sushiList[key].sort!"a>b".array;
    }

    long[] topList;
    long[] leftList;
    foreach (key; sushiList.keys) {
        topList ~= sushiList[key].front;
        leftList ~= sushiList[key][1..$];
    }
    topList = topList.sort!"a>b".array;
    leftList = leftList.sort!"a>b".array;

    long[] topSum = [0];
    foreach (i; 0..topList.length) topSum ~= topSum[$-1] + topList[i];
    long[] leftSum = [0];
    foreach (i; 0..leftList.length) leftSum ~= leftSum[$-1] + leftList[i];

    long ans = 0;
    foreach (i; 1..N+1) {
        if (i >= topSum.length) continue;
        if (K-i >= leftSum.length) continue;
        if (K-i < 0) continue;
        ans = max(ans, topSum[i] + leftSum[K-i] + i^^2);
    }
    writeln(ans);
}



Measured memory_bytes: 28796
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 = sc.nextInt();
		int A = sc.nextInt();
		int[] x = new int[N + 1];
		
		for(int i = 1; i <= N; i++) {
			x[i] = sc.nextInt();
		}
		long[][][] dp = new long[N + 1][N + 1][N * A + 1];
		
		for(int i = 0; i <= N; i++) {
			for(int j = 0; j <= N; j++) {
				for(int k = 0; k <= N * A; k++) {
					if(i == 0 && j == 0 && k == 0) {
						dp[i][j][k] = 1;
					} else if(i > 0 && x[i] > k) {
						dp[i][j][k] = dp[i - 1][j][k];
					} else if(i > 0 && j > 0 && x[i] <= k) {
						dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]];
					} else {
						dp[i][j][k] = 0;
					}
				}
			}
		}
		long ans = 0;
		
		for(int i = 1; i <= N; i++) {
			ans += dp[N][i][i * A];
		}
		System.out.println(ans);
	}
	
}


Measured memory_bytes: 84680
#include <bits/stdc++.h>
using namespace std;
string k;
long long d;
long long dp[100009][109][2];
long long mod = 1000000007;
long long bt(int id,int sum,int t){
	if(id==k.size()){
		return (sum%d == 0);
	}
	long long &ret=dp[id][sum][t];
	if(ret!=-1)return ret;
	ret=0;
	int r=9;
	if(t==1)r=k[id]-'0';
	for(int i=0;i<r;i++){
		ret=(ret+bt(id+1,(sum+i)%d,0))%mod;
	}
	ret=(ret + bt(id+1,(sum+r)%d,t))%mod;
	return ret;
}
int main(){
	memset(dp,-1,sizeof(dp));
	cin>>k>>d;
	cout<<(bt(0,0,1)-1+mod)%mod<<endl;
}


Measured memory_bytes: 171520
#include <stdio.h>
 
#define N 2000
#define M 200
 
int solve(int,int);
 
int A[N];
int n;
 
int main(){
 
  int ans,q,i;
  int mi[M];
 
  scanf("%d",&n);
 
  for(i=0 ; i<n ; i++){
    scanf("%d",&A[i]);
  }
 
  scanf("%d",&q);
  for(i=0 ; i<q ; i++){
    scanf("%d",&mi[i]);
  }
 
 
  for(i=0 ; i<q ; i++){
    ans = solve(0,mi[i]);
    if(ans==1) printf("yes\n");
    else printf("no\n");
  }
 
  return 0;
}
 
int solve(int i, int m){
 
  int ans;
 
    if(m==0)return 1;
    if(i>=n)return 0;
 
    ans = solve(i+1,m) || solve(i+1,m-A[i]);
 
}


Measured memory_bytes: 2108
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
template<class T>using vv = vector<vector<T>>; template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

double f(ll n) {
    ll s = 0;
    for (ll n_ = n; n_; n_ /= 10) s += n_ % 10;
    return s / (1.0 * n);
}

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

    ll a = 1;
    ll b = 0;
    
    for (int i = 1; K; ) {
        write(b + a * i);
        K--;

        if (f(b + a * (i + 1)) >= f(b * 10 + 9 + a * 10 * (i / 10 + 1))) {
            i++;
        }
        else {
            b = b * 10 + 9;
            a = a * 10;
            i = i / 10 + 1;
        }
    }
}

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

struct node{
	string s;
	int data;
}a[55]; 

int main(){
	int n,i,sum=0;
	string s1;
	cin >> n;
	for(int i= 0;i<n;i++)
		cin >> a[i].s >>a[i].data ;
	cin >> s1;
	for(i= 0;i<n;i++)
		if(a[i].s==s1) break;
	for(i+=1;i<n;i++)
		sum += a[i].data;
	cout << sum<< endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>

typedef long long ll;
const int N=210;
std::vector<int> V;
ll n;

int main()
{
	scanf("%lld",&n),n++;
	int tot=0,flag=0;
	for(ll k=1ll<<50;k;k>>=1)
	{
		if(tot){if(flag)V.push_back(++tot);else flag=1;}
		if(n&k)V.insert(V.begin(),++tot);
	}
	printf("%d\n",tot*2);
	for(auto it:V)printf("%d ",it);
	for(int i=1;i<=tot;i++)printf("%d ",i);
	printf("\n");
	return 0;
}


Measured memory_bytes: 256
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Scanner;

public class Main {
	static Scanner sc;

	public static void main(String[] args) throws Exception {
		InputStream in = System.in;
		sc = new Scanner(in);

		int H = sc.nextInt();
		int W = sc.nextInt();

		int[][] map = new int[10][10];
		int[] a = new int[10];

		for(int i = 0; i < 10; i++){
			for(int j = 0; j < 10; j++){
				map[j][i] = sc.nextInt();
				if(map[j][i] == 0){
					map[j][i] = -1;
				}
			}
		}

		for(int i = 0; i < W*H; i++){
			int j = sc.nextInt();
			if(j >= 0){
				a[j] += 1;
			}
		}

		int answer = 0;
		for(int i = 0; i < 10; i++){
			if(a[i] >= 1){
				int[] distance = new int[10]; 

				dijkstra(map, i, distance);
				
				answer += distance[1] * a[i];
			}
		}

		System.out.println(answer);

	}

	public static void dijkstra(int[][] map,int src,int[] distance) {
		int nTown = distance.length;
		boolean[] fixed = new boolean[nTown]; 
		for (int i=0; i<nTown; i++) { 
		    distance[i] = Integer.MAX_VALUE; 
		    fixed[i] = false;	
		}
		distance[src] = 0;	
		while (true) {
		    
		    int marked = minIndex(distance,fixed);
		    if (marked < 0) return; 
		    if (distance[marked]==Integer.MAX_VALUE) {
		    	return; 
		    }
		    fixed[marked] = true; 
		    for (int j=0; j<nTown; j++) { 
			if (map[j][marked]>0 && !fixed[j]) { 
			    
			    int newDistance = distance[marked]+map[j][marked];
			    
			    if (newDistance < distance[j]) distance[j] = newDistance;
			}
		    }
		}
	    }
	    
	    static int minIndex(int[] distance,boolean[] fixed) {
		int idx=0;
		for (; idx<fixed.length; idx++)	
		    if (!fixed[idx]) break;
		if (idx == fixed.length) return -1; 
		for (int i=idx+1; i<fixed.length; i++) 
		    if (!fixed[i] && distance[i]<distance[idx]) idx=i;
		return idx;
	    }
}

Measured memory_bytes: 44708
function main(input) {
  var N = input[0].split(" ")[0]-0;
  var list = input[1].split(" ").map(v=>v-0);
  var ans = 0;
  list.forEach(v=>{
    var cnt = 0;
    while(v%2==0){
      v/=2;
      cnt++;
    };
    ans += cnt;
  })
  console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 11468
x = input().split()

a = int(x[0])
b = int(x[1])
k = int(x[2])


if b-a+1 <= k*2:
	for i in range(a, b+1):
		print(i)
else:
	for i in range(a, a+k):
		print(i)
	for i in range(b-k+1, b+1):
		print(i)

        

Measured memory_bytes: 3060
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;

class Program
{
    static void Main(string[] args)
    {
        //入力を受け取る
        var N = long.Parse(Console.ReadLine());
        long L = 1;
        long R = 1;
      
        for(long i = 0;i < N ; i++){
          var TA = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
          var T = TA[0];
          var A = TA[1];
          
          var multi = Math.Max((L-1)/T+1,(R-1)/A+1);
          L = (long)multi*(long)T;
          R = (long)multi*(long)A;
        }
        Console.WriteLine(L+R);
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <string.h>
using namespace std;
int main(){
  int n,i,j,len,count,which,flag;
  char in[1025];
  char data[10][6]={
    {' ',' ',' ',' ',' '},
    {'.',',','!','?',' '},
    {'a','b','c'},
    {'d','e','f'},
    {'g','h','i'},
    {'j','k','l'},
    {'m','n','o'},
    {'p','q','r','s'},
    {'t','u','v'},
    {'w','x','y','z'}
  };
  cin >> n;
  for(i=0;i<n;i++){
    cin >> in;
    len=strlen(in);
    count=-1;
    which=0;
    for(j=0;j<len;j++){
      flag=0;
      if(in[j]=='1') which=1;
      else if(in[j]=='2') which=2;
      else if(in[j]=='3') which=3;
      else if(in[j]=='4') which=4;
      else if(in[j]=='5') which=5;
      else if(in[j]=='6') which=6;
      else if(in[j]=='7') which=7;
      else if(in[j]=='8') which=8;
      else if(in[j]=='9') which=9;
      else{
        if(which==0) continue;
	if(which==1) count%=5;
	else if(which==2||which==3||which==4||which==5||which==6||which==8) count%=3;
	else if(which==7||which==9) count%=4;
	cout << data[which][count];
	flag=1;
        count=-1;
        which=0;
      }
      if(flag==0) count++;
    }
    cout << endl;
  }
  return 0;
}

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

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;
 
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;

int main() {
  
  int n,k,x;
  cin >> n >> k;
  
  int kyori = 0;
  
  for ( int i = 0; i < n; i++){
    cin >> x;
    if ( x <= k - x ){
      kyori += x * 2;
    }else{
      kyori += ( k - x ) * 2;
    }
  }
  
  cout << kyori << endl;

}

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

typedef long long ll;

ll A, B;
ll G;
ll R = 1;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

int main() {
  cin >> A >> B;
  G = gcd(A, B);
  for (ll i = 2; i * i <= G; ++i) {
    if (G % i == 0) {
      ++R;
      while (G % i == 0) G /= i;
    }
  }
  if (G != 1) ++R;
  cout << R << endl;
}


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

int main()
{
    int num;
    cin >> num;

    char chara;
    int ans = 0,current = 0;
    
    for(int i=0;i<num;i++){
        cin >> chara;
        if(chara == 'I'){
            current ++;
        }else if(chara == 'D'){
            current --;
        }
        if(ans < current){
            ans = current;
        }
    }

    cout << ans << endl;

    return 0;
}

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

signed main() {
    int n, ans;
    
    cin >> n;
    ans = 0;
    
    for ( int i = 1; i <= n; i++ ) {
        if ( (i >= 1 && i < 10) || (i >= 100 && i < 1000) || ( i >= 10000 && i < 100000) ) {
            ans++;
        }
    }
    
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<utility>
#include<numeric>

#define FOR(i, a, b) for(int i=a; i<b; i++)

using namespace std;
using Int = long long;

int main(){
    Int N;
    cin >> N;
    vector<Int> A(N);

    FOR(i, 0, N){
        cin >> A[i];
    }

    int cnt = 0;
    int run_length = 1;

    FOR(i, 0, N-1){
        if (A[i] == A[i+1]){
            run_length ++;
        }else{
            if (run_length / 2  > 0){
                cnt += run_length / 2;
            }
            run_length = 1;
        }
    }
    

    if (run_length / 2  > 0){
        cnt += run_length / 2;
    }
    cout << cnt << endl;
}

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

using namespace std;

int N, T;
int a[100000];
int mxben[100000];

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

    int mx = -2000000000;
    int mxmxben = -2000000000;
    for (int i = N - 1; i >= 0; --i) {
        cin >> a[i];
        mx = max(a[i], mx);
        mxben[i] = mx - a[i];
        mxmxben = max(mxben[i], mxmxben);
    }

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        if (mxben[i] == mxmxben) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#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 N,M;
  cin>>N>>M;
  if(M==0){
    cout<<0<<" "<<0;
    return 0;
  }
  int p;
  string s;
  int ans[N]={0};
  int pena[N]={0};
  rep(i,M){
	cin>>p>>s;
    if(s=="AC")ans[p-1]=1;
    if(s=="WA" && ans[p-1]==0)pena[p-1]++;
  }
  int A=0;
  int P=0;
  rep(i,N){
    
    A+=ans[i];
    if(ans[i]==1){
     
      P+=pena[i];
    }
  }
  cout<<A<<" "<<P;
}


Measured memory_bytes: 1024
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    if a + b >= 10 {
        println!("error");
    } else {
        println!("{}", a + b);
    }
}

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


Measured memory_bytes: 4352
S = gets.strip.to_s
m = S.size
if m%2==0
  i = 0
  cnt = 0
  while i < m/2 do
    if S[2*i]=="R" || S[2*i]=="U" || S[2*i]=="D"
      if S[2*i+1]=="L" || S[2*i+1]=="U" || S[2*i+1]=="D"
        cnt += 1
      end
    end
    i += 1
  end
  if cnt == m/2
    puts "Yes"
  else
    puts "No"
  end
else
  i = 0
  cnt = 0
  if m != 1
    while i < (m-1)/2 do
      if S[2*i]=="R" || S[2*i]=="U" || S[2*i]=="D"
        if S[2*i+1]=="L" || S[2*i+1]=="U" || S[2*i+1]=="D"
          cnt += 1
        end
      end
      i += 1
    end
  end
  if S[m-1]=="R" || S[m-1]=="U" || S[m-1]=="D"
    cnt += 1
  end
  if cnt == (m+1)/2
    puts "Yes"
  else
    puts "No"
  end
end

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var AB = new List<int[]>();
            for (int i = 0; i < N; i++)
            {
                var input = ReadArrayInt();
                var A = input[0];
                var B = input[1];
                AB.Add(new int[] { A, B });
            }
            AB = AB.OrderBy(l => l[1]).ThenBy(l => l[0]).ToList();
            var time = 0L;
            for (int i = 0; i < N; i++)
            {
                time += AB[i][0];
                if (time > AB[i][1])
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            
            Console.WriteLine("Yes");
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 35496
import numpy as np

N, M, C = map(int, input().split())
B = np.array(list(map(int, input().split())))

ans = 0
for n in range(N):
    A = np.array(list(map(int, input().split())))
    if np.dot(A, B) + C > 0:
        ans += 1
print(ans)




Measured memory_bytes: 22040
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const int mod=1e9+7;
const ll inf = 1LL << 60;
const ld pi = (acos(-1));
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }




int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  int n; cin >>n;
  map<string,int> p;
  rep(i,0,n){
    string s; cin >> s;
    p[s]++;
  }
  int ans=p.size();
  cout << ans << endl;
}

Measured memory_bytes: 19272
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define lb lower_bound
#define debug(x) cout<<"["<<#x<<": "<<x<<"]"<<endl
#define f(p,n) for(ll i=p;i<n;i++)
ll exp(ll a,ll b,ll m);

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

 	/*#ifndef ONLINE_JUDGE
        freopen("/home/savish/Desktop/2019/io/input.txt", "r", stdin);
        freopen("/home/savish/Desktop/2019/io/output.txt", "w", stdout);
    #endif*/

    ll n;
    cin>>n;
    ll a[n];
    f(0,n) cin>>a[i];

    ll c[n];
    c[0]=0;
    c[1]=abs(a[1]-a[0]);

    f(2,n)
    {
    	c[i]=min(c[i-1]+abs(a[i]-a[i-1]),c[i-2]+abs(a[i]-a[i-2]));
    }
    
    cout<<c[n-1]<<endl;
    
return 0;
}

ll exp(ll a,ll b,ll m)
{
	if(b==0)
	{
		return 1;
	}
	ll temp =exp(a,b/2,m);
	temp=(temp*temp)%m;
	if(b&1)
	{
		return (temp*(a%m))%m;
	}
	return temp;
}

Measured memory_bytes: 1792
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<type_traits>
#include<numeric>
#include<limits>
#include<iomanip>
#include<set>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;

//define
#define INF 100000000
#define NUM 1000000007

int main() {
	long long int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	long long int ans;

	if (a+b<2*c) {
		ans = a * x + b * y;
	}else if (max(x, y) == x) {
		ans = min(c * 2 * y + a * (x - y), c * 2 * max(x, y));
	}else {
		ans = min(c * 2 * x + b * (y - x), c * 2 * max(x, y));
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, M: int, P: "List[int]", Y: "List[int]"):
    d = {}
    for i, (p, y) in enumerate(zip(P, Y)):
        d.setdefault(p, []).append((y, i))

    r = []
    for p, vs in d.items():
        r += [(n, "{:06}{:06}".format(p, i+1)) for i, (_, n) in enumerate(sorted(vs))]
    r.sort()

    return '\n'.join([c for _, c in r])


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    P = [int()] * (M)  # type: "List[int]" 
    Y = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        P[i] = int(next(tokens))
        Y[i] = int(next(tokens))
    result = solve(N, M, P, Y)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 55468
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
#define fst first
#define snd second
#define fr(i, a, b) for(int i=a; i<b; i++)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n); 
    for(int i=0; i<n; i++) cin>>a[i];
    int res = 0;
    for(int i=0; i<n; i++) {
        for(int j=i+1;j <n; j++) {
            res += a[i] * a[j];
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

const int kMax = 1000 + 10;

int n, m;
char a_str[kMax], b_str[kMax];
int dp[kMax];

vector<int> init_num() {
    vector<int> res;
    map<char, set<int> > table;
    for(int i = 0;i < n;++ i) {
        if(table.count(a_str[i]) > 0) table[a_str[i]].insert(i);
        else {
            set<int> s;
            s.insert(i);
            table[a_str[i]] = s;
        }
    }
    for(int i = 0;i < m;++ i) {
        if(table.count(b_str[i]) > 0) {
            for(auto it = table[b_str[i]].rbegin();it != table[b_str[i]].rend();++ it) {
                res.push_back(*it);
            }
        }
    }
    return res;
}

int solve() {
    n = strlen(a_str);
    m = strlen(b_str);
    vector<int> num = init_num();
    if(num.empty()) return 0;
    int res = 1;
    dp[0] = num[0];
    for(int i = 1;i < num.size();++ i) {
        if(dp[res - 1] < num[i]) dp[res ++] = num[i];
        else dp[lower_bound(dp, dp + res, num[i]) - dp] = num[i];
    }
    return res;
}

int main() {
    int q;
    scanf("%d", &q);
    while(q --) {
        scanf("%s%s", a_str, b_str);
        printf("%d\n", solve());
    }
    return 0;
}

Measured memory_bytes: 8552
#include<iostream>
#include<algorithm>
#define maxn 100005
#define inf 0x3f3f3f3f
using namespace std;
typedef long int ll;
int main()
{
    string s;
    cin >> s;
    int ls = s.size(), ans = ls;
    for (int i = 1; i < ls; ++i) if (s[i - 1] != s[i]) ans = min(ans, max(i, ls - i));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512