akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_A&lang=jp

#define MAX 1000005
#define NIL -1

int n;
struct Node
{
    int l, r, p;
};
Node T[MAX];
int D[MAX];

static void setDepth(int id, int d) {
    D[id] = d;
    if (T[id].l != NIL) setDepth(T[id].l, d+1);
    if (T[id].r != NIL) setDepth(T[id].r, d);
}

static void print(int id) {
    cout << "node " << id << ": ";
    cout << "parent = " << T[id].p << ", ";
    cout << "depth = " << D[id] << ", ";
    if (T[id].p == NIL) cout << "root, ";
    else if (T[id].l == NIL) cout << "leaf, ";
    else cout << "internal node, ";

    int cnt = 0;
    cout << "[";
    for (int c  = T[id].l; c != NIL; c = T[c].r) {
        if (cnt) cout << ", ";
        cnt++;
        cout << c;
    }
    cout << "]\n";

}


int main() {
    cin >> n;
    REP(i, n) T[i].l = T[i].r = T[i].p = NIL;
    REP(i, n) {
        int id, deg; cin >> id >> deg;
        int l = 0;
        REP(j, deg) {
            int c; cin >> c;
            if (j == 0) T[id].l = c;
            else T[l].r = c;
            l = c;
            T[c].p = id;
        }
    }

    int root = 0;
    REP(i, n) if (T[i].p == NIL) root = i;
    setDepth(root, 0);

    REP(i, n) print(i);

    return 0;
}



Measured memory_bytes: 4660
n = int(input())

red = []

for i in range(n):
	red.append(map(int,raw_input().split()))

blue = []

for i in range(n):
	blue.append(map(int,raw_input().split()))


redflug = []
for i in range(n):
	redflug.append(0)

blue.sort()

ans = 0
for i in range(n):
	t = -1
	maxy = -1
	for j in range(n):
		if redflug[j] == 0 and blue[i][0] > red[j][0] and blue[i][1] > red[j][1] and red[j][1] > maxy :
			t = j
			maxy = red[j][1]

	if t != -1 :
		redflug[t] = 1
		ans += 1

print ans

Measured memory_bytes: 2696
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define md 998244353
#define trace(...)
#define ll long long int
#define ld long double
#define fi first
#define se second
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define frr(i,b,a) for(ll i=b;i>=a;i--)
#define mem(a) memset(a, 0, sizeof(a))
#define vpi std::vector<pair<int,int>>
#define pii pair<int,int>
#define pb push_back
#define sall(v) sort(v.begin(),v.end())
#define all(v) (v.begin(),v.end())
#define minf -10000000
#define vi vector<int>
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}
ll power(ll x, ll y,ll p) { 
    ll res = 1;      
    x = x % p;  
    while (y > 0) {  
        if (y & 1){  
            res = (res*x) % p;  
        }
        y = y>>1;
        x = (x*x) % p;   
    } 
    return res; 
}
ll power(ll x, ll y) { 
    ll res = 1;       
    while (y > 0) {    
        if (y & 1) 
            res = (res*x) ;  
        y = y>>1; 
        x = (x*x);   
    } 
    return res; 
}
 
ll max3(ll a,ll b,ll c){
    return max(a,max(b,c));
}
ll min3(ll a,ll b,ll c){
    return min(a,min(b,c));
}
bool isPrime(ll n) { // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}
const int nax=2e5+5;
void solve(){
    int n;cin>>n;
    vector<ll> v(n);fr(i,0,n-1)cin>>v[i];
    ll cnt=0,mx=v[0];
    fr(i,1,n-1){cnt+=max(0ll,mx-v[i]);mx=max(mx,v[i]);}
    cout<<cnt<<endl;
    return;
}

int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout<<fixed<<setprecision(8);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    int t;
    // cin>>t;
    t=1;
    while(t--){
        solve();
    }
    #ifndef ONLINE_JUDGE
    cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
    #endif
    return 0;
}

Measured memory_bytes: 4808
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
#import math
#import time
import random  # randome is not available at Codeforces
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
#eps=10**(-10)
#ts=time.time()
#sys.setrecursionlimit(10**6)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
#show_flg=True

n=I()
if n%2==0:
    ans=n//2-1
else:
    ans=n//2

#for _ in range():
    

print(ans)


Measured memory_bytes: 39536
// ---------- begin chmin, chmax ----------
trait ChangeMinMax {
    fn chmin(&mut self, x: Self) -> bool;
    fn chmax(&mut self, x: Self) -> bool;
}

impl<T: PartialOrd> ChangeMinMax for T {
    fn chmin(&mut self, x: Self) -> bool {
        *self > x && {
            *self = x;
            true
        }
    }
    fn chmax(&mut self, x: Self) -> bool {
        *self < x && {
            *self = x;
            true
        }
    }
}
// ---------- end chmin, chmax ----------

use proconio::*;
use proconio::marker::*;

