akhauriyash/Code-Regression huggingface dataset:
import java.util.*;                                                                                  

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] l = line.split(" ");
        int[] a = { 
          Integer.parseInt(l[0]),
          Integer.parseInt(l[1]),
          Integer.parseInt(l[2])
        };  
    
        Arrays.sort(a);

        for(int i = 0; i < a.length; i++) {
          if(0 < i) {
            System.out.print(" ");
          }   
          System.out.print(a[i]);
          if(i == a.length - 1) {
            System.out.println();
          }   
        }   
    }   
}

Measured memory_bytes: 25928
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

bool check(int a, int b, int c){
	return (a < b + c and b < a + c and c < b + a);
}

int32_t main(){
	fastio();
	int n;
	cin >> n;
	vector<int>v;
	for(int i = 0; i < n; i++){
		int x;
		cin >>x;
		v.push_back(x);
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n ; j++){
			for(int k = j + 1; k < n; k++){
				if(v[i] != v[j] and v[i] != v[k] and v[j] != v[k] and (check(v[i],v[j],v[k]))) ans++;
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 3660
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    ds <- sort <$> getIntList
    m <- getInt
    ts <- sort <$> getIntList
    putStrLn $ if solve ds ts then "YES" else "NO"

solve _ [] = True
solve [] _ = False
solve (d:ds) (t:ts) | d == t = solve ds ts
                    | d < t = solve ds (t:ts)
                    | otherwise = False

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

int main() {
  int count, n;
  count = 0;
  bool a = true;
  cin >> n;
  vector<int> vec(n);
  for(int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  while(a) {
    for(int i = 0; i < n; i++) {
      if(vec.at(i) % 2 == 1) {
        a = false;
      break;
      }
      if(a) {
        vec.at(i) /= 2;
      }
      else {
        break;
      }
    }
  count++;
  }
  cout << count - 1 << endl;
}

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

using namespace std;

string str;
int l;
char ch;
int main(){
	cin >> str;
	l = str.length() - 1;
	for(int i=0;i<=l/2;i++){
		ch = str[i];
		str[i] = str[l-i];
		str[l-i] = ch;
	}
	cout << str << endl;
	return 0;
}

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

// Utility
#define ALL(X) (X).begin(), (X).end()
#define RANGE(I, X, Y) for (int I = (X); I < (Y); I++)
using ll = int64_t;
using ull = uint64_t;
namespace std {
template<class ...Ts>        istream& operator>>(istream& i, tuple<Ts...>& x) { apply([&](auto&&... ys){ ((i >> ys), ...); }, x); return i; }
template<class T1, class T2> istream& operator>>(istream& i, pair<T1, T2>& x) { i >> x.first >> x.second; return i; }
template<class T>            istream& operator>>(istream& i, vector<T>& x)    { for (auto& y : x) { i >> y; } return i; }
}

// Debugging
#define DD(X) std::cout << #X ": " << (X) << std::endl << std::flush
namespace std {
template<class ...Ts>        ostream& operator<<(ostream& o, const tuple<Ts...>& x) { o << "("; apply([&](auto&& y, auto&&... ys){ o << y; ((o << ", " << ys), ...); }, x); o << ")"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const pair<T1, T2>& x) { o << tie(x.first, x.second); return o; }
template<class T>            ostream& operator<<(ostream& o, const vector<T>& x)    { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const set<T1, T2>& x)  { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const map<T1, T2>& x)  { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
}

// Main
void mainCase() {
  int k;
  string s;
  cin >> k >> s;
  int n = s.size();

  string res;
  if (n <= k) {
    res = s;
  } else {
    res = s.substr(0, k) + "...";
  }
  cout << res << endl;
}

int main() {
  mainCase();
  return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>

int main(void) {
    int a[5], i, j, k;

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

    scanf("%d", &k);

    for (i = 0; i < 4; i++) {
        for (j = i + 1; j < 5; j++) {
            if (a[j] - a[i] > k) {
                printf(":(\n");
                return 0;
            }
        }
    }

    printf("Yay!\n");

    return 0;
}

Measured memory_bytes: 128
# https://atcoder.jp/contests/abc119/tasks/abc119_d
# 

from bisect import bisect_left,bisect_right
A,B,Q=map(int,input().split())
s= [int(input()) for _ in range(A)]
t= [int(input()) for _ in range(B)]
#print(s)
#print(t)
for i in range(Q):
    x=int(input())
    #print(bisect_left(s,x),bisect_left(t,x))
    sl=float("-inf")
    sr=float("inf")
    tl=float("-inf")
    tr=float("inf")
    a=bisect_left(s,x)
    if a>0:
        sl = s[a-1]
    if a<=A-1:
        sr = s[a]
    b=bisect_left(t,x)
    if b>0:
        tl = t[b-1]
    if b<=B-1:
        tr = t[b]
    #print(sl,sr)
    #print(tl,tr)
    
    pat_LL = x - min(sl,tl)
    pat_LR = sr-tl + min(sr-x,x-tl)
    pat_RL = tr-sl + min(tr-x,x-sl)
    pat_RR = max(sr,tr)-x
    
    print(min(pat_LL,pat_LR,pat_RL,pat_RR))

Measured memory_bytes: 16840
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

int main(){
    string str;
    cin >> str;
    reverse(str.begin(), str.end());
    cout << str << endl;
}


Measured memory_bytes: 3112
tiles = list(map(int, input()))

even = tiles[0::2]
odd = tiles[1::2]

if even.count(0) >= even.count(1):
    ans1 = even.count(1) + odd.count(0) 

else:
    ans1 = even.count(0) + odd.count(1)
    
if odd.count(0) >= odd.count(1):
    ans2 = odd.count(1) + even.count(0) 

else:
    ans2 = odd.count(0) + even.count(1)

print (min(ans1, ans2))

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

//Const
const int seg[10] = {0x77, 0x24, 0x5d, 0x6d, 0x2e, 0x6b, 0x7b, 0x25, 0x7f, 0x6f};

//Input
int N;
int K;
int p[99], q[99];

//Data
int dispFlag[14][10];
int dispNum[14][10];

//Data2
int hms[99];

//function
bool isUruu( int year ){
	if( year % 400 == 0 || (year % 4 == 0 && year % 100 != 0) )
		return true;
	return false;
}

bool nextDay( int &day, int &month, int &year ){
	int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	if( isUruu(year) )
		days[2]++;
	day++;
	if( day > days[month] ){
		day = 1;
		month++;
	}
	if( month > 12 ){
		month = 1;
		year++;
	}
	if( year >= 10000 )
		return false;
	return true;
}

void solve(){
	int day = 1, month = 1, year = 0;
	long long ans = 0;
	do{
		int x = 0;
		x += dispNum[0][year/1000];
		x += dispNum[1][(year%1000)/100];
		x += dispNum[2][(year%100)/10];
		x += dispNum[3][year%10];
		x += dispNum[4][month/10];
		x += dispNum[5][month%10];
		x += dispNum[6][day/10];
		x += dispNum[7][day%10];
		if( x <= N ){
			ans += hms[N - x];
		}
	}while( nextDay(day, month, year) );
	cout << ans << endl;
}

void preSolve(){
	for( int i = 0; i <= N; i++ ){
		hms[i] = 0;
	}
	for( int i = 0; i < 86400; i++ ){
		int h = i / 3600;
		int m = (i % 3600) / 60;
		int s = i % 60;
		int x = 0;
		x += dispNum[8][h/10];
		x += dispNum[9][h%10];
		x += dispNum[10][m/10];
		x += dispNum[11][m%10];
		x += dispNum[12][s/10];
		x += dispNum[13][s%10];
		hms[x]++;
	}
}

void input(){
	int i, j;
	
	for( i = 0; i < 14; i++ ){
		for( j = 0; j < 10; j++ ){
			dispFlag[i][j] = seg[j];
		}
	}
	
	cin >> N >> K;
	for( i = 0; i < K; i++ ){
		cin >> p[i] >> q[i];
		for( j = 0; j < 10; j++ ){
			dispFlag[p[i]][j] &= ~(1 << q[i]);
		}
	}
	
	for( i = 0; i < 14; i++ ){
		for( j = 0; j < 10; j++ ){
			dispNum[i][j] = 0;
			for( int k = 7; k >= 0; k-- ){
				if( (dispFlag[i][j] >> k) & 1 )
					dispNum[i][j]++;
			}
			//printf("%4d", dispNum[i][j]);
		}
		//printf("\n");
	}
}

int main()
{
	//cout << "C";
	input();
	//cout << "K";
	preSolve();
	//cout << "P";
	solve();
	//cout << "??????";
	return 0;
}

Measured memory_bytes: 1164
int main(void){
  char a[4];
  int b=0;
  
  scanf("%s",a);
  
  if(a[0] == a[3] && a[1] == a[2]) b += 1;
  if(a[0] == a[2] && a[1] == a[3]) b += 1;
  if(a[0] == a[1] && a[2] == a[3]) b += 1;
  
  printf("%s",b==1? "Yes" : "No");
}

Measured memory_bytes: 128
N, K = map(int, input().split())
S = list(input())

if S[K-1] == 'A':
    S[K-1] = 'a'
elif S[K-1] == 'B':
    S[K-1] = 'b'
elif S[K-1] == 'C':
    S[K-1] = 'c'

ANS = "".join(S)
print(ANS)


Measured memory_bytes: 2940
a,b,c,d,e,k = gets.chomp.to_i,gets.chomp.to_i,gets.chomp.to_i,gets.chomp.to_i,gets.chomp.to_i,gets.chomp.to_i
result = []
result << (a-b).abs
result << (a-c).abs
result << (a-d).abs
result << (a-e).abs
result << (b-c).abs
result << (b-d).abs
result << (b-e).abs
result << (c-d).abs
result << (c-e).abs
result << (d-e).abs
i = 0
while result.size != i
  if result[i] <= k
  else
    puts ":("
    exit
  end
  i+=1
end
puts "Yay!"
exit


Measured memory_bytes: 1788
/**
n 	16 8 4 2 1 num
   ------
0 -  0 0 0 <- 0       0 <- 0     0 <- 0    
1 -  0 0 0 <- 0       0 <- 0     1 <- 1
2 -  0 0 0 <- 0       1 <- 1     0 <- 2
3 -  0 0 0 <- 0       1 <- 1     1 <- 3
4 -  0 0 1 <- 1       0 <- 3     0 <- 4
5 -  0 0 1 0 <- 1     1
6 -  0 0 1 1 <- 1     0
7 -  0 0 1 1 <- 1      1
8 -  0 1 0 0       0
9 -  0 1 0 0       1
10 - 0 1 0 1       0
11 - 0 1 0 1       1
12 - 0 1 1 0       0
13 - 0 1 1 0       1
14 - 0 1 1 1       0
15 - 0 1 1 1       1
16 - 1 0 0 0       0
17 - 1 0 0 0       1
18 - 1 0 0 1       0
19 - 1 0 0 1       0
**/
/**
	If you only do what you can do, 
	You will never be more than you are now!
	----------------------------------------
	We must all suffer from one of two pains: the pain of discipline or the pain of regret. 
	The difference is discipline weighs grams while regret weighs tons.
**/
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>

using namespace std;

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

#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
#define int ll

const int N = 2e5;
const int INF = 1e9;

int a, b;

int calc(int n) {
	int ans = 0;
	ans += (((n + 1) / 2) & 1);
	for(int x = 2; x <= n; x *= 2) {
		int num = n / x;
		//	cerr << "==================================\n";
		//	show(n);
		//	show(x);
		//	show(num);
		//	cerr << "==================================\n";
		if(n % 2 == 0 && num % 2 == 1) {
			ans += x;
		}
	}
	return ans;
}

main () {
	ios_base::sync_with_stdio(false);
	cin >> a >> b;
	show(calc(b));
	show(calc(a - 1));
	cout << (calc(b) ^ calc(a - 1));	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int I=X;I<Y;I++)
#define REP(I,X,Y) for(int I=Y-1;I>=X;I--)
#define INF 1000000007
using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  long long factorial[100010];
  factorial[0] = 1;
  FOR(i,1,100010)factorial[i] = (i*factorial[i-1])%INF;
  if(abs(N-M) < 2){
    if(abs(N-M))cout << (factorial[N]*factorial[M])%INF << endl;
    else cout << (2*factorial[N]*factorial[M])%INF << endl;
  }
  else{
    cout << 0 << endl;
  }
}


Measured memory_bytes: 1532
import collections
n = int(input())
s = []
dic = collections.defaultdict(int)
for sent in range(n):
  sent_s = "".join(sorted(input()))
  dic[sent_s] += 1

ans = 0
for key,val in dic.items():
  ans += (val*(val-1))/2
print(int(ans))

Measured memory_bytes: 62168
import numpy as np
n = int(input())
ary = [list(map(int,input().split())) for _ in range(n)]
ary = np.array(ary)
dp = np.zeros((n,3))
dp[0] = ary[0]
for i in range(n-1):
    for j in range(3):
        for k in range(3):
            if k == j:continue
            check = dp[i][j] + ary[i+1][k]
            if check > dp[i+1][k]:
                dp[i+1][k] = check
print(int(max(dp[n-1])))


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

int main() {
    
    int a,b;
    char op;
    
    cin >> a >> op >> b;
    
    if(op == '+'){
        cout << a + b << endl;
    }
    else if(op == '-'){
        cout << a - b << endl;
    }
    
    return 0;
}

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

using namespace std;
using ll = long long;


int main()
{
    int n; cin >> n;
    int cnt = 0;
    vector<int> a(n);
    for(int i = 0; i < n; i++)cin >> a[i];
    sort(a.begin(), a.end());

    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            for(int k = j + 1; k < n; k++) {
                if(a[i] == a[j] || a[j] == a[k] || a[i] == a[k])continue;
                if(a[k] < a[i] + a[j])cnt++;
            }
        }
    }
    cout << cnt << endl;
}

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

int main() {
    int n, m;
    int x, y, a[100][100], b[100];
    int c = 0;
    cin >> n >> m;
    
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++) {
            cin >> x;
            a[i][j] = x;
        }
    }
    for (int j = 0; j < m; j++) {
        cin >> y;
        b[j] = y;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            c += a[i][j] * b[j];
        }
        cout << c << endl;
        c = 0;
    }
    return 0;
}
    


