akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
  int h,w;
  cin>>h>>w;
  int count=0;
  vector<string> s(h);
  for(int i=0;i<h;i++)
    cin>>s[i];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j]=='.'){
        count=0;
        for(int k=-1;k<=1&&i+k<h;k++){
          for(int l=-1;l<=1&&j+l<w;l++){
            if(i==0&&k==-1) k=0;
            if(j==0&&l==-1) l=0;
            if(s[i+k][j+l]=='#')
              count++;
          }
        }
        s[i][j]='0'+count;
      }
    }
  }
  for(int i=0;i<h;i++)
    cout<<s[i]<<endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main { 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		int halfCircle = Integer.parseInt(line);
		
		System.out.println(3*halfCircle*halfCircle);
		
		
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1<<(i))))
#define setbit1(n,i) ((n)|(1<<(i)))
#define togglebit(n,i) ((n)^(1<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
ll a[5][5];   
ll b[100];
ll c[5][5];
int main()
{
    fastread;
    ll n,i,j,k,l;
    for(i=1;i<=3;i++){
    	for(j=1;j<=3;j++)
    	cin>>a[i][j];
	}
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>b[i];
		int flag=0;
		for(j=1;j<=3&&flag==0;j++){
			for(k=1;k<=3;k++){
				if(a[j][k]==b[i])
				{
				   c[j][k]=1;
				   flag=1;
				   break;
			    }
			}
		}
	}
	int flag1=0;
	for(i=1;i<=3;i++){
		if(c[i][1]==c[i][2]&&c[i][2]==c[i][3]&&c[i][3]==1)
		flag1=1;
	}
	for(i=1;i<=3;i++){
		if(c[1][i]==c[2][i]&&c[2][i]==c[3][i]&&c[3][i]==1)
		flag1=1;
	}
	if(c[1][1]==c[2][2]&&c[2][2]==c[3][3]&&c[3][3]==1)
	flag1=1;
	if(c[3][1]==c[2][2]&&c[2][2]==c[1][3]&&c[1][3]==1)
	flag1=1;
	if(flag1==1)
	cout<<"Yes";
	else
	cout<<"No";
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		run();
	}
	static void run(){
		Scanner scan = new Scanner(System.in);
		while(true){
			int x, y;
			int max;
			y = scan.nextInt();
			x = scan.nextInt();
			if(x == 0 && y == 0) break;
			int[][] osenbeiField = new int[y][x];
			for(int i = 0; i < y; i++){
				for(int j = 0; j < x; j++){
					osenbeiField[i][j] = scan.nextInt();
				}
			}
			max = enumeration(osenbeiField, y, x);
			System.out.println(max);
		}
	}
	
	static int enumeration(int[][] osenbeiField, int y, int x){
		int max;
		int sum;
		int tmp;
		int[][] osenbeiFieldTmp = new int[y][x];
		for(int i = 0; i < y; i++){
			for(int j = 0; j < x; j++){
				osenbeiFieldTmp[i][j] = osenbeiField[i][j];
			}
		}
		max = 0;
		tmp = 0;
		
		for(int i = 0; i < Math.pow(2, y); i++){
			sum = 0;
			String[] turn = new String[10];
			for(int j = 0; j < 10; j++){
				turn[j] = "0";
			}
			
			turn = toBinary(i).split("");
			for(int j = 0; j < turn.length; j++){
				if(turn[j].equals("1")){
					horizontalLine(osenbeiField, j, x);
				}
			}

			for(int j = 0; j < x; j++){
				if(sumVerLine(osenbeiField, y, j) < sumVerLine(verticalLine(osenbeiField, y, j), y, j)){
					verticalLine(osenbeiField, y, j);
				}
			}
			
			for(int j = 0; j < y; j++){
				for(int k = 0; k < x; k++){
					sum += osenbeiField[j][k];
				}
			}
			
			tmp = x * y - sum;
			max = Math.max(tmp, max);
			for(int j = 0; j < y; j++){
				for(int k = 0; k < x; k++){
					osenbeiField[j][k] = osenbeiFieldTmp[j][k];
				}
			}
			
		}
		return max;
	}
	
	//??????
	static int turnOver(int osenbei){
		if(osenbei == 0){
			return 1;
		}
		return 0;
	}
	
	//????????????
	static int[][] verticalLine(int[][] osenbeiField, int a, int b){
		for(int i = 0; i < a; i++){
			osenbeiField[i][b] = turnOver(osenbeiField[i][b]);
		}
		return osenbeiField;
	}
	
	//?¨??????????
	static int[][] horizontalLine(int[][] osenbeiField, int a, int b){
		for(int i = 0; i < b; i++){
			osenbeiField[a][i] = turnOver(osenbeiField[a][i]);
		}
		return osenbeiField;
	}
	
	//?¨????????¨?
	static int sumVerLine(int[][] osenbeiField, int a, int b){
		int sum;
		sum = 0;
		for(int i = 0; i < a; i++){
			sum += osenbeiField[i][b];
		}
		return sum;
	}
	
	//??????????¨?
	static int sumHorLine(int[][] osenbeiField, int a, int b){
		int sum;
		sum = 0;
		for(int i = 0; i < b; i++){
			sum += osenbeiField[a][i];
		}
		return sum;
	}
	
	//????????°??????
	static String toBinary(int a){
		String binary;
		binary = Integer.toBinaryString(a);
		return binary;
	}
}