fn run() {
    input! {
        h: usize,
        w: usize,
        s: [Bytes; h],
    }
    let mut ans = std::cmp::max(h, w);
    let mut height = vec![1; w];
    height[w - 1] = 0;
    let mut stack: Vec<(usize, usize)> = vec![];
    for i in 1..h {
        stack.clear();
        for j in 0..w {
            if j + 1 < w {
                let mut cnt = 0;
                for (x, y) in [(!0, 0), (!0, 1), (0, 0), (0, 1)].iter() {
                    cnt += (s[i + x][j + y] == b'#') as usize;
                }
                if cnt & 1 == 0 {
                    height[j] += 1;
                } else {
                    height[j] = 1;
                }
            }
            let mut p = j;
            while stack.last().map_or(false, |p| p.0 > height[j]) {
                let (x, y) = stack.pop().unwrap();
                p = y;
                ans.chmax(x * (j + 1 - y));
            }
            stack.push((height[j], p));
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 10060
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int n, m;
map<string, int> mp;
int main()
{
	cin >> n;
	REP(i, 0, n) {
		string s;
		cin >> s;
		mp[s]++;
	}
	cin >> m;
	REP(i, 0, m) {
		string s;
		cin >> s;
		mp[s]--;
	}
	int ans = 0;
	for (auto itr : mp) {
		ans = max(ans, itr.second);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <climits>

using namespace std;

int main(void)
{
    int tests;
    tests = 1;
    // cin >> tests;
    for(int test = 0;test < tests;test++)
    {
        int n;
        cin >> n;
        long long two = 1;
        while(two <= n)
        {
            two *= 2;
        }
        cout << two/2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
s=input()
t=input()
n=0
c=0
for e in t:
    try:
        i=s[c:].index(e)
        n+=i+1
        c=(c+i+1)%len(s)
    except ValueError:
        try:
            i=s.index(e)
            n+=len(s)-c+i+1
            c=i+1
        except ValueError:
            n=-1
            break
print(n)

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

int main()
{
    int s , w ;
    cin >> s >> w ;
    if(s<=w)
    {
        cout << "unsafe" << endl ;
    }
    else
    {
        cout << "safe" << endl ;
    }
    
}

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

char chs[10][10]={
  " ",
  "',.!?",
  "abcABC",
  "defDEF",
  "ghiGHI",
  "jklJKL",
  "mnoMNO",
  "pqrsPQRS",
  "tuvTUV",
  "wxyzWXYZ",
};

int idx;
char s[10002];

void printChar(void){
  int count = 0;
  char ch = s[idx];

  idx++;

  for(;s[idx]==ch;idx++,count++);

  if(ch == '0'){
    while(count-- > 0) cout<<" ";
    return;
  }

  cout<<chs[ch-'0'][count%strlen(chs[ch-'0'])];
}

int main(void){
  while(cin>>s){
    for(idx=0;idx<strlen(s);){
      printChar();
    }
    cout<<endl;
  }

  return 0;
}

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

int main()
{
    // 変数の宣言
    int n = 0;
    int a = 0;

    // 変数の入力を受け取る
    cin >> n;
    cin >> a;

    // 出力
    cout << n * n - a << endl;
}


Measured memory_bytes: 3592
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

#define un(x)           x.erase(unique(all(x)), x.end())
#define xx              first
#define yy              second
#define pb              push_back
#define all(v)          v.begin(), v.end()

#define D(x)            cerr << #x " = " << x << '\n'
#define DBG             cerr << "Hi!" << '\n'

#define CLR(a)          memset(a, 0, sizeof(a))
#define SET(a)          memset(a, -1, sizeof(a))

inline int setBit(int n, int pos) { return n = n | (1 << pos); }
inline int resetBit(int n, int pos) { return n = n & ~(1 << pos); }
inline bool checkBit(int n, int pos) { return (bool)(n & (1 << pos)); }

// int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
// int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1};

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// unsigned int num = rng();
// shuffle(V.begin(), V.end(), rng);

/******************************************************************************************/

// const int MAX = 500010;
// const int INF = 0x3f3f3f3f;
// const int MOD = 998244353;

// inline int add(int a, int b) { return a + b >= MOD ? a + b - MOD : a + b; }
// inline int sub(int a, int b) { return a - b < 0 ? a - b + MOD : a - b; }
// inline int mul(int a, int b) { return (a * 1LL * b) % MOD; }

string s[10];

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

    // freopen("in", "r", stdin); 
    // freopen("out", "w", stdout);
    
    int h, w, k;
    cin >> h >> w >> k;
    for(int i=0;i<h;i++) cin >> s[i];
    int ans = 0;
    for(int i=0;i<(1<<h);i++) {
        for(int j=0;j<(1<<w);j++) {
            int cnt = 0;
            for(int x=0;x<h;x++) {
                if(checkBit(i, x)) continue;
                for(int y=0;y<w;y++) {
                    if(checkBit(j, y)) continue;
                    if(s[x][y] == '#') cnt++;
                }
            }
            if(cnt == k) ans++;
        }
    }
    cout << ans << endl;
    
    return 0;
}


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

int main(){
  vector<int> vec(3);
    cin>>vec.at(0)>>vec.at(1)>>vec.at(2);
  
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  cout<<vec.at(0)*10+vec.at(1)+vec.at(2)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  
  int p, w, g, y;
  p = 0;
  w = 0;
  g = 0;
  y = 0; //def
  
  for ( int i = 0; i < N; i++ ){
    string S;
    cin >> S;
    
    if ( S == "P"){
      p = 1;
    }
    
    else if ( S == "W"){
      w = 1;
    }
    
    else if ( S == "G"){
      g = 1;
    }
    else {
      y = 1;
    }
  }

  //display
  if ( p + w + g + y == 3){
    cout << "Three" << endl;
  }
  else {
    cout << "Four" << endl;
  }
}
      

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

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; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int n, m; cin >> n >> m;
    int loss = m * 1900 + (n - m) * 100;
    print(loss * (1 << m));

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  long long a,b,c,k;
  cin >> a >> b >> c >> k;
  bool flag = false;
  long long n = k%2==0?a-b:b-a;
  cout << n << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;



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

  ll A, B, K;
  cin >> A >> B >> K;
  cout << max((ll)0, A-K) << " " << max((ll)0, min(B, A+B-K)) << "\n";
  return 0;
}


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

const int N = 1e5 + 10;
int a[2 * N];

int check(int x, int k)
{
	if (x >= k) return 1;
	return 0;
}

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < 2 * n - 1; i++)
	{
		cin >> a[i];
	}
	int l = 1, r = 2 * n;
	while (r - l > 1)
	{
		int mid = (l + r) / 2;
		int f = 0, ans = 0;
		int indx = n - 1;
		for (int i = 1; i <= n - 1; i++)
		{
			if (check(a[indx + i], mid) == check(a[indx + i - 1], mid))
			{
				f = 1;
				ans = check(a[indx + i], mid);
				break;
			}
			if (check(a[indx - i], mid) == check(a[indx - i + 1], mid))
			{
				f = 1;
				ans = check(a[indx - i], mid);
				break;
			}
		}
		if (!f)
		{
			if (n % 2 == 0)
			{
				ans = 1 - check(a[indx], mid);
			}
			else
			{
				ans = check(a[indx], mid);
			}
		}
		if (ans == 1)
		{
			l = mid;
			continue;
		}
		r = mid;
	}
	cout << l;
}


Measured memory_bytes: 4324
n = int(input())
s = list(map(int, input().split()))

r = "YES"
cnt = 0
for i in range(n - 1):
	if(s[i + 1] - s[i] < 1):
		cnt += 1
		if(cnt == 1):
			a_value = s[i]
			a_index = i
		elif(cnt == 2):
			b_value = s[i + 1]
			b_index = i + 1
		elif(cnt > 2):
			r = "NO"
			break

if(cnt == 1):
	r = "NO"
elif(cnt == 2):
	s[a_index] = b_value
	s[b_index] = a_value
	if(s[a_index + 1] - s[a_index] < 1) or (s[b_index] - s[b_index - 1] < 1):
		r = "NO"

print (r)


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

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }

const int MAXN = 100000;

int n;
int a[MAXN];

int b[MAXN], nb;

int cnt[2 * MAXN + 1];

ll calc(int val) { // # medians <= val
	REPE(i, 2 * n) cnt[i] = 0;
	int at = n; ll ret = 0; ++cnt[at]; ll sum = 0;
	REP(i, n) {
		if (a[i] <= val) sum += cnt[at], ++at; else --at, sum -= cnt[at];
		ret += sum; ++cnt[at];
		//printf("\t%d: at=%d sum=%lld ret=%lld\n", i, at - n, sum, ret);
	}
	//printf("%d: %lld\n", val, ret);
	return ret;
}

void run() {
	scanf("%d", &n);
	REP(i, n) scanf("%d", &a[i]);

	nb = 0; REP(i, n) b[nb++] = a[i]; sort(b, b + nb); nb = unique(b, b + nb) - b;
	ll total = (ll)n*(n + 1) / 2;
	int l = -1, r = nb - 1; // (l,r] med of med <= b[i]
	while (l + 1 < r) {
		int m = l + (r - l) / 2;
		ll cur = calc(b[m]);
		if (2 * cur <= total)  l = m; else r = m;
	}
	printf("%d\n", b[r]);
}

int main() {
	run();
	return 0;
}


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

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

	//string s;
	int a,b;

	cin >> a >> b;
	
	vector<int> ans(3);
	
	ans[0]=a+b,ans[1]=a-b,ans[2]=a*b;
	
	sort(ans.begin(),ans.end());
	
	cout << ans[2] << "\n";
	
	
	return 0;

    }

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

char tu[maxn][maxn];
int dp[maxn][maxn];
int main(){
    int r,c;
    cin >> r >> c;
    getchar();
    for (int i=1; i<=r; i++){
        for(int j =1;j<=c;j++){
            scanf("%c",&tu[i][j]);
        }
        getchar();
    }
    if(tu[1][1]=='#'){
        dp[1][1]=1;
    }
    for (int i = 1; i <=r; i++){
        for(int j =1; j<=c;j++){
            if(i==1 && j == 1){
                continue;
            }
            if(i==1 && j!=1){
                if(tu[i][j]=='#')
                    dp[i][j]=dp[i][j-1]+(tu[i][j-1]=='.');
                else
                    dp[i][j]=dp[i][j-1];
                continue;
            }
            if(i!=1 && j==1){
                if(tu[i][j]=='#')
                    dp[i][j]=dp[i-1][j]+(tu[i-1][j]=='.');
                else
                    dp[i][j]=dp[i-1][j];
                continue;
            }
            if(tu[i][j]=='#'){
                dp[i][j]=min(dp[i-1][j]+(tu[i-1][j]=='.'),dp[i][j-1]+(tu[i][j-1]=='.'));
            }else{
                dp[i][j]=min(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    cout << dp[r][c];
}

Measured memory_bytes: 2688
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if(a>b){
            int d;
            d=a;
            a=b;
            b=d;
        }
        if(a>c){
            int d;
            d=a;
            a=c;
            c=d;
        }
        if(b>c){
            int d;
            d=b;
            b=c;
            c=d;
        }
        System.out.println(a+" "+b+" "+c);
        sc.close();
    }
}


Measured memory_bytes: 26340
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[int(_) for _ in input().split()]
    A.sort()
    A_cum=[0]*n
    A_cum[0]=A[0]
    for i in range(1,n):
        A_cum[i]=A_cum[i-1]+A[i]
    for i in range(n-2,-1,-1):
        if 2*A_cum[i]<A[i+1]:
            print(n-1-i)
            break
    else:
        print(n)


if __name__=='__main__':
    main()

Measured memory_bytes: 14304
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;



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

}

Measured memory_bytes: 256
def main() :
    n = int(input())
    nums = [int(i) for i in input().split()]
    exchange_count = 0

    for i in range(n) :
        min_idx = nums[i:].index(min(nums[i:]))
        if nums[i] != nums[min_idx + i] :
            exchange_count += 1
        nums[i], nums[min_idx + i] = nums[min_idx + i], nums[i]

    print(" ".join(map(str, nums)))
    print(exchange_count)

if __name__ == '__main__' :
    main()

Measured memory_bytes: 7788
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, string> pls;

int root[200010];

int main()
{
	int n,m;
	cin >> n >>  m;
	vector<pl> v(m);
	
	for (int i = 0; i < m; i++) {
		cin >> v[i].first >> v[i].second;
		if (v[i].first == 1) {
			root[v[i].second] = 1;
		}
	}

	for (int i = 0; i < m; i++) {
		if (root[v[i].first]) {
			if (v[i].second == n) {
				cout << "POSSIBLE" << endl;
				return 0;
			}
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}


Measured memory_bytes: 4096
/*input
2
5 2 8 5 1 5
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

ll a[maxn];

int main(){
	IOS;
	ll n;
	cin>>n;
	REP(i,3*n) cin>>a[i];
	sort(a,a+n*3);
	ll ans=0;
	for(int i=n;i<3*n;i+=2) ans+=a[i];
		cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    scanf("%d", &n);
    int a[n+1];
    for(int i = 0; i < n; i++) scanf("%d", &a[i]);
    vector<int> dp;
    dp.push_back(a[0]);
    for(int i = 1; i <= n-1; i++){
        if(a[i] > dp[dp.size()-1]){
            dp.push_back(a[i]);
        }
        else{
            *lower_bound(dp.begin(), dp.end(), a[i]) = a[i];
        }
    }
    printf("%d\n", dp.size());
    return 0;
}


Measured memory_bytes: 3840
#include <iostream>

using namespace std;

int main() {
    while(true) {
        int N;
        cin >> N;
        if(!N) break;
        int cnt = 0;
        for(int i = 1; i <= N; ++i) {
            int n = i;
            while(n > 0 && n % 5 == 0) {
                ++cnt;
                n /= 5;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

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

int main() {
    int n = 0, a[101] = {0};
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    for (int i = n - 1; i >= 0; --i) {
        cout << a[i];
        if (i != 0) {
            cout << " ";
        }
    }
    cout << endl;
}

Measured memory_bytes: 2908
n = gets.to_i
h = gets.split.map(&:to_i)

dh = Array.new(n)
dh[0] = 0
for i in 1..(n-1)
  dh[i] = h[i] - h[i-1]
end

flag = 1
sum = 0
for i in 0..(n-1)
  if dh[i] <= -2
    flag = 0
    break
  elsif dh[i] == -1
    sum += dh[i]
    if sum <= -2
      flag = 0
      break
    end
  elsif dh[i] >= 1
    sum = 0
  end
end
if flag == 1
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 9356
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <iomanip>
#include <queue>
#include <string>
#include <map>
#include <fstream>
#include <cassert>
#include <stack>
#include <climits>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <memory>
#include <functional>
#include <cfloat>
#include <numeric>
#include <random>


int main() {
	int n; std::cin >> n;
	std::vector<long long int> nums(3 * n);
	for (auto& a : nums) std::cin >> a;
	std::priority_queue<long long int, std::vector<long long int>, std::greater<>> min_queue;
	long long int sum{ 0 };
	std::vector<long long int> max(3 * n, LLONG_MIN);
	for (auto i = 0; i < nums.size(); ++i) {
		min_queue.push(nums[i]);
		sum += nums[i];
		if (min_queue.size() > n) {
			sum -= min_queue.top();
			min_queue.pop();
		}
		if (min_queue.size() == n) {
			max[i] = sum;
		}
	}
	std::priority_queue<long long int> max_queue;
	sum = 0;
	long long int result{ LLONG_MIN };
	for (auto i = nums.size() - 1; i >= n; --i) {
		sum += nums[i];
		max_queue.push(nums[i]);
		if (max_queue.size() > n) {
			sum -= max_queue.top();
			max_queue.pop();
		}
		if (max_queue.size() == n) {
			result = std::max(max[i - 1] - sum, result);
		}
	}
	std::cout << result << '\n';
}

Measured memory_bytes: 10312
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int H, W, N, X, Y, x, y, cnt, res;
set<int>st[200000];

int main() {
	cin >> H >> W >> N;
	for (int i = 0; i < N; ++i) {
		cin >> X >> Y;
		--X;
		--Y;
		st[Y].insert(X);
	}
	for (int i = 0; i < W; ++i) {
		st[i].insert(H);
	}
	res = intmax;
	while (true) {
		if (st[y].find(x + 1) != st[y].end()) {
			res = min(res, cnt + 1);
			break;
		}
		else {
			res = min(res, cnt + *st[y].lower_bound(x) - x);
			if (y == W - 1)break;
			++x;
			if (st[y + 1].find(x) == st[y + 1].end()) {
				++y;
			}
			++cnt;
		}
	}
	cout << res << endl;
}



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

int main(){
  ll N;
  cin >> N;
  vector<ll> vec(N);
  ll sum=0;
  for(int i=0;i<N;i++){
    cin >> vec[i];
    sum+=vec[i];
  }
  ll a=pow(10,9)+7;
  ll ans=0;
  for(int i=0;i<N-1;i++){
    sum-=vec[i];
    ll b=sum%a;
    ans=(ans+(b*vec[i]))%a;
   
  }
  cout << ans <<endl;
}
  
    

Measured memory_bytes: 4784
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

long long n, k, a[200009], f[200009];

bool fun(long long cur)
{
	long long cnt = 0;
	for (int i = 0; i < n; i++) {
		if (f[i] * a[i] <= cur) continue;
		long long tmp = cur / f[i];
		cnt += a[i] - tmp;
	}
	if (cnt <= k) return true;
	return false;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> f[i];
	}
	sort(a, a + n);
	sort(f, f + n);
	reverse(f, f + n);
	long long l = -1, r = 1e12;
	while (l + 1 < r) {
		long long mid = (l + r) / 2;
		if (fun(mid)) r = mid;
		else l = mid;
	}
	cout << r << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 3328
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import defaultdict, deque
    n, m = map(int, readline().split())
    edge = defaultdict(list)

    for _ in range(m):
        l, r, d = map(int, readline().split())
        edge[l].append((r, d))
        edge[r].append((l, -d))

    visited = [False] * (n + 1)

    for x in range(1, n + 1):
        costs = dict()
        if not visited[x]:
            costs[x] = 0
            que = deque()
            que.append((x, 0))
            while que:
                u, cost = que.popleft()
                visited[u] = True
                while edge[u]:
                    v, w = edge[u].pop()
                    if v in costs:
                        if costs[v] != cost + w:
                            print("No")
                            sys.exit()
                    costs[v] = cost + w
                    que.append((v, cost + w))

    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 105304
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main(){
  int X;
  cin >>X;
  int C = X/100;
  if (X- 100*C <= 5*C){
  cout <<"1" << endl;
  return 0;
  }
  cout << "0" <<endl;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;

public class Main {

	public static void main(String[] args) {

		// 入力
		Scanner sc = new Scanner(System.in);
		long now = Long.parseLong(sc.next());
		long k = Long.parseLong(sc.next());
		long dist = Long.parseLong(sc.next());

		// 現在地が負なら、正にして考えても同じこと
		if (now < 0) {
			now = -1 * now;
		}

		// なるべく0に近づくのが目的なので、0を通り過ぎたら折り返さなければならない。
		// そこでまずは「0を通り過ぎる」が発生するかどうかを判定する。
		// ただし、k（移動回数）とdist（１回の移動距離）が大きすぎるため、
		// k * dist の計算はBigIntegerを使う。（BigIntegerは今日初めて知った）
		BigInteger bigK = BigInteger.ONE.multiply(BigInteger.valueOf(k));
		BigInteger bigSeki = bigK.multiply(BigInteger.valueOf(dist));
		BigInteger bigNow = BigInteger.ONE.multiply(BigInteger.valueOf(now));
		BigInteger bigHoge = bigNow.subtract(bigSeki);
		int hikaku = bigHoge.compareTo(BigInteger.ZERO);

		// 移動回数を使い切っても0まで到達しないパターン
		if (hikaku == 1) {
			System.out.println(now - (k * dist));
			return;
		}

		// 移動を使い切ったときにぴったり0にゴールするパターン
		if (hikaku == 0) {
			System.out.println(0);
			return;
		}

		// 以下、0を通り過ぎるパターン

		// まず0の直前まで歩く
		k -= now / dist;
		now = now % dist;

		// 残り回数が偶数なら、現在地がゴール
		if (k % 2 == 0) {
			System.out.println(now);
			return;
		}

		// 残り回数が奇数なら、0を一度だけ通り過ぎて着いたところがゴール
		System.out.println(dist - now);

	}
}

Measured memory_bytes: 35816
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,p,a,b;
    cin>>n>>m>>p>>a>>b;
    while(n != 0){
      vector<ll> t(8,0);
      FOR(i,0,n)cin>>t[i];
      vector<vector<P>> g(m+1);
      FOR(i,0,p){
        ll in1,in2,c;
        cin>>in1>>in2>>c;
        g[in1].push_back(P(in2,c));
        g[in2].push_back(P(in1,c));
      }

      vector<vector<ld>> cost(m+1,vector<ld>(1<<8,1e9));

      queue<ll> q;
      q.push(a);
      cost[a][(1<<8)-1] = 0;
      while(!q.empty()){
        ll from = q.front();
        q.pop();
        FOR(i,0,g[from].size()){
          ll to = g[from][i].first;
          ld c = g[from][i].second;
          ll f = 0;
          FOR(j,0,1<<8){
            if(cost[from][j] != 1e9){
              FOR(k,0,8){
                if(t[k] == 0 )continue;
                if(j & (1<<k)){
                  ll bi = j - (1<<k);
                  if(cost[to][bi] > cost[from][j] + c/t[k]){
                    cost[to][bi] = cost[from][j] + c/t[k];
                    f = 1;
                  }
                }
              }
            }
          }
          if(f == 1) q.push(to);
        }
      }

      ld mi = 1e9;
      FOR(i,0,cost[b].size()){
        mi = min(mi, cost[b][i]);
      }


      if(mi == 1e9)cout<<"Impossible"<<endl;
      else cout<<mi<<endl;
      cin>>n>>m>>p>>a>>b;
    }
}



Measured memory_bytes: 3376
#include<stdio.h>
int sosu(int a){
	int  b=0;
	for(int i=2;i<a;i++){
		if(a%i==0){
			b=1;
		}
	}
	return b;
}
int main(void){
	int n;
	int x[55]={0};
	scanf("%d",&n);
	int cnt=0;
	int c;
	x[0]=11;
	for(int i=0;i<n;i++){
		for(int j=x[i]+1;j<55555;j++){
			if(sosu(j)==0 && j%5==1){
				x[i+1]=j;
				break;
			}
		}
	}
	for(int i=0;i<n;i++){
		printf("%d ",x[i]);
	}
	return 0;
}

Measured memory_bytes: 128
n,k = gets.chomp.split(" ").map(&:to_i)

edge = Array.new(n).map{Array.new}
for i in 1..n-1 do
    a,b = gets.chomp.split(" ").map(&:to_i)
    edge[a-1].push(b)
    edge[b-1].push(a)    
end
stack = [[1,0]]
sum = k
while ! stack.empty?
    tars = stack.shift
    tar = tars[0]
    last = tars[1]
    if last == 0
        cnt = 0
    else
        cnt = 1
    end
    for i in edge[tar-1]
        if i != last
            stack.push([i,tar])
            sum *= k-1-cnt
            sum %= 10**9 +7
            cnt += 1
        end
    end
end
p sum % (10**9 +7)

Measured memory_bytes: 12908
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);
const long MOD = 998244353;

long n;
long d[100005];
long cnt[100005];
long max = 0;
long ans = 1;

long power(long a, long b, long MOD){
	if(b == 0){
		return 1;
	}else if(b % 2 == 1){
		return a * power(a, b-1, MOD) % MOD;
	}else{
		long r = power(a, b/2, MOD);
		return r * r % MOD;
	}
}


int main(){
    scanf("%ld", &n);
    for(int i = 0; i < n; i++){
        scanf("%ld", &d[i]);
        cnt[d[i]]++;
        max = std::max(max, d[i]);
    }
    /*
    for(int i = 0; i < n; i++){
        printf("  %ld\n", d[i]);

    }

    printf("%ld\n", max);
    //*/
    if(d[0] != 0 || cnt[0] > 1){
        printf("0\n");
        return 0;
    }
    for(int i = 0; i < max; i++){
    //    printf("%ld (%ld %ld), %ld\n", i, cnt[i], cnt[i+1], power(cnt[i], cnt[i+1], MOD));
        ans *= power(cnt[i], cnt[i+1], MOD);
        ans %= MOD;
    }
    printf("%ld\n", ans);
}


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

using namespace std;

using ll = long long;
using ld = long double;

bool Solve() {
    int H, W, N;
    cin >> H >> W >> N;

    using P = pair<int, int>; // 行，列
    P s;
    cin >> s.first >> s.second;

    string S, T;
    cin >> S >> T;

    // 右に出すことが可能化?
    P cur = s;
    for (int i = 0; i < N; ++i) {
        if (S[i] == 'R') ++cur.second;
        if (W < cur.second) return false;
        if (T[i] == 'L')
            cur.second = max(1, cur.second - 1);
    }

    // 左に出すことが可能化?
    cur = s;
    for (int i = 0; i < N; ++i) {
        if (S[i] == 'L') --cur.second;
        if (cur.second < 1) return false;
        if (T[i] == 'R')
            cur.second = min(W, cur.second + 1);
    }

    // 下に出すことが可能化?
    cur = s;
    for (int i = 0; i < N; ++i) {
        if (S[i] == 'D') ++cur.first;
        if (H < cur.first) return false;
        if (T[i] == 'U')
            cur.first = max(1, cur.first - 1);
    }


    // 上に出すことが可能化?
    cur = s;
    for (int i = 0; i < N; ++i) {
        if (S[i] == 'U') --cur.first;
        if (cur.first < 1) return false;
        if (T[i] == 'D')
            cur.first = min(H, cur.first + 1);
    }

    return true;
}

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

    if (Solve()) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 920
a, b, c, k = list(map(int, input().split()))
def solve(a,b, c, k):
    ans = 0
    one = min(a, k)
    ans += one
    k -= one
    if k>= 0:
        zero = min(k, b)
        k -= zero
        if k >=0:
            neg_one = min(k, c)
            ans -= neg_one
    return ans
print(solve(a,b, c, k))


Measured memory_bytes: 9184
#include<iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {

	int n,A[10000],B[10000];
	int ANS[2] = {0};

	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			cin >> A[i] >> B[i];
			if (A[i] == B[i]) {
				ANS[0] += A[i];
				ANS[1] += B[i];
			}
			else if (A[i] > B[i])
				ANS[0] += A[i] + B[i];
			else
				ANS[1] += A[i] + B[i];
		}
		cout << ANS[0] << " " << ANS[1] << endl;
		ANS[0] = 0;
		ANS[1] = 0;
	}

	return 0;

}

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

