akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

int main(){
	string s,t,u;
   	int l,r;
   	cin>>s>>t;
   	cin>>l>>r;
   
   	cin>>u;
   	if(u==s){
   		l--;
   	}else{
   		r--;
   	}
   	cout<<l<<" "<<r;
    return 0;
}

Measured memory_bytes: 256
s = gets().split(" ");
for h in 0..2
 s[h] = s[h].to_i;
end

s_a = s.sort;

for h in 0..2
 s_a[h] = s_a[h].to_i;
end

eo = Array.new(2,0);
count = 0;

for i in 0..2
	if s_a[i]%2==0
		eo[0]+=1;
	elsif s_a[i]%2==1
		eo[1]+=1;
	end
end

big = 0;
small = 0;
ant = 0;

if eo[0] ==3
	count += (s_a[2]-s_a[1])/2;
	count += (s_a[2]-s_a[0])/2;
elsif eo[0]==2
	for j in 0..2
		if s_a[j] %2 == 0
			s_a[j] +=1;
		end
	end
	count = (s_a[2]-s_a[1])/2 + (s_a[2]-s_a[0])/2 +1;
elsif eo[0]==1
	for j in 0..2
		if s_a[j]%2 == 1
			s_a[j] += 1;
		end
	end
	count = (s_a[2]-s_a[1])/2 + (s_a[2]-s_a[0])/2 +1;
elsif eo[0]==0
	count += (s_a[2]-s_a[1])/2;
	count += (s_a[2]-s_a[0])/2;
end

puts(count);

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

int main(){

    while(true){
        double d,e;

        double ans = 100000000000.0;

        cin >> d >> e;

        if(d == 0.0 && e == 0.0){
            break;
        }

        int loop = static_cast<int>(d);

        for(int i=0; i<loop; i++){
            int y = loop - i;
            int x = i;

            ans = min(ans, abs(sqrt(x*x + y*y)-e));

        }

        cout << ans << endl;
    }

}


Measured memory_bytes: 3292
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
const int p = 2147483647;
int n, q, cm, x, y;
int a[123456];//0,1,2,...
int b[12345]; //0~9,10~19,20~29,...
int c[1234];  //0~99,100~199,100~299,...
int d[123];   //0~999,1000~1999,2000~2999...
signed main() {
	cin >> n >> q;
	for (int w = 0; w < q; w++) {
		cin >> cm >> x >> y;
		if (!cm) {
			a[x] += y;
			x /= 10;
			b[x] += y;
			x /= 10;
			c[x] += y;
			x /= 10;
			d[x] += y;
		}
		else {
			int r = 0;
			while (x <= y) {
				if (x % 10 != 0 || y - x < 10) {
					r += a[x];
					x++;
				}
				else if (x % 100 != 0 || y - x < 100) {
					r += b[x / 10];
					x += 10;
				}
				else if (x % 1000 != 0 || y - x < 1000) {
					r += c[x / 100];
					x += 100;
				}
				else {
					r += d[x / 1000];
					x += 1000;
				}
			}
			cout << r << endl;
		}
	}
}


Measured memory_bytes: 3920
S = list(input())
N = len(S)
count=0
count_max=0

for i in range(N):
    if S[i] == 'A' or S[i]=='T' or S[i]=='C' or S[i]=='G':
        count = count + 1
        count_max=max(count_max,count)
    else :
        count = 0
        continue

print(count_max)

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

void show(int block[3][10]) {
	int i, j;
	for (i = 0; i < 3; i++) {
		for (j = 0; j < 10; j++) {
			cout << " " << block[i][j];
		}
		cout << endl;
	}
}

int main() {
	int n, i;
	int b, f, r, v;
	int one[3][10] = {{0}, {0}};
	int two[3][10] = {{0}, {0}};
	int three[3][10] = {{0}, {0}};
	int four[3][10] = {{0}, {0}};
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> b >> f >> r >> v;
		switch (b) {
			case 1:
				one[f-1][r-1] += v;
				break;
			case 2:
				two[f-1][r-1] += v;
				break;
			case 3:
				three[f-1][r-1] += v;
				break;
			case 4:
				four[f-1][r-1] += v;
				break;
			default:
				break;
		}
	}
	show(one);
	cout << "####################" << endl;
	show(two);
	cout << "####################" << endl;
	show(three);
	cout << "####################" << endl;
	show(four);
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;

vector<pair<int64, int>> factor(int64 rhs){
    vector<pair<int64, int>> ret;
    
    int64 i=2;
    while(rhs!=1){
        int num = 0;
        while(rhs%i==0){
            rhs/=i;
            ++num;
        }
        if(num!=0){ ret.push_back({i, num}); }
        ++i;
    }
    return ret;
}

