akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize "trapv"
//-D_GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pm(m) for(auto itr=(m).begin();itr!=(m).end();itr++){itr->first<<" "<<itr->second<<"\n";}
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define ii pair<int,int>
#define Max 100000+5
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f first
#define s second
#define pb push_back
#define bug(x) cout<<(x)<<" ";exit(0);
int mod = 1000000007;
int mod1 = 998244353;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
vector<int> g[Max];
bool vis[Max];
int d, x, y;
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
void ex(int A, int B) {
    if(B == 0) {
        d = A;
        x = 1;
        y = 0;
    }
    else {
        ex(B, A%B);
        int temp = x;
        x = y;
        y = temp - (A/B)*y;
    }
}


void dfs(int u){

	vis[u]=1;
	for(int i=0;i<g[u].size();i++){
		int v=g[u][i];
		if(vis[v]!=1)
			dfs(v);
	}
}



int power(int a,int b){
    if(b==1)return a;
    if(a>mod)a%=mod;
    int r=1;
    while(b){
        if(b&1)r=r%mod*a%mod;
        a=a%mod*a%mod;
        b/=2;
    }
    return r;
}
class uf{
    vector<int> v;
    vector<int> sz;
    
    
    public :
    uf(int n){
        v.resize(n+1);
        iota(v.begin()+1,v.end(),1);
        sz.resize(n+1,1);
        //1 to sz
    }
    int root(int b){
        while(v[b]!=b){
            b = v[b];
        }   
        return b;
    }
    void join(int a, int b){
        //combine a and b
        
        int ra=root(a);
        int rb=root(b);
        if(ra==rb)return ;
        if(sz[ra]<sz[rb])swap(ra,rb);
        v[rb]=ra;
        sz[ra]+=sz[rb];
        
    }
    bool same(int a,int b){
        //same set
        return (root(a)==root(b));
    }
    int size(int a){
        return sz[root(a)];
    }
   
    
};
vector<int> matmul(vector<int> a,vector<int> b){
    vector<int> c(4,0);
    c[0] = (a[0]%mod*b[0]%mod + a[1]%mod*b[2]%mod)%mod;
    c[1] = (a[0]%mod*b[1]%mod + a[1]%mod*b[3]%mod)%mod;
    c[2] = (a[2]%mod*b[0]%mod + a[3]%mod*b[2]%mod)%mod;
    c[3] = (a[2]%mod*b[1]%mod + a[3]%mod*b[3]%mod)%mod;
    return c;
}
vector<int> id={1,0,0,1};

int32_t main(){
	IO
	//freopen("input.txt","r",stdin);
    	//freopen("output.txt","w",stdout);
    int a,b;
    cin>>a>>b;
    for(int i=0;i<10;i++){
       
        int val = b*10+i;
        if(floor(1.0*val*0.08)==a){
            cout<<val;
            exit(0);
        }
    }
    cout<<-1;
}

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

using namespace std;

vector <long long> p;

bool isPrime(long long n) {
    if (n <= 1) {
        return 0;
    }
    long long m = sqrt(n);
    for (long long i = 2; i <= m; i++) {
        if (n % i == 0) {
            return 0;
        }
    }
    return 1;
}