void select( int* x, bitset<10> b, int n, int s, int i, int& c )
{
    if( i == 10 )
    {
        if( b.count() == n )
        {
            int sum = 0;
            for( int j = 0; j < 10; j++ )
            {
                if( b[j] == 1 )
                    sum += x[j];
            }
            if( sum == s )
                c++;
        }
        return;
    }
    b[i] = 0;
    select( x, b, n, s, i + 1, c );

    b[i] = 1;
    select( x, b, n, s, i + 1, c );
}

int main()
{
    int x[10];
    bitset<10> b;
    int n, s;

    for( int i = 0; i < 10; i++ )
        x[i] = i;

    while( cin >> n >> s )
    {
        int cnt = 0;
        if( n == 0 && s == 0 )
            break;
        select( x, b, n, s, 0, cnt );
        cout << cnt << endl;
    }

    return 0;
}


Measured memory_bytes: 3080
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin>>n;
  int x[n];
  for(int i=0;i<n;i++){
    cin>>x[i];
  }
  int c[n];
  for(int i=0;i<n;i++){
    c[i]=x[i];
  }
  sort(c,c+n);
  int ml=c[n/2-1];
  int mr=c[n/2];
  for(int i=0;i<n;i++){
    if(x[i]<mr)cout<<mr<<endl;
    else cout<<ml<<endl;
  }
  return 0;
}

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

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

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

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

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

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

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