int numDivs(int64 N){
    vector<pair<int64, int>> vPN = factor(N);
    
    uint divs=1;
    for(uint i=0; i<vPN.size(); ++i){
        divs *= (vPN[i].second + 1);
    }
    return divs;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    uint N; cin >> N;
    uint num=0;
    for(uint i=1; i<=N; i+=2){
        if(numDivs(i)==8){ ++num; }
    }
    cout << num << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
// #include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD1 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int N,C;
  cin>>N>>C;
  vector<vector<int> >  data (C,vector<int>(C,0));
  for (int i = 0; i < C; i++)
  {
    for (int j = 0; j < C; j++)
    {
       cin>>data[i][j];
    }
  }
  vector<vector<int> > vec (3);
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N; j++)
    {
      int X;cin>>X;
      int M = (i+j)+2;
      vec[M%3].push_back(X);
    }
    
  }
  int res = INF;
  vector<vector<int> > cost (3,vector<int>(C,0));
  for (int i = 0; i < 3; i++)
  {
    for (int c = 0; c < C; c++)
    {
      int s = 0;
      for (auto &&x : vec[i])
      {
        s += data[x-1][c];
      }
      cost[i][c] = s;
    }
    
  }
  


  for (int c1 = 0; c1 < C; c1++)
  {
    for (int c2  = 0; c2  < C; c2 ++)
    {
      for (int c3 = 0; c3 < C; c3++)
      {
        if(c1 == c2 || c2 == c3 || c3 == c1)continue;
        int cost_s = 0;
        cost_s = cost[0][c1] + cost[1][c2] + cost[2][c3];
        chmin(res,cost_s);       

      }
      
    }
    
  }
  cout<<res<<endl;
 
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 5248
//by tzupengwang™
#include<algorithm>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;

int n , m ;
char s[ 50 ][ 50 ] ;

void init() {
  scanf( "%d%d" , &n , &m ) ;
  for ( int i = 0 ; i < n ; i ++ ) scanf( "%s" , s[ i ] ) ;
}
int cnt[ 25 ] ;

void process() {
  for ( int i = 0 ; i < n ; i ++ ) {
    for ( int j = 0 ; j < m ; j ++ ) {
      if ( s[ i ][ j ] == '#' ) {
        cnt[ i + j ] += 1 ;
        if ( i + j != 0 ) {
          if ( ( j == 0 || s[ i ][ j - 1 ] != '#' ) && ( i == 0 || s[ i - 1 ][ j ] != '#' ) ) {
            puts( "Impossible" ) ;
            return ;
          }
        }
      }
    }
  }
  for ( int i = 0 ; i <= n + m - 2 ; i ++ ) {
    if ( cnt[ i ] != 1 ) {
      puts( "Impossible" ) ;
      return ;
    }
  }
  puts( "Possible" ) ;
}