Measured memory_bytes: 3152
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        char[] a = sc.next().toCharArray();
        int ans = 0;
        for (char b : a) {
            switch (b) {
            case '+':
                ans++;
                break;
            case '-':
                ans--;
                break;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include "iostream"
#include "vector"

using namespace std;
typedef long long ll;

ll sum(int n, ll x)
{
  vector<ll> power_2(55);
  power_2[0] = 1;
  for (int i = 1; i < 55; i++)
  {
    power_2[i] = 2 * power_2[i - 1];
  }
  if (n == 0)
  {
    return x;
  }
  else
  {
    if (x == 0)
    {
      return 0;
    }
    else
    if (x < power_2[n + 1] - 1)
    {
      return sum(n - 1, x - 1);
    }
    else
    {
      return power_2[n + 1] - 1 - sum(n, power_2[n + 2] - 3 - x);
    }
  }
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  
  if(C-B<=0){
    cout << "delicious" << endl;
  }
  else if(C-B<=A){
    cout << "safe" << endl;
  }
  else{
    cout << "dangerous" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a;
	int i;
	int vis;
	
	while (1){
		int b[7] = {0};
		scanf("%d", &vis);
		
		if (vis == 0){
			break;
		}
		for (i = 0; i < vis; i++){
			scanf("%d", &a);
			
			if (a < 10){
				b[0]++;
			}
			else if (a < 20){
				b[1]++;
			}
			else if (a < 30){
				b[2]++;
			}
			else if (a < 40){
				b[3]++;
			}
			else if (a < 50){
				b[4]++;
			}
			else if (a < 60){
				b[5]++;
			}
			else {
				b[6]++;
			}
		}
		for (i = 0; i < 7; i++){
			printf("%d\n", b[i]);
		}
	}
	
	return (0);
}

Measured memory_bytes: 600
n,m=map(int,input().split())
a=list(map(int,input().split()))

dp=[10**5]*(n+1)
dp[0]=0
dp[a[0]]=1

for i in range(n+1):
    for j in range(m):
        if i-a[j]>=0:
            dp[i]=min(dp[i],dp[i-a[j]]+1)
print(dp[-1])


Measured memory_bytes: 7264
#include <iostream>
#include <stdlib.h>
#include <vector> //vector
#include <algorithm> //sort()
#include <numeric>
#include <tuple>

#define rep(i, n) for(int i=0; i<(int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define debug(a) cout << "debug (" #a "):" << endl << (a) << endl;

typedef uint64_t ulint;
typedef int64_t lint;

using namespace std;

template<class T> inline bool chmin(T& a, T b);
template<class T> inline bool chmax(T& a, T b);
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v);

template<class T> lint sum(vector<T> a);
template<class T> double ave(vector<T> a);

lint n, k;

int main(){
//////////////////////////////////////////////////////

    cin >> n;

    cout << n*n*3 << endl;

// //////////////////////////////////////////////////////

//     cout << dp[n] << endl;

//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}


//最小化用関数
template<class T> inline bool chmin(T& a, T b)
{
    if (a > b) 
    {
        a = b;
        return true;
    }
    return false;
}

//最大化関数
template<class T> inline bool chmax(T& a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}


// vectorprint用
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}

// //合計
// template<class T> lint sum(vector<T> a)
// {
//     return std::accumulate(a.begin(), a.end(), 0);
// }


// //平均
// template<class T> double ave(vector<T> a)
// {
//     return std::accumulate(a.begin(), a.end(), 0.0) / a.size();
// }


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt(),x=scan.nextInt(),m,s=n,t=1000,i;
		for(i=0;i<n;i++) {
			m=scan.nextInt();
			if(t>m) t=m;
			x-=m;
		}
		scan.close();
		s+=x/t;
		System.out.print(s);
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main()
{
	int A, B;

	cin >> A >> B;

	if (A >= 1 && A <= 9 &&
		B >= 1 && B <= 9)
		cout << A * B;
	else
		cout << -1;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
    int l,m,n,i,j,k=0,A[200][200],B[200][200];
    long C[200][100]={0};
    scanf("%d %d %d",&l,&m,&n);
    for(i=0;i<l;i++){
        for(j=0;j<m;j++){
            scanf("%d",&A[i][j]);
        }
    }
    for(i=0;i<m;i++){
        for(j=0;j<n;j++){
        scanf("%d",&B[i][j]);
        }
    }
    for(i=0;i<l;i++){
        for(j=0;j<n;j++){
            for(k=0;k<m;k++){
                C[i][j]+=A[i][k]*B[k][j];
            }
        }
    }
    for(i=0;i<l;i++){
        for(j=0;j<n;j++){
            printf("%ld",C[i][j]);
            if(j!=n-1) printf(" ");
        }
        printf("\n");
    }
    return 0;
}


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

int main(){
 int h,a;
 cin >>h>>a;
 int ans=h/a;
 if (h%a>0)
 cout << ans+1<<endl;
 else cout  <<  ans<< endl;
}

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

int main() {
    int n;
    cin >> n;
    int a[n];
    for(int i = 1;i <= n;i++){
        cin >> a[i];
    }
    int ans = 0,x = 1;
    while(1){
        x = a[x];
        ans++;
        if(x == 2)break;
        else if(ans > n){
            ans = -1;
            break;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 640
// ABC147_B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;
int main()
{
	int a, b, c;
	cin >>a;
	cin >> b;
	if (a == 1 && b == 2)c = 3;
	if (a == 2 && b == 1)c = 3;
	if (a == 1 && b == 3)c = 2;
	if (a == 3 && b == 1)c = 2;
	if (a == 2 && b == 3)c = 1;
	if (a == 3 && b == 2)c = 1;
	cout << c << endl;
	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#define ll long long int
#define MOD 1000000007LL
using namespace std;
int main() {
    int n;
    cin>>n;
    int s=1;
    int a[114514]={};
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=1;i<n;i++){
        if(a[i]!=a[i-1]){
            s++;
        }
    }
    if(s%2==0){
        cout<<s-1<<endl;
    }else{
        cout<<s<<endl;
    }
}

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

int main() {
  int N, D, Y=0, cnt=0;
  cin >> N >> D;
  vector<vector<int>> X(N,vector<int>(D));
  rep(i, N){
    rep(j, D) cin >> X.at(i).at(j);
  }
  rep(i, N-1){
    for(int k=i+1; k<N; k++){
      rep(j, D) Y=Y+(X.at(i).at(j)-X.at(k).at(j))*(X.at(i).at(j)-X.at(k).at(j));
      for (int l=1; l*l<=Y; l++){
        if(l*l==Y) cnt++;
      }
      Y=0;
    }
  }
  cout << cnt << endl;
}

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

using namespace std;

#define debug(x) (cout << # x ": " << x << endl)
#define ll long long int
#define repeat(n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()

int main() {
    int n, m;
    cin >> n >> m;
    
    if (m % 2 == 0) {
        repeat(m / 2) {
            if (i != 0) cout << endl;
            cout << i + 1 << " " << m - i + 1 << endl;
            cout << m + i + 2 << " " << 2 * m - i + 1;
        }
    } else {
        repeat(m / 2) {
            cout << i + 1 << " " << m - i<< endl;
            cout << m + i + 1 << " " << 2 * m - i + 1 << endl;
        }
        cout << m + m / 2 + 1 << " " << 2 * m - m / 2 + 1;
    }

    return 0;
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'

int main(int argc, char const *argv[])
{
    /*#ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
    #endif */
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    int a,b,k;
    cin>>a>>b>>k;
    for(int i=a;i<a+k&&i<=b;i++)
    	cout<<i<<endl;
    for(int i=b-k+1;i<=b;i++)
    	{
    		if(i<a+k)
    			continue;
    		cout<<i<<endl;
    	}
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))

b=[0]*(n+1)

for i in range(k):
	b[k]+=a[i]

for i in range(k+1,n+1):
	#print(i,b[i],b[i-1],a[i-1],a[i-k-1])
	b[i]=b[i-1]+a[i-1]-a[i-k-1]

for i in range(k+1,n+1):
	if b[i]>b[i-1]:
		print("Yes")
	else:
		print("No")

Measured memory_bytes: 31436
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
int main(){
    string s;
    cin >> s;
    int b,w;
    int n=s.length();
    int64_t ans=0;
    int count=0;
    rep(i,n){
        if(s[i]=='W'){
            ans += i-count;
            count++; 
        }
    }
    cout <<ans<<endl;
}

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

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

using namespace std;

int main() {

	int N, M;
	cin >> N >> M;
	vector<int> H(N);

	vector<vector<int>> path(N);
	rep(i, N) {
		cin >> H[i];
	}

	rep(i, M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		path[a].push_back(b);
		path[b].push_back(a);
	}

	int ans = 0;
	rep(i, N) {
		ans++;
		for (auto j : path[i])
		{
			if (H[i] <= H[j]) {
				ans--;
				break;
			}

		}
	}

	cout << ans;
	//cin >> N;

	return 0;
}

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

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

int main() {
	int N, L;
	
	while (cin >> N >> L, N != 0) {
		vector< char > d(N);
		vector< int > p(N);
		for_(i,0,N) cin >> d[i] >> p[i];
		
		int step = 0;
		vector< int > leave(N, -1);
		bool end = false;
		
		while (!end) {
			++step;
			
			for_(i,0,N) {
				if (1 <= p[i] && p[i] < L) {
					p[i] += (d[i] == 'L' ? -1 : 1);
					if (p[i] < 1 || p[i] >= L) leave[i] = step;
				}
			}
			
			for_(i,0,N) for_(j,0,N) {
				if (leave[i] > 0 || leave[j] > 0 || i == j) continue;
				if (p[i] == p[j]) d[i] = (d[i] == 'L' ? 'R' : 'L');
			}
			
			end = true;
			for_(i,0,N) end &= (leave[i] > 0);
		}
		
		int ant = -1;
		for_(i,0,N) {
			if (leave[i] == step) {
				if (ant > 0) {
					if (d[i] == 'L') ant = i + 1;
				} else {
					ant = i + 1;
				}
			}
		}
		
		cout << step << " " << ant << endl;
	}
}

Measured memory_bytes: 3076
#include<stdio.h>

int main(){
   int x[5],i;
   int dif = 0;
   for(i = 0;i<5;i++){
      scanf("%d",&x[i]);
      if(x[i]==0){
         dif=i+1;
      }
   }
   printf("%d",dif);
   return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define PI 3.141592653589793
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const ll INF = 1LL << 60;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    ll n,d,ans=0;
    cin >> n >> d;
    d=d*d;
    for (ll i=0;i<n;i++){
        ll x,y;
        cin >>  x >> y;
        if (x*x+y*y<=d){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3616
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
using namespace std;


int fun(int pi[10]){
	int sum=0,pi2[10],judge=0;;
	for(int i=1;i<10;i++){
		sum += pi[i];
	}
	if(sum==0) return 1;
	for(int i=1;i<10;i++){
		for(int k=1;k<10;k++){
			pi2[k] = pi[k];
		}
		if(pi2[i]>=3){
			pi2[i] -=3;
			judge = fun(pi2);
		}
		if(judge) break;
	}
	for(int i=1;i<8;i++){
		for(int k=1;k<10;k++){
			pi2[k] = pi[k];
		}
		if(pi2[i]>0&&pi2[i+1]>0&&pi2[i+2]>0){
			pi2[i]--;
			pi2[i+1]--;
			pi2[i+2]--;
			judge = fun(pi2);
		}
		if(judge) break;
	}
	return judge;
}


int pairfun(int pi[10]){
	int judge=0,pi2[10];
	for(int i=1;i<10;i++){
		for(int k=1;k<10;k++){
			pi2[k] = pi[k];
		}
		if(pi2[i]>=2){
			pi2[i] -=2;
			judge = fun(pi2);
		}
		if(judge) break;
	}
	return judge;
}
	
	


int main(){
	int pi[10],pi2[10],judge,f;
	char arr[15];
	while(scanf("%s",arr) != EOF){
		judge=0;
		f=1;
		for(int i=1;i<10;i++){
			pi[i]=0;
		}
		for(int i=0;i<13;i++){
			pi[arr[i] - '0']++;
		}
		for(int j=1;j<10;j++){
			if(pi[j]<4){
				for(int k=1;k<10;k++){
					pi2[k] = pi[k];
				}
				pi2[j]++;
				judge = pairfun(pi2);
				if(judge){
					if(f){
						printf("%d",j);
						f=0;
					}
					else  printf(" %d",j);
				}
			}
		}
		if(f) printf("0");
		printf("\n");
	}
		
	
	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
 
int h, w;
const int MAX = 110;
char C[MAX][MAX];
bool seen[MAX][MAX];
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};
 
struct UnionFind{
    vector<int> par;
    UnionFind(int N) : par(N){
        for(int i = 0; i < N; i++){
            par[i] = -1;
        }
    }
    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        else{
            if(par[rx] == par[ry]){
                if(rx > ry) swap(rx, ry);
            }else if(par[rx] > par[ry]) swap(rx, ry);
            par[rx] += par[ry];
            par[ry] = rx;
       }
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    void check(){
        for(auto x : par){
            cout << x << " ";
        }
        cout << endl;
    }
};
 
void dfs(int x, int y, char c, UnionFind &uf){ 
    seen[x][y] = true;
    for(int i = 0; i < 4; i++){
        int nx, ny;
        nx = dx[i] + x;
        ny = dy[i] + y;
        if(nx < 0 or ny < 0 or nx >= h or ny >= w) continue;
        if(C[nx][ny] != c or seen[nx][ny]) continue;
        uf.unite(x * w + y, nx * w + ny);
        dfs(nx, ny, c, uf);
    }
    return;
}
 
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    while(true){
        cin >> h >> w;
        if(h == 0 and w == 0){
            return 0;
        }

        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                seen[i][j] = false;
            }
        }

        UnionFind uf(h * w);
    
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                cin >> C[i][j];
            }
        }
    
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                dfs(i, j, C[i][j], uf);
            }
        }
    
        set<int> st;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                st.insert(uf.root(i * w + j));
            }
        }
 
        cout << st.size() << endl;
    }

    return 0;
}