Measured memory_bytes: 72468
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<cstdio>
#define MAXA 100000
#define MAX 2000000000
#define s(i) scanf("%d", &(i))
#define p(i) printf("%d", (i))
#define ps() printf(" ") 
#define rer(i,j,k) for((i)=(j);(i)<(k);++(i))
#define ret(i,j,k) for((i)=(j);(i)>(k);--(i))
using namespace std;
int num[MAXA] = {0};
int main(){
	int i, is = 0, n, t;
	cin >> n;
	rer(i,0,n){
		cin >> num[i];
	}
	if(n==1){
		cout << "Yes" << endl;
	}else{
		rer(i,0,n-1){
			if(num[i+1]-num[i] == -1){
				num[i+1]++;
			}else if(num[i+1]-num[i] <= -2){
				is = 1;
				break;
			}
		}
		if(is){
			cout << "No" << endl;
		}else{
			cout << "Yes" << endl;
		}
	}
	
	return 0;
} 

Measured memory_bytes: 764
#include <stdio.h>
int main(){
  int n, m;
  int i, j;
  char newline;
  int arr_m[100][100];
  int arr_v[100];
  int arr_result[100];
  int input_m, input_v;

  //input matrix information
  scanf("%d %d", &n, &m);
  for(i=0; i<n; i++){
    for(j=0; j<m; j++){
      scanf("%d", &input_m);
      arr_m[i][j]=input_m;
    }
  }

  //input vector information
  for(j=0; j<m; j++){
    scanf("%d", &input_v);
    arr_v[j]=input_v;
  }

  //output calculation
  for(i=0; i<n; i++){
    for(j=0; j<m; j++){
      arr_result[i]+=(arr_m[i][j]*arr_v[j]);
    }
    printf("%d\n", arr_result[i]);
  }
  return 0;
}



Measured memory_bytes: 2080
S = input()
T = input()
len_T = len(T)
d = len(S)-len_T
result = 10000
for i in range(d+1):
    if i == d:
        x = S[i:]
    else:
        x = S[i:-d+i]
    sum = 0
    for i in range(len_T):
        if T[i] == x[i]:
            sum += 1
    sum = len_T - sum
    if result > sum:
        result = sum
print(result)

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    ll N, C, K; cin >> N >> C >> K;
    vector<ll> a(N);
    rep(i, N) cin >> a[i];
    sort(all(a));
    ll res=0, cnt=0, now=0;
    rep(i, N){
        if(now == 0) now = a[i];
        if(a[i]-now > K){
            now = a[i];
            if(cnt > 0){
                cnt = 0;
                res++;
            }
        }
        cnt++;
        if(cnt == C){
            res++;
            cnt = 0;
            now = 0;
        }
    }
    if(cnt > 0) res++;
    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 5120
import collections

n = int(input())
A = list(map(int, input().split(' ')))
 
c = dict(collections.Counter(A))
num_dict = {}
total = 0
for a, count in c.items():
  num_dict[a] = (count*(count-1)/2, (count-1)*(count-2)/2)
  total += count*(count-1)/2