int main() {
  init() ;
  process() ;
  return 0 ;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
// D - String Equivalence

using namespace std;

#define fi first
#define se second

vector<pair<string,int>> ans1,ans2;

int main() {
    int N,i,j;
    string s;

    scanf("%d",&N);

    ans1.push_back({"a",0});
    for (i = 1;i < N;i++) {
        for (pair<string,int> a : ans1) {
            s = a.fi;
            for (j = 0;j <= a.se;j++) {
                s.push_back(j + 'a');
                ans2.push_back({s,a.se});
                s.pop_back();
            }

            s.push_back(a.se + 'a' + 1);
            ans2.push_back({s,a.se + 1});
            s.pop_back();
        }

        swap(ans1,ans2);
        ans2.clear();
    }

    for (pair<string,int> a : ans1)
        cout << a.fi << "\n";

    return 0;
}


Measured memory_bytes: 11884
#!/usr/bin/env ruby
sx, sy, tx, ty = STDIN.readline.strip.split(' ').map(&:to_i)
d = ['U', 'D', 'R', 'L']
def reverse_d(path)
  path.map do |p|
    p == 'U' ? 'D' : p == 'D' ? 'U' : p == 'R' ? 'L' : 'R'
  end
end
path_1 = ['U'] * (ty - sy) + ['R'] * (tx - sx)
# puts "path_1:#{path_1.join()}"
path_1 +=  reverse_d(path_1)
# puts "path_1:#{path_1.join()}"
path_2 = ['L'] + ['U'] * (ty - sy + 1)  + ['R'] * (tx - sx + 1) + ['D']
path_2 +=  reverse_d(path_2)
# puts "path_2:#{path_2.join()}"
puts "#{(path_1+path_2).join()}"


Measured memory_bytes: 2556
#include<bits/stdc++.h>
using namespace std;
inline int gcd(int x, int y) {
	return y == 0 ? x : gcd(y, x % y);
}
int main(){
	int n;
	cin >> n;
	cout << 360 / gcd(n, 360) << endl;
  return 0;
}

Measured memory_bytes: 3632
# encoding: utf-8
import math

N, X = map(int, input().split())
x = sorted(list(map(int, input().split())) + [X])

def gcf2(a, b):
    if b == 0: return a
    else: return gcf2(b, (a % b))

# Greatest common factor
# print(x)
GCF = x[1] - x[0]
x_min = x[0]
for i, xi in enumerate(x):
    if i == 0: continue
    GCF = gcf2(GCF, (xi - x_min))

print(GCF)

Measured memory_bytes: 15020
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <array>

using namespace std;

int main(){
  int p;
  cin>>p;
  int ans=0;
  while(p>=10000){
    ans+=10000;
    p-=10000;
  }
  while(p>=5000){
    ans+=5000;
    p-=5000;
  }
  while(p>=1000){
    ans+=1000;
    p-=1000;
  }
  while(p>=500){
    ans+=500;
    p-=500;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <sstream>
#include <stdlib.h>

using namespace std;

int main(void){
	
	string str, ans;
	getline(cin, str);
	ans = str;
	for(int i = 0; i < str.length(); i++ ) {
		if( str[i] < 'a' || str[i] > 'z' ) continue;
		ans[i] = str[i] - 'a' + 'A';
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
//#define vvector(name,typ,m,n)vector<vector<typ> > name(m,vector<typ> (n))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
ll ceil(ll a,ll b){
    return ((a+b-1)/b);
}
const int INF = 2000000000;
const ll INF64 = 9223372036854775807ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;
//mapは、if関数などで覗いただけで構成されるので注意しよう！
//std::vector<vector<int>> g;


//std::vector<std::set<int>> g;
int f(string s){
    int h,m,ss;
    h=stoi(s.substr(0,2));
    m=stoi(s.substr(3,2));
    ss=stoi(s.substr(6,2));
    return h*3600+m*60+ss;
}
int main(){
    ffor{
        int n;
    std::cin >> n;
    if(n==0)return 0;
    std::vector<int> c(25*3600+50);
    int m=25*3600+50;
    rep(i,n){
        string a,b;
        std::cin >> a>>b;
      //  std::cout << f(a) << std::endl;
        //std::cout << f(b) << std::endl;
        c[f(a)]++;
        c[f(b)]--;
    }
    int ans=c[0];
    rrep(i,1,m){
        c[i]+=c[i-1];
        chmax(ans,c[i]);
    }
    std::cout << ans << std::endl;
    }
    
}


Measured memory_bytes: 3404
N = int(input())
A_list = list(map(int,input().split()))
A_list.sort()

if A_list[0]==0:
    answer = 0
else:      
    answer = 1
    for a in A_list:
        answer *= a
        if len(str(answer-1)) > 18:
            answer = -1
            break
print(answer)

Measured memory_bytes: 21604
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <stack>
#include <cstdlib>

using namespace std;

int main(){
    string s;
    stack <int> a;
    while(cin >> s){
        if(s=="+"||s=="-"||s=="*"){
            int b,c;
            b =a.top();
            a.pop();
            c =a.top();
            a.pop();
            if(s=="+") a.push(b+c);
            if(s=="-") a.push(c-b);
            if(s=="*") a.push(b*c);
        }
        else {
            a.push(atoi(s.c_str()));
        }
    
    }
    cout << a.top() << endl;
    return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef vector<int> vi;
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define SZ(x) (int((x).size()))
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
#define repe(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	string s;
	cin >> s;
	for (auto & ch : s) {
		if (ch == '?') ch = 'D';
	}
	cout << s << endl;
	return 0;
}

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

typedef long long ll;
const int N = 3e5+5;

ll MOD = 998244353;

int n;
ll a , b , k;
ll fac[N] , inv[N];

ll mul(ll a , ll b){
	return (a * b) % MOD;
}

ll fast_exp(ll a , ll b){
	if(b == 0)return 1;
	ll x = fast_exp(a , b >> 1);
	x = mul(x , x);
	if(b & 1)x = mul(x , a);
	return x;
}

ll fact(){
	fac[0] = 1;
	for(int i = 1;i <= n;i++){
		fac[i] = mul(fac[i - 1] , i);
	}
	inv[0] = 1;
	for(int i = 1;i <= n;i++){
		inv[i] = fast_exp(fac[i] , MOD - 2);
	}
}

ll ncr(int n , int k){
	ll ans = mul(fac[n] , mul(inv[k] , inv[n - k]));
	return ans;
}

ll sum(ll a , ll b){
	return (a + b) % MOD;
}

int main(){
	cin >> n >> a >> b >> k;
	fact();
	ll ans = 0;
	for(int c = 0;c <= n;c++){
		ll l = a * c;
		if(l > k)break;
		if((k - l) % b)continue;
		ll d = (k - l) / b;
		if(d > n)continue;
		ans = sum(ans , mul(ncr(n , c) , ncr(n , d)));
	}
	cout << ans << endl;
}

Measured memory_bytes: 4992
/*
2017_04_13_AC
?????????DP??????????????£????????????????????¨??£??????????¨???????:2*10^8????????§???????????????
*/

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

/*dp[i]: ??´??°i????§??????§??????????°??????£?????¢?????°????????°*/
int dp1[1000005], dp2[1000005];
void makeDP(){
  vector<int> v1;
  vector<int> v2;
  int tn = 1;
  while(1){
      int tmp = tn*(tn+1)*(tn+2)/6;
      if(tmp < 1000000){
        v1.push_back(tmp);
        if(tmp % 2 != 0) v2.push_back(tmp);
      }else{
        break;
      }
      tn++;
  }
  /*1?????£?????¢?????°????????§??????????????????????????°??????????????°??§?§??????????*/
  REP(i,0,1000005) dp1[i] = i, dp2[i] = i;
  REP(i,1,v1.size()){
    REP(j,0,1000005){
      if(j-v1[i] >= 0) dp1[j] = min(dp1[j], dp1[j-v1[i]] + 1);
    }
  }
  REP(i,1,v2.size()){
    REP(j,0,1000005){
      if(j-v2[i] >= 0) dp2[j] = min(dp2[j], dp2[j-v2[i]] + 1);
    }
  }
}

int main() {

  makeDP();

  int N;
  while(1){
    cin>>N;
    if(N==0) break;
    cout<<dp1[N]<<" "<<dp2[N]<<endl;
  }

  return 0;
}

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

#define INF 2e9

#define REP(i,n) for(int i = 0; i < n;++i)
#define REPA(i,a,n) for(int i = a; i < n; ++i)
#define ALL(a) a.begin, a.end()

using namespace std;

int main(void) {

	string S;

	cin >> S;
	
	int N = S.size();

	vector<int> c(N, 0);
	int length;

	REP(i, N) {
		REPA(j, i+1, N) {
			if (S[j] == 'L') {
				REPA(k, j, N) {
					if (S[k] == 'R' || k == N - 1) {
						if (k == N - 1) k++;
						length = k - i;
						if (length % 2 == 0) {
							c[j] = length / 2;
							c[j - 1] = length / 2;
						}
						else {
							if ((j - i) > (k - j)) { // Rの方が多い
								if ((j - i) % 2 == 0) { // Rが偶数個
									c[j] = (length + 1) / 2;
									c[j - 1] = (length - 1) / 2;
								}
								else { // Rが奇数個
									c[j] = (length - 1) / 2;
									c[j - 1] = (length + 1) / 2;
								}
								
							}
							else { // Lの方が多い
								if ((k - j) % 2 == 0) { // Lが偶数個
									c[j] = (length - 1) / 2;
									c[j - 1] = (length + 1) / 2;
								}
								else { // Lが奇数個
									c[j] = (length + 1) / 2;
									c[j - 1] = (length - 1) / 2;
								}
								
							}
						}

						if (k == N - 1) i = k;
						else i = k - 1;
						break;
					}
				}
				
				break;
			}
		}
	}

	REP(i, N) cout << c[i] << ' ';
	cout << '\n';

	return 0;
}


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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	long long a, b, c;
	cin >> a >> b >> c;
	
	long long nr = 0;
	
	nr += min(b, c);
	
	b -= nr;
	c -= nr;
	
	nr *= 2;
	
	if(c == 0)
	{
		cout << nr + b;
	}
	else
	{
		nr++;
		c--;
		
		nr += min(a, c);
		
		cout << nr;
	}
}

Measured memory_bytes: 768
#include<iostream>
using namespace std;
int main(){
    int a,b;
    char op;
    while( op != '?'){
        cin >> a >> op >> b;
        if (op == '+'){
        cout << a+b <<endl;
        }
        else if (op == '-'){
            cout << a-b <<endl;
        }
        else if (op == '/'){
            cout << a/b <<endl;
        }
        else if (op == '*'){
            cout << a*b <<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3088
import copy
n,m=map(int,input().split())
node=[[0 for _ in range(n)] for _ in range(n)]
aL=[0 for _ in range(m)]
bL=[0 for _ in range(m)]
for i in range(m):
    a,b=map(int,input().split())
    node[a-1][b-1]=1
    node[b-1][a-1]=1
    aL[i]=a
    bL[i]=b
    
tmp1=copy.deepcopy(node)
chk=[0 for _ in range(n)]
def DFS(x):
    chk[x]=1
    for i in range(n):
        if chk[i]!=1 and tmp1[x][i]==1:
            tmp1[x][i]=0
            tmp1[i][x]=0
            chk[i]=1
            DFS(i)
    return chk

cnt=0
for j in range(m):
    tmp1[aL[j]-1][bL[j]-1]=0
    tmp1[bL[j]-1][aL[j]-1]=0
    if sum(DFS(0))!=n:
        cnt+=1
    tmp1=copy.deepcopy(node)
    chk=[0 for _ in range(n)]
print(cnt)

Measured memory_bytes: 3572
n = int(input())
s = input()
s_table = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
    for j in range(i, n):
        if i != j and s[i] == s[j]:
            s_table[i][j] = 1
            s_table[j][i] = 1

# print(s_table)
ans = 0
for i in range(n):
    cnt = 0
    start = i
    j = 0
    while i < n and j < n:
        # print(i, j, start)
        if s_table[i][j] == 1 and start != j:
            # print(1)
            cnt += 1
            ans = max(cnt, ans)
        else:
            cnt = 0
            start = i + 1
        i += 1
        j += 1
print(ans)

Measured memory_bytes: 247560
/*Bismillahir Rahmanir Rahim
->>Code by Aimon
->>CUET,CSE
*/
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef unsigned long long ull;
typedef vector<int> vi;
const int MX=2e5+5;
#define f(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define endl "\n"
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int a[n],d[MX];
    ll s{0};
    f(i,0,n)
    {
        cin>>a[i];
        s+=a[i];
        d[a[i]]++;
    }
    int q,b,c;
    cin>>q;
    while(q--)
    {
        int h{0};
        cin>>b>>c;

        h=d[b];
        d[b]=0;
        d[c]+=h;
        s+=h*(c-b);

        cout<<s<<endl;
    }


    return 0;
}

Measured memory_bytes: 4432
def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30\
            if 0 < min(a, b, c) else int(1e9+7)

    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    ret4 = dfs(cur + 1, a, b, c)

    return min(ret1, ret2, ret3, ret4)


N, A, B, C = map(int, input().split())

l = [int(input()) for i in range(N)]

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
/**
*    created: 30.06.2020 17:07:11
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcountll(bit)
using namespace std;
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 long double pi = acos(-1.0);
const int inf = 1LL << 60;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int h, w;
    cin >> h >> w;
    int mp[h+2][w+2];
    rep(i,h+2) rep(j,w+2) mp[i][j] = 0;
    string s;
    rep2(i,1,h+1) {
        cin >> s;
        rep2(j,1,w+1) if (s[j-1] == '#') mp[i][j] = 1;
    }
    rep2(i,1,h+1) rep2(j,1,w+1) if (mp[i][j] == 1) {
        if (mp[i+1][j] == 0 && mp[i-1][j] == 0 && mp[i][j+1] == 0 && mp[i][j-1] == 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

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

const long long MOD = 1000000007;

int main(){
  ll x;
  ll a=101;
  int ans=1;
  cin >> x;
  while(a<x){
    a+=a/100;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(void)
{
    char str[1024];
    int i;
    
    scanf("%s", str);
    for (i = 0; str[i] != 0; i++){
        putchar((str[i] - 'A' + 23) % 26 + 'A');
    }
    puts("");
    
    return 0;
}

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

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

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int c[3][3];
	FOR(i,0,3){
		FOR(j,0,3){
			cin >> c[i][j];
		}
	}
	bool ans = true;
	FOR(i,0,2){
		if(c[i+1][0] - c[i][0] != c[i+1][1] - c[i][1] || c[i+1][1] - c[i][1] != c[i+1][2] - c[i][2])
			ans = false;
	}
	FOR(i,0,2){
		if(c[0][i+1] - c[0][i] != c[1][i+1] - c[1][i] || c[1][i+1] - c[1][i] != c[2][i+1] - c[2][i])
			ans = false;
	}
	Yes(ans);
	return 0;
}


Measured memory_bytes: 256
A, B = map(int, input().split())

if A == B:
    print(A)

elif A % 2 == 0:
    if B % 2 == 0:
        if ((B - 1) - A + 1)/2 % 2 == 0:
            print(B)
        else:
            print(B^1)
    else:
        if (B - A + 1)/2 % 2 == 0:
            print(0)
        else:
            print(1)

else:
    if B % 2 == 0:
        if ((B - 1) - (A + 1) + 1)/2 % 2 == 0:
            print(A^B)
        else:
            print((A^1)^B)
    else:
        if (B - (A + 1) + 1)/2 % 2 == 0:
            print(A)
        else:
            print(A^1)

Measured memory_bytes: 3064
#include<stdio.h>
main(){
  int n,i;
  double a[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%lf",&a[i]);
  }

  printf("1:");
  for(i=0;i<n;i++){
    if(165>a[i]){
     printf("*");
    }
  }
  puts("");

  printf("2:");
  for(i=0;i<n;i++){
    if(165<=a[i] && a[i]<170){
      printf("*");
    }
  }
  puts("");

  printf("3:");
  for(i=0;i<n;i++){
    if(170<=a[i] && a[i]<175){
      printf("*");
    }
  }
  puts("");

  printf("4:");
  for(i=0;i<n;i++){
    if(175<=a[i] && a[i]<180){
      printf("*");
    }
  }
  puts("");

  printf("5:");
  for(i=0;i<n;i++){
    if(180<=a[i] && a[i]<185){
      printf("*");
    }
  }
  puts("");

  printf("6:");
  for(i=0;i<n;i++){
    if(185<=a[i]){
      printf("*");
    }
  }
  puts("");

  return(0);
}

Measured memory_bytes: 348
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<string.h>
#include<math.h>
#include<stdio.h>
#include<queue>
#include<utility>
#include<cstdio>
#include<cstring>
#include<new>
#include<float.h>
#include<ctype.h>
#include<cfloat>
#include<cmath>
#include<cctype>
#include<errno.h>
#include<cerrno>
#include<memory>
#include<memory.h>
#include<assert.h>
#include<cassert>
#include<deque>
#include<sstream>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qui queue<int>
#define vit vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define prq priority_queue
#define pii pair<int,int>
#define mp make_pair
#define sz size()
#define em empty()
#define ct continue
#define ms multiset
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define ppf pop_front()
using namespace std;
ll n,m,ans=1,an=1e9+7;
int main()
{
	cin>>n>>m;
	if(abs(n-m)>1){
		cout<<"0";
		return 0;
	}
	fo(i,1,n+1){
		ans*=i;
		ans%=an;
	}
	fo(i,1,m+1){
		ans*=i;
		ans%=an;
	}
	if(m==n)ans*=2;
	cout<<ans%an<<endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
	os << "[ "; for(auto v : V) os << v << " "; return os << "]";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1> void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << endl;
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1<<" | ";
	__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define mems(x, y) memset(x, y, sizeof(x))
#define rep(i, n) for (int i = 0; i < n; ++i)
#define irep(i, n) for (int i = 1; i <= n; ++i)
#define print(x) cout << x << '\n'
#define err(x) clog << x << '\n'
typedef long long ll;
#define int ll
typedef long double ld;
#define double ld
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
const int INF = 0x3f3f3f3f;
const int M = 1e9+7;
const int N = 21;

int n;
int a[N][N];
int dp[N][1<<N];

signed main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

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

	rep(i, n) dp[0][1<<i] = a[0][i];
	irep(i, n-1) {
		rep(m, 1<<n) {
			if (__builtin_popcountll(m) != i) continue;
			rep(j, n) {
				if ((m >> j) & 1 || !a[i][j]) continue;
				dp[i][m|(1<<j)] += dp[i-1][m], dp[i][m|(1<<j)] %= M;
			}
		}
	}

	print(dp[n-1][(1<<n)-1]);
}


Measured memory_bytes: 307456
import scala.io.StdIn

object Main extends App {
  val in = StdIn.readLine.split(" ").map(_.toInt)
  val n = in(0).toInt
  val y = in(1).toInt / 1000
  val l10k = y / 10
  val l05k = y / 5

  val res =
    for{
      i <- 0 to l10k
      a10k = 10 * i
      j <- 0 to l05k
      rem = y - a10k - 5 * j
      if rem >= 0 && rem == n - i - j
    } yield (i, j, n-i-j)

  val ans = if(res.size == 0) (-1,-1,-1) else res(0)

  println(ans._1 + " " + ans._2 + " " + ans._3)
}

Measured memory_bytes: 114800
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N;cin >> N;
    vector<int> v(N);
    rep(i,N)cin >> v[i];
    sort(all(v));
    double tmp1;
    double tmp2 = pow(2.0,N-1);
    rep(i,N){
        if(i == 0){
            tmp1 += v[0];
        }
        else if(i == 1){
            tmp1 += v[1];
        }
        else{
            tmp1 += v[i]*pow(2.0,i-1);
        }
    }
    cout << fixed << setprecision(10) << tmp1/tmp2 << endl;
}

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

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

const int MAXN = 2e5;

int n, h[MAXN+10], arr[MAXN+10];
ll ans;

ll tree[MAXN+10];
void update(int i, ll val) { for(; i<=n; i+=(i&-i)) tree[i]=max(tree[i], val); }
ll query(int i) { ll ret=0; for(; i>0; i-=(i&-i)) ret=max(ret, tree[i]); return ret; }

int main()
{
    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(false);
    int i, j;

    scanf("%d", &n);
    for(i=1; i<=n; i++) scanf("%d", &h[i]);
    for(i=1; i<=n; i++) scanf("%d", &arr[i]);

    for(i=1; i<=n; i++)
    {
        ll now=query(h[i]-1)+arr[i];
        update(h[i], now);
        ans=max(ans, now);
    }
    printf("%lld", ans);
    return 0;
}


Measured memory_bytes: 3456
#include "iostream"
#include <vector>
using namespace std;

int main(){
    string S;
    int N;

    cin >> N;
    cin >> S;

    int l = S.size();
    char chars[52] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
                      'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};

    vector<char> ans;
    for (int i = 0; i < l; i++){
        char c = S[i];
        for (int j = 0; j < 26; j++){
            if (c == chars[j]){
                cout << chars[j+N] ;
            }
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;

int main() {
    int n, x; scanf("%d%d", &n, &x);
    vector<int> t(n); repeat (i, n) scanf("%d", &t[i]);
    int result = x;
    repeat (i, n - 1) {
        result += x - max(0, t[i] + x - t[i + 1]);
    }
    printf("%d\n", result);
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    string s,t ;
    cin >> s >> t;
    sort(all(s));
    sort(all(t));
    reverse(all(t));
    if(s<t)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
 
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> temp(n);
  for(int& i:temp)
    cin>>i;
  int ans=0;
  sort(temp.begin(),temp.end());
  for(int i=0;i<k;i++){
    ans+=temp[i];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3560
fn main() {
    let (a, b, c) = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        #[allow(deprecated)]
        let s = s.trim_right().to_owned();
        let mut s = s.split_whitespace();
        (
            s.next().unwrap().parse::<u32>().unwrap(),
            s.next().unwrap().parse::<u32>().unwrap(),
            s.next().unwrap().parse::<u32>().unwrap(),
        )
    };
    let mut ans = 0;
    let mut sum = 0;
    while sum < c {
        sum += a;
        if ans % 7 == 6 {
            sum += b;
        }
        ans += 1;
    }
    println!("{}", ans);
}



Measured memory_bytes: 5028
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy
import bisect


def dfs(s, prev, pre):
  val[s] += Ope[s] + prev
  for i in G[s]:
    if(i == pre):
      continue
    dfs(i, val[s], s)

#X = str(input()).split()
#a = [int(x) for x in input().split()]
#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())

N, M = map(int, input().split())
s= []
c= []

n = [0]*N

ans = 0

for i in range(M):
  sc = str(input()).split()
  s.append(int(sc[0]))
  c.append(int(sc[1]))
  n[s[i]-1] = c[i]

#map(str, n)
ans = "".join(map(str,n))


for i in range(M):
 for j in range(M):
  if(s[i]==s[j]):
    if(c[i]!=c[j]):
      ans =-1
  if(s[i]==1):
    if(c[i]==0):
      if(N!=1):
        ans = -1


if(ans == -1):
  print(-1)
else:
  if(N==1 and n[0]==0):
    print(0)
  else:
    if(n[0]==0):
      n[0]=1
    ans = "".join(map(str,n))
    print(ans)




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

#define pb push_back

#define ll long long

#define ft first

#define sd second

using namespace std;

const int N = 5050 ;

bool used[N];

ll z , r , w ;

ll p = -1 ;

int main(){

    string s ;
    cin >> s ;
    for(int i = 0 ; i < s.size() ; i ++ ){
        if(i%2==0){
            if(s[i]=='L'){
                z++;
            }
        }
        if(i % 2 !=0){
            if(s[i]=='R'){
                z++;
            }
        }
    }
    if(!z){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

}


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

field = [[0 if x == '.' else 1 for x in xx] for xx in s]
result = [[''] * w for _ in range(h)]

for i in range(h):
    for j  in range(w):
        if field[i][j] == 1:
            result[i][j] = '#'
            continue
        
        total = 0
        for ii in range(i-1, i+2):
            for jj in range(j-1, j+2):
                if ii < 0 or ii >= h:
                    continue
                if jj < 0 or jj >= w:
                    continue
                total += field[ii][jj]
        result[i][j] = str(total)

for r_line in result:
    print("".join(r_line))

Measured memory_bytes: 40304
/**Bismillahir Rahmanir Rahim.**/
#include<bits/stdc++.h>
#include<stdlib.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long int            ll;
typedef long double              ld;
#define Faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi                 acos(-1);
#define test        int t; cin>>t; while(t--)
//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());
//cin.getline(array,size);
int main()
{
    #ifndef ONLINE_JUDGE
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ll a,b,c,d,m;
    cin>>a>>b>>c>>d;
    cout<<max(a*c,max(a*d,max(b*c,b*d)))<<endl;
    
    #ifndef ONLINE_JUDGE
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
}

Measured memory_bytes: 3672
//😄😄😄😄😄😄😄😄😄😄😄😄😄
//Apno Swagat che//
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pi pair<int,int>
#define vp vector<pi>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define For(i,a,b) for(ll i=a;i<b;i++)
#define endl "\n"
#define debug(x) cout<<"AA Baju Smit------> "<<#x<<" -> "<<x<<endl
#define all(x) x.begin(),x.end()
#define mint map<int,int>
#define mod 10000007
#define ciN cin

////////////////////////////////////////////////////////////////
//Ha Moj Ha///
////////////////////////////////////////////////////////////////
////TEST CASES ATTACHED CHE BHULTO NAI......///////////////////
void jabru() {
	string s; ciN >> s;
	ll ans = 0;
	if (count(all(s), 'R') == 0) {
		cout << 0 << endl;
		return ;
	}
	else {
		ans = 1;
		if (count(all(s), 'R') == 3) {
			cout << 3 << endl;
			return;
		}
		if (count(all(s), 'R') == 1) {
			cout << 1 << endl;
			return ;
		}
		if (count(all(s), 'R') == 2) {
			if (s[1] == 'S') {
				cout << 1 << endl; return;
			}
			else {
				cout << 2 << endl; return;
			}
		}
	}

}




////////////////////////////////////////////////////////////////
//Bas aabaju nai javanu///
////////////////////////////////////////////////////////////////

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	//int t; cin >> t;
	//while (t--)
	jabru();

	return 0;
}





///////////////////////////////////////////////////////////////////////////////////////////
//Kai baju bhai???



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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int,int> PII;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;

/*FUNCs=================================================*/
vi move1 = {0,0,1,-1};
vi move2 = {1,-1,0,0};

/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(10);
    
    int h, w; cin >> h >> w;
    vector<vector<char>> grid(h, vector<char>(w));

    int b_cnt = 0;
    rep(i,h) {
        rep(j, w) {
            cin >> grid[i][j];
            if(grid[i][j] == '#') ++b_cnt; 
        }
    }

    //bfs
    vii dist(h, vi(w, -1));
    queue<PII> que;
    que.emplace(0,0);
    dist[0][0] = 0;
    while(que.size()) {
        int x, y;
        tie(x,y) = que.front(); que.pop();
        rep(i,4) {
            int nx = x + move1[i];
            int ny = y + move2[i];
            if(0>nx || nx>=h || 0>ny || ny>=w) continue;
            if(grid[nx][ny] == '#') continue;
            if(dist[nx][ny] != -1) continue;
            dist[nx][ny] = dist[x][y] + 1;
            que.emplace(nx,ny);
        }
    }

    if(dist[h-1][w-1] == -1) {
        cout << -1 << '\n';
        return 0;
    }
    else {
        cout << h*w -  dist[h-1][w-1] - b_cnt - 1 << '\n';
        return 0;
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        ArrayList<Integer> fir = new ArrayList<Integer>();
        ArrayList<Integer> sec = new ArrayList<Integer>();
        String[] input1 = sc.nextLine().split(" ");
        String[] input2 = sc.nextLine().split(" ");
        int ans = 0;
        for(int i=0 ; i<n ; i++){
            fir.add(Integer.parseInt(input1[i]));
            sec.add(Integer.parseInt(input2[i]));
        }
        fir.add(0);
        sec.add(0);
        //System.out.println(fir + " " + sec);
        for(int i = 0 ; i < n ; i++){
            int count = get(n ,i ,fir , sec );
            if(ans <= count){
                ans = count;
            }
        }
        System.out.println(ans);
    }

    static int get(int n,int sign , ArrayList<Integer> a , ArrayList<Integer> b){
        int sum = 0;
        for(int i = 0;i <= sign; i++){
            sum += a.get(i);
        }
        for(int i = sign; i < n; i++){
            sum += b.get(i);
        }
        return sum;
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int n, a;
    cin >> n >> a;
    n %= 500;
    if (n <= a) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<string> a(N);
    for (int i = 1;i <= N;i++) {
        a[i-1] = to_string(i);

    }
    int ans = 0;
    for (int i = 0;i < N;i++) {
        if(a[i].size() % 2 == 1){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5760
#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 N;
	cin >> N;
	vector<ll> A(N);
	rep(i, N) cin >> A[i];

	vector<ll> B(N);
	B[N-1] = A[N-1];
	for(int i = N-2; i >= 0; i--)
		B[i] = (B[i+1] + A[i]) % 1000000007;

	ll ans = 0;
	for(int i = 0; i < N-1; i++) {
		ans += A[i] * B[i+1] % 1000000007;
		ans %= 1000000007;
	}

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

Measured memory_bytes: 6420
N,h=gets.split(' ').map(&:to_i)
res,a,b=0,[],[]
N.times{|i|a[i],b[i]=gets.split(' ').map(&:to_i)}
a=a.sort{|i, j| j<=>i}
b=b.sort{|i, j| j<=>i}
while h>0
  if b[0]!=nil&&a[0]<b[0]
    h-=b.shift
    res+=1
  else
    res+=(h.to_f/a[0]).ceil
    h=-1
  end
end
puts res

Measured memory_bytes: 5724
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf = 1e9;

bool isPrime[100010]; // n<1000010
void hurui(int n) {
    isPrime[0] = isPrime[1] = false;
    for (int i = 2; i < n + 1; i++) isPrime[i] = true;

    for (int i = 2; i*i <= n; i++) {
        for (int j = i * 2; j < n + 1; j += i) {
            isPrime[j] = false;
        }
    }
    return;
}

bool like[100010];
int sum[100010];
int Q;
int l,r;
int main() {
    hurui(100010);
    for(int i=3;i<100010;i+=2){
        if(isPrime[i] && isPrime[(i+1)/2]){
            like[i]=true;
        }
    }
    for(int i=3;i<100010;i+=2){
        sum[i]=sum[i-2] + like[i];
    }

    cin>>Q;
    REP(i,0,Q){
        cin>>l>>r;
        p(sum[r] - sum[l-2]);
    }
    return 0;
}

Measured memory_bytes: 1280
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		
		// 入出力高速化 java.io.* とthrows IOExceptionを忘れずに
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int N = Integer.parseInt(br.readLine());
		String[] IN =br.readLine().split(" ") ; 
		
		String ans = "YES";
			
			HashMap<String,Integer> count = new HashMap<String,Integer>();
			for(int i=0; i<N; i++) {
				if (!count.containsKey(IN[i])){
					count.put(IN[i], 1); //まだHashMapにキーが登録されていないなら、登録する
				}else{//HashMapに既にキーがあるとき
					int now = count.get(IN[i]); //キーSに紐づく中身のintを取得
					count.replace(IN[i], now + 1);
				}
			}
			
			for(int key1:count.values()) {
				if(key1 > 1) {
					ans = "NO";
				}
			}
		
		System.out.println(ans);	
	}
}

Measured memory_bytes: 62088
#include <stdio.h>
int main(){
 int x[5]={1,2,3,4,5};
 scanf("%d %d %d %d %d",&x[0],&x[1],&x[2],&x[3],&x[4]);
 for(int i=0;i<5;i++){
  if(x[i]==0)printf("%d",i+1);
 }
 return 0;
}

Measured memory_bytes: 2132
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int h,w,n;
int x,y;
string s,t;

bool calc(char L,char R,int Max,int sta){
    int left=1,right=Max;
    if (s[n-1]==R) right-=1; 
    if (s[n-1]==L) left+=1; 
    per(i,n-1){
        if (t[i]==R) left=max(1,left-1);
        if (t[i]==L) right=min(right+1,Max); 
         
        if (s[i]==R) right-=1;
        if (s[i]==L) left+=1;
        

        if (left>right) return false;
    }

    return left<=sta && sta<=right;

}

void solve(){
    cin >> h >> w >> n;
    cin >> y >> x;
    cin >> s >> t;
    bool a1=calc('L','R',w,x);
    bool a2=calc('U','D',h,y);
    puts(a1&&a2 ? "YES" : "NO");
}



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

Measured memory_bytes: 920
n = int(input())
INF = int(1e9)
h = list(map(int, input().split(' ')))
dp = [INF for _ in range(n)]
dp[0] = 0
for i in range(n):
    for j in [1, 2]:
        if i - j >= 0:
            # print(i-j)
            dp[i] = min(dp[i], abs(h[i] - h[i - j]) + dp[i - j])

print(dp[n-1])


Measured memory_bytes: 54540