long long gcd(long long a, long long b) {
    while (b > 0) {
        long long r = a % b;
        a = b;
        b = r;
    }

    return a;
}

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

    long long a, b;
    cin >> a >> b;

    long long n = gcd(a, b);
    long long m = sqrt(n);

    for (int i = 1; i <= m; i++) {
        if (n % i == 0 && n / i != i) {
            p.push_back(i);
            p.push_back(n / i);
        }
        else if (n / i == i && n % i == 0) {
            p.push_back(i);
        }
    }

    long long l = p.size();

    long long sum = 1;
    for (int i = 0; i < l; i++) {
        if (isPrime(p[i]) == 1) {
            sum++;
        }
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n;
string str;

int main(){
	cin >> n;
	if(n <= 9){cout << n << endl;}
	if(n > 9 && n <= 99){cout << 9 << endl;}
	if(n > 99 && n <= 999){cout << n-99+9 << endl;}
	if(n > 999 && n <= 9999){cout << 999-99+9 << endl;}
	if(n > 9999 && n <= 99999){cout << n-9999+999-99+9 << endl;}
	if(n > 99999 && n <= 999999){cout << 99999-9999+999-99+9 << endl;}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define ALL(a) (a).begin(),(a).end()
#define EACH(e,v) for(auto& e:v)
#define SORT(v) sort(ALL(v))
#define PERM(v) SORT(v);for(bool c##p=1;c##p;c##p=next_permutation(ALL(v)))
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
template <class T> void chmax(T & a, T const & b) { if (b > a) a = b; }
template <typename T>
string to_string(const T &n){ostringstream stm;stm << n;return stm.str();}
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = 1000'000'007;
 
signed main(){
    string s,t;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    string u;
    cin>>u;

    if(s==u){
        a--;
    }else{
        b--;
    }
    cout<<a<<' '<<b<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		char[] c = new char[3];
		c[0] = s.charAt(0);
		c[1] = s.charAt(1);
		c[2] = s.charAt(2);
		int r = 0;
		for (int i = 0; i < 3; i++) {
			if (c[i] == '1') {
				r++;
			}
		}
		System.out.println(r);
	}
}


Measured memory_bytes: 21588
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000001
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
vector<int>seg[(1<<18)];
void update(int a,int b)
{
	a+=(1<<17)-1;
	seg[a].pb(b);
}
void all()
{
	for(int i=(1<<17)-2;i>=0;i--)
	{
		if(seg[i*2+1].empty() && seg[i*2+2].empty()) continue;
		else if(seg[i*2+1].empty()) seg[i] = seg[i*2+2];
		else if(seg[i*2+2].empty()) seg[i] = seg[i*2+1];
		else
		{
			seg[i].resize(seg[i*2+1].size()+seg[i*2+2].size());
			merge(seg[i*2+1].begin(),seg[i*2+1].end(),seg[i*2+2].begin(),seg[i*2+2].end(),seg[i].begin());
		}
	}
}
int query(int a,int b,int k,int lb,int ub,int q,int w)
{
	if(ub < a || b < lb) return 0;
	if(a <= lb && ub <= b)
	{
		int s = lower_bound(seg[k].begin(),seg[k].end(),q)-seg[k].begin();
		int t = upper_bound(seg[k].begin(),seg[k].end(),w)-seg[k].begin();
		return s+seg[k].size()-t;
	}
	int lk = query(a,b,k*2+1,lb,(lb+ub)/2,q,w);
	int uk = query(a,b,k*2+2,(lb+ub)/2+1,ub,q,w);
	return lk+uk;
}

int a[100005],n;

int main()
{
	cin >> n;
	for(int i=1;i<=n;i++)
	{
		cin >> a[i];
		update(i,a[i]);
	}
	all();
	int q; cin >> q;
	for(int i=0;i<q;i++)
	{
		int l,r,e; cin >> l >> r >> e;
		cout << query(l,r,0,0,(1<<17)-1,min(a[l],a[r])-e,max(a[l],a[r])+e) << endl;
	}
}

Measured memory_bytes: 19348
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main(void){
    string AL = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", al = "abcdefghijklmnopqrstuvwxyz";
    string s;
    getline(cin, s);
    for(int i = 0; i < s.size(); i++){
        if(s[i] >= 'a' && s[i] <= 'z') cout << AL[s[i] - 'a'];
        else if(s[i] >= 'A' && s[i] <= 'z') cout << al[s[i] - 'A'];
        else cout << s[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const double pi=acos(-1.0);

int main(){
	ll a,b,c,k,sum=0;
	cin>>a>>b>>c>>k;
	if(k<=a)cout<<k;
	else if(k<=a+b)cout<<a;
	else cout<<a-(k-a-b);
	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <math.h>



using namespace std;


int main(){
	int a, b;
	cin >> a >> b;
	int x = (a + b) % 24;
	printf("%d\n", x);
	
}






Measured memory_bytes: 256
// problem Atcoder - https://atcoder.jp/contests/dp/tasks/dp_o

#include<bits/stdc++.h>
 
using namespace std;
 
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
 
// #define N 311111
#define A 1111111
#define BLOCK 555 // ~sqrt(N)
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
 
const ll INF = 1e18 +5;
const int nax = 100005;
const long M = 1000000007;
 
ll dp[1<<22];
vi edges[nax];
// int in_degree[nax];
// vector<int> edges[nax];

// return number of ways to paint b,w
pair<ll ,ll> dfs(int node, int parent){
	ll all_white_child = 1;
	ll sth_is_black = 0;
	for(int child : edges[node]){
		if(child != parent){
			pair<ll,ll> p = dfs(child, node);
			sth_is_black = ((all_white_child * p.first)%M + (sth_is_black * ((p.first + p.second)%M)%M))%M;
			all_white_child = (all_white_child*p.second)%M;
		}
	}
	return MP(all_white_child, (all_white_child + sth_is_black)%M);
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	// cout<<fixed;
	// cout<<setprecision(10);
	int t;
	// cin>>t;
	t = 1;
	while(t--){
		int n;
		cin>>n;
		for (int i=0;i<n-1;i++){
			int x,y;
			cin>>x>>y;
			edges[x].push_back(y);
			edges[y].push_back(x);
		}
		pll ans = dfs(1,-1);
		cout<<(ans.first + ans.second)%M<<endl;
	}
}

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

int P[10010];

void init (int N){
    for (int i = 0; i < N; i++) P[i] = i;
}

int root (int a){
    if (P[a] == a) return a;
    return (P[a] = root(P[a]));
}

bool is_same_set(int a, int b){
    return root(a) == root(b);
}

void unite (int a, int b){
    P[root(a)] = root(b);
}

int main(){
    int n,q,x,y,com;
    cin >> n >> q;
    init(n);
    for (int i = 0; i < q; i++){
        cin >> com >> x >> y;
        if (com == 0) unite (x,y);
        if (com == 1){
            if (is_same_set(x,y)) cout << "1" << endl;
            else cout << "0" << endl;
        }
    }
}

Measured memory_bytes: 1312
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

n = readint()

ans = [0]*(n+1)

for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            a = x**2+y**2+z**2+x*y+x*z+z*y
            if a<=n:
                ans[a] += 1

printrows(ans[1:])






Measured memory_bytes: 73904
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

int n,m;
char s[111][111];
int cnt[333];

int main() {
	scanf("%d%d", &n, &m);
	FOR(i,n) scanf("%s", s[i]);
	FOR(i,n) FOR(j,m) cnt[s[i][j]]++;
	int four = 0, two = 0, one = 0;
	if (n%2 == 0) {
		if (m%2 == 0) {
			four = n*m/4;
		} else {
			two = n/2;
			m--;
			four = n*m/4;
		}
	} else {
		if (m%2 == 0) {
			two = m/2;
			n--;
			four = n*m/4;
		} else {
			one = 1;
			two = (n+m-2)/2;
			n--;
			m--;
			four = n*m/4;
		}
	}
	FOR(i,333) if (cnt[i] % 2 == 1) {
		if (one) {
			one--;
			cnt[i]--;
		} else {
			printf("No\n");
			return 0;
		}
	}
	FOR(i,333) if (cnt[i] % 4 == 2) {
		if (two) {
			two--;
			cnt[i] -= 2;
		} else {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

//最小公倍数
ll lcm(ll x, ll y){
	ll g = gcd(x,y);
	return x/g*y;
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

int main() {
    int n,m;cin>>n>>m;
    vector<string> a(n),b(m);
    rep(i,n)cin>>a[i];
    rep(i,m)cin>>b[i];
    rep(i,n-m+1)rep(j,n-m+1){
        bool found = true;
        rep(p,m)rep(q,m){
            if(b[p][q] != a[i+p][j+q]){
                found = false;
            }
        }
        if(found){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}



Measured memory_bytes: 256
from heapq import heappush, heappop
 
N,M = map(int,input().split())
A = [0]*N
B = [0]*N
for i in range(N):
    A[i],B[i] = map(int,input().split())
AB = [[] for _ in range(M+1)] # A に対する B
for a,b in zip(A,B):
    if a <= M:
        AB[a].append(b)
        
q = []
answer = 0

for day in AB:
    # 制限より短いものからも選べるように全文pushして一番良いものだけpopする
    for pay in day:
        heappush(q,-pay)
    if len(q) > 0:
        answer += -heappop(q)
        
print(answer)

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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		long[] h = new long[N];
		for (int i = 0; i < N; i++) {
			h[i] = sc.nextLong();
		}
		Arrays.sort(h);

		long ans = Integer.MAX_VALUE;
		for (int i = K - 1; i < N; i++) {
			ans = Math.min(ans, h[i] - h[i - K + 1]);
		}

		System.out.println(ans);
	}
}


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

using namespace std;

typedef long long ll;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define INF 1000000000

int main() {

	int n, q, ans[100100];
	ans[0] = 0;
	string s;
	cin >> n >> q;
	cin >> s;
	FOR(i, n - 1) {
		if (s[i] == 'A'&&s[i + 1] == 'C')ans[i + 1] = ans[i] + 1;
		else ans[i + 1] = ans[i];
	}
	vector<int> l(q), r(q);
	FOR(i, q)cin >> l[i] >> r[i];
	FOR(i, q)cout << ans[r[i] - 1] - ans[l[i] - 1] << endl;
	

	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 40;
char str[40000];
int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif // LOCAL
    ios::sync_with_stdio(0);
    int n;
    scanf("%d", &n);
    for(int i=111; i < 1000; i += 111){
        if (i >= n) {
            printf("%d", i);
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int h,w,d;
  cin>>h>>w>>d;

  char ans[h+1][w+1]={};
  for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
          int x=(i+j)%(2*d);
          int y=(i-j)%(2*d);
          y=(y+2*d)%(2*d);
          if(x<d){
              if(y<d) ans[i][j]='R';
              else ans[i][j]='B';
          }else{
              if(y<d) ans[i][j]='Y';
              else ans[i][j]='G';
          }
      }
  }

  for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
          cout<<ans[i][j];
      }
      cout<<endl;
  }

  return 0;
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int n = (int)Math.sqrt(a);
        boolean isNotNature = true;
        while(isNotNature) {
            isNotNature = false;
            for (int i = 2; i <= n; i++) {
                if (a % i == 0){
                    isNotNature = true;
                    break;
                }
            }
            if(!isNotNature) break;
            a++;
        }
        System.out.println(a);
    }
}


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

using namespace std;

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

    int p1 = s / 100;
    int p2 = s % 100;

    auto is_month = [](int num) {
        return 0 < num && num <= 12;
    };

    if (is_month(p1) && is_month(p2))
    {
        cout << "AMBIGUOUS" << endl;
    }
    else if (!is_month(p1) && !is_month(p2))
    {
        cout << "NA" << endl;
    }
    else if (is_month(p1) && !is_month(p2))
    {
        cout << "MMYY" << endl;
    }
    else
    {
        cout << "YYMM" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX_N 100000

int n, A[MAX_N];

void swap(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

int partition(int p, int r) {
  int x = A[r];
  int i = p-1, j;
  for(j = p; j < r; j++) {
    if(A[j] <= x) {
      i++;
      swap(&A[i], &A[j]);
    }
  }
  swap(&A[i+1], &A[r]);
  return i+1;
}

int main() {
  int i;

  scanf("%d", &n);
  for(i = 0; i < n; i++) scanf("%d", A+i);

  int q = partition(0, n-1);
  for(i = 0; i < n; i++) {
    if(i) putchar(' ');
    if(i == q) putchar('[');
    printf("%d", A[i]);
    if(i == q) putchar(']');
  }
  puts("");

  return 0;
}

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

#define ll long long int
#define ull unsigned long long int
#define Size(Array) sizeof(Array)/sizeof(Array[0])
#define sof(a) sizeof(a)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define bk back
#define ed endl
#define en cout << endl
#define mod (ll)(1e9 + 7)
#define f(i, a, b) for(ll i = a; i < b; i++)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MAX 100005

using namespace std;

int main()
{
    FAST;

    int m, n = 3;
    cin >> m;
    int a[m][n], t = 0;
    f(i, 0, m)
    {
        f(j,0, n)
        {
            cin >> a[i][j];
        }
    }

    f(i, 1, m)
    {
        f(j, 0, n)
        {
            a[i][j] += max(a[i-1][(j+1)%n], a[i-1][(j+2)%n]);
        }
    }

    f(i, 0, n)
    {
        t = max(t, a[m-1][i]);

    }

    cout << t << ed;

    return 0;
}



Measured memory_bytes: 1408
import java.util.*;
public class Main{
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n;
        double m, a2;
        int s[] = new int[1000];
        while(true){
        	n = sc.nextInt();
        	if(n == 0)break;
        	m = 0;
        	a2 = 0; 
        	for(int i = 0; i < n; i++){
        		s[i] = sc.nextInt();
        		m += s[i];
        	}
        	m = m/ n;
        	for(int i = 0; i < n; i++){
        		a2 += (s[i] - m)*(s[i] - m) / n;
        	}
        	System.out.printf("%.8f\n",Math.sqrt(a2));
        }
    }
 
}

Measured memory_bytes: 23780
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
#define endl '\n'
#define M_PI 3.14159265358979323846

using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    long double x;
    cin >> x;
    cout << x * M_PI * 2;
    return 0;
}

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


int main()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	
	ll n,k;
	
	cin>>n>>k;
	
	ll st = k;
	
	for(ll i=n-1;i>=0;i--)
	{
		cout<<st-i<<" ";
	}
	for(ll i=1;i<n;i++)
	{
		cout<<st+i<<" ";
	}cout<<endl;
	
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <math.h>
#include <sstream>
#include <iomanip>
#include <time.h>
#include <fstream>

using namespace std;

int main(){
	int N;
	cin>>N;
	vector<int> a;
	a.resize(N);
	
	int best = 30;
	for(int i = 0; i < N; i++){
		cin>>a[i];
		int current = 0;
		while(a[i]%2 == 0){
			a[i] /= 2;
			current++;
		}
		best = min(current, best);
	}
	cout<<best<<endl;
	return 0;
}

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

using namespace std;

const int maxn = 110;
const int base = 1e9+7;

int n,a[maxn];
ll f[maxn][maxn];
map<int,int> cnt;
vector<int> h;

ll pw(int a,int n) {
    if (n==0) return 1ll;
    if (n==1) return a;
    ll tmp = pw(a,n/2);
    tmp = (tmp*tmp)%base;
    if (n%2==0) return tmp;
    return (tmp*a)%base;
}

int main() {
  //  freopen("in.txt","r",stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for (int i=1;i<=n;i++) {
        cin>>a[i];
        if (cnt[a[i]]!=0) continue;
        h.push_back(a[i]);
        cnt[a[i]]=1;
    }
    cnt.clear();
    h.push_back(0);
    sort(h.begin(),h.end());
    h.erase(unique(h.begin(),h.end()),h.end());
    for (int j=0;j<h.size();j++) cnt[h[j]]=j;
    for (int j=0;j<h.size();j++)
        if (h[j] == 0) f[1][j] = pw(2,a[1]);
        else if (h[j] <= a[1]) f[1][j] = pw(2,a[1] - h[j]+1);
    for (int i=2;i<=n;i++) {
        if (a[i] < a[i-1]) {
            int mi = cnt[a[i]];
            for (int j=0;j<h.size();j++)
                if (h[j] <= a[i])
                    f[i][j] = (f[i-1][j] + f[i-1][mi])%base;
        } else {
            int mi = cnt[a[i-1]];
            for (int j=0;j<h.size();j++) {
                if (h[j] <= a[i-1]) f[i][j] = ((f[i-1][j] + f[i-1][mi])%base * pw(2,a[i] - a[i-1])) % base;
                else if (h[j] <= a[i]) f[i][j] = (pw(2,a[i] - h[j]+1) * f[i-1][mi]) % base;
            }
        }
    }
    cout<<f[n][0]<<endl;

}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main() {
    
    set<string> s;
    int n;
    cin>>n;
    vs v(n);
    rep(i,n){
        cin>>v[i];
        if(s.count(v[i])==1){
            fin("No");
            return 0;
        }
        s.insert(v[i]);
    }
    rep(i,n-1){
        if(v[i][v[i].size()-1]!=v[i+1][0]){
            fin("No");
            return 0;
        }
    }
    fin("Yes");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  llong A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << max(A*B, C*D) << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env ruby

n = gets.to_i
line1 = gets.split.map {|num| num.to_i }
line2 = gets.split.map {|num| num.to_i }

line1scores = line1.clone
line2scores = line2.clone

(0..n-1).reverse_each do |i|
  line2scores[i] += line2scores[i+1].to_i

  left = line1scores[i+1].to_i
  down = line2scores[i]
  line1scores[i] += (left > down)? left : down
end

puts line1scores[0]


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
signed main()
{
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	 cout.tie(NULL);
	 int n;
	 cin>>n;
	 cout<<(n+1)/2<<endl;
	 return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin>>s;
  s[s.size()-1]='0';
  int l=s.size();
  int ans=0;
  for(int i=1;i<=l/2;i++){
    bool q=true;
    for(int j=0;j<i;j++){
      if(s[j]!=s[i+j]){
        q=false; 
      }
    }
    if(q==true)ans=i;
  }
  cout<<2*ans<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main()
{
	int n,cnt,i;
	char s[100001];
	scanf("%d",&n);
	scanf("%s",s);
	cnt=0;
	i=0;
	while(i<n-1){
		if(s[i]!=s[i+1]){
			cnt++;
			i++;
		}
		i++;
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 2860
import sys
from itertools import accumulate


def calc(tasks):
    tasks_l, tasks_r = zip(*tasks)
    tasks_l_acc_fwd = list(accumulate(tasks_l, func=max))
    tasks_l_acc_bwd = list(reversed(list(accumulate(reversed(tasks_l), func=max))))
    tasks_r_acc_fwd = list(accumulate(tasks_r, func=min))
    tasks_r_acc_bwd = list(reversed(list(accumulate(reversed(tasks_r), func=min))))
    # print(tasks)
    # print(tasks_r_acc_fwd)
    # print(tasks_r_acc_bwd)

    score = 0
    for i in range(1, n):
        left_max_l = tasks_l_acc_fwd[i - 1]
        left_min_r = tasks_r_acc_fwd[i - 1]
        right_max_l = tasks_l_acc_bwd[i]
        right_min_r = tasks_r_acc_bwd[i]
        tmp_score = max(0, left_min_r - left_max_l + 1) + max(0, right_min_r - right_max_l + 1)
        score = max(score, tmp_score)
    return score


n = int(input())
appeared_lr = set()
tasks = []
for line in sys.stdin:
    l, r = list(map(int, line.split()))
    appeared_lr.add(l)
    appeared_lr.add(r)
    tasks.append((l, r))

tasks.sort()
ans1 = calc(tasks)

tasks.sort(key=lambda lr: (lr[0], -lr[1]))
ans2 = calc(tasks)

tasks.sort(key=lambda lr: (lr[1] - lr[0], lr[0], lr[1]))
ans3 = calc(tasks)

print(max(ans1, ans2, ans3))


Measured memory_bytes: 41364
#include<bits/stdc++.h>
using namespace std;
int main(){
  long a,b,k; cin >> a >> b >>k;
  for(int i = 0; i < k; i++){
    if(i % 2 == 0){
      if(a % 2 == 1)a--;
      b += a/2;
      a =max(a/2,0l);
    }
    else{
      if(b % 2 == 1) b--;
      a += b/2;
      b = max(b/2,0l);
    }
    //printf("%d %d\n",a,b);
  }
  printf("%d %d\n",a,b);
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define ll long long 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int MAXN=2e5;
int main(){
	IOS;
	
string s, t;
cin>>s>>t;
int len=s.length(), c=0;
for(int i=0;i<len;i++){
	if(s[i]!=t[i])
	c++;
}
cout<<c;
	}

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

using namespace std;
int main()
{
    long long n,k,x,y;
    cin>>n>>k>>x>>y;
    if(k>=n)
    {
        cout<<n*x<<endl;
    }
    else
    {
        cout<<k*x + (n-k)*y<<endl;
    }

}


Measured memory_bytes: 3440
def gcd(a,b):
  if b == 0:
    return a
  return gcd(b,a%b)

def lcm(a,b):
  return (a*b)//gcd(a,b)
 
n = int(input())
arr = [int(x) for x in input().split()] 
mod=1000000007
lc = arr[0]
for i in range(1, len(arr)): 
  	lc = lcm(lc,arr[i])
ans=0
for i in range(n):
    ans=ans+lc//arr[i]
print(int(ans)%mod)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  vector<bool> dp(1e6+5, true);
  ll ans = 0;
  for(int i = 0; i < n; i++){
    bool flg = true;
    if(!dp[a[i]]) continue;
    if(a[i] == a[i+1]) flg = false;
    for(int j = a[i]; j < 1e6+5; j += a[i]) dp[j] = false;
    if(flg) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4260
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST

main :: IO ()
main = getLine >>= print . solve . map read . words
solve :: [Int] -> Int
solve (x:a:_) = if x < a then 0 else 10

Measured memory_bytes: 508
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        
        if(b%a == 0){
            System.out.println(a+b);
        }else{
            System.out.println(b-a);
        }
    }
}

Measured memory_bytes: 23124
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int i, j, k, l = 0, m, n, s;
int main() {
	scanf("%d%d", &n, &s);
	for(i = 0; i <= n; i++) for(j = 0; j <= n; j++) {
		k = s - i - j;
		if(k >= 0 && k <= n) l++;
	}
	printf("%d\n", l);
}

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

int main()
{
    uint64_t i;
    std::cin >> i;
    uint64_t v1 = (i / 500);
    uint64_t tmp = i - 500 * v1;
    uint64_t v2 = tmp / 5;
    std::cout << (v1 * 1000 + v2 * 5) << std::endl;
}

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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k;
  cin >> n >> k;

  ll keta = 0;
  ll tmp = k;
  while(tmp > 0){
    keta++;
    tmp /= 2;
  }

  VLL a(n), b(n);
  rep(i,n) cin >> a[i] >> b[i];

  ll ans = 0;

  ll nomal = 0;
  rep(i,n){
    ll tmp = a[i];
    rep(j,30) {
      if( (k >> j) & 1 ) tmp |=  1LL << j;
    }
    if(tmp == k) {
      nomal += b[i];
    }
  }

  ans = max(nomal,ans);


  for(int bit = 30; bit >= 0; bit--){
    if( !((k >> bit) & 1) ) continue;
    // このビットより上のbitは一致している
    // それよりしたのビットはなんでも良い
    ll res = 0;
    ll highBit = ( (k >> bit) - 1) * (1LL << bit);
    // std::cout << std::bitset<5>(highBit) << endl;

    rep(i,n){
      // 上位bitがhighBitと一致
      ll tmpHigh = ( (a[i] >> bit)) * (1LL << bit);
      bool ngFlag = false;
      for(int j = 30; j >= 0; j--){
        if(  ((highBit >> j) & 1) == 0 && ((tmpHigh >> j) & 1) == 1){
          ngFlag = true;
        }
      }

      if(ngFlag == false){
        res += b[i];
      }
    }
    ans = max(res, ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
n, a, b = list(map(int, input().split()))
mod = 10 ** 9 + 7

ans = pow(2, n, mod) - 1

def comb(x):
    tmp = 1
    for i in range(1, x + 1):
        tmp = tmp * (n - i + 1) % mod
    for i in range(1, x + 1):
        tmp = tmp * pow(i, mod-2, mod) % mod
    return tmp

ans -= comb(a)
ans -= comb(b)
ans = (ans % mod + mod) % mod

print(ans)

Measured memory_bytes: 39280
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
      
		if(x==7 || x==5 || x==3) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <sstream>
using namespace std;

typedef long long ll;

const ll month[2][12] = {
  {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30},
  {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30},
};

const ll mayad[] = {144000, 7200, 360, 20, 1};

bool isLeap(const int &y){
  if(y % 4 != 0) return false;
  return y % 100 != 0 || y % 400 == 0;
}

ll getDayYMD(const ll &y, const ll &m, const ll &d){
  ll res = 0;
  bool leap = isLeap(y);

  for(ll i = 0; i < y; i++){
    if(isLeap(i)) res += 366;
    else          res += 365;
  }

  for(ll i = 0; i < m - 1; i++){
    res += month[leap][i];
  }

  return res + d;
}

ll getDayMAYA(const vector<ll> &v){
  ll res = 0;
  for(int i = 0; i < 5; i++){
    res += mayad[i] * v[i];
  }
  return res;
}

vector<ll> split(const string &str){
  vector<ll> res;
  stringstream ss(str);
  ll x;
  char ch;

  while(ss >> x >> ch){
    res.push_back(x);
  }
  res.push_back(x);
  return res;
}

void toMAYA(ll day){
  for(int i = 0; i < 5; i++){
    if(i == 0){
      ll div = day / mayad[i];
      div %= 13;
      day %= mayad[i];
      cout << div;
    }
    else{
      cout << ".";
      cout << day / mayad[i];
      day %= mayad[i];
    }
  }
  cout << endl;
}

void toYMD(ll day){
  ll y = 2012;

  // year
  while(true){
    bool leap = isLeap(y);
    if(leap){
      if(day - 366 < 0) break;
      day -= 366;
    }
    else{
      if(day - 365 < 0) break;
      day -= 365;
    }
    y++;
  }

  ll m = 1;

  while(m < 12){
    bool leap = isLeap(y);

    if(day - month[leap][m - 1] < 0){
      break;
    }
    day -= month[leap][m - 1];
    m++;
  }

  ll d = day + 1;

  cout << y << "." << m << "." << d << endl;
}

int main(){
  const ll base = getDayYMD(2012, 12, 21);

  string str;

  while(cin >> str, str != "#"){
    vector<ll> v = split(str);

    if(v.size() == 3){
      ll day = getDayYMD(v[0], v[1], v[2]);
      day -= base;
      toMAYA(day);
    }
    else{
      ll day = getDayMAYA(v) + getDayYMD(0, 12, 20);
      toYMD(day);
    }
  }
}

Measured memory_bytes: 1240
A, B, M = map(int, input().split())
AA = list(map(int, input().split()))
BB = list(map(int, input().split()))
ans = min(AA) + min(BB)
for i in range(M):
    x, y, c = map(int, input().split())
    ans = min(AA[x-1] + BB[y-1] - c, ans)
print(ans)

Measured memory_bytes: 70892
#include <iostream>
#include <cstdlib>
#include <bitset>
#include <map>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#include <sstream>
#include <math.h>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecchar vector<char>
#define vecstr vector<string>
#define vec2str vector<vector<string>>
#define vecbool vector<bool>
#define vec2bool vector<vector<bool>>
#define pairll pair<ll,ll>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

#define Pi 3.1415926535897932384626

int main() {
	ll x,k,d, ans = 0,max = 0;
	bool flag = false;
	string s;

	cin >> x >> k >> d;

	ll buf = abs(x) / d;

	if (buf > k)
	{
		ans = abs(abs(x) - k * d);
	}
	else
	{
		if ((k - buf) % 2 == 0)
		{
			ans = abs(abs(x) - buf * d);
		}
		else
		{
			ans = abs(abs(x) - (buf+1) * d);
		}
	}

	cout << ans;
}


Measured memory_bytes: 3632
n = int(input())
s = list(input().strip().lower())
r = 0
g = 0
b = 0
extra = 0
for i in range(n):
    if s[i] == 'r':
        r += 1
    elif s[i] == 'g':
        g += 1
    elif s[i] == 'b':
        b += 1

    for j in range(1, min(i + 1, n - i)):
        left = s[i - j]
        mid = s[i]
        right = s[i + j]
        if left != mid and left != right and mid != right:
            extra += 1

print(r*g*b-extra)


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

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;
}

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  ll result = 1;
  rep(i, n) {
    if (i == 0)
      result *= k;
    else
      result *= k - 1;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Arrays;
import java.util.Objects;

public class Main{
    public static void main(String[] args){
        FastScanner sc = new FastScanner();

        int r = sc.nextInt();
        int c = sc.nextInt();
        int[][] a = new int[r+1][c+1];

        for(int i=0;i<r;i++){
            for(int j=0;j<c;j++){
                a[i][j] = sc.nextInt();
                a[i][c] += a[i][j];
                a[r][j] += a[i][j];
            }
            a[r][c] += a[i][c];
        }

        for(int i=0;i<=r;i++){
            for(int j=0;j<c;j++)System.out.print(a[i][j]+" ");
            System.out.println(a[i][c]);
        }

    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}



Measured memory_bytes: 34252
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  
  ll n,k,s; cin >> n >> k >> s;
  
  rep(i,k){
    cout << s << ' ' ;
  }
  
  rep(i,n-k){
    if(s == 1000000000) cout << 1 << ' ';
    else cout << 1000000000 << ' ' ;
  }
  
  cout << endl;
  
  
}

Measured memory_bytes: 3576
n = int(input())
A = list(map(int, input().split()))
table = [0] * 32
for a in A:
    for i in range(32):
        if a>>i & 1:
            table[31-i] += 1
arr = [0] * 32
ans = 0
for i, v in enumerate(table):
    if v % 2 == 1:
        arr[i] = 1
for i, a in enumerate(arr):
    ans += a * (2**(31-i))
for a in A:
    print(ans^a, end=" ")

Measured memory_bytes: 94032
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    n=I()
    dic=defaultdict(lambda:0)
    k=1
    while k*(k-1)//2<10**6:
        dic[k*(k-1)//2]=k
        k+=1
    #print(dic)
    if dic[n]==0:
        print("No")
        sys.exit()
    print("Yes")
    x=dic[n]
    #print(x)
    item=x-1
    ans=[[0]*(item+1) for i in range(x)]
    res=0
    for i in range(item):
        for j in range(item-i):
            ans[i][j+i+1]=j+res+1
            #print(i,j)
        res+=item-i
    #print(ans)
    print(x)
    res=0
    for i in range(item):
        for j in range(item-i):
            ans[j+i+1][i+1]=j+res+1
        res+=item-i
    for i in range(item+1):
        ans[i][0]=item
    for i in range(item+1):
        print(*ans[i])
    
        
    
    
    


    
if __name__=="__main__":
    main()


Measured memory_bytes: 75936
#include<iostream>
#include<climits>
#include<string>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<math.h>
#include<algorithm>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> TP;

int main()
{
    string s;
    cin >> s;
    int p = 0;
    int g = 0;

    for( int i = 0; i < s.length(); ++i )
    {
        if( s[i] == 'p' )
        {
            p++;
        }
        else
        {
            g++;
        }
    }

    int answer = ( g - p ) / 2;

    cout << answer << endl;
}


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

int main() {
  long long N;
  cin >> N;
  long long ans = 0;
  for (long long i = 1; i <= N; i++) {
    long long x = N / i;
    ans += x * (x + 1) / 2 * i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  string s;
  cin >> s;

  regex re(R"(AC)");
  smatch m;

  bool ans = regex_search(s, m, re);

  cout << (ans ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%s", $s);
for ($i = 0; $i < strlen($s); $i++) {
  if ($i % 2 && $s[$i] == 'R' || !($i % 2) && $s[$i] == 'L') {
    echo "No";
    exit;
  }
}
echo "Yes";
?>

Measured memory_bytes: 4604
loop {
    n, k = gets.split.map &:to_i
    break if n == 0
    a = (1..n).map { gets.to_i }
    max = sum = a[0..k-1].inject(:+)
    (1..n-k).map{|i|
        sum = sum - a[i-1] + a[i + k - 1]
        max = sum if sum > max
    }
    p max
}

Measured memory_bytes: 7644
/*#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;


#define int long long
// #define double ld
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}


signed main() {
    srand(time(0));
    accell();
    int n, k;
    cin >> n >> k;
    vector<int>a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    sort(rall(a));
    int res = 0;
    for (int i = k; i < n; ++i) {
        res += a[i];
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 1792
def main():
    #a, b = map(float, input().split())
    a, b = input().split()

    a = int(a)
    b1, b2 = b.split('.')
    b1 = int(b1)
    b2 = int(b2)

    zajedno = a*b1 + (b2*a)//100
    print(int(zajedno))


if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
import java.util.Scanner;

public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
if (a < b) {
System.out.println("a < b");
} else if(a > b) {
System.out.println("a > b");
}else{
    System.out.println("a == b");
}
}
}


Measured memory_bytes: 26204
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.Bool (bool)

main :: IO ()
main = do
  a <- T.head <$> T.getLine :: IO Char
  putStrLn . bool "A" "a" $ 'a' <= a

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


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

#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <math.h>

int main() {

    long long int a, b, c, d, k;
    cin >> a >> b >> c >> d >> k;

    a = a * 60 + b;
    b = c * 60 + d;

    if ( a < b ) {
        cout << b - a - k << endl;
    } else {
        cout << ( 24 * 60 - a + b ) - k << endl;
    }

    return 0;

}


Measured memory_bytes: 3636
from collections import deque
H, W = map(int, input().split())
Field = [list(input()) for i in range(H)]

que = deque()
que.append([0, 0])
Field[0][0] = 0

while que:
    now = que.popleft()
    if now == [H-1, W-1]:
        break

    if now[0]+1 <= H -1:
        if Field[now[0]+1][now[1]] == ".":
            Field[now[0]+1][now[1]] = str(int(Field[now[0]][now[1]])+1)
            que.append([now[0]+1, now[1]])

    if now[0]-1 >= 0:
        if Field[now[0]-1][now[1]] == ".":
            Field[now[0]-1][now[1]] = str(int(Field[now[0]][now[1]])+1)
            que.append([now[0]-1, now[1]])

    if now[1] + 1 <= W -1:
        if Field[now[0]][now[1]+1] == ".":
            Field[now[0]][now[1]+1] = str(int(Field[now[0]][now[1]])+1)
            que.append([now[0], now[1]+1])

    if now[1] -1 >= 0:
        if Field[now[0]][now[1]-1] == ".":
            Field[now[0]][now[1]-1] = str(int(Field[now[0]][now[1]])+1)
            que.append([now[0], now[1]-1])
else:
    print(-1)
    exit()
Z = int(Field[H-1][W-1])

sharp_cnt = 0
for f in Field:
    sharp_cnt += f.count("#")

print(H*W - sharp_cnt - Z - 1)


Measured memory_bytes: 3444