akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
const int INF = 0x3f3f3f3f;
const double pi = acos(-1.0);
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int maxn = 2e5 + 10; 

int main()
{
	//fastIO;
	double r; cin >> r;
	printf("%.3f",2.0 * pi * r);
	return 0;
}

Measured memory_bytes: 3784
#include <iostream>
#include<set>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define fo(i,n) for(int i=1;i<=n;i++)
#define fo1(i,n) for(int i=0;i<n;i++)
#define lli long long int
#define llu unsigned long long int
#define vi vector <int>
#define vii vector <long long int>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define mk make_pair
#define mpp map<int,int>
#define ff first
#define ss second
#define mod 1000000007

using namespace std;

int main()
{
	fast;
	int x,n;
	cin>>x>>n;
	int a[n];
	set <int> s;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		s.insert(a[i]);
	}
	int y,z,cnt,cnt1;
	for(int i=0;i<=100;i++)
	{
		if(s.count(x-i)==0)
		{
			cout<<x-i<<"\n";
			break;
		}
		else if(s.count(x+i)==0)
		{
			cout<<x+i<<"\n";
			break;
		}
	}
}


Measured memory_bytes: 3200
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    string s;
    cin >> s;
    int counter = 0;
    for(int i = 0;i < 3;i++) {
        if(s[i] == '1') {
            counter++;
        }
    }
    cout << counter << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <iomanip>
#include <cassert>
 
using namespace std; 

const double PI=3.14159265358979323846264;

long long gcd(long long x,long long y){
	return y==0?x:gcd(y,x%y);
}

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

	long long x,y;
	cin>>x>>y;


	for(int i=0;i<n-1;i++){
		
		long long t,a;
		cin>>t>>a;

		if(t<x || a<y){	
			long long l=0,r=max(x/t,y/a)+10;
			while(r-l>1){
				long long mid=(l+r)/2LL;
				if(t*mid>=x && a*mid>=y) r=mid;
				else l=mid;
			}
			x=r*t,y=r*a;
		}else{
			x=t,y=a;
		}
		

	}

	cout<<x+y<<endl;
 
	return 0;
 
}

Measured memory_bytes: 256
/*
        |___Arshit Mangukiya___|
        |___DA-IICT____|
        |___201801173____|
*/
        //__WRITE  YOUR  CODE  HERE___//
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;            
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppl;
typedef vector<pll> vpl;
#define ff first
#define ss second
#define pi acos(-1)
#define mr_ad_0501 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define all(a)      a.begin(),a.end()
#define f(i,a,n) for(ll i=a;i<n;i++)
#define MOD 1000000007
#define MAX 200007
#define LM LLONG_MAX
#define sz size()
#define p(x)        cout<< x << " ";
#define pe(x)       cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
const int N=1e5+5;

/*  bool fun(pair<int,int>a , pair<int,int>b)
            {
                if(a.ff == b.ff)    return a.ss < b.ss;
                else            return a.ff < b.ff;
            }*/
           
 /*void bfs(ll x)
 {
    queue<ll> q;
    q.push(x);
    while(!q.empty())
    {
        ll k=q.front();
        q.pop();
        for(auto X:v[k])
        {
            if(!vis[X])
            {
                l[X]=l[k]+1;
                vis[X]=1;
                q.push(X);
            }
        }
    }
 }*/
//ll i,j;
/*void dfs(ll v) {
    visited[v] = true;
    for (auto u : adj[v]) {
        if (!visited[u])
            dfs(u);
    }
}*/

bool prime(ll n)
{
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++)
        if(n%i==0) return false;
    return true;
}

ll getSetBitsFromOneToN(ll N)
{
    ll two = 2, ans = 0;
    ll n = N;
 
    while (n) {
        ans += (N / two) * (two >> 1);
 
        if ((N & (two - 1)) > (two >> 1) - 1)
            ans += (N & (two - 1)) - (two >> 1) + 1;
 
        two <<= 1;
        n >>= 1;
    }
    return ans;
}

