akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    while(cin >> S) {
        each(c, S)if(c == ',')c = ' ';
        cout << S << endl;
    }
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  string s; cin >> s;
  sort(s.begin(), s.end());
  cout << (s == "abc" ? "Yes" : "No") << endl;
}


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

typedef long long   ll;
const ll mod = 1e9 + 7;

#define speedup_IO      ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n)     for(ll i = a; i < n; i++)
#define ford(i,n,a)     for(ll i = n-1; i >= a; i--)
#define pb              push_back
#define lb              lower_bound
#define ub              upper_bound
#define pll             pair<ll,ll>
#define all(a)          (a).begin(),(a).end()
#define reset(a,x)      memset(a,x,sizeof(a))

ll mypow(ll base, ll exp) {ll res = 1; while (exp) {if (exp & 1) res = (res * base) % mod; exp >>= 1, base = (base * base) % mod;} return res;}
ll gcd(ll a, ll b)  { return b ? gcd(b, a % b) : a;            }
ll mult(ll a, ll b) { return ((a % mod) * (b % mod)) % mod;    }
ll add(ll a, ll b)  { return (a % mod + b % mod) % mod;        }
ll sub(ll a, ll b)  { return (a % mod + mod - b % mod) % mod;  }

const ll inf = 1e18;
const int nax = 1e5 + 5;
const int SZ = 2;
const int MOD = 1e9 + 7;

ll fact[nax],invfact[nax],inverse[nax];

void pre()
{
	fact[0] = 1;
	forn(i,1,nax)
	{
		fact[i] = mult(fact[i-1],i);
	}

	invfact[nax-1] = mypow(fact[nax-1],mod-2);

	ford(i,nax,1)
	{
		invfact[i-1] = mult(invfact[i],i);
	}
}

ll ncr(ll n,ll r)
{
	if(r>n)
		return 0;

	ll ans = mult(fact[n],mult(invfact[n-r],invfact[r]));

	return ans;
}



int main()
{
	speedup_IO;
	pre();
	ll n,k;
	cin>>n>>k;
	
	ll a[n];
	forn(i,0,n)
	{
		cin>>a[i];
	}

	sort(a,a+n);

	vector<ll>cnt;
	forn(i,0,n)
	{
		ll j = i;
		ll x = 0;
		while(j<n && a[j] == a[i])
		{
			x++;
			j++;
		}
		cnt.pb(x);
		i = j-1;	
	}

	ll maxi = 0,mini = 0;

	ll upto = 0;
	for(ll j =cnt.size()-1;j>=0;j--)
	{
		ll x = cnt[j];
		upto += x;
		forn(i,1,min(k,x)+1)
		{
			if(n-upto>=0 && x-i>=0 && n-upto-(k-i)>=0)
			{
				if(a[n-upto]<0)
				{
					a[n-upto]+=mod;
				}
				ll y = ncr(x,i);
				y = mult(y,ncr(n-upto,k-i));
				y = mult(a[n-upto],y);
				maxi = add(maxi,y);
			}
		}
	}

	upto = 0;
	for(ll j =0;j<(ll)cnt.size();j++)
	{
		ll x = cnt[j];
		upto+=x;
		forn(i,1,min(k,x)+1)
		{
			if(n-upto>=0 && x-i>=0 && n-upto-(k-i)>=0)
			{
				if(a[n-upto]<0)
				{
					a[n-upto]+=mod;
				}
				ll y = ncr(x,i);
				y = mult(y,ncr(n-upto,k-i));
				y = mult(a[upto-1],y);
				mini = add(mini,y);
			}
		}
	}	
		
	ll ans = sub(maxi,mini);
	cout<<ans;
	return 0;
}

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

using namespace std;

typedef long long ll;

const int N = (1 << 16) + 5;
int arr[16][16];
int n;
ll val[N];
vector<int> m[N];
ll dp[N];

void get_masks(int idx, int mask, int pos)
{
  if(idx == n)
  {
    if(mask)
      m[pos].push_back(mask);
    return;
  }
  get_masks(idx + 1, mask, pos);
  if(mask & (1 << idx))
    get_masks(idx + 1, mask ^ (1 << idx), pos);
}

int main()
{
  cin >> n;
  for(int i = 0; i < n; i++)
    for(int j = 0; j < n; j++)
      cin >> arr[i][j];
  for(int i = 0; i < (1 << n); i++)
  {
    for(int j = 0; j < n; j++)
    {
      for(int k = j + 1; k < n; k++)
      {
        if((i & (1 << j)) && (i & (1 << k)))
          val[i] += arr[j][k];
      }
    }
  }
  for(int i = 0; i < (1 << n); i++)
  {
    int newMask = i;
    for(int j = 0; j < n; j++)
      newMask ^= (1 << j);
    get_masks(0, newMask, i);
  }
  for(int i = (1 << n) - 2; i >= 0; i--)
  {
    for(auto &x: m[i])
    {
      dp[i] = max(dp[i], dp[i | x] + val[x]);
    }
  }
  cout << dp[0];
  return 0;
}


Measured memory_bytes: 173948
N =int(input())
a = list(map(int,input().split()))
alice=0
bob=0
a.sort(reverse=True)
for i in range(N):
	if i%2==0:
		alice =alice+a[i]
	if i%2==1:
		bob = bob+a[i]
ans = alice-bob
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 100000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

const ll MAX = 1000000;