Measured memory_bytes: 5020
#include <stdio.h>
#include <iostream>
using namespace std;
int a[110],ans[110];
int main(){
	int n,i,j,k;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(k=n;k>=1;k--){
		for(i=k;i>=1;i--)
			if(a[i]==i){
				ans[k]=i;
				break;
			}
		if(i==0) break;
		for(j=i+1;j<=k;j++) a[j-1]=a[j];
	}
	if(k) printf("-1\n");
	else for(i=1;i<=n;i++) printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 256
def main():
    h, w = map(int, input().split())
    s = [input() for _ in range(h)]

    m = [[0] + [0 if e == "#" else 1 for e in s[i]] + [0] for i in range(h)]
    m.append([0] * (w + 2))
    m.insert(0, [0] * (w + 2))

    m_t = [[m[i][j] for i in range(h+2)] for j in range(w+2)]

    lr = []
    for i in range(h + 2):
        sm = 0
        row = []
        for j in range(w + 2):
            if m[i][j]:
                sm += 1
            else:
                row += [sm] * sm + [0]
                sm = 0

        lr.append(row)

    ud = []
    for i in range(w + 2):
        sm = 0
        row = []
        for j in range(h + 2):
            if m_t[i][j]:
                sm += 1
            else:
                row += [sm] * sm + [0]
                sm = 0

        ud.append(row)

    ans = 0
    for i in range(1, h + 1):
        for j in range(1, w + 1):
            sm = lr[i][j] + ud[j][i] - 1
            ans = max(ans, sm)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 193284
W,H,N = map(int, input().split())
a = [0] * N
x = [0] * N
y = [0] * N

xl = 0
xr = W
yt = H
yb = 0

for i in range(N):
    x,y,a = map(int, input().split())
    if a == 1:
        xl = max(x,xl)

    elif a == 2:
        xr = min(x,xr)
    
    elif a == 3:
        yb = max(y,yb)    

    else :
        yt = min(y, yt)

# print(xr)
# print(xl)
# print(yt)
# print(yb)

ans = (xr - xl) * (yt - yb)
if ans <= 0 or ((xr - xl < 0 )or (yt - yb < 0)):
    ans = 0

print(ans)
        

Measured memory_bytes: 3064
L = int(input())
dig = 1
for i in range(1,21):
    if (1 << i) > L:
        dig = i
        break

edge = []
for i in range(dig-1):
    if (L >> i) & 1:
        edge.append((i+1,dig,L-(1<<i)))
        L = L-(1<<i)

for i in range(dig-1):
    edge.append((i+1,i+2,0))
    edge.append((i+1,i+2,1<<i))

print(str(dig) + " " + str(len(edge)))
s = "{0} {1} {2}"
for v,v2,w in edge:
    print(s.format(v,v2,w))

Measured memory_bytes: 38384
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define MAX 500500
char ch[MAX];
int a[MAX<<1],n,s;
int main()
{
	scanf("%s",ch+1);n=strlen(ch+1);
	for(int i=n;i;--i)a[i]=(ch[n-i+1]-48)*9;
	for(int i=1;i<=n;++i)a[i+1]+=a[i]/10,a[i]%=10;
	if(a[n+1])++n;
	for(int i=1;i<=n;++i)s+=a[i];
	for(int i=1;i<=n;++i)
	{
		a[1]+=9;int p=1;s+=9;
		while(a[p]>=10)
		{
			s-=a[p+1];a[p+1]+=a[p]/10;s+=a[p+1];
			s-=a[p];a[p]%=10;s+=a[p];
			++p;if(p>n)n=p;
		}
		if(s<=i*9){printf("%d\n",i);return 0;}
	}
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
#define REP(i,n) for (int i = 0; i < n; ++i)

const int MAX = 1e5+10;
const int MOD = 1e9+10;

int A, B, C, D, N;
int main() {
    cin >> N >> A;
    if (A == 1) cout << 0 << endl;
    else {
        cout << N-A << endl; 
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,c,k;cin >> n >> c >> k;
	vector<int> t(n);
	rep(i,n) cin >> t.at(i);
	sort(t.begin(),t.end());
	int T=t.at(0),cnt=0,ans=0;
	rep(i,n){
		if(T+k<t.at(i) || cnt==c){
			T=t.at(i);
			cnt=1;
			ans++;
		}
		else cnt++;
	}
	cout << ++ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<cmath>
#include<queue>
#include<unordered_map>
#include<map>
#include<stack>
#include<bits/stdc++.h>
#include<string.h>
#include <ext/pb_ds/assoc_container.hpp>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
//#define f first
//#define s second
#define respr(fir,sec) for(int i=0;i<=fir;i++){for(int j=0;j<=sec;j++){cout << res[i][j] << " ";}cout << "\n";}
#define pb push_back
//#define INF (1LL<<31)
using namespace std;
using namespace __gnu_pbds;
const int mod = 1e9+7;
const ll MAX = 1000000000000000000;
const ll INF = 1000000000000000000;
typedef pair<int,ll> pii;
typedef pair<ll,int> pi;
typedef tuple<long long,int> tp;
typedef tuple<int,int,long long> tu;
typedef multimap<pii , int> mpp;
typedef priority_queue< tp , vector<tp>, greater<tp>>  minheap;
typedef priority_queue<pii , vector<pii>> maxheap;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>  new_data_set;
const int nax=105;
//const int nax1 = 105;


int main()
{
	FASTIO;
	int n,w;
	cin >> n >> w;
	//vector<vector<int>> dp(n+1,vector<int>(w+1,0));
	vector<int> weight(n);
	vector<int> value(n);
	for(int i=0;i<n;i++){
		cin >> weight[i] >> value[i];
	}
	
	int sum_value=0;
	for(int i=0;i<n;i++)
		sum_value += value[i];
	
	vector<ll> dp(sum_value+1,INF);
	
	dp[0]=0;
	
	for(int item=0;item<n;item++){
		
		for(int su_alr = sum_value-value[item];su_alr>=0;su_alr--){
		
				dp[su_alr+value[item]] = min(dp[su_alr+value[item]], dp[su_alr]+weight[item]);
		}
		
	}
	
	ll answer=0;
	for(int i=0;i<=sum_value;i++){
		if(dp[i]<=w)
			answer = max((ll)i, answer);
	}
	cout << answer << "\n";
	return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<ll>;
using P = pair<ll,ll>;

int main()
{
    int n;cin >>n;
    V a(n),b(n);
    rep(i,n)cin >>a[i];
    rep(i,n)cin >>b[i];
    int mx=0;
    rep(i,n){
        int sum=0;
        for(int j=0;j<=i;j++){
            sum+=a[j];
        }
        for(int k=i;k<n;k++){
            sum+=b[k];
        }
        mx=max(mx,sum);
    }
    cout <<mx<< endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int add(int v) {
	int res = 0;
	while (v % 2 == 0) {
		v /= 2;
		res++;
	}

	return res;
}

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

	int n;
	cin >> n;

	vector<int> a(n);
	for (auto& v : a) {
		cin >> v;
	}

	int ans = 0;
	for (auto v : a) {
		ans += add(v);
	}

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


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args) {
    	Scanner itr = new Scanner(System.in);
      	int n = itr.nextInt();
      
      	dfs("", 'a', n);
    
    }
  
  	public static void dfs(String s, char max, int n) {
    	if (n == s.length()) {
        	System.out.println(s);
          	return;
        }
      
      	for (int i = 0; i <= (max - 'a'); i++) {
          	char cur = (char) (i + 'a');
        	dfs(s + cur, (max == cur ? (char)(max + 1) : max), n);
        }
    }
}


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

int main() {
  int x,y;
  while(1){
    cin >> x >> y;
    
    if(x==0 && y==0)
      break;
    
    if(x>y)
      swap(x,y);
    
    cout << x << ' ' << y << endl;
    }
 
    
}


Measured memory_bytes: 3080
import bisect
N=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))
print(sum(bisect.bisect_left(A,b)*(N-bisect.bisect_right(C,b)) for b in B))

Measured memory_bytes: 23092
#include <iostream>
#include <algorithm>
#include <vector>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef pair<llong, llong> pll;

const llong inf = 1e18;
int n;
int A[200001];
llong sum[200001];
int E[200001];
int O[200001];
int L[200001];
int R[200001];
llong solve(int s, int e) {
    if (s > e) return inf;
    int m = (s + e) / 2;
    llong Lv = inf;
    for (int i = s; i <= m; ++i) {
        int j = L[i - 1];
        Lv = min(Lv, sum[j] + E[i - 1] - E[j] + O[m - 1] - O[i - 1]);
    }
    llong Rv = inf;
    for (int i = m; i <= e; ++i) {
        int j = R[i];
        Rv = min(Rv, sum[n] - sum[j] + E[j] - E[i] + O[i] - O[m]);
    }
    llong ret = Lv + Rv;
    if ((A[m] & 1) == 0) ++ret;
    ret = min({ ret, solve(s, m - 1), solve(m + 1, e) });
    return ret;
}

pll seg[1 << 20];
void update(int i, int s, int e, int x, llong v) {
    if (s == e) {
        seg[i] = pll(v, x);
        return;
    }
    int m = (s + e) / 2;
    if (x <= m) update(i << 1, s, m, x, v);
    else update(i << 1 | 1, m + 1, e, x, v);
    seg[i] = min(seg[i << 1], seg[i << 1 | 1]);
}

pll query(int i, int s, int e, int x, int y) {
    if (e < x || y < s) return pll(inf, -1);
    if (x <= s && e <= y) return seg[i];
    int m = (s + e) / 2;
    return min(query(i << 1, s, m, x, y), query(i << 1 | 1, m + 1, e, x, y));
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> A[i];
        sum[i] = sum[i - 1] + A[i];
    }
    int e = 0, o = 0;
    for (int i = 0; i <= n; ++i) {
        if (i) {
            if (A[i] & 1) ++e;
            else ++o;
            if (A[i] == 0) e += 2;
        }
        E[i] = e;
        O[i] = o;
        update(1, 0, n, i, sum[n] - sum[i] + e);
    }
    for (int i = 0; i <= n; ++i) R[i] = query(1, 0, n, i, n).se;
    e = 0;
    for (int i = n; 0 <= i; --i) {
        update(1, 0, n, i, sum[i] + e);
        if (i) {
            if (A[i] & 1) ++e;
            if (A[i] == 0) e += 2;
        }
    }
    for (int i = 0; i <= n; ++i) L[i] = query(1, 0, n, 0, i).se;
    llong ret = sum[n];
    for (int i = 1; i <= n; ++i) {
        int Li = L[i], Ri = R[i];
        ret = min(ret, sum[n] - sum[Ri] + E[Ri] - E[Li] + sum[Li]);
    }
    ret = min(ret, solve(1, n));
    printf("%lld\n", ret);
    return 0;
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<P,int>
#define int long long 

int n;
const int N=100100;
int a[N],b[N],c[N];
int cnt[2][N];
int rui[N];
signed main(){
    cin>>n;
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    rep(i,n)cin>>c[i];

    sort(a,a+n);
    sort(b,b+n);
    sort(c,c+n);

    rep(i,n){
        cnt[0][i]=n-(upper_bound(b,b+n,a[i])-b);
        cnt[1][i]=n-(upper_bound(c,c+n,b[i])-c);
        rui[i]=cnt[1][i];
    }

   // rep(i,n)cout<<cnt[0][i]<<" ";cout<<endl;
   // rep(i,n)cout<<cnt[1][i]<<" ";cout<<endl;


    for(int i=n-1;i>0;i--)rui[i-1]+=rui[i];

    int ans=0;
    rep(i,n){
        if(cnt[0][i]==0)
            continue;
        ans+=rui[n-cnt[0][i]];
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 4992
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        ll R, G, B, N;
        cin >> R >> G >> B >> N;

        ll ans = 0;

        for (int i = 0; i <= 3000; ++i) {
            for (int j = 0; j <= 3000; ++j) {
                ll k = N - R * i - G * j;
                if (k >= 0 && k % B == 0) ans++;
            }
        }

        cout << ans << endl;


    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
int main(){
  ll a,b,c;
  cin >> a >> b >>c;
  ll p=(c-a-b),q=4*a*b;
  p=p*p;
  if(c-a-b>=0 && q<p){
    cout << "Yes";
  }else{
    cout << "No";
  }
}

Measured memory_bytes: 3600
#!/usr/bin/env python3

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def main():
    n, a, b, c, d = map(int, input().split())
    diff = b - a
    for m in range(n):
        mi = -d * m + c * (n - 1 - m)
        ma = -c * m + d * (n - 1 - m)
        if mi <= diff <= ma:
            return True
    return False

print("YES" if main() else "NO")


Measured memory_bytes: 3444
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ll N;
	cin >> N;
    string ans;
    while (N) {
        ll r = N % 26;
        if (r == 0) r = 26;
        ans.push_back('a' + r - 1);
        N -= r;
        N /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3604
#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)

int main(){
  long long n;
  while(cin>>n){
    int ans = 1;
    long long tmp = 3;
    while(tmp<n){
      tmp *= 3;
      ans ++;
    }
    cout<<ans<<endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

pair<int, int> n[50];
pair<int, int> m[50];
int ans[50];

int determineCheckPoint(int nIndex, int M)
{
    int mIndex = 0;
    auto minD = abs(n[nIndex].first - m[0].first) + abs(n[nIndex].second - m[0].second);
    
    for (int i = 1; i < M; i++)
    {
        auto d = abs(n[nIndex].first - m[i].first) + abs(n[nIndex].second - m[i].second);
        if (d < minD)
        {
            mIndex = i;
            minD = d;
        }
    }
    return mIndex + 1;
}

int main()
{
    int N, M;
    
    cin >> N >> M;
    
    
    for (int i = 0; i < N; i++)
    {
        cin >> n[i].first >> n[i].second;
    }
    for (int i = 0; i < M; i++)
    {
        cin >> m[i].first >> m[i].second;
    }
    
    for (int i = 0; i < N; i++)
    {
        ans[i] = determineCheckPoint(i, M);
    }
    
    for (int i = 0; i < N; i++)
    {
        printf("%d\n", ans[i]);
    }
    
    return 0;
}


Measured memory_bytes: 256