ans_dict = {}
for a in c.keys():
  ans_dict[a] = total - num_dict[a][0] + num_dict[a][1]

for k in range(n):
  print(int(ans_dict[A[k]]))

Measured memory_bytes: 55060
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;


int main() {
    ll H, W, N;
    cin >> H >> W >> N;
    vector<ll> a(N, 0);
    rep(i, N) cin >> a[i];
    ll ans[H][W] = {0};
    ll id=0;
    
    rep(i,H){
        if(i % 2 == 0){
            rep(j,W){
                ans[i][j] = id + 1;
                a[id]--;
                if(a[id] == 0) id++;
            }
        }
        else{
            for(ll j = W - 1;j >= 0; j--){
                ans[i][j] = id + 1;
                a[id]--;
                if(a[id] == 0) id++;
            }
        }
    }

    rep(i,H){
        rep(j,W){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }

}

Measured memory_bytes: 3700
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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


int main(){
    ll n,m;
    cin >> n >> m;
	
	ll ans = 0;

	if(n <= m/2){
	    ans = n;
        m -= n*2;
        n = 0;
        ans += m/4;
    }else{
        ans = m/2;
        n -= m/2;
        m %= 2;
        //if(n > 0 && m > 1)ans++;
    }

    P(ans);
	return  0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
#define mod 1000000007
//#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT{
    __INIT(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout<<fixed<<setprecision(15);
    }
}__init;

ll f(vvb c,ll k,ll h,ll w,ll kuro){
    ll cnt = 0;
    rep(yoko,1<<w){
        rep(tate,1<<h){
            vvb tc(h,vb(w,false));
            rep(i,6){
                if(yoko&(1<<i)){
                    rep(j,h) tc[j][i] = true;
                }
                if(tate&(1<<i)){
                    rep(j,w) tc[i][j] = true;
                }
            }
            ll tcnt = 0;
            rep(i,h) rep(j,w){
                if(tc[i][j] && c[i][j]) tcnt++;
            }
            if(kuro-tcnt == k) cnt++;
        }
    }
    return cnt;
}

int main(){
    ll h,w,k;
    cin>>h>>w>>k;
    vvb c(h,vb(w,false));
    ll kuro = 0;
    rep(i,h) rep(j,w){
        char tmp;
        cin>>tmp;
        c[i][j] = tmp=='#';
        if(c[i][j]) kuro++;
    }
    cout<<f(c,k,h,w,kuro)<<endl;
    return 0;
}


Measured memory_bytes: 3664
import itertools
L, R = map(int, input().split())
if R - L > 2019:
    R = L + 2019
li = set([i%2019 for i in range(L, R+1)])

min = 2019
for i in itertools.combinations(li,2):
    tmp = i[0]*i[1]%2019
    if min > tmp:
        min = tmp
print(min)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define int long long
signed main() {
	int n; cin >> n;
	double ans = 0;
	for (int i = 0; i < n; i++) {
		double p; string s; cin >> p >> s;
		if (s[0] == 'B')p *= 380000;
		ans += p;
	}
	printf("%.6f\n", ans);
	cin >> n;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n; cin>>n;
    vector <int> a(n);
    for (int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    int mon=0;
    for (int i=0;i<n;i++){
        if(i!=n-1)mon+=a[i];
        else mon+= a[i]/2;
    }
    cout<<mon<<endl;
}

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

int main() {
  string s;
  int N;
  int x = 0;
  cin >> N;
  
  for (int i; i < N; i++) {
  	cin >> s;
    if (s == "Y") {
      	x += 1;
    	break;
    }
  }
  if (x == 1) {
  	cout << "Four" << endl;
  }
  else {
  	cout << "Three" << endl;
  }
}




Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 整数の入力
# a = int(input())
# # スペース区切りの整数の入力
# b, c = map(int, input().split())
# 文字列の入力
s = input()
# 出力
char_list = list(s)
count = 0
result = True

# print(char_list)
for char in char_list:
    count += 1
    # print(count)
    if count % 2 == 0:
        if char == "R":
            # print(char)
            result = False
    else:
        if char == "L":
            # print(char)
            result = False



if result == True:
    print("Yes")
else:
    print("No")

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

using namespace std;

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

    int n, ans = 2e9;
    cin >> n;
    int arr[n];

    for (int i = 0; i < n; i++)
        cin >> arr[i];

    for (int t = 0; t < n - 1; t++) {
        int s1 = 0, s2 = 0;
        for (int i = 0; i < n; i++)
            i > t ? s2 += arr[i] : s1 += arr[i];
        ans = min(ans, abs(s1 - s2));
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,m;

int main(){
  ll ans=0;
  cin >> n >> m;
  ans=n*(n-1)/2+m*(m-1)/2;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    if(a>b){
        if(a>c){
            cout << c*b/2<<endl;
        }
        else{
            cout << a*b/2<<endl;
        }

    }
    else{
        if(b>c){
            cout << a*c/2<<endl;
        }
        else{
            cout << a*b/2<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int ans = 0;
		if (c <= b) {
			ans += c + b;
		} else {
			ans += 2 * b;
			c -= b;
			b = 0;
			ans += Math.min(c, a);
			c -= Math.min(c, a);
			if (c > 0) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}


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

if  a <= b <= c:
    print(a, b, c)
elif a <= c <= b:
    print(a, c, b)
elif b <= a <= c:
    print(b, a, c)
elif b <= c <= a:
    print(b, c, a)
elif c <= b <= a:
    print(c, b, a)
elif c <= a <= b:
    print(c, a, b)
    


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
#define int long long 
 
int find(vector<int> a,vector<int> b,int n) {
  	int sum = 0;
  	for (int i=0;i<n;i++) {
        sum += min(a[i], b[i]);
        if (b[i] > a[i]) {
            sum += min(a[i + 1], b[i] - a[i]);
            a[i + 1] -= min(a[i + 1], b[i] - a[i]);
        }
    }
    return sum;
}
 
int32_t main() {
	int n;	cin >> n;
  	vector<int> a(n+1),b(n);
  	for(int i=0;i<n+1;i++) cin >> a[i];  	
  	for(int i=0;i<n;i++) cin >> b[i];
  	cout << find(a,b,n) << endl;
  	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>

using namespace std;

typedef long long int64;

int64 GCD(int64 a,int64 b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}

int main(void){
    int64 A,B,C,D;
    cin>>A>>B>>C>>D;
    int64 ans=0;
    int64 lcm;
    lcm=C*D/GCD(C,D);
    ans+=B/C;
    ans-=(A-1)/C;
    ans+=B/D;
    ans-=(A-1)/D;
    ans-=B/lcm;
    ans+=(A-1)/lcm;
    cout<<B-A+1-ans<<endl;

    return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        k: i64,
    };
    let mut found = None;
    let mut x = 7;
    for i in 1..=k {
        if x % k == 0 {
            found = Some(i);
            break;
        }
        x = (x * 10 + 7) % k;
    }
    let ans = found.unwrap_or(-1);
    println!("{}", ans);
}


Measured memory_bytes: 2100
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE Strict #-}
{-# LANGUAGE StrictData #-}
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Data.Array.Unboxed
import Data.Array.ST
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Data.List
import Data.Char
import qualified Data.Set as Set

main :: IO ()
main = do
    (n,k) <- (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    xss <- replicateM k $ getLine >> unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    let an = Set.size $ Set.fromList $ concat xss
    print $ n - an

Measured memory_bytes: 5160
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		int h,w;
		cin >> h >> w;
		string s[h];
		rep(i,0,h) cin >> s[i];
		int dp[h][w];
		rep(i,0,h){
			rep(j,0,w) dp[i][j] = INF;
		}
		if(s[0][0]=='.') dp[0][0] = 0;
		else dp[0][0] = 1;
		rep(i,0,h){
			rep(j,0,w){
				if(i==0 and j==0) continue;
				int cost = (s[i][j] == '#');
				if(i>=1) dp[i][j] = min(dp[i][j], dp[i-1][j]+min((s[i-1][j]=='.')*1ll, cost));
				if(j>=1) dp[i][j] = min(dp[i][j], dp[i][j-1]+min((s[i][j-1]=='.')*1ll,cost));
			}
		}
		cout << dp[h-1][w-1];
	}
}

Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define REP(i,n) for(i=0;i<(int)(n);++i)//for文簡略化マクロ
#define SIZE 3010// 文字列の長さの最大値
int i,j;//for文の添字

int max(int a,int b){//a,bのうち大きい方を返す
    if(a>b)return a;
    else return b;
}

int main(){
    // 変数の初期化
    char s1[SIZE],s2[SIZE];
    int ls1=0,ls2=0;
    int dp[SIZE][SIZE]={};
    char res[SIZE];
    int lcslen;
    int ms1,ms2;
    int cnt = 0;
    memset(res,'\0',SIZE);
    // 入力処理
    fgets(s1,SIZE,stdin);
    fgets(s2,SIZE,stdin);

    ls1 = strlen(s1);
    ls2 = strlen(s2);
    // 動的計画法
    REP(i,ls1){
        REP(j,ls2){
            if(i==0||j==0){
                dp[i][j]=0;
            }else{
                if(s1[i-1]==s2[j-1]){
                    dp[i][j]=dp[i-1][j-1]+1;
                }else{
                    dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                }
            }
        }
    }
    // 動的計画法の復元
    lcslen = dp[ls1-1][ls2-1];
    ms1=ls1-1;
    ms2=ls2-1;
    cnt = lcslen-1;
    while(dp[ms1][ms2]!=0){
        if(s1[ms1-1]==s2[ms2-1]){
            res[cnt--] = s1[ms1-1];
            ms1--;
            ms2--;
        }else if(dp[ms1-1][ms2]>=dp[ms1][ms2-1]){
            ms1--;
        }else{
            ms2--;
        }
    }
    // 出力処理
    printf("%s\n",res);
    return 0;
}

Measured memory_bytes: 35584
#include  <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1000000007
//vector<vector<int>> vec(縦, vector<int>(横));
#define REP(i,N) for(int i=0;i<N;i++)
int gcd(int a, int b) {
    if(a>b){
        swap(a,b);
        }
    while(b%a!=0){
        b%=a;
        swap(a,b);
    }
    return a;
}
int ctoi(char c){
  if(c>='0'&&c<='9'){
    return c-'0';
  }
  return 0;
}


//cout << setprecision(123)<<ans;
//int a=atoi(S.c_str());
//string S=to_string(a);
//int &a=b;
int main(){
  int N,ans=0;
  string S;
  cin>>N>>S;
  
  for(int i=0;i<=9;i++){
    REP(j,N-2){
      int s=ctoi(S[j]);
      if(s==i){
        for(int ii=0;ii<=9;ii++){
          for(int jj=j+1;jj<N-1;jj++){
            int ss=ctoi(S[jj]);
            if(ss==ii){
              for(int iii=0;iii<=9;iii++){
                for(int jjj=jj+1;jjj<N;jjj++){
                  int sss=ctoi(S[jjj]);
                  if(sss==iii){
                    ans++;
                    break;
                  }
                }
              }//for iii
              break;
            }
          }//for jj end
        }//for ii end
        break;
      }
    }//rep j end
  }//if i end
  cout<<ans<<endl;
}

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


main()
{
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n;i++)
    cin >> a[i];
  int s = 0;
  for (int i = 0;i<n;i++)
    s += a[i];
  sort(a.begin(), a.end());
  cout << n + (x - s) / a[0] << endl;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

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


long long int n,cnt=0,ans=0,a[ohara],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>n;
      map<ll,ll> mp;
      rep(i,n){
        cin>>a[i];
        mp[a[i]]++;
      }
      rep(i,n){
        if(mp[a[i]]==0)continue;
         if(mp[a[i]]==a[i])continue;
         if(mp[a[i]]<a[i])ans+=mp[a[i]];
         else{
           ans+=mp[a[i]]-a[i];
         }
        mp[a[i]]=0;
      }
      Cout(ans);
     

       
return 0;
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define inf 1000000000
#define ninf -1000000000
#define for0(n) for(int i=0;i<n;i++)
#define fori(a,n) for(int i=a;i<n;i++)
#define rev(n,d) for(int i=n;i>=d;i--)
#define mem(ar,x) memset(ar,x,sizeof ar)
inline long long  max2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  max3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  min2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  min3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int,int> > vii;
typedef long long ll;
 
#define  modu 1000000007


int main() {
    
    {
        int n,i,h,w;cin>>n>>h>>w;
        cout<<(n-h+1)*(n-w+1);
    }
    return 0;
}

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

int main(){
    int i,n,m,h[100002]={},a[100002]={},b[100002]={},zentai[100002]={},count=0;
    scanf("%d%d",&n,&m);
    for (i=0; i<n; i++) scanf("%d",&h[i]);
    for (i=0; i<m; i++) scanf("%d%d",&a[i],&b[i]);
    for (i=0; i<m; i++) {
        if (h[a[i]-1]>h[b[i]-1]) zentai[b[i]]++;
        else if (h[a[i]-1]<h[b[i]-1]) zentai[a[i]]++;
        else {zentai[a[i]]++;zentai[b[i]]++;}
    }
    
    for (i=1; i<=n; i++) {
        if (zentai[i]==0) count++;
    }
    printf("%d",count);
    return 0;
}




Measured memory_bytes: 3292
#include <iostream>
#include <vector>
#include <complex>
using namespace std;
static const double EPS = 1e-12;
#define rep(i,n) for(int i=0;i<n;i++)

const double INF = 1e12;
typedef complex<double> P,point;
namespace std {bool operator < (const P& a, const P& b) {return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);}}
double cross(const P& a, const P& b) {return imag(conj(a)*b);}
double dot(const P& a, const P& b) {return real(conj(a)*b);}
struct L : public vector<P> {L(const P &a, const P &b) {push_back(a); push_back(b);}};

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

bool intersectSS(const L &s, const L &t) {
	return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 && ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
P crosspoint(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  return m[0] + B / A * (m[1] - m[0]);
}
double getArea(P a, P b , P c){
		b-=a, c-=a;
		return fabs( b.real() * c.imag() - c.real() * b.imag() ) / 2.0; 
}
int main(){
	double a,b,c,d;
	while(cin >> a >> b >> c >> d , a || b || c || d){
		L one = L(P(a,b),P(c,d));
		cin >> a >> b >> c >> d;
		L two = L(P(a,b),P(c,d));
		cin >> a >> b >> c >> d;
		L three = L(P(a,b),P(c,d));
		double ret = 0;
		
		if(intersectSS(one,two) && intersectSS(two,three) && intersectSS(one,three)){
			ret = getArea( crosspoint(one,two) , crosspoint(two,three) , crosspoint(one,three) );
		}
		if(ret >= 1900000){
			cout << "dai-kichi" << endl;
		}else if(ret >= 1000000){
			cout << "chu-kichi" << endl;
		}else if(ret >= 100000){
			cout << "kichi" << endl;
		}else if(ret > 0){
			cout << "syo-kichi" << endl;
		}else{
			cout << "kyo" << endl;
		}
	}
}

Measured memory_bytes: 1236
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = list(li())
x = [0]*n

xsum = sum(a) // 2
x[0] = xsum - sum(a[1::2])

for i in range(1, n):
    x[i] = a[i-1] - x[i-1]

print(*list(map(lambda y: 2*y, x)))

Measured memory_bytes: 16876
m;char*n="Thurs\0Fri\0__Satur\0Sun\0__Mon\0__Tues\0_Wednes";main(d){for(;scanf("%d%d",&m,&d),m;printf("%sday\n",n+(d-13*~m/5)%7*6))m<3?d-=2,m+=12:0;}

Measured memory_bytes: 0
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

ll inf=1ll<<60;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll i,a[100000],n,b[2]={0},j=0;
	cin>>n;
	for (i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for (i=n-1;i>=1;i--){
		if (a[i]==a[i-1]){
			b[j]=a[i];
			j++;
			i--;
			if (j==2){
				break;
			}
		}
	}
	cout<<b[0]*b[1];
	return 0;
}

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


int main(){
  int N;
  cin>>N;
  int maxA = 0;
  long long int minA = 1000000000;
  for(int i=0;i<N;i++){
    long long int A;
    cin>>A;
    if(A>maxA)maxA=A;
    if(A<minA)minA=A;
  }
  cout<<maxA-minA<<endl;
}


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

int main(){
  vector<int> v(3);
  cin>>v[0]>>v[1]>>v[2];
  sort(v.begin(),v.end());
  v[1]-=v[0];v[2]-=v[0];v[0]=0;

  int a=v[1],b=v[2];
  if(a%2==0){cout<<b-a+a/2;}
  else{cout<<a/2+b-a+2;}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

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

    ll X, A;
    cin >> X >> A;
    if(X < A) cout << 0 << endl;
    else cout << 10 << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    S = input()
    K = int(input())

    i = 0

    for i in range(K):
        if S[i]=="1":
            continue
        else:
            print(S[i])
            exit()
    print(1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61924
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    char n[2];
    rep(i, 2) cin >> n[i];

    if (n[0] == '9' || n[1] == '9'){
        p("Yes");
    }else{
        p("No");
    }
}


Measured memory_bytes: 256
# include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k=1;
	map<string ,string>mp;
	cin>>n;
	string s[n];
	for(int i=0;i<n;i++)
	{
	cin>>s[i];
	}
	for(int i=0;i<n;i++)
	{
	mp[s[i]];
	}
	cout<<mp.size()<<endl;
	
	
}

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll a, b, c;
  cin >> a >> b >> c;

  cout << (b / a > c ? c : b / a) << "\n";
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
char c;
int H,W;
int main(){
  cin >> H >> W;
  for(int i=0;i<=H+1;i++){
    for(int j=0;j<=W+1;j++){
      if(i==0 || j==0 || i==H+1 || j==W+1) cout << '#';
      else{cin >> c; cout << c;}
    }
    cout << endl;
  }
}

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

vector<int> to[200005];
vector<int> ans;
void dfs(int v, int p = -1)
{
  for (int u : to[v])
  {
    if (u == p)
      continue;
    ans[u] += ans[v];
    dfs(u, v);
  }
}
int main()
{
  int n, q;
  cin >> n >> q;
  for (int i = 0; i < n - 1; i++)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans.resize(n);
  for (int i = 0; i < q; i++)
  {
    int p, x;
    cin >> p >> x;
    p--;
    ans[p] += x;
  }
  dfs(0);
  for (int i = 0; i < n; i++)
  {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 23552
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

#include <bits/stdc++.h>
using namespace std;

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

const size_t N = 2E2 + 5;

int a[N][N];
vector<int> g[N];
int match[N]; bool vis[N];

bool dfs(int u) {
    if (vis[u]) return false;
    vis[u] = 1;
    for (int v : g[u]) {
        if (!~match[v] || dfs(match[v])) {
            match[u] = v;
            match[v] = u;
            return true;
        }
    }
    return false;
}

int main() {
    int n = read(), m = read();
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            a[i][j] = read() - 1;
        }
    }

    for (int j = 0; j < m; ++j) {
        memset(match, -1, sizeof match);
        for (int i = 0; i < n; ++i) {
            g[i].clear();
            for (int k = j; k < m; ++k) {
                g[i].emplace_back(a[i][k] / m + n);
            }
        }
        for (int i = 0; i < n; ++i) {
            memset(vis, 0, sizeof vis);
            assert(dfs(i));
        }
        for (int i = 0; i < n; ++i) {
            for (int k = j; k < m; ++k) {
                if (a[i][k] / m == match[i] - n) {
                    swap(a[i][k], a[i][j]);
                    break;
                }
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            printf("%d%c", a[i][j] + 1, "\n "[j + 1 < m]);
        }
    }
    for (int j = 0; j < m; ++j) {
        vector<int> vc(n);
        for (int i = 0; i < n; ++i) {
            vc[i] = a[i][j];
        }
        sort(begin(vc), end(vc));
        for (int i = 0; i < n; ++i) {
            a[i][j] = vc[i];
            assert(a[i][j] / m == i);
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            printf("%d%c", a[i][j] + 1, "\n "[j + 1 < m]);
        }
    }
    return 0;
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        int n = 0;
        long[] as = null;
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String[] elems = br.readLine().split(" ");
            n = Integer.parseInt(elems[0]);
            elems = br.readLine().split(" ");
            as = new long[n*3];
            for (int i = 0; i < elems.length; i++) {
                as[i] = Long.parseLong(elems[i]);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        Arrays.sort(as);
        long sum = 0;
        int head = 0;
        int last = as.length - 2;
        while (head < last) {
            sum += as[last];
            head++;
            last--;last--;
        }
        System.out.println(sum);
    }
}


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

const int N = 200002;

int a[N], b[N];

int main() {
        ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int n, c = 0; cin >> n;
        for(int i = 1; i <= n; i++) cin >> a[i];
        for(int i = n; i >= 1; i--) {
                int cnt = 0;
                for(int j = i + i; j <= n; j += i) cnt ^= b[j];
                b[i] = cnt ^ a[i];
                c += b[i];
        }
        cout << c << endl;
        for(int i = 1; i <= n; i++) if(b[i]) cout << i << endl;


}


Measured memory_bytes: 2560
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	LL n; cin >> n;
	if (n == 2) { cout << 1 << endl; return 0; }
	set<LL> s; s.insert(n); s.insert(n - 1);

	for (LL i = 2; i*i <= n; i++) {
		if (n%i == 0) {
			LL x = n;
			while (x%i == 0) {
				x /= i;
			}

			if (x%i == 1)s.insert(i);

			LL y = n;

			if (i*i != n) {
				LL j = n / i;

				while (y%j == 0) {
					y /= j;
				}

				if (y%j == 1)s.insert(j);

			}
		}
	}

	n--;
	for (LL i = 2; i*i <= n; i++) {
		if (n%i == 0) {
			s.insert(i);
			if (i*i != n)s.insert(n / i);
		}
	}

	cout << s.size() << endl;

	return 0;
}


Measured memory_bytes: 3636
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

use std::collections::VecDeque;

fn f(i: usize, j: usize, h: usize, w: usize, mat: &Vec<Vec<char>>) -> u32 {
    let mut check: Vec<Vec<bool>> = vec![vec![false; w]; h];
    let mut ret = 0;
    for i2 in 0..h {
        for j2 in 0..w {
            if mat[i2][j2] == '#' {
                check[i2][j2] = true;
            }
        }
    }

    let mut vd = VecDeque::new();
    vd.push_back((i, j, 0));
    check[i][j] = true;

    loop {
        match vd.pop_front() {
            None => {
                break;
            }
            Some((i2, j2, d)) => {
                check[i2][j2] = true;
                if i2 > 0 && !check[i2 - 1][j2] {
                    check[i2 - 1][j2] = true;
                    vd.push_back((i2 - 1, j2, d + 1));
                    ret = d + 1;
                }
                if i2 < h - 1 && !check[i2 + 1][j2] {
                    check[i2 + 1][j2] = true;
                    vd.push_back((i2 + 1, j2, d + 1));
                    ret = d + 1;
                }
                if j2 > 0 && !check[i2][j2 - 1] {
                    check[i2][j2 - 1] = true;
                    vd.push_back((i2, j2 - 1, d + 1));
                    ret = d + 1;
                }
                if j2 < w - 1 && !check[i2][j2 + 1] {
                    check[i2][j2 + 1] = true;
                    vd.push_back((i2, j2 + 1, d + 1));
                    ret = d + 1;
                }
            }
        }
    }

    ret
}

fn main() {
    let hw: Vec<usize> = read_vec();
    let h = hw[0];
    let w = hw[1];
    let sv: Vec<String> = read_col(h);
    let mat: Vec<Vec<char>> = sv.into_iter().map(|s| s.chars().collect()).collect();

    let mut ans = 0;
    for i in 0..h {
        for j in 0..w {
            if mat[i][j] == '#' {
                continue;
            }
            let tmp = f(i, j, h, w, &mat);
            if tmp > ans {
                ans = tmp;
            }
            // println!("{} {} {}", i, j, tmp);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    set<int> ans;
    for (int i = a; i < min(b+1, a + k); i++)
        ans.insert(i);
    for (int i = b; i > max(a-1, b - k); i--) {
        ans.insert(i);
    }
    for (auto t : ans)
        cout << t << endl;

    return 0;
}

Measured memory_bytes: 256