int main(){
    int n, w, h;
    cin >> n >> w >> h;
    vector<pair<int,int> > tate(n);
    vector<pair<int,int> > yoko(n);
    for (int i=0; i<n; i++) {
        int x,y,ww;
        cin >> x >> y >> ww;
        tate[i] = {y-ww,y+ww};
        yoko[i] = {x-ww,x+ww};
    }
    sort(tate.begin(), tate.end());
    int b=tate[0].second;
    bool ch = true;
    if (tate[0].first <= 0) {
        for (int i=1; i<n; i++) {
            if (tate[i].first>b) {
                ch = false;
            }
            b = max(b,tate[i].second);
        }
        if (b<h) {
            ch = false;
        }
        if (ch) {
            cout << "Yes"<<endl;
            return 0;
        }
    }
    sort(yoko.begin(), yoko.end());
    b = yoko[0].second;
    ch = true;
    if (yoko[0].first <= 0) {
        for (int i=1; i<n; i++) {
            if (yoko[i].first>b) {
                ch = false;
            }
            b = max(b,yoko[i].second);
        }
        if (b<w) {
            ch = false;
        }
        if (ch) {
            cout << "Yes"<<endl;
        }else{
            cout << "No" <<endl;
        }
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 2588
n=int(input())
a=[0]+[int(x) for x in input().split()]
x=[0]*(n+1)

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

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

x.pop(0)

print(*x)

Measured memory_bytes: 90756
N, M = map(int, input().split())
X = [int(i) for i in input().split()]
if N >= M:
  print(0)
  exit()

X.sort()
dist = []
for i in range(M-1):
  dist.append(X[i+1]-X[i])
dist.sort()

ans = 0
for i in range(M-N):
  ans += dist[i]
print(ans)


Measured memory_bytes: 13832
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string S;
    cin >> S;
    string ini=S.substr(0,1);
    int pos=S.substr(1,3).find(S.substr(0,1));
    if(pos==string::npos) cout << "No" << endl;
    else
    {
        S.erase(S.begin());
        S.erase(S.begin() + pos);
        if(S.substr(0,1)==ini) cout << "No" << endl;
        else if(S.substr(0,1)==S.substr(1,1)) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int n;
string s;



int main(){

    int n;
    cin>>n;
    int ans=0;
    int b[n-1];
    for(int i=0;i<n-1;i++)
        cin>>b[i];
    ans+=b[n-2]+b[0];
    for(int i=n-2;i>0;i--){
        ans+=min(b[i],b[i-1]);
    }
    cout<<ans;

return 0;
}


Measured memory_bytes: 3624
from sys import stdin
from copy import deepcopy
from functools import reduce
from fractions import gcd
import math
import itertools
from collections import Counter
from itertools import chain  ##list(chain.from_iterable(l)) ##flatten
from heapq import heappush, heappop
import bisect

"""
N = int(input())
A, B = map(int,input().split())
A = list(map(int,input().split())) ## 横一列
A = [int(input()) for _ in range(N)] ## 縦一列
lst = [list(map(int,input().split())) for i in range(M)] ## 二次元
"""

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
  

  

N = int(input())  

if N == 1:
  print(0)
  exit()

div = factorization(N)
#print(div)

ans = 0
for i in range(len(div)):
  x = div[i][1]
  var = int((-1 + math.sqrt(1 + 8*x)) / 2)
  ans += var
  #print(x, var)
  

print(ans)



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

using namespace std;

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

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

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

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

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

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

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

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

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

int n,m,a,b,c;
int d[100005] = {};
string s;

int main(){

    cin >> a >> b;
    cin >> s;

    rep(i,0,a)if( s[i] < '0' || '9' < s[i]){
        No;
        ret 0;
    } 

    if(s[a] != '-'){
        No;
        ret 0;
    }
    rep(i,a+1,sz(s))if( s[i] < '0' || '9' < s[i]){
        No;
        ret 0;
    }
    
    Yes;
	
	return  0;
}

Measured memory_bytes: 256
# A0J 0009 Prime Number

$MAX_N = 999999
$prime = Array.new($MAX_N + 1, true)
$sum_primes = Array.new($MAX_N + 1, 0)

# エラトステネスの篩
def eratosthenes
  max = Math.sqrt($MAX_N).to_i

  $prime[0] = $prime[1] = false

  (2..max).each do |x|
    next unless $prime[x]

    k = 2 * x
    while k <= $MAX_N
      $prime[k] = false
      k += x
    end
  end
end

# 素数の数の累積和の計算
def calc_sum
  sum = 0
  (2..$MAX_N).each do |x|
    sum += 1 if $prime[x]
    $sum_primes[x] = sum
  end
end

eratosthenes
calc_sum

nums = ARGF.each_line.map {|line| line.to_i}
nums.each do |n|
  puts $sum_primes[n]
end

Measured memory_bytes: 21740
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 100010
int d[N];
int main(){
    int n;cin>>n;
    lol(i,n+1)d[i]=mod;
    d[0]=0;
    lol(i,n){
	if(d[i]==mod)continue;
	lol(j,6)d[i+j]=min(d[i+j],d[i]+j);
	int k=6;
	while(i+k<=n){
	    d[i+k]=min(d[i+k],d[i]+1);
	    k*=6;
	}
	k=9;
	while(i+k<=n){
	    d[i+k]=min(d[i+k],d[i]+1);
	    k*=9;
	}
    }
    cout<<d[n]<<endl;
    return 0;
}


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

using namespace std;

string dd[20]=
{"AKIHABARA",
 "AKIHABAR",
 "AKIHABRA",
 "AKIHBARA",
 "KIHABARA",
 "AKIHABR",
 "AKIHBAR",
 "KIHABAR",
 "AKIHBRA",
 "KIHABRA",
 "KIHBARA",
 "AKIHBR",
 "KIHBAR",
 "KIHBRA",
 "KIHABR",
 "KIHBR"};
 string tp;
int main()
{
	cin >> tp;
	for(int i=0;i<=15;i++)
		if(tp==dd[i])
		{
			puts("YES");
			return 0 ;
		}
	puts("NO");
	return 0;
}

Measured memory_bytes: 256
//ABC146A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <numeric>
using namespace std;

int main(){
	string s;
	cin >> s;
	int ans;
	if(s == "SUN"){
		ans = 7;
	}else if(s == "MON"){
		ans = 6;
	}else if(s == "TUE"){
		ans = 5;
	}else if(s == "WED"){
		ans = 4;
	}else if(s == "THU"){
		ans = 3;
	}else if(s == "FRI"){
		ans = 2;
	}else if(s == "SAT"){
		ans = 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
k = 26
D = gets.to_i
c = gets.split.map(&:to_i)
s = D.times.map { gets.split.map(&:to_i) }
max_satis = -1
max_r = -1
k.times do |r|
  t = []
  D.times do |d|
    t[d] = (d + r) % k + 1
  end
  
  last = Array.new(k, 0)
  satis = 0
  D.times do |d|
    satis += s[d][t[d] - 1]
    last[t[d] - 1] = d + 1
    k.times do |i|
      satis -= c[i] * ((d + 1) - last[i])
    end
  end
  if max_satis < satis
    max_satis = satis
    max_r = r
  end
end

D.times do |d|
  puts (d + max_r) % k + 1
end


Measured memory_bytes: 14456
#include<cstdio>
const int MOD = int(1E9) + 7;
const int MAXN = 15;
int nxt[MAXN], dp[1<<MAXN];
int pw[MAXN*MAXN], f[1<<MAXN];
int lowbit(int x) {
	return x & -x;
}
int main() {
	int N, M;
	scanf("%d%d", &N, &M);
	for(int i=1;i<=M;i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		x--, y--;
		nxt[x] |= (1<<y);
	}
	pw[0] = 1;
	for(int i=1;i<=MAXN*MAXN;i++)
		pw[i] = 1LL * pw[i-1] * 2 % MOD;
	int ans = pw[M], t = (1<<N) - 1;
	for(int i=1;i<=t;i++)
		f[i] = f[i^lowbit(i)] + 1;
	dp[0] = 1;
	for(int s=1;s<=t;s++) {
		for(int s1=s;;s1=s&(s1-1)) {
			if( (!(s1&1)) != (!(s1&2)) ) continue;
			int s2 = s ^ s1, del = dp[s1];
			for(int i=0;i<N;i++) {
				if( (1<<i) & s ) {
					if( (1<<i) & s1 ) {
						int p = (nxt[i] & s2);
						del = 1LL * del * (pw[f[p]] - 1) % MOD;
					}
					else {
						int p = (nxt[i] & s1);
						del = 1LL * del * pw[f[p]] % MOD;
					}
				}
			}
			dp[s] = (dp[s] + del) % MOD;
			if( !s1 ) break;
		}
	}
	printf("%d\n", ((ans - dp[t]) % MOD + MOD) % MOD);
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000001;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int main() {

	rep(i,200){
		ll a,b;
		cin>>a>>b;
		if(cin.eof())break;
		ll t=a+b,ans=1;
		while(t/10>0){
			t/=10;
			ans++;
		}
		cout<<ans<<endl;
	}

	return 0;
}



Measured memory_bytes: 3060
use proconio::{input, fastout};
use proconio::marker::Chars;

#[fastout]
fn main() {
    input! {
        s: Chars,
        t: Chars,
    };

    let mut dp = vec![vec![0; t.len()+1]; s.len()+1];
    let mut max = 0;
    let mut ans = String::new();
    //let mut prev = vec![vec![[0, 0]; t.len()+1]; s.len()+1];

    for (i, ss) in s.iter().enumerate() {
        for (j, tt) in t.iter().enumerate() {
            if ss == tt {
                dp[i+1][j+1] = dp[i][j] + 1;
                if max < dp[i+1][j+1] {
                    max = dp[i+1][j+1];
                }
            } else {
                dp[i+1][j+1] = dp[i][j+1].max(dp[i+1][j]);
            }
        }
    }

    let mut i = s.len();
    let mut j = t.len();

    while i > 0 && j > 0 {
        if dp[i][j] == dp[i-1][j] {
            i -= 1;
        } else if dp[i][j] == dp[i][j-1] {
            j -= 1;
        } else {
            ans.insert(0, s[i-1]);
            i -= 1;
            j -= 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 37308
#include "bits/stdc++.h"
using namespace std;

int main(){
    string s;
    cin>> s;
    int a=0,b=0;
    for(int i=0;s[i]!=0;i++){
        if(s[i]=='0'){
            a+=i%2;
            b+=(i+1)%2;
        }else{
            a+=(i+1)%2;
            b+=(i)%2;
        }
    }
    int ans;
    ans=a>b?b:a;
    cout<<ans<<"\n";
    return(0);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 1000005
#define il inline
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,n,a) for(int i=n;i>=a;i--)
#define  pi  acos(-1)
#define ld  double
#pragma GCC optimize(2)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int a[N];
int main() {
    IOS
    int n,m;
    ll sum=0;
    cin>>n>>m;
    int fl=1;
    for (int i = 0; i <m ; ++i) {
        cin>>a[i];
        if(fl)n-=a[i];
        if(n<0)fl=0;
    }
    if(n<0||fl==0)cout<<-1;
    else cout<<n;
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <regex>
#include <locale>

using namespace std;

int main() {
  long long n,a,b,cnt,amari;
  cin >> n >> a >> b;
  cnt = n / (a + b) * a;
  amari = n % (a + b);
  if(amari < a) {
      cnt += amari;
  } else {
      cnt += a;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a - 1) * (b - 1) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {

  int N, T; cin >> N >> T;
  int c, t, cmin = 10000;
  for (int i=0; i<N; i++){
    cin >> c >> t;
    if (t<=T)
      cmin = min(cmin, c);
  }
  
  if (cmin == 10000)
    cout << "TLE" << endl;
  else
    cout << cmin << endl;
  
  return 0;
}

Measured memory_bytes: 256
NO_SOL = (-1, -1)
 
 
# 所与の文字列の部分文字列であって、アンバランスなものを1つ探す
# 対象とするのは、"AA"および"ABA"のみ
# 結果のインデックスは0始まりである
def search_unbalanced_substr(s):
    n = len(s)
    # "AA"を探す
    for i in range(n - 1):
        if s[i] == s[i + 1]:
            return i, i + 1
    # "ABA"を探す
    for i in range(n - 2):
        if s[i] == s[i + 2]:
            return i, i + 2
    # 見つからなければ
    return NO_SOL
 
 
def main():
    ans = search_unbalanced_substr(input())
    if ans == NO_SOL:
        print(*ans)
    else:
        print(*(i + 1 for i in ans))
 
 
if __name__ == '__main__':
    main()
 

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

for i in range(h):
    for j in range(w):
        link = [(-1, 0), (1, 0), (0, -1), (0, 1)]
        if dot_map[i][j] == '#':
            count = 0
            for n, m in link:
                if 0<= i + n < h and 0 <= j + m < w and dot_map[i + n][j + m] == '#':
                    count += 1
            if count == 0:
                print('No')
                exit(0)

print('Yes')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 3000000
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int n,m,t,s1[N],s2[N],ans;
struct P{int x,y,id;}a[N],b[N],c[N];
inline bool cmp(P x,P y){return x.y<y.y;}
struct node{int l,r,mx,tag;}T[N];
inline void down(int o)
{	T[o].mx+=T[o].tag;
	if(T[o].l!=T[o].r) T[o+o].tag+=T[o].tag,T[o+o+1].tag+=T[o].tag; T[o].tag=0;
}
inline void update(int o)
{	if(T[o+o].tag) down(o+o); if(T[o+o+1].tag) down(o+o+1);
	T[o].mx=max(T[o+o].mx,T[o+o+1].mx);
}
void build(int l,int r,int o)
{	T[o].l=l; T[o].r=r; T[o].tag=0;
	if(l==r){T[o].mx=m+a[l].y;return;}
	int mid=(l+r)>>1;
	build(l,mid,o+o); build(mid+1,r,o+o+1);
	update(o);
}
void add(int l,int r,int k,int o)
{	if(T[o].tag) down(o);
	if(T[o].l==l&&T[o].r==r){T[o].tag+=k;down(o);return;}
	int mid=(T[o].l+T[o].r)>>1;
	if(r<=mid) add(l,r,k,o+o);
	else if(l>mid) add(l,r,k,o+o+1);
	else add(l,mid,k,o+o),add(mid+1,r,k,o+o+1);
	update(o);
}
int query(int l,int r,int o)
{	if(T[o].tag) down(o);
	if(T[o].l==l&&T[o].r==r) return T[o].mx;
	int mid=(T[o].l+T[o].r)>>1;
	if(r<=mid) return query(l,r,o+o);
	else if(l>mid) return query(l,r,o+o+1);
	else return max(query(l,mid,o+o),query(mid+1,r,o+o+1));
}
inline void solve()
{	int top1=0,top2=0,t1=0,t2=0,p1,p2; a[t+1].y=n;
	sort(a+1,a+t+1,cmp); build(1,t+1,1);
	for(rint i=1;i<=t;i++)
	if(a[i].x<=m/2) b[++t1]=a[i],b[t1].id=i; else c[++t2]=a[i],c[t2].id=i;
	b[t1+1].y=c[t2+1].y=n+1; b[t1+1].x=0; c[t2+1].x=m;
	b[t1+1].id=c[t2+1].id=t+1; p1=t1+1; p2=t2+1;
	sort(b+1,b+t1+1,cmp); sort(c+1,c+t2+1,cmp);
//	for(rint i=1;i<=t2+1;i++) cerr<<"!!!"<<c[i].x<<" "<<c[i].y<<endl;
//	debug(query(6,6,1));
	for(rint j=t+1;j>=1;j--)
	{//	debug(j);debug(a[j].x);debug(a[j].y);
	//	if(j==2) debug(query(t+1,t+1,1));
		if(j==t+1||a[j].x<=m/2)
		{//	debug(b[p1].x);debug(b[p1].y);
			if(top1) add(j+1,b[s1[top1]].id,-b[p1].x,1);
			for(;top1>1&&b[s1[top1]].x<b[p1].x;top1--)
			add(b[s1[top1]].id+1,b[s1[top1-1]].id,b[s1[top1]].x-b[p1].x,1);
		//	if(j==1) fgx,fgx,debug(query(4,4,1)-a[j-1].y);
			s1[++top1]=p1--; 
		}
		if(j==t+1||a[j].x>m/2)
		{	if(top2) add(j+1,c[s2[top2]].id,c[p2].x-m,1);
			for(;top2>1&&c[s2[top2]].x>c[p2].x;top2--)
			add(c[s2[top2]].id+1,c[s2[top2-1]].id,c[p2].x-c[s2[top2]].x,1);
			s2[++top2]=p2--;
		}
	//	debug(a[4].x);debug(a[4].y);debug(query(4,4,1)-a[j-1].y);
	//	debug(query(t+1,t+1,1)-a[j-1].y);
	//	debug(j);debug((j==t+1));
	//	debug(query(t+1,t+1,1)-a[j-1].y);
	//	debug(query(j,t+1,1)-a[j-1].y);
		ans=max(ans,query(j,t+1,1)-a[j-1].y);
	}
}
int main()
{//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	int tt,x,y; cin>>m>>n>>tt; ans=max(n,m)+1;
	for(rint i=1;i<=tt;i++){scanf("%d%d",&x,&y);if(x!=m&&y!=n)a[++t].x=x,a[t].y=y;}
	solve();
	swap(n,m); for(rint i=1;i<=t;i++) swap(a[i].x,a[i].y);
	solve();
	cout<<ans*2;
	return 0;
}


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

long long N,arr[300001];

int main(){
	cin>>N;
	for(int i=0; i<3*N; i++){
		cin>>arr[i];
	}
	sort(arr,arr+3*N);
	long long total=0,sum=0;
	for(int i=3*N-1; i>=0; i--){
		if((3*N-i)%2==0&&total<N){
			sum+=arr[i];
			total++;
		}
	}
	cout<<sum<<'\n';
}

Measured memory_bytes: 5860
#include<bits/stdc++.h>
using namespace std;
int ans;
int main(){
    int N,K;
    cin>>N>>K;
    if(N==0){
        N=1;
    }
    else if(N==1){
        N=100;
    }
    else {
        N=10000;
    }
    if(K==100){
        cout<<N*101;
    }
    else cout<<N*K;
    return 0;
}


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



int main (){
    int D, N;
    cin>>D>>N;
    if(N<100){
        cout<<pow(100, D)*N;
    }
    else{
      	cout<<101;
      	for(int i=0; i<D*2; i++){
          cout<<0;
        }
    }
}

Measured memory_bytes: 384
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 10010010010010;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

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

    int N;cin >> N;
    vector<long long> retu(N);
    vector<long long> dict(100005);
    long long ans = 0;
    for(int i = 0;i<N;i++){
        cin >> retu.at(i);
        dict.at(retu.at(i))++;
        ans += retu.at(i);
    }
    int Q;cin >> Q;
    for(int i = 0;i<Q;i++){
        long long from,to;cin >> from >> to;
        long long fromCount = dict.at(from);
        long long minus = fromCount*from;
        long long plus = fromCount*to;
        dict.at(from) = 0;
        dict.at(to) += fromCount;
        cout << ans-minus+plus << endl;
        ans += plus;
        ans -= minus;
    }
}


Measured memory_bytes: 4744
#include<bits/stdc++.h>
using namespace std;
#define int     long long
#define F       first
#define S       second
#define _READ   freopen("input.txt","r", stdin);
#define _FAST   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
void solve()
{
    string s;
    cin>>s;
    if(s[0]=='7' || s[1]=='7' || s[2]=='7')
        cout<<"Yes";
    else
    {
        cout<<"No";
    }
    
}
int32_t main()
{
    clock_t tStart = clock();
    #ifndef ONLINE_JUDGE
    _READ
    #endif
    
    int t;
    t=1;
    while(t--)
        solve();
    
    #ifndef ONLINE_JUDGE
    cout<<fixed<<setprecision(5)<<"\nTime taken: "<<(double)(clock() - tStart)/CLOCKS_PER_SEC;
    #endif
    
    return 0;
}
/*
===FOR N-Dimensional Vector===
https://codeforces.com/blog/entry/76149
g++ -std=c++17 -Wshadow -Wall -g -fsanitize=address -fsanitize=undefined a.cpp -o a -D_GLIBCXX_DEBUG
*/

Measured memory_bytes: 3632
package main

import "fmt"

func main() {

	var (
		n int
		m int
		c int
	)

	fmt.Scan(&n)
	fmt.Scan(&m)
	fmt.Scan(&c)

	var a int
	var memo int
	b := make([]int, m)

	for i := 0; i < m; i++ {
		fmt.Scan(&b[i])
	}

	for i := 0; i < n; i++ {
		ans := 0
		for j := 0; j < m; j++ {
			fmt.Scan(&a)
			ans += a * b[j]
		}
		ans += c
		if ans > 0 {
			memo++
		}
	}

	fmt.Print(memo)

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
using namespace std;
vector<ll> nex[100009],used(100009,0),col(100009,-1);
int main(){
	ll n,m,is=0,nb=0,nnb=0;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		ll x,y;
		cin>>x>>y;
		nex[x].pb(y);
		nex[y].pb(x);
	}
	for(int i=1;i<=n;i++){
		if(used[i]==0){
			used[i]=1;
			if(nex[i].size()==0){
				is++;
			}
			else{
				queue<ll> que;
				vector<ll> old;
				que.push(i);
				old.pb(i);
				col[i]=0;
				ll fl=0;
				while(!que.empty()){
					ll cur = que.front(); que.pop();
					used[cur]=1;
					for(int j=0;j<nex[cur].size();j++){
						if(used[nex[cur][j]]==0){
							que.push(nex[cur][j]);
							old.pb(nex[cur][j]);
							if(col [ nex[cur][j] ] == -1){
								col [ nex[cur][j] ] = col [cur] +1;
							}
							if( (col[nex[cur][j]]-col[cur])%2!=1){
								if(fl==0){
									fl=1;
									nnb++;
								}
							}
						}
					}
				}
				if(fl==0)nb++;
				for(int i=0;i<old.size();i++){
					used[ old[i] ] =1;
				}
			}
		}
	}
	//cout<<is<<" "<<nb<<" "<<nnb<<endl;
	cout<< 2*n*is - is*is + 2*nb*nb + 2*nb*nnb + nnb*nnb<<endl;
	return 0;
}

Measured memory_bytes: 17500
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a=sc.nextLine();
		String b=sc.nextLine();
		String s=a+a;
		if(s.indexOf(b)!=-1){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		}


}


Measured memory_bytes: 26320
n = int(input())
a = []
for i in range(n):
    a.append([int(num) for num in input().split()])
#print(a)

ans = True
for i in range(n):
#    print(a[i][0])
#    print(a[i][1] + a[i][2])
    if(a[i][0] >= (a[i][1] + a[i][2])):
        if(a[i][0]%2 != (a[i][1] + a[i][2])%2):
            ans = False
            break
    else:
        ans = False
        break
    
if(ans):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 21156
#include <stdio.h>

int main(void)
{
    int i,j,x;
    int a[10000];

    for(i=1;;i++){
        scanf("%d",&x);

        if(x==0){
            break;
        }

    a[i]=x;
    }

    for(j=1;j<i;j++){
        printf("Case %d: %d\n",j,a[j]);
    }

    return 0;
}





Measured memory_bytes: 2704
package main

import (
	"bufio"
	"fmt"
	"math/bits"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

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

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

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func popCount(X []byte) int {
	cnt := 0
	for _, v := range X {
		if v == '1' {
			cnt++
		}
	}
	return cnt
}

func g(x int) int {
	cnt := 0
	for x > 0 {
		cnt++
		x = x % bits.OnesCount(uint(x))
	}
	return cnt
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N := getInt()
	X := []byte(getString())

	popcount := popCount(X)
	popcount1 := popcount - 1
	popcount0 := popcount + 1

	mod1 := 0
	mod0 := 0
	for i := 0; i < N; i++ {
		if popcount1 != 0 {
			mod1 = mod1*2 + int(X[i]-'0')
			mod1 %= popcount1
		}
		mod0 = mod0*2 + int(X[i]-'0')
		mod0 %= popcount0
	}

	// f := make([]int, 220000)
	// f[0] = 0
	// popcnt := make([]int, 220000)
	onePow2 := make([]int, 220000)
	zeroPow2 := make([]int, 220000)
	onePow2[0] = 1
	zeroPow2[0] = 1
	for i := 1; i < 220000; i++ {
		// popcnt[i] = popcnt[i/2] + i%2
		// f[i] = f[i%popcnt[i]] + 1

		onePow2[i] = 1
		zeroPow2[i] = 1
		if popcount1 != 0 {
			onePow2[i] = onePow2[i-1] * 2 % popcount1
		}
		zeroPow2[i] = zeroPow2[i-1] * 2 % popcount0
	}

	for i := N - 1; i >= 0; i-- {
		if X[N-1-i] == '1' {
			if popcount1 != 0 {
				next := mod1
				next -= onePow2[i]
				next %= popcount1
				if next < 0 {
					next += popcount1
				}
				out(g(next) + 1)
				// out(f[next] + 1)
			} else {
				out(0)
			}
		} else {
			next := mod0
			next += zeroPow2[i]
			next %= popcount0
			out(g(next) + 1)
			// out(f[next] + 1)
		}
	}
}


Measured memory_bytes: 7444
import sys
sys.setrecursionlimit(1000000)
n,m = map(int,input().split())
p = 10**9 + 7

def fact(n):
  if n == 1:
    return 1
  return n*fact(n-1)%p

if abs(n-m) >1:
  print(0)
elif abs(n-m) == 1:
  print(fact(n)*fact(m)%p)
else:
  print(2*fact(n)*fact(m)%p)

Measured memory_bytes: 83316
N, K = map(int, input().split())
X = list(map(int, input().split()))

ans = 1e9
for i in range(N - K + 1):
    x1, x2 = X[i], X[i + K - 1]
    if x2 <= 0:
        r = -x1
    elif x1 >= 0:
        r = x2
    else:
        r = min(2*x2 - x1, x2 - 2*x1)
    ans = min(ans, r)
print(ans)

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

int main(){
	int n; cin>>n;
	char s[100];
	bool flag=false;
	for(int i=0;i<n;i++) cin >> s[i];
	for(int i=0;i<n;i++){
		if(s[i]=='Y') flag=true;
	}
	if(flag) cout << "Four" << endl;
	else cout << "Three" << endl;
}


Measured memory_bytes: 256
n = int(input())
l = [0] * 100
l[0] = 2
l[1] = 1
if n == 1:
    ans = l[1]
else:
    for i in range(2, n + 1):
        l[i] = l[i - 1] + l[i - 2]
    ans = l[n]
print(ans)


Measured memory_bytes: 9172
#include<stdio.h>
int main(){
  int n;
  int max=0;
  int max1=0;
  int count=0;
  int a[200000];
  int ans;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(a[i]>max){
      max1=max;
      max=a[i];
    }
    else if(a[i]>max1){
      max1=a[i];
    }
  }
  
  for(int i=0;i<n;i++){
    if(max==a[i]){
      count+=1;
    }
  }
  
  for(int i=0;i<n;i++){
    if(count!=1){
      ans=max;
    }
    else{
      if(a[i]==max){
        ans=max1;
      }
      else{
        ans=max;
      }
    }
          printf("%d\n",ans);
  }
    
  return 0;
}




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

void Main()
{
    int n, q;
    string s;
    cin >> n >> s >> q;
    vector<set<int>> bs(27);
    for (int i = 0; i < n; i++)
    {
        bs[s[i]-'a'].insert(i);
    }
    for (int i = 0; i < q; i++)
    {
        int o;
        cin >> o;
        if(o == 1){
            int p;
            char c;
            cin >> p >> c;
            p--;
            if(s[p] != c) {
                bs[s[p]-'a'].erase(p);    
                bs[c-'a'].insert(p);
                s[p] = c;
            }
        }else{
            int l, r;
            cin >> l >> r;
            l--; r--;
            int ct = 0;
            for (int j = 0; j < 27; j++)
            {
                auto cl = bs[j].lower_bound(l);
                if(cl != bs[j].end() && *cl <= r) ct++;
            }
            cout << ct << endl;
        }
    }
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 27204
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int d[222][222];
int main()
{
	int num, way, gen;
	scanf("%d%d%d", &num, &way, &gen);
	vector<int>v;
	for (int i = 0; i < gen; i++)
	{
		int z;
		scanf("%d", &z);
		z--;
		v.push_back(z);
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < num; i++)for (int j = 0; j < num; j++)d[i][j] = 1000000000;
	for (int i = 0; i < way; i++)
	{
		int za, zb, zc;
		scanf("%d%d%d", &za, &zb, &zc);
		za--, zb--;
		d[za][zb] = d[zb][za] = zc;
	}
	for (int i = 0; i < num; i++)d[i][i] = 0;
	for (int i = 0; i < num; i++)for (int j = 0; j < num; j++)for (int k = 0; k < num; k++)d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
	int mini = 2100000000;
	for (;;)
	{
		int sum = 0;
		for (int i = 0; i < gen - 1; i++)sum += d[v[i]][v[i + 1]];
		mini = min(mini, sum);
		if (!next_permutation(v.begin(), v.end()))break;
	}
	printf("%d\n", mini);
}

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

typedef long long ll;
typedef pair<ll, ll> P;

int N, M;

int main(){
    cin >> N >> M;

    if(N == 2 || M == 2){
        cout << 0 << endl;
        return 0;
    }
    if(N == 1 || M == 1){
        cout << max({N-2, M-2, 1});
        return 0;
    }

    cout << (ll)(N-2) * (M-2) << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
struct Man {
	int l;
	int bit;
};
int N, M, a, b;
int main() {
	while (cin >> N, N) {
		vector<Man> D(N);
		for (int i = 0; i < N; i++) {
			cin >> M >> D[i].l;
			for (int j = 0; j < M; j++) {
				cin >> a >> b;
				for (int k = a - 6; k < b - 6; k++) D[i].bit |= (1 << k);
			}
		}
		vector<vector<int> > dp(N + 1, vector<int>(1 << 16));
		for (int i = 1; i <= N; i++) {
			for (int j = 1; j < 1 << 16; j++) {
				dp[i][j] = dp[i - 1][j];
				if (~j & D[i - 1].bit) continue;
				dp[i][j] = max(dp[i][j], dp[i - 1][j - D[i - 1].bit] + D[i - 1].l);
			}
		}
		cout << dp[N][(1 << 16) - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 28932
#include <iostream>
#include <vector>
#define INF 1e9
using namespace std;

int main(){
    //declaration and input
    int n;
    cin >> n;
    int u, k;
    vector<vector<int>> graph(n, vector<int>(n, INF));
    for (int i = 0; i < n; i++){
        cin >> u >> k;
        int v, c;
        for (int j = 0; j < k; j++){
            cin >> v >> c;
            graph[u][v] = c;
        }
    }
    vector<int> cost(n, INF);
    vector<int> parent_of(n, -1);
    vector<bool> is_visit(n, false);

    //Dijkstra
    //init
    cost[0] = 0;
    
    //loop
    while(true){
        int mincost = INF;
        int next = -1;
        for (int i = 0; i < n; i++){
            if (!is_visit[i] && cost[i] < mincost){
                mincost = cost[i];
                next = i;
            }
        }
        if (next == -1)
            break;
        is_visit[next] = true;
        for (int i = 0; i < n; i++){
            if (!is_visit[i] && graph[next][i] < INF){
                if (cost[next] + graph[next][i] < cost[i]){
                    cost[i] = cost[next] + graph[next][i];
                    parent_of[i] = next;
                }
            }
        }
    }

    //output
    for (int i = 0; i < n; i++)
        cout << i << ' ' << cost[i] << endl;
    return 0;
}


Measured memory_bytes: 3180
a = [int(input()) for _ in range(5)]
b = [n for n in a if n % 10 == 0]  # 余り0
c = [n for n in a if n % 10 > 0]  # 余り0でない

res = sum(b)
if c:  # not empty
    r = min(n % 10 for n in c)
    res += sum((n // 10 + 1) * 10 for n in c) - 10 + r

print(res)


Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <deque>
#include <string>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(A);
    scanInt(B);
    scanInt(C);
    if (A == B){
        printf("%d\n", C);
    }else if (B == C){
        printf("%d\n", A);
    }else{ // A == C
        printf("%d\n", B);
    }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

const int INF = 1 << 30;
const uint64_t MOD = 1000000000 + 7;

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

	vector<int> l(n + 1);
	l.at(0) = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> l.at(i);
	}

	int d = 0;
	int cnt = 0;
	for (int i = 0; i <= n; i++)
	{
		d = d + l.at(i);
		if (d <= x)
		{
			cnt++;
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main { //クラス名はMain
    public static void main(String[] args) {
      //整数の入力
      Scanner sc = new Scanner(System.in);
      int A = Integer.parseInt(sc.next());

      int mai = A%1000 == 0 ? A/1000 : A/1000 + 1;

      int oturi =  (mai*1000) - A;

      System.out.println(oturi);
    }  
}


Measured memory_bytes: 35612
while (n=gets.chomp.split.map(&:to_i)).uniq[0] !="-1"&&n.uniq.size !=1
unless n[0]==-1||n[1]==-1
case (n[0]+n[1])
when 80..100;puts "A"
when 65...80;puts "B"
when 50...65;puts "C"
when 30...50;puts n[2]>=50? "C" : "D"
else;puts "F";end
else;puts "F";end
end


Measured memory_bytes: 6876
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        // Codes for input goes here
        int A = scn.nextInt();
        int B = scn.nextInt();
        scn.close();
        B = 2 * B;
        int diff = A - B;
        if(diff<0)
            diff =0;
        System.out.println(diff);

    }
}

Measured memory_bytes: 22868
n = int(input())
b = list(map(int,input().split()))
op = []
while b:
    cur = 0
    for i in range(len(b)):
        if b[i] == i+1:
             cur = max(cur,i+1)
        else:
            continue
    if cur == 0:
        print(-1)
        exit()
    else:
        op.append(cur)
        b = b[0:cur-1]+b[cur:]
for i in range(n):
    print(op.pop())

Measured memory_bytes: 38896
def main():
    H, W = map(int, raw_input().split())
    G = [list(raw_input()) for i in range(H)]


    up = [[0] * W for i in range(H)]  # あるマスから上に連続していくつ障害物のないマスが続くか
    right = [[0] * W for i in range(H)]  # あるマスから右に連続していくつ障害物のないマスが続くか
    down = [[0] * W for i in range(H)]  # あるマスから下に連続していくつ障害物のないマスが続くか
    left = [[0] * W for i in range(H)]  # あるマスから左に連続していくつ障害物のないマスが続くか


    # up
    for w in range(W):
        for h in range(1, H):
            if G[h - 1][w] == '#':
                continue
            up[h][w] = up[h - 1][w] + 1

    # right
    for h in range(H):
        for w in reversed(range(W - 1)):
            if G[h][w + 1] == '#':
                continue
            right[h][w] = right[h][w + 1] + 1

    # down
    for w in range(W):
        for h in reversed(range(H - 1)):
            if G[h + 1][w] == '#':
                continue
            down[h][w] = down[h + 1][w] + 1

    # left
    for h in range(H):
        for w in range(1, W):
            if G[h][w - 1] == '#':
                continue
            left[h][w] = left[h][w - 1] + 1


    ans = 0
    for h in range(H):
        for w in range(W):
            if G[h][w] == '#':
                continue
            ans = max(ans, up[h][w] + right[h][w] + down[h][w] + left[h][w] + 1)

    print(ans)


if __name__ == '__main__':
    main()

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

int main() {
  int a, b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  if (a == 0){
    cout << 1 << endl;
  }
  if (b == 0){
    cout << 2 << endl;
  }
  if (c == 0){
    cout << 3 << endl;
  }
  if (d == 0){
    cout << 4 << endl;
  }
  if (e == 0){
    cout << 5 << endl;
  } 
  
}

Measured memory_bytes: 3584
#include<stdio.h>
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
int c[26],s[365][26]={{0}},type[365];
void solve(int d)
{
  int since[26]={0};
  for(int i=0;i<d;i++)
  {
    int max=1<<31,now=-1,keep;
    for(int j=0;j<26;j++){keep=s[i][j]-c[j]*(i-since[j]);if(max<keep){max=keep;now=j;}}
    type[i]=now;since[now]=i;
  }
}
int main()
{
  int D=IN(),i=0,j=0;
  while(i<26){c[i++]=IN();}i=0;
  while(i<D){while(j<26){s[i][j++]=IN();}i++,j=0;}i=0;
  solve(D);
  while(i<D){printf("%d\n",type[i++]+1);}
}

Measured memory_bytes: 1616
n = int(input())
ab=[list(map(int,input().split())) for i in range(n)]
cnt=0
for i in reversed(range(n)):
    a,b=ab[i]
    a+=cnt
    if a%b==0:
        continue
    if a<=b:
        cnt+=(b-a)
        continue
    cnt += -(-a//b) * b - a
print(cnt)

Measured memory_bytes: 60888
#include <iostream>
#include <algorithm>
using namespace std;
#define int long long
#define INF 0x3f3f3f3f
const int maxn = 1e5 + 10;

int n , k , a [ maxn ];
int sum_min = INF , sum , ret , fir;

inline int read ( )
{
	register int s = 0 , t = 1; register char ch = getchar ( );
	while ( !isdigit ( ch ) ) { if ( ch == '-' ) t = -1; ch = getchar ( ); }
	while ( isdigit ( ch ) ) { s = ( s << 3 ) + ( s << 1 ) + ( ch ^ 48 ); ch = getchar ( ); }
	return s * t;
}

signed main ( void )
{
	n = read ( ); k = read ( );
	for ( int i = 1 ; i <= n ; i++ ) {
		a [ i ] = read ( );
		if ( a [ i - 1 ] < 0 && a [ i ] >= 0 ) ret = i - 1;
	}
	if ( ret == 0 && a [ 1 ] > 0 ) {
		cout << a [ k ] << endl;
		return 0;
	} else if ( ret == 0 && a [ 1 ] < 0 ) {
		cout << abs ( a [ n - k + 1 ] ) << endl;
		return 0;
	}
	if ( ret <= k ) {
		fir = 1;
	} else {
		fir = ret - k + 1;
	}
	for ( int i = fir ; i <= ret + 1 && i + k - 1 <= n ; i++ ) {
		sum_min = min ( ( abs ( a [ i ] ) ) * 2 + abs ( a [ i + k - 1 ] ) , sum_min );
		sum_min = min ( ( abs ( a [ i + k - 1 ] ) ) * 2 + abs ( a [ i ] ) , sum_min );
	}
	cout << sum_min << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;

LL n,l,id = -1;
LL a[200005];

int main(){
	ios::sync_with_stdio(false);
	cin >> n >> l;
	for(LL i = 1;i <= n;i ++) cin >> a[i];
	for(LL i = 1;i < n;i ++) if(a[i] + a[i + 1] >= l) id = i;
	if(id == -1) cout << "Impossible" << endl;
	else{
		cout << "Possible" << endl;
		for(LL i = 1;i < id;i ++) cout << i << endl;
		for(LL i = n - 1;i > id;i --) cout << i << endl;
		cout << id << endl;
	}
	return 0;
}
//

Measured memory_bytes: 1664
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

typedef long long ll;

int main(void)
{
    long long a, b, n;
    cin >> a >> b >> n;
    if (b - 1 <= n)
    {
        // n = b -1
        cout << a * (b - 1) / b << endl;
    }
    else
    {
        cout << n * a / b << endl;
    }
}

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

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  bool have = true;
  if(e - a > k){
    have = false;
  }
  
  if(have){
    cout << "Yay!";
  }
  if(!have){
    cout << ":(";
  }
  return 0;
}

Measured memory_bytes: 256