// ---- ----

string s;

int main() {
	cin >> s;
	
	cout << (count(ALL(s), 'o') + 7) * 100 << endl;
	
	return 0;
}


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

int gcd(int A,int B){
  if(B>A)swap(A,B);
  if(B==0)return A;
  return gcd(B,A%B);
}

int main(){
  string S;
  cin >> S;
  int cnt0=0;
  int cnt1=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='0'){
      cnt0++;
    }
    else{
      cnt1++;
    }
  }
  cout << min(cnt0,cnt1)*2 << endl;
}
  
  

Measured memory_bytes: 512
#include<stdio.h>
int main(void){
  int n;
  int d[50];
  int i;
  int sum = 0;
  int allsum;
  int sq =0;
  scanf("%d",&n);
  
  for (i=0;i< n;i++){
    scanf("%d",&d[i]);
    sum += d[i];
    sq += d[i] * d[i];
  }
  
  allsum = (sum*sum - sq)/2;
  printf("%d",allsum);
  return 0;
}
  

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(){
    int n;

    cin >> n;
    
    for(int i = 3; i <= n; i++){
        int x = i;
        if(i % 3 == 0) {
            cout << " " << i;
        } else {
            do{
                if(x % 10 == 3){
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
            while(x);
        }
    }
    cout << endl;
}

Measured memory_bytes: 1160
def gcd(t, u):
    if t < u:#t > uにする
        t, u = u, t
    while u > 0:
##        print(t, u)
        t, u = u, t % u
    return t

def nl(): return list(map(int, input().split()))

n, k = nl()
a = nl()

g = a[0]
for x in a:
##    print(g)
    g = gcd(x, g)

print('POSSIBLE' if k <= max(a) and k % g == 0 else 'IMPOSSIBLE')    

Measured memory_bytes: 14228
#include <bits/stdc++.h> 
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    long long q(1);//cin>>q;
    while(q--){
       long long n,m,tot(1e9),cnt(0);string s,k;cin>>s>>k;
       n=s.length();m=k.length();
       for(int i=0;i<=n-m;i++){
        cnt=0;
        for(int j=i;j<i+m;j++){
            if(s[j]!=k[j-i])
                cnt++;
        }
        tot=min(tot,cnt);
       }
       cout<<tot<<endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <iomanip>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  ll i = 0;
  for (auto x : v){os << " [" << i++ << "]" << x; if (i % 5 == 0) os << std::endl;}
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 5 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll x, a, b;
  std::cin >> x >> a >> b;

  ll ans = (x - a) % b;
  print(ans);

  return 0;
}


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

int main(){
    int a[5];
    for(auto &i: a) cin>>i;

    for(int i=0; i<5; i++){
        if(a[i]==0){
            cout<<i+1;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cmath>
#include <iomanip>
#include <algorithm>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 aa, vv, bb, ww, tt, muki;
	cin >> aa >> vv;
	cin >> bb >> ww;
	cin >> tt;
	if(aa < bb)
	{
		muki = 1;
	}
	else
	{
		muki = -1;
	}
	aa += vv * tt * muki;
	bb += ww * tt * muki;
	if(muki == 1 && aa >= bb)
	{
		puts("YES");
	}
	else if(muki == -1 && aa <= bb)
	{
		puts("YES");
	}
	else
	{
		puts("NO");
	}
	return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int L = a + b; 
        int R = c + d; 

        if(L > R){
            System.out.println("Left");
        }
        else if(L == R){
            System.out.println("Balanced");
        }
        else if(L < R){
            System.out.println("Right");
        }
    }
}


Measured memory_bytes: 22612
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define max4(a,b,c,d) max(max(a,d),max(b,c))
#define MAX   1e9
#define MIN  -1e9
#define PI 3.14159265358979
#define eps 1e-9
typedef map<int,int> mpi;
typedef set<int> seti;
typedef multiset<int> mseti;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(long long int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(long long int i = a; i >= (n); --i)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define trav(a, x) for(auto& a : x)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl
#define inp(a,start,len) for(long long int i = start;i < len;i++) cin>>a[i]
struct Interval{ll start,end;};
bool compare(Interval i1, Interval i2) {return (i1.start < i2.start);}

ll dp[200005];
ll mod = 998244353;

int main(){
	fio;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ll T = 1;
	// cin>>T;
	while(T--){
		ll n,k;
		cin>>n>>k;
		vpll segments(k);
		rep(i,k)
		cin>>segments[i].f>>segments[i].s;
		sort(all(segments));
		ll prefix[n+1];
		prefix[0] = 0;
		prefix[1] = 1;
		dp[0] = 0;
		dp[1] = 1;
		repA(i,2,n){
			prefix[i] = prefix[i-1];
			dp[i] = 0;
			rep(j,k){
				if(i-segments[j].s>0){
					dp[i] = (dp[i] + prefix[i-segments[j].f] - prefix[i-segments[j].s-1] + mod)%mod;
				}
				else if(i-segments[j].f>0){
					dp[i] = (dp[i] + prefix[i-segments[j].f])%mod;
				}
			}
			// dbg2(i,dp[i]);
			prefix[i] = (prefix[i] + dp[i])%mod;
		}
		cout<<dp[n];
	}
	return 0;
}


Measured memory_bytes: 6676