ll power(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll mod_pow(ll a,ll b,ll m)
{
    ll res = 1;
    while(b)
    {
        if(b&1)
        {
        res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}
 
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll mod_inverse(ll a)
{
	return mod_pow(a , MOD-2 , MOD);
}


void solve()
{
	ll n;
    cin>>n;
    ll a[n];
    f(i,0,n)cin>>a[i];
    ll ans=0;
    f(i,1,n)
    {
        if(a[i-1]>a[i])
        {
        	ans+=a[i-1]-a[i];
        	a[i]=a[i-1];
        }
    }
    cout<<ans;
}

int32_t main(){
    mr_ad_0501;
    ll t=1;
    //cin >> t;
    while(t--)
    {
        solve();
    }	
}

Measured memory_bytes: 5172
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007

using namespace std;


int main(void){
	int n;
	cin >> n;
	pair<int,int> red[n],blue[n];
	rep(i,n) cin >> red[i].first >> red[i].second;
	rep(i,n) cin >> blue[i].first >> blue[i].second;

	sort(red,red+n);
	sort(blue,blue+n);

	/*cout << "red" << endl;
	rep(i,n) cout << red[i].first << " " << red[i].second << endl;
	cout << "blue" << endl;
	rep(i,n) cout << blue[i].first << " " << blue[i].second << endl;*/
	
	bool flag[n];
	rep(i,n) flag[i] = true;
	int ans = 0;
	
	//cout << "loop start" << endl;
	
	for(int i=0;i<n;i++){
	  int id = -1,val = -1;
	  for(int j=0;j<n;j++){
		if(blue[i].first <= red[j].first) break;
		//cout << i << " " << j << endl;
		//cout << red[j].first << ":" << blue[i].first << " " << red[j].second << ":" << blue[i].second << endl;  
		if(val < red[j].second && flag[j] && red[j].first < blue[i].first && red[j].second < blue[i].second){
		  //cout << "update:" << id << "->" << j << endl;
		  id = j;
		  val = red[j].second;
		}
	  }
	  if(id != -1){
		flag[id] = false;
		ans++;
	  }
	}
 

	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

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

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  string s; cin >> s;
  string t; cin >> t;
  sort(ALL(s));
  sort(RALL(t));
  if (s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){
	int N, d[110], ans=1;

	cin >> N;
	for(int i = 0; i < N; i++) cin >> d[i];

	sort(d, d+N);

	for(int i = 1; i < N; i++) if(d[i-1] != d[i]) ans++;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
program main
  implicit none
  integer :: n, m, i, dx, dy
  character(50) :: a(50), b(50), res
  read (*, *) n, m
  a(:) = ""
  b(:) = ""
  do i = 1, n
    read (*, *) a(i)
  end do
  do i = 1, m
    read (*, *) b(i)
  end do
  res = "No"
  do dy = 0, n - m
    inner: do dx = 0, n - m
      do i = 1, m
        if (a(i + dy)(1 + dx:m + dx) /= b(i)(1:m)) cycle inner
      end do
      res = "Yes"
    end do inner
  end do
  write (*, "(a)") trim(res)
end program main


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int N, D; cin >> N >> D;
  vector<int> X(N), Y(N);
  rep(i, N) cin >> X[i] >> Y[i];

  int ans = 0;
  
  rep(i, N) if(X[i]*X[i]+Y[i]*Y[i] <= D*D) ans++;
  
  cout << ans << endl;

}

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

using namespace std;

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

	vector<int> count(s.size(), 0);

	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A' | s[i] == 'C' | s[i] == 'G' | s[i] == 'T') {
			if (i == 0) {
				count[i]++;
			}
			else {
				count[i] = count[i-1] + 1;
			}
		}
	}
	sort(count.begin(), count.end(), greater<int>());

	cout << *(count.begin()) << endl;

	return 0;
}

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

// n switch: m light
int n, m, k, p[10], cnt, tmp;
vector<int> lights[10];

bool allPowerON(ll bit){
  rep(i,m){
    int switch_count =0;
    rep(j,lights[i].size()){
      if((bit>>(lights[i][j]-1))%2 ==1) switch_count++;
    }
    if(switch_count%2 != p[i]) return false;
  }
  return true;
}

int main(){


  cin >> n >> m;
  rep(i,m){
    cin >> k;
    rep(j,k) {
      cin >> tmp;
      lights[i].push_back(tmp);
    }
  }
  rep(i,m) cin >> p[i];

  cnt = 0;
  for(ll i=0; i < 1<<n; i++){
    if(allPowerON(i)) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
import collections
def main():
    N, M = map(int, input().split())
    graph = collections.defaultdict(dict)
    for _ in range(M):
        L, R, D = map(int, input().split())
        graph[L][R] = D
        graph[R][L] = -D

    visited = set()
    used = set()
    for i in range(1, N+1):
        if i not in visited:
            dist = dict()
            dist[i] = 0
            cur = [i]
            visited.add(i)
            while cur:
                temp = []
                for j in cur:
                    for k in graph[j]:
                        if (j, k) not in used and (k, j) not in used:
                            used.add((j, k))
                            used.add((k, j))
                            if k not in dist:
                                dist[k] = dist[j] + graph[j][k]
                                temp.append(k)
                                visited.add(k)
                            elif k in dist:
                                if dist[k] != dist[j] + graph[j][k]:
                                    return "No"
                cur = temp

    return "Yes"

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 151036
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	ls := make([]int, n)
	for i := range ls {
		fmt.Scan(&ls[i])
	}

	var sum, mx int
	for _, l := range ls {
		sum += l
		mx = max(mx, l)
	}

	if mx < sum-mx {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

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

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x);
    vector<ll> b(y);
    vector<ll> c(z);
    for(int i = 0; i < x; i++)
    {
        cin >> a[i];
    }
    for(int i = 0; i < y; i++)
    {
        cin >> b[i];
    }
    for(int i = 0; i < z; i++)
    {
        cin >> c[i];
    }

    vector<ll> absum(x*y);
    for(int i = 0; i < x; i++)
    {
        for(int j = 0; j < y; j++)
        {
            absum[i*y + j] = a[i] + b[j];
        }
    }
    sort(absum.begin(), absum.end());
    reverse(absum.begin(), absum.end());

    int m = min(int(absum.size()), k);
    vector<ll> abc(m*z);
    for(int i = 0; i < m; i++)
    {
        for(int j = 0; j < z; j++)
        {
            abc[i*z + j] = absum[i] + c[j];
        }
    }
    sort(abc.begin(), abc.end());
    reverse(abc.begin(), abc.end());

    for(int i = 0; i < k; i++)
    {
        cout << abc[i] << endl;
    }
}


Measured memory_bytes: 31616
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(int a, int b){
   return b ? GCD(b, a%b) : a;
}

int LCM(int a, int b){
   return (a * b)/(GCD(a, b));
}

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

int main(){
   int n, x;
   cin >> n >> x;
   vector<int> l(n);
   for(int i = 0; i < n; i++){
      cin >> l[i];
   }

   int cnt = 0;
   vector<int> d(1,0);
   for(int i = 1; i <= n; i++){
      int di = d[i-1] + l[i-1];
      d.push_back(di);
   }



   for(int i = 0; i < d.size(); i++){
      if(d[i] <= x){
         cnt++;
      }
   }

   cout << cnt << endl;
   return 0;
}

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

typedef long long ll;

struct st
{
    ll num;
    ll cnt;
};

bool cmp(struct st &a,struct st &b)
{
    return a.num < b.num;
}


const int N = 1e5+10;

st s[N];

int main()
{
    ll n,k;
    ll a,b;
    cin >> n >> k;

    for (int i = 0; i < n; i ++ )
    {
        cin >> a >> b;
        s[i].num = a;
        s[i].cnt = b;
    }

    sort(s,s+n,cmp);

    ll sum = 0;
    for (int i = 0; i < n; i ++ )
    {
        sum += s[i].cnt;
        if(k <= sum)
        {
            cout << s[i].num << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 1792
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
using namespace std;
#define     loop(n,i,a)     for(ll i=a;i<n;i++)
#define     loopR(n,i,a)    for(ll i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
int KnightI[] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int KnightJ[] = { 1, 2, 2, 1, -1, -2, -2, -1 };
template<typename T>
void max_self(T &a,T b){
    a=max(a,b);
}
template<typename T>
void min_self(T &a,T b){
    a=min(a,b);
}
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=1e3+1,oo=0x3f3f3f3f,MOD=1e9+7;
const double PI = acos(-1);

void solve(){
    int n;
    cin>>n;
    ll arr[n];
    ll sum=0;
    loop(n,i,0)
        cin>>arr[i];
    ll res=0;
    loop(n,i,0){
        res=((res%MOD)+(sum%MOD)*(arr[i]%MOD))%MOD;
        sum+=arr[i];
    }
    cout<<res<<endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}


Measured memory_bytes: 5220
import math
 
def main():
  a, b = list(map(int, input().split()))
  
  for i in range(a, 1099):
    if not math.floor(i * 0.08) == a:
      continue
    if not math.floor(i * 0.1) == b:
      continue
    return i
  
  return -1
  
print(main())

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
typedef long long LL;
LL mod=1e9+7;
LL ppower(LL s)
{
	LL r=1,a=2;
	while(s)
	{
		if(s&1) r=r*a%mod;
			a=a*a%mod;
			s=s>>1;
	}
	return r;
}
int main()
{
	LL a[100005],n,m,resu;
	while(~scanf("%ld",&n))
	{
		memset(a,0,sizeof(a));
		for(LL i=0;i<n;i++)
		{
			scanf("%ld",&m);
			a[m]++;
		}
		LL flag=0;
		if(n&1)
		{
			if(a[0]>1)
				flag=1;
			else 
			{
				for(LL i=1;i<n;i++)
				{
					if(a[i]>2||a[i]==1)
						flag=1;
					if(flag) 
						break;
				}		
			}
			if(!flag)
				resu=ppower(n/2) ;
		}
		else
		{
			if(a[0]>0)
				flag=1;
			else 
			{
				for(LL i=1;i<n;i++)
				{
					if(a[i]>2||a[i]==1)
						flag=1;
					if(flag) 
						break;
				}		
			}
			if(!flag)
				resu=ppower(n/2) ;
		}
		if(flag) printf("0\n");
		else printf("%ld\n",resu);
	}
	return 0;
}

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

int number(char a){
  if (a=='I')
    return 1;
  if (a=='V')
    return 5;
  if (a=='X')
    return 10;
  if (a=='L')
    return 50;
  if (a=='C')
    return 100;
  if (a=='D')
    return 500;
  if (a=='M')
    return 1000;
}

int RomanToNum(string r){
	int num = 0;
	for(int i=0;i<r.size();i++){
		if(i <r.size()-1 && number(r[i])<number(r[i+1])){
			num += number(r[i+1]);
			num -= number(r[i]);
			i++;
		}
		else{
			num += number(r[i]);
		}
	}
	return num;
}

int main(){
  string roman;
  while(cin >> roman){
		cout << RomanToNum(roman) << endl;
  }
  return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int H, W, N;
	vector<llong> col;

	cin >> H >> W >> N;
	col.resize(N+1);
	for(int i = 1; i <= N; i++)
		cin >> col[i];

	vector<vector<llong> > ans(H, vector<llong>(W));
	int h = 0,w = 0;
	for(int i = 1; i <= N; i++){
		for(int j = 0; j < col[i]; j++){
			ans[h][w] = i;
			if((w == W-1 && h&1^1) || (w == 0 && h&1))
				h++;
			else if(h&1)
				w--;
			else
				w++;
		}
	}

	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: 512
N, M = map(int, input().split())
adj = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    adj[A].append(B)
    adj[B].append(A)

def grouping(adj):
    "0-indexed の無向グラフを連結成分に分解する。"
    n = len(adj)
    ret = [-1] * n
    g = 0
    for v in range(n):
        if ret[v] == -1:
            ret[v] = g
            stack = [v]
            while stack:
                v = stack.pop()
                for nv in adj[v]:
                    if ret[nv] == -1:
                        ret[nv] = ret[v]
                        stack.append(nv)
            g += 1
    return ret

print(max(grouping(adj)))

Measured memory_bytes: 81816
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10,p=1e9+7;
int inc(int x,int y){x+=y;return x>=p?x-p:x;}
int dec(int x,int y){x-=y;return x<0?x+p:x;}
int mul(int x,int y){return (ll)x*y%p;}
int n,m,a[N];//dp[i]表示第一个走到*的位置是a[i]的美丽值
struct matrix{
	int a[3][3];
	matrix(){memset(a,0,sizeof a);}
	matrix operator * (matrix x)const{
		matrix ans;
		for (int i=0;i<3;i++)
		for (int j=0;j<3;j++)
		for (int k=0;k<3;k++)
			ans.a[i][j]=inc(ans.a[i][j],mul(a[i][k],x.a[k][j]));
		return ans;
	}
	matrix operator + (matrix x)const{
		matrix ans;
		for (int i=0;i<3;i++)
		for (int j=0;j<3;j++)
			ans.a[i][j]=inc(a[i][j],x.a[i][j]);
		return ans;
	}
	matrix operator - (matrix x)const{
		matrix ans;
		for (int i=0;i<3;i++)
		for (int j=0;j<3;j++)
			ans.a[i][j]=dec(a[i][j],x.a[i][j]);
		return ans;
	}
	matrix operator * (int x){
		matrix ans;
		for (int i=0;i<3;i++)
		for (int j=0;j<3;j++)
			ans.a[i][j]=mul(a[i][j],x);
		return ans;
	}
	void print(){
		for (int i=0;i<3;i++,puts(""))
		for (int j=0;j<3;j++) printf("%d ",a[i][j]);
		puts("");
	}
}I,x,ix,beg,sum[N];
matrix power(matrix x,int y){
	matrix ans=I;
	for (;y;y>>=1,x=x*x)
		if (y&1) ans=ans*x;
	return ans;
}
int calc(int n){
	matrix now=beg*power(x,n);
	return now.a[0][2];
}
int dp[N];
int main()
{
	I.a[0][0]=I.a[1][1]=I.a[2][2]=1;
	x.a[0][0]=4;x.a[0][1]=1;
	x.a[1][0]=p-2;x.a[1][2]=1;
	x.a[2][0]=1;
	ix.a[0][2]=1;
	ix.a[1][0]=1;ix.a[1][2]=p-4;
	ix.a[2][1]=1;ix.a[2][2]=2;
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++) scanf("%d",&a[i]);
	a[++m]=n;
	beg.a[0][0]=5;beg.a[0][1]=1;beg.a[0][2]=0;
	dp[0]=1;
	for (int i=1;i<=m;i++){
		dp[i]=calc(a[i]);
		matrix now=sum[i-1]*power(x,a[i]);
		dp[i]=dec(dp[i],now.a[0][2]);
		sum[i]=sum[i-1]+beg*dp[i]*power(ix,a[i]);
	}
	printf("%d\n",dp[m]);
	return 0;
}

Measured memory_bytes: 4608
from collections import deque
n=int(input())
edge=[[] for i in range(n+1)]
ab=[]
ans=dict()
for i in range(n-1):
  a,b=map(int,input().split())
  ab.append([a,b])
  ans[(a,b)]=0
  edge[a].append(b)
  edge[b].append(a)
hantei=0  
for i in edge:
  if hantei<len(i):
    hantei=len(i)
iro=hantei
print(iro)
color_list=[0]*(n+1)
def bfs(x,ans):
  qu=deque([])
  qu.append(1)
  count=1
  while qu:
    now=qu.popleft()
    if now!=1:
      pre=qu.popleft()
    else:
      pre=0
    count=1
    for i in edge[now]:
      if i!=pre:
        qu.append(i)
        qu.append(now)
        if now!=1 and ans[(pre,now)]==count:
          count+=1
        ans[(now,i)]=count
        count+=1
  return ans
bfs(1,ans)
for i,j in ab:
  print(ans[(i,j)])
  

Measured memory_bytes: 46256
X=int(input())

import math
import bisect

candidate = [i for i in range(2, 100004)] 
prime = []
limit = math.sqrt(100004) + 1 

while True:
    p = min(candidate)
    if limit <= p:
        prime.extend(candidate)
        break
    prime.append(p)
    candidate = [i for i in candidate if i % p != 0]

a=bisect.bisect_left(prime,X)
print(prime[a])

Measured memory_bytes: 7448
#include <bits/stdc++.h> 
using namespace std; 
#define for_(i, s, e) for (int i = s; i < e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl "\n"


int main() {
	#ifndef ONLINE_JUDGE
	//freopen("test.in", "r", stdin);
	#endif
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	ll a, b, c, k; cin >> a >> b >> c >> k;
	bool valid = false;
	for_(i, 0, k+1) {
		ll aa = a;
		for_(_, 0, i) aa *= 2;
		for_(j, 0, k-i+1) {
			ll bb = b;
			for_(_, 0, j) bb *= 2;
			for_(l, 0, k-i-j+1) {
				ll cc = c;
				for_(_, 0, l) cc *= 2;
				if (bb > aa and cc > bb) {
					valid = true;
				}
			}
		}
	}
	
	cout << (valid ? "Yes" : "No") << endl;

	return 0;
}



Measured memory_bytes: 3596
#include <stdio.h>
int main(void){
    int a, b, d, r;
    double f;
    scanf("%d %d", &a, &b);
    d=a/b;
    r=a%b;
    f=1.00000*a/b;
    printf("%d %d %f\n",d,r,f);
    return 0;
}



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

int isprime[104730] = { 0 };

int main() {

  for(int i=4; i<104730; i+=2)
    isprime[i] = 1;

  isprime[1] = 1;
  for(int i=3; i*i < 104730; i++)
    if(isprime[i] == 0)
      for(int j=2; i*j < 104730; j++)
	isprime[i*j] = 1;

  int n;
  while(1) {
    cin>>n;
    if(!n) break;
    int sum=0;
    for(int i=2;n>0;i++){
      if(isprime[i] == 0) {
	sum += i;
	n--;
      }
    }
    cout<<sum<<endl;
  }
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(i, v) for(auto i =  v.begin(); i !=  v.end(); ++i)
#define RFOR(i, v) for(auto i = v.rbegin(); i != v.rend(); ++i)

template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T> ostream & operator<<(ostream & os, const vector<T> & v) {
	os << "[";
	FOR(it, v) {
		if(it != v.begin()) { os << ", "; }
		os << *it;
	}
	os << "]";
	return os;
}
template<typename F, typename S> ostream & operator<<(ostream & os, const pair<F, S> & p) {
	os << "<" << p.FI << ", " << p.SE << ">";
	return os;
}

// ---- ----

LL n, a[100000], b[100000];
LL sum;

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i] >> b[i]; }
	
	dec(i, n) {
		sum += (b[i] - (a[i] + sum) % b[i]) % b[i];
	}
	
	cout << sum << endl;
	
	return 0;
}


Measured memory_bytes: 1792
#include <vector>
#include <utility>
#include <algorithm>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

bool sortbyfirst(pair<int, int> a, pair<int, int> b)
{
    return (a.first < b.first);
}

// the first element is the number of people present when such student entered the room
// the second element is the serial of the student

int main()
{
    vector<pair<int, int>> s;
    int n, tmp;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &tmp);
        s.push_back(make_pair(tmp, i+1));
    }
    sort(s.begin(), s.end(), sortbyfirst);
    for (auto is : s) printf("%d ", is.second);
    return 0;
}

Measured memory_bytes: 1780
const MAX_NTAB: usize = 3010;

fn memo(
    pos: usize,
    total: usize,
    dp: &mut Vec<Vec<Option<usize>>>,
    ab: &Vec<(usize, usize)>,
    n: usize,
    t: usize,
) -> usize {
    if pos >= n || total >= t {
        return 0;
    }
    if let Some(value) = dp[pos][total] {
        return value;
    }
    let mut result = 0;
    //eat
    let (time, taste) = ab[pos];
    result = std::cmp::max(result, memo(pos + 1, total + time, dp, ab, n, t) + taste);

    //not eat
    result = std::cmp::max(result, memo(pos + 1, total, dp, ab, n, t));
    dp[pos][total] = Some(result);
    result
}
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let t: usize = sc.read();
    let mut ab: Vec<(usize, usize)> = (0..n)
        .map(|_| {
            let a: usize = sc.read();
            let b: usize = sc.read();
            (a, b)
        })
        .collect();
    ab.sort();
    let mut dp: Vec<Vec<Option<usize>>> = vec![vec![None; MAX_NTAB]; MAX_NTAB];
    let result = memo(0, 0, &mut dp, &ab, n, t);
    println!("{}", result);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

int main(){
	int m[20][20]={},x,y,s,X,Y,max=0,ans=0;
	char c;
	while(cin>>x){
		cin>>c>>y>>c>>s;
		X=x+2; Y=y+2;
		m[X][Y]++; m[X+1][Y]++; m[X-1][Y]++;
		m[X][Y-1]++; m[X][Y+1]++;
		if(s==2||s==3){
			m[X-1][Y-1]++; m[X-1][Y+1]++;
			m[X+1][Y-1]++; m[X+1][Y+1]++;
		}
		if(s==3){
			m[X][Y-2]++; m[X][Y+2]++;
			m[X-2][Y]++; m[X+2][Y]++;
		}
	}
	rep(i,2,12){
		rep(j,2,12){
			if(m[i][j]==0) ans++;
			if(m[i][j]>max) max=m[i][j];
		}
	}
	cout<<ans<<endl<<max<<endl;
}

Measured memory_bytes: 1160
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    x, n = map(int, readline().split())
    p = list(map(int, readline().split()))
    check = float('inf')
    ans = 0
    for i in range(102):
        if i not in p:
            if check > abs(x - i):
                ans = i
                check = abs(x - i)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
/***************************************** 
****       Solution by SlavicG        ****
*****************************************/
 
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm> 
#include <set>
#include <utility>
#include <queue>
#include <map>
#include <assert.h>
#include <stack>
using namespace std;
#define ll long long
#define forn(i,n) for(int i=0;i<n;++i)
#define MX 10000000001
#define pow2(a) ((a)*(a))
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define endl "\n"
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 int longestIncreasingSubsequenceLenghtDP(int a[],int n){
    int dp[n],ans=0;
    for(int k = 0;k<n;k++){
        dp[k] = 1;
        for(int i = 0;i<k;i++){
            if(a[i] <= a[k]){
                dp[k] = max(dp[k],dp[i] + 1);
                ans = max(dp[k],ans);
            }
        }
    }
    return ans;
 }
int result[1000] = {0};
int factDP(int n) 
{
   if (n >= 0) {
      result[0] = 1;
      for (int i = 1; i <= n; ++i) {
         result[i] = i * result[i - 1];
      }
      return result[n];
   }
}
bool checkPrime(int n)
{
    if(n<2) return false;
    for(int x = 2;x*x <=n;x++)
    {
        if(n%x == 0)return false;
    }
    return true;
}
vector<int> primeFactors(int n){
    vector<int> f;
    for(int x = 2;x*x<=n;x++){
        while(n%x==0){
            f.push_back(x);
            n/=x;
        }
    }
    if(n>1)f.push_back(n);
    return f;
}
int binary_Search_Classic(int n, int arr[],int target){
	int l,r,mid;
	l=0;
	r=n-1;
	while(l<=r){
		mid= l+(r-l)/2;
		if(arr[mid] == target){
			return mid;
		}
		if(arr[mid] < target){
			l=mid+1;
		}else
		{
			r=mid-1;
		}
	}
	return -1;
}
int binary_Search_First_Greater(int n, int arr[],int target){
	int l,r,ans,mid;
	l = 0;
	r = n-1;
	ans=-1;
	while(l<=r){
		mid = l + (r-l)/2;
		if(arr[mid] > target){
			ans=mid;
			r=mid-1;
		}else{
			l = mid+1;
		}
	}
	return ans;
}
int countDistinctCharsString(string s) {
    unordered_map<char, int> m; 
    for (int i = 0; i < s.length(); i++) { 
        m[s[i]]++; 
    }
    return m.size(); 
} 
int main()
{
	int a,b;
	cin >> a >> b;
	if(a <= 8 && b <= 8)
	{
		cout << "Yay!" << endl;
	}else{
		cout << ":(" << endl;
	}
	return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long int ll;
const int MOD=1000000007;

struct UnionFind{
    vector<int> d;//d[i]:iの親の番号。根なら木のサイズ*(-1)
    UnionFind(int n=0):d(n,-1){}//全ての木のサイズが１と初期.n点
    
    int find(int x){//根を返す
    if(d[x] < 0) return x;//xが根の時はxを返す
    return d[x] = find(d[x]);
    }

    bool unite(int x,int y){//xとyの木をつなげたらtrue.大きい方に小さい方をつなげる.
    x = find(x);y = find(y);//根を求める
    if(x==y) return false;//同じ木に属していたらつなげる必要なし
    if(d[x]>d[y]) swap(x,y);//yの方がサイズが大きい時は交換する
    d[x] += d[y];//サイズの更新
    d[y] = x;//根の更新
    return true;
    }

    bool same(int x,int y){return find(x)==find(y);}//xとyが同じ木にあるか

    int size(int x){return -d[find(x)];}//xの木のサイズを返す
};
int main(){
    int n,m,k;cin>>n>>m>>k;
    vector<vector<int>> block(n),follow(n); 
    UnionFind fr(n);

    rep(i,m){
        int a,b;cin>>a>>b;a--;b--;
        fr.unite(a,b);
        follow[a].push_back(b);
        follow[b].push_back(a);
    }
    rep(i,k){
        int c,d;cin>>c>>d;c--;d--;
        block[c].push_back(d);
        block[d].push_back(c);
    }
    int ans[n];
   //rep(i,n){rep(j,follow[i].size()){cout<<block[i][j];}cout<<endl;}
    rep(i,n){
        ans[i] = fr.size(i)-follow[i].size()-1;
    }
    //rep(i,n)cout<<ans[i]<<" ";
    rep(i,n){
        rep(j,block[i].size()){
            if(fr.same(block[i][j],i))ans[i]--;
        }
    }
    rep(i,n)cout<<ans[i]<<" ";
    return 0;
}

Measured memory_bytes: 12536
n=int(input())
ans=[]
for i in range(1,n):
  for j in range(i+1,n+1):
    ans.append([i,j])
if(n%2==1):
  m=(n-1)**2//2
  for i in range(1,n//2+1):
    ans.remove([i,n-i])
else:
  m=n*(n-2)//2
  for i in range(1,n//2+1):
    ans.remove([i,n+1-i])
print(m)
for i in ans:
  print(str(i[0])+" "+str(i[1]))


Measured memory_bytes: 3828
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<random>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

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

	int MOD=998244353;
	int n,k;
	cin>>n>>k;
	vi l(k),r(k);
	rep(i,k)cin>>l[i]>>r[i];

	vi dp(n+2),dp2(n+2);
	dp[1]=1;dp2[1]=1;
	rep(i,n){
		rep(j,k){
			(dp[i+2]+=MOD+dp2[max(0ll,i+2-l[j])]-dp2[max(0ll,i+1-r[j])])%=MOD;
		}
		(dp2[i+2]+=dp2[i+1]+dp[i+2])%=MOD;
	}
	cout<<dp[n]<<endl;
}


Measured memory_bytes: 6328
#include<stdio.h>
int main () {
	int sheet[101][101] = {0};
	int width , height;
	int i , s;
	scanf("%d %d" , &height , &width);
	for(i = 0; i < height; i++) {
		for(s = 0; s <width; s++) {
			scanf("%d" , &sheet[i][s]);
			sheet[i][width] += sheet[i][s];
			sheet[height][s] += sheet[i][s];
			sheet[height][width] += sheet[i][s];
		}
	}
	for(i = 0; i <= height; i++) {
		for(s = 0; s <= width; s++) {
			printf("%d" , sheet[i][s]);
			if (s < width) printf(" ");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;

int h, w, ans = 0;
queue<pair<int, int>> q;
vector<vector<int>> moves = {
  { 1, 0 },
  { -1, 0 },
  { 0, 1 },
  { 0, -1 }
};

int main() {
  cin >> h >> w;
  vector<vector<char>> a(h, vector<char>(w));
  vector<vector<int>> memo(h, vector<int>(w, -1));
  REP(i, h) REP(j, w) {
    cin >> a[i][j];
    if (a[i][j] == '#') {
      q.push(make_pair(i, j));
      memo[i][j] = 0;
    }
  }
  while(!q.empty()) {
    auto front = q.front();
    q.pop();
    int x = front.first, y = front.second;
    for (auto move: moves) {
      int nx = x + move[0], ny = y + move[1];
      if (nx < 0 || ny < 0 || nx >= h || ny >= w) continue;
      if (memo[nx][ny] >= 0) continue;
      memo[nx][ny] = memo[x][y] + 1;
      q.push(make_pair(nx, ny));
    }
  }
  REP(i, h) REP(j, w) ans = max(ans, memo[i][j]);
  cout << ans << "\n";
}

Measured memory_bytes: 13328
s=input()
if s[0] == s[1] == s[2] == 'R':
  print(3)
elif s[0] == s[1] =='R' or s[1] ==s[2] =='R':
  print(2)
elif s[0] =='R' or s[1] =='R' or s[2] =='R':
  print(1)
else:
  print(0)

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

int main() {
  
  int a, b;
  cin >> a >> b;
  
  int c = a+b;
  int d = a-b;
  int e = a*b;
  
  int ans = max(c, max(d, e));
  
  cout << ans << endl;
  
  
}


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

using namespace std;

#define INF 1000000007
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
signed main()
{
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> AB(N);
    rep(i, N)
    {
        int a, b;
        cin >> a >> b;
        AB[i] = make_pair(a, b);
    }
    sort(AB.begin(), AB.end());
    int ans = 0;
    rep(i, N)
    {
        if (M > AB[i].second)
        {
            ans += AB[i].second * AB[i].first;
            M -= AB[i].second;
        }
        else
        {
            ans += AB[i].first* M;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(j, m) for (int j = 0; j < (int)(m); j++)
#define rep2(i, l, n) for (int i = l; i < (int)(n); i++)


int main() {
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    ll d = max(a,max(b,c));
    rep(i,k) {
        d *= 2;
    }
    cout << a + b + c + d - max(a,max(b,c)) << endl;
}



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

int main()
{
    int n;

    cin >> n;

    long long ans = 1;

    for(int i = 1 ; i<=n ; i++)
    {
        long long x;

        cin >> x;

        long long gcd = __gcd(x , ans);

        ans = ans/gcd*x;


    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
S = input()
T = input()

# 文字の変換を行う（0回以上文字の入れ替えを行う）
converter = dict()

for s, t in zip(S, T):
    # 出力とTの文字が一致しているか確認
    if converter.get(s) is not None:
        if converter[s] != t:
            print('No')
            break
    else:
        converter[s] = t

# 入力と出力の整合性を確認
# 入力が同じなら出力も同じなのと同様に、出力が同じなら入力も同じになる
# すなわち、出力が重複していることはありえない
else:  
    if len(converter.values()) != len(set(converter.values())):
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 3760
//s配列に格納した単語を、辞書順にソートする
//  sort(s.begin(), s.end());
//  string t = "keyence";//で文字列入力ができる
//s.empty() //emptyなら1を出力 入っていれば0を出力
/*//ABC018-B 部分的にreverseをかける解法
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  rep(i,n) cin>>a.at(i)>>b.at(i);
  rep(i,n)a.at(i)--;
  rep(i,n)b.at(i)--;
  string t;
  rep(i,n){
    t = s;
    for(int k=0;k<=b.at(i)-a.at(i);k++){
      t.at(a.at(i)+k) = s.at(b.at(i)-k);
    }
    s = t;
  }
  cout << s << endl;
}
*///ABC018-B
//  string s;
//  cin >> s;
//  cout << s.at(0) <<endl;
//  cout << s.at(0)-'0' <<endl;
//  Aが16？
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int kan_hyaku(int n){
  int kurai = 0;
  for(int i=0;i<3;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int kan_ju(int n){
  int kurai = 0;
  for(int i=0;i<2;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int kan_ichi(int n){
  int kurai = 0;
  for(int i=0;i<1;i++){
    kurai = n%10;
    n /=10;
  }
  return kurai;
}
int main() {
  ll a,b,n;
  cin >> a >> b >> n;
  if(b-1 <= n){
    cout << a * (b-1) / b;
  }
  else{
   cout << a * n / b; 
  }
/*
for(int x=1;x<=n;x++){
    ll floor_first  = a * x / b;
    ll floor_second = x / b;
    cout << floor_first - a * floor_second << endl;
  }

*/
  
}

Measured memory_bytes: 3636
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();
		int C = sc.nextInt();

		int sum = A + B + C;

		int max = Math.max(A, B);
		max = Math.max(max, C);

		int kouho1 = max * 3;
		int kouho2 = (max + 1) * 3;

		int ans = 0;
		if (sum % 2 == kouho1 % 2) {
			ans = (kouho1 - sum) / 2;
		} else {
			ans = (kouho2 - sum) / 2;
		}

		System.out.println(ans);

	}
}


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


int main()	
{
	ll n,w,a,b,c[4],s[4];
	ll ans=-1;
	vector<ll>v[4];
	cin>>n>>w;
	for(ll i=0;i<n;i++)
	{
		cin>>a>>b;
		if(i)v[a-c[0]].push_back(b);
		else
		{
			v[0].push_back(b);
			c[0]=a,c[1]=a+1,c[2]=a+2,c[3]=a+3;
		}
	}
	for(ll i=0;i<4;i++)
	{
		if(v[i].size())sort(v[i].begin(),v[i].end());
		s[i]=v[i].size();
	}
	for(ll i=0;i<=n;i++)
	{
		for(ll j=0;j<=n-i;j++)
		{
			for(ll k=0;k<=n-i-j;k++)
			{
				for(ll r=0;r<=n-i-j-k;r++)
				{
					ll sum=0;
					for(ll l=0;l<max(max(i,j),max(k,r));l++)
					{
						if(l<min(i,s[0])&&v[0].size())sum+=v[0][v[0].size()-1-l];
						if(l<min(j,s[1])&&v[1].size())sum+=v[1][v[1].size()-1-l];
						if(l<min(k,s[2])&&v[2].size())sum+=v[2][v[2].size()-1-l];
						if(l<min(r,s[3])&&v[3].size())sum+=v[3][v[3].size()-1-l];
					}
					if(i*c[0]+j*c[1]+k*c[2]+r*c[3]<=w)ans=max(ans,sum);
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
    int n,b,f,r,v;
    cin>>n;
    int a1[3][10],a2[3][10],a3[3][10],a4[3][10];
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 10; ++j) {
            a1[i][j]=0;a2[i][j]=0;a3[i][j]=0;a4[i][j]=0;
        }
    }
    for (int k = 0; k < n; ++k) {
        cin>>b>>f>>r>>v;
        switch (b){
            case 1:
                a1[f-1][r-1] += v;
                break;
            case 2:
                a2[f-1][r-1] += v;
                break;
            case 3:
                a3[f-1][r-1] += v;
                break;
            case 4:
                a4[f-1][r-1] += v;
                break;
            default:break;
        }
    }
    for (int l = 0; l < 3; ++l) {
        for (int i = 0; i < 10; ++i) {
            cout<<" "<<a1[l][i];
        }
        cout<<endl;
    }
    for (int m = 0; m < 20; ++m) {
        cout<<"#";
    }
    cout<<endl;
    for (int l = 0; l < 3; ++l) {
        for (int i = 0; i < 10; ++i) {
            cout<<" "<<a2[l][i];
        }
        cout<<endl;
    }
    for (int m = 0; m < 20; ++m) {
        cout<<"#";
    }
    cout<<endl;
    for (int l = 0; l < 3; ++l) {
        for (int i = 0; i < 10; ++i) {
            cout<<" "<<a3[l][i];
        }
        cout<<endl;
    }
    for (int m = 0; m < 20; ++m) {
        cout<<"#";
    }
    cout<<endl;
    for (int l = 0; l < 3; ++l) {
        for (int i = 0; i < 10; ++i) {
            cout<<" "<<a4[l][i];
        }
        cout<<endl;
    }

    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

int main(){
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	vector<pair<ll, ll>> sum(n+1, pair<ll, ll>(0, 0));
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
		pair<ll, ll> p = make_pair(a[i]+b[i], i);
		sum[i] = p;
	}
	sort(sum.rbegin(), sum.rend());
	ll ans = 0;
	for(int i = 0; i < n; i+=2){
		ans += a[sum[i].second];
		if(sum[i+1].first==0 && sum[i+1].second==0) continue;
		ans -= b[sum[i+1].second];
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560