akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

const MOD: usize = 1e9 as usize + 7;

fn main() {
    input!{
      n: usize,
      m: usize,
      ss: [usize; n],
      ts: [usize; m],
    }
    let mut dp = vec![0usize; n+1];
    dp[0] = 1;
    for i in 0..m {
        let t = ts[i];
        let mut acm = dp[0];
        for i in 0..n {
            let s = ss[i];
            let temp = dp[i+1];
            if s == t {
                dp[i+1] += acm;
                dp[i+1] %= MOD;
            }
            acm += temp;
            acm %= MOD;
        }
    }
    let mut ans = 0;
    for v in dp {
        ans += v;
        ans %= MOD;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<atcoder/all>
using namespace atcoder;

#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

using MLL = static_modint<998244353>;

struct RQV { MLL C, X; };
RQV f(RQV a, RQV b) { return { a.C + b.C, a.X + b.X }; }
RQV e() { return { 0,0 }; }
RQV mapping(MLL a, RQV b) { if (a == 10) return b; return { b.C, b.C * a }; }
MLL composition(MLL a, MLL b) { if (a == 10) return b; return a; }
MLL id() { return 10; }

int main() {
    int N, Q; cin >> N >> Q;
    vector<RQV> V(N);
    V[0] = { 1,1 };
    rep(i, N - 1) V[i + 1] = { V[i].C * 10,V[i].X*10 };
    reverse(V.begin(), V.end());
    lazy_segtree<RQV, f, e, MLL, mapping, composition, id> G(V);
    rep(i, Q) {
        int l, r, d; cin >> l >> r >> d; l--;
        G.apply(l, r, MLL::raw(d));
        cout << G.all_prod().X.val() << endl;
    }

    return 0;
}

Measured memory_bytes: 9896
/* ****devACE**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		int n;
		cin>>n;
		int a[n];
		memset(a,0,sizeof a);

		for(int i=0;i<n-1;i++){
			int num;
			cin>>num;
			a[num-1]++;
		}

		for(int i=0;i<n;i++)cout<<a[i]<<"\n";
	}
	return 0;
}

Measured memory_bytes: 4440
N, M, L= map(int,input().split())
cost = [[float('inf')]*N for i in range(N)]

for i in range(N):
    cost[i][i] = 0

for _ in range(M):
    a,b,c = map(int,input().split())
    cost[a-1][b-1] = c
    cost[b-1][a-1] = c
def func(f):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                f[i][j] = min(f[i][k] + f[k][j], f[i][j])
    return f
cost = func(cost)
for i in range(N):
    for j in range(N):
        if cost[i][j] > L:
            cost[i][j] = float('inf')
        else:
            cost[i][j] = 1
cost = func(cost)

Q = int(input())
ans = []
for i in range(Q):
    s,t = map(int,input().split())
    ans.append(cost[s-1][t-1]-1)
for i in ans:
    if i == float('inf'):
        print(-1)
    else:
        print(i)


Measured memory_bytes: 127452
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
#define NUM 100005
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int GCD(int a,int b){int c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
int LCM(int a,int b){return a*b/GCD(a,b);}
int POW(int a,int n){int i;LL x=a;if(n==0)return 1;else if(n==1)return a;else FOR(i,0,n-1){x=x*a;if(x>MOD)x%=MOD;}return (int)x;}
int cmp(const void* a,const void* b){return *(int*)a-*(int*)b;}

int main() {
  int L,R,i,j,ans=0;
  scanf("%d%d",&L,&R);
  if(R-L<2019){
    ans=2019;
    L%=2019;R%=2019;
    if(R<L)R+=2019;
    FOR(i,L,R)FOR(j,L+1,R+1)if(ans>(i*j)%2019)ans=(i*j)%2019;
  }

  printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int i = 1;
		while (true) {
			int num1 = scanner.nextInt();
			if (num1 == 0)
				break;
			else {
				System.out.println(String.format("Case %s: %s", i, num1));
				i++;
			}
		}
	}
}

Measured memory_bytes: 49508
x=int(input())

for i in range(2*10**3):
  for j in range(0,i,1):
    if i**5-j**5==x:
      print(i,j)
      exit()

for i in range(0,70,1):
  for j in range(0,-70,-1):
    if i**5-j**5==x:
      print(i,j)
      exit()

Measured memory_bytes: 9136
n,k=map(int,input().split())
a=list(map(int,input().split()))
k-=1
n-=1
c=(1<<k)-1
b=10**18
while c<1<<n:
    w=a[0]
    t=0
    f=1
    for i in range(n):
        if c>>i&1:
            t+=max(0,w-a[i+1]+1)
            w=max(a[i+1],w+1)
        else:
            if a[i+1]>w:
            	f=0
            	break
    if f:
        b=min(b,t)
    x=c&-c
    y=c+x 
    c=((c&~y)//x>>1)|y 
print(b)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int maxn=(1e5+10);
string s;
pair<int,int> dp[maxn];
int ans[maxn];
int main()
{
	cin>>s;
	int n=s.size();
	for(int i=0;i<n;i++)
		dp[i].first=dp[i].second=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='L')
		{
			for(int j=i-1;j>=0;j--)
			{
				if(dp[j].first)
					break;
				dp[j]=make_pair(dp[j+1].first+1,i);
			}
			if(s[i-1]=='L')
				dp[i]=make_pair(dp[i-1].first+1,dp[i-1].second);
			else
				dp[i]=make_pair(2,i);
		}
	}
	for(int i=0;i<n;i++)
	{
		if(dp[i].first%2==0)
			++ans[dp[i].second];
		else
			++ans[dp[i].second-1];
	}
	for(int i=0;i<n;i++)
		cout<<ans[i]<<" ";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3

n, m = list(map(int, input().split()))
a = list(map(int, input().split()))


all_weights = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
weights = [all_weights[i] for i in a]

# print(weights)

dp = [-1 for _ in range(n+1)]
dp[0] = 0

for i in range(1, n+1):
    # print(dp)
    for j in range(len(weights)):
        if i-weights[j] >= 0:
            dp[i] = max(dp[i-weights[j]]*10 + a[j], dp[i])

print(dp[-1])


Measured memory_bytes: 14516
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		String astr = sc.next();
		String bstr = sc.next();
		String cstr = sc.next();

		int count = 0;

		for(int i=0; i<n; i++) {
			if(astr.substring(i, i+1).equals(bstr.substring(i, i+1)) &&
					astr.substring(i, i+1).equals(cstr.substring(i, i+1))) {
				continue;
			} else if(astr.substring(i, i+1).equals(bstr.substring(i, i+1)) &&
					!(astr.substring(i, i+1).equals(cstr.substring(i, i+1)))) {
				count = count + 1;
			} else if(!(astr.substring(i, i+1).equals(bstr.substring(i, i+1))) &&
					astr.substring(i, i+1).equals(cstr.substring(i, i+1))) {
				count = count + 1;
			} else if(!(astr.substring(i, i+1).equals(bstr.substring(i, i+1))) &&
					!(astr.substring(i, i+1).equals(cstr.substring(i, i+1))) &&
					bstr.substring(i, i+1).equals(cstr.substring(i, i+1))) {
				count = count + 1;
			} else {
				count = count + 2;
			}
		}

		System.out.println(count);
		sc.close();
	}

}


Measured memory_bytes: 21716
//SOGさんのコードを見て書きました

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>

using namespace std;

int main(){

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

	long long ans = b/x - a/x;
	if( a%x == 0 ) ans++;
	cout << ans <<endl;

	return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
import copy
import math

class manacher:
    """Cache radius array of palindrome to judge in linear time."""

    def __init__(self, l):
        """Insert '&' to judge both even and odd length palindrome."""
        self.n = len(l)
        self.m = 2*self.n+1
        self.d = ['&']*self.m
        self.r = [0]*self.m
        for i in range(self.n):
            self.d[2*i+1] = l[i]
        self.make_r()

    def make_r(self):
        """Make self.r[i] (radius of palindrome whose center is self.d[i])."""
        i, j = 0, 0
        while i < self.m:
            while j <= i < self.m-j and self.d[i-j] == self.d[i+j]:
                j += 1
            self.r[i] = j
            k = 1
            while k <= i < self.m-k and k+self.r[i-k] < j:
                self.r[i+k] = self.r[i-k]
                k += 1
            i += k
            j -= k

    def judge(self, start, end):
        """Return 1 if l[start, end) is a palindrome."""
        center = start+end
        return 2*end-1 < center+self.r[center]

    def get_num(self, center):
        return self.r[center]


def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [S] = [(input_raw[0])]
    dic = {}
    for s in S:
        if s not in dic:
            dic[s] = 1
        else:
            dic[s] += 1
    count = len(S) * (len(S) - 1)/2 + 1
    for s in dic:
        count -= dic[s] * (dic[s] - 1)/2
    print count

##    mana = manacher(S)
##    s = 0
##    for i in range(0, len(S) * 2, 2):
##        #print (mana.get_num(i) + mana.get_num(i + 1)) /2,
##        s += (mana.get_num(i) + mana.get_num(i + 1)) /2

    #print (len(S) * (len(S) + 1))/2 - s + 1


if __name__ == '__main__':
    main()


Measured memory_bytes: 3312
#include <bits/stdc++.h>
    #define mp make_pair
    #define f1 first
    #define f2 second
    #define pb push_back
    #define pii pair<int ,int>
    #define ios  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #define int long long
    using namespace std;
    const int mox=18;
    map<pair<string,string> , int> ma;
    main()
    {
       int n;
       cin>>n;
       string s;
       cin>>s;
       string t=s;
       reverse(t.begin()+n,t.end());
       for(int i=0 ; i<(1<<n) ; i++)
       {    string a,b;
           for(int j=0 ; j<n ; j++)
           {
               if((i&(1<<j)))
               {
                   a+=s[j];
               }
               else
                b+=s[j];
           }
           ma[{a,b}]+=1;
       }
       int ans=0;
       for(int i=0 ; i<(1<<n) ; i++)
       {
           string a,b;
           for(int j=0 ; j<n ; j++)
           {
               if((i&(1<<j)))
               {
                   a+=t[j+n];
               }
               else
                b+=t[j+n];
           }
           ans+=ma[{b,a}];
       }
       cout<<ans;
    }


Measured memory_bytes: 60900
data class Edge(val to: Int, val id: Int)
fun main(args: Array<String>) {
    val N = nextInt()
    val G = Array<MutableList<Edge>>(N) { mutableListOf<Edge>() }
    var ans = Array<Int>(N - 1) { 0 }
    repeat(N - 1) {
        val (a, b) = listOfInt(-1)
        G[a].add(Edge(b, it))
        G[b].add(Edge(a, it))
    }
    fun dfs(v: Int, c: Int = -1, p: Int = -1) {
        var k = 1
        repeat(G[v].count()) {
            val u = G[v][it].to
            val e = G[v][it].id
            if (u != p) {
                if (k == c) k += 1
                ans[e] = k++
                dfs(u, ans[e], v)
            }
        }
    }
    dfs(0)
    println(G.map { it.count() }.max())
    println(ans.joinToString(separator = "\n"))
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }
fun printErr(value: Any) = System.err.println(value)


Measured memory_bytes: 78976
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	int n,a[110],flag=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i]%2==0){
			if(a[i]%3!=0&&a[i]%5!=0){
				flag=1;
			}
		}
	}
	if(flag){
		printf("DENIED\n");
	}
	else{
		printf("APPROVED\n");
	}
	return 0;
}

Measured memory_bytes: 256
#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;

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

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

int main(){
  string s,s1;
  cin >>s;
  rep(i,s.size()-8) s1 += s[i];
  cout << s1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

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

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
class Edge{
public:
    int from,to,value;
    Edge(int a,int b,int c){
        from = a;
        to = b;
        value = c;
    }
    Edge(int a,int b){
        from = a;
        to = b;
    }
};
int main(){
    CIN(N);
    string str;cin >> str;
    int ans = 0;
    for(int a = 1;a < N;a++){
        string s = str.substr(0,a);
        string w = str.substr(a,N-a);
       // cout<<w<<endl;
        //cout<<s<<endl;
        //cout<<endl;
        set<char> q;
        FOREACH(b,s){
            if(count(ALL(w),b)>=1){
                q.insert(b);
            }
        }
        int r = q.size();
        ans = max(ans,r);
    }
    COUT(ans);
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  int N = (int)S.size() + 1;
  vector<int> a(N);

  rep(i, N - 1) {
    if (S.at(i) == '<') {
      a.at(i + 1) = a.at(i) + 1;
    }
  }

  // rep(i, N - 1) cout << a.at(i) << " " << S.at(i) << " ";
  // cout << a.at(N - 1) << endl;

  rep(i, N - 1) {
    int j = N - 2 - i;
    if (S.at(j) == '>') {
      if (a.at(j) <= a.at(j + 1)) a.at(j) = a.at(j + 1) + 1;
    }
  }

  // rep(i, N - 1) cout << a.at(i) << " " << S.at(i) << " ";
  // cout << a.at(N - 1) << endl;

  uint64_t ans = 0;
  rep(i, N) ans += a.at(i);

  cout << ans << endl;

  return 0;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

static const ll INF = 1e15;

int main(void)
{

	ll x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<P> values;
	values.reserve(a + b + c);
	rep(i, a) {
		ll v;
		cin >> v;
		values.emplace_back(v, 0);
	}
	rep(i, b) {
		ll v;
		cin >> v;
		values.emplace_back(v, 1);
	}
	rep(i, c) {
		ll v;
		cin >> v;
		values.emplace_back(v, 2);
	}
	sort(values.begin(), values.end(), greater<P>());

	ll cs[3] = { 0,0,0 };
	ll sum = 0;
	int i = 0;
	for(int i = 0;i < values.size();i++){
		if (cs[0] + cs[1] + cs[2] >= x + y) break;
		ll id = values[i].second;
		if (id == 0) {
			if (cs[0] >= x) continue;
		}
		if (id == 1) {
			if (cs[1] >= y) continue;
		}
		cs[id]++;
		sum += values[i].first;
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>
#include<stdlib.h>

typedef struct {
  int val;
  int index;
} node;

node min(node a,node b){
  return a.val<b.val?a:b;
}

typedef struct RMQ{
  node *a;
  int size;
} segTree;

segTree* newRMQ(const int n,const int *h){
  int k=1;
  while(k<n) k*=2;
  segTree *s=(segTree *)malloc(sizeof(segTree));
  s->a=(node *)calloc(2*k,sizeof(node));
  s->size=k;
  int i;
  for(i=0;i<n;i++){
    s->a[i+k]=(node){h[i],i};
  }
  for(;i<k;i++){
    s->a[i+k]=(node){1000000000+1,i};
  }
  for(i=k-1;i>=1;i--) s->a[i]=min(s->a[2*i],s->a[2*i+1]);
  return s;
}

node query(segTree *s,int l,int r){
  node res={1000000000+1,-1};
  for(l+=s->size,r+=s->size;l<r;l>>=1,r>>=1){
    if(l&1) res=min(res,s->a[l++]);
    if(r&1) res=min(res,s->a[--r]);
  }
  return res;
}

typedef struct {
  int l,r;
} range;

typedef long long int int64;

void run(void){
  int n;
  scanf("%d",&n);
  int *h=(int *)calloc(n,sizeof(int));
  int i;
  for(i=0;i<n;i++) scanf("%d",h+i);
  segTree *s=newRMQ(n,h);
  range stack[64];
  int top=0;
  stack[top++]=(range){0,n};
  int64 max=0;
  while(top>0){
    range t=stack[--top];
    if(t.l>=t.r) continue;
    node q=query(s,t.l,t.r);
    int64 area=(int64)q.val*(t.r-t.l);
    if(max<area) max=area;
    int m=q.index;
    if(m-t.l<=t.r-(m+1)){
      stack[top++]=(range){m+1,t.r};
      stack[top++]=(range){t.l,m};
    } else {
      stack[top++]=(range){t.l,m};
      stack[top++]=(range){m+1,t.r};
    }
  }
  printf("%lld\n",max);
}

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



Measured memory_bytes: 4248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int h, w, x;
    cin >> h >> w >> x;
    char c[h][w];
    rep(i, 0, h) {
        rep(j ,0, w) {
            cin >> c[i][j];
        }
    }
    int ans = 0;
    rep(i, 0, (1 << h)) {
        rep(j, 0, (1 << w)) {
            char s[h][w];
            rep(k, 0, h) rep(l, 0, w) s[k][l] = c[k][l];
            rep(k, 0, h) {
                if (i & (1 << k)) {
                    rep(l, 0, w) s[k][l] = 'r';
                }
            }
            rep(k, 0, w) {
                if (j & (1 << k)) {
                    rep(l, 0, h) s[l][k] = 'r';
                }
            }
            int sum = 0;
            rep(k, 0, h) rep(l, 0, w) if (s[k][l] == '#') sum++;
            if (sum == x) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int h, w;
  cin >> h >> w;
  vs f(h);
  rep(i,h) cin >> f[i];
  rep(i,h) {
    bool ok = true;
    rep(j,w) {
      if(f[i][j] == '#') ok = false;
    }
    if(ok) {
      rep(j,w) f[i][j] = '-';
    }
  }
  rep(i,w) {
    bool ok = true;
    rep(j,h) {
      if(f[j][i] == '#') ok = false;
    }
    if(ok) {
      rep(j,h) f[j][i] = '-';
    }
  }
  rep(i,h) {
    bool ok = false;
    rep(j,w) {
      if(f[i][j] != '-') {
        cout << f[i][j];
        ok = true;
      }
    }
    if(ok) cout << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
using namespace std;
#define int long long
int get_center(char *str, int l){
	int x=0;
	for(int i=0;i<l;i++){
		if(*(str+i) == ',' && x==1) return i;
		else if(*(str+i) == '(') x++;
		else if(*(str+i) == ')') x--;
	}
	return 0;
}
string subs(char* s, int l){
	string str(s);
	return str.substr(0, l);
}
string make(char op, char* str1, int str1l, char* str2, int str2l){
	if(op=='u' && str1l==0) return subs(str2,str2l);
	else if (op=='u' && str2l==0) return subs(str1,str1l);
	else if(str1l==0 || str2l==0) return "";
	else {
		int c1 = get_center(str1, str1l);
		int c2 = get_center(str2, str2l);
		return "(" + make(op,str1+1,c1-1,str2+1,c2-1) + "," + make(op,str1+c1+1,str1l-c1-2,str2+c2+1,str2l-c2-2) + ")";
	}
}
signed main(){
	char c;
	char buf1[512], buf2[512];
	while( cin >> c >> buf1 >> buf2 ){
		cout << make(c, buf1, strlen(buf1), buf2, strlen(buf2)) << endl;
	}
	return 0;
}

Measured memory_bytes: 3144
#include<iostream>
#include<cmath>
#include<vector>
#include<utility>
#include<string>
using namespace std;

int main(){
    int A,B,C,X,Y;
    cin>>A>>B>>C>>X>>Y;
    int totalcost = 0;
    int Z;

    if(X>Y){
        Z = Y;
    }else{
        Z = X;
    }
    X -= Z; Y -= Z;

    int single_cost = (A+B);
    if(2 * C > single_cost){
        totalcost += single_cost * Z;
    }else{
        totalcost += C * 2 * Z;
    }
    //cout<<"totalcost = "<<totalcost<<endl;

    if(X > 0){
        if(A  > C * 2 ){
            totalcost += C * 2 * X;
        }else{
            totalcost += A * X;
        }
    }else if(Y > 0){
        if(B > C * 2 ){
            totalcost += C * 2 * Y;
        }else{
            totalcost += B * Y;
        }
    }

    cout<<totalcost<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int p,q,r;
  cin>>p>>q>>r;
  int ans,M;
  M = max(p,max(q,r));
  ans = p+q+r-M;
  cout<<ans<<endl;
  return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  while(A>0 || C>0) {
    C -= B;
    if(C<=0) break;
    A -= D;
    if(A<=0) break;
  }
  if(C<=0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

const int MAXN = 1e5 + 1;

int n, h[MAXN], f[MAXN];

int main() {
	scanf("%d", &n);
        for (int i = 1; i <= n; i++) { scanf("%d", &h[i]); }
        int cnt = 0;
        for (int i = n - 1; i >= 1; i--) {
          if (h[i] >= h[i + 1]) {
            f[i] = ++cnt;
          } else {
            f[i] = cnt = 0;
          }
        }
        int maxn = -11;
        for (int i = 1; i <= n; i++) { maxn = max(maxn, f[i]); }
        printf("%d", maxn);
        return 0;
}	


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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, d, m[10101], c[101][10101], s[101], mn;

signed main() {
	while (1) {
		cin >> n >> d;
		if (n==0) break;
		mn = inf;
		zero(m), zero(s);
		rep(i,n) {
			cin >> m[i];
			rep(j,m[i]) {
				cin >> c[i][j];
				s[i] += c[i][j];
			}
			m[i]--;
			chmin(mn, s[i]);
		}
		bool b = 1;
		while (b) {
			b = 0;
			rep(i,n) {
				if (m[i]==-1) continue;
				s[i] -= c[i][m[i]];
				if (*max_element(s,s+n) - *min_element(s,s+n) <= d) m[i]--, b = 1;
				else s[i] += c[i][m[i]];
			}
		}
		cout << (accumulate(m,m+n,0)==-n ? "Yes" : "No") << ln;
	}
}


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

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define REPRl(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < (int)n; i++)
#define FORl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define ALL(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
int main() {
  int a,b;cin>>a>>b;
  int ans=a;
  if(a>b){
    ans--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
int main(void) {
	int n,d,count=0;
	scanf("%d%d",&n,&d);
	long int x[n],y[n];
	for(int i=0;i<n;i++){
		scanf("%ld%ld",&x[i],&y[i]);
	}
	for(int i=0;i<n;i++){
		long long int x2 = pow(x[i],2);
		long long int y2 = pow(y[i],2);
		double ans = (double)sqrt(x2+y2);
		if((double)ans<=(double)d){
			count++;
			//printf("%ld %ld=>%lld*%lld=%lf\n",x[i],y[i],x2,y2,ans);
		}
	}
	printf("%d\n",count);
}


Measured memory_bytes: 5228
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] data = new int[n];
		for(int i = 0 ; i < n ; i ++){
			data[i]=scan.nextInt();
		}
		for(int i = 1 ; i <= n ; i ++){
			System.out.print("node "+i+": key = "+data[i-1]+", ");
			if(i/2>0){
				System.out.print("parent key = "+data[i/2-1]+", ");
			}
			if(2*i<=n){
				System.out.print("left key = "+data[i*2-1]+", ");
			}
			if(2*i+1<=n){
				System.out.print("right key = "+data[i*2]+", ");
			}	
			System.out.println("");
		}
	}

}

Measured memory_bytes: 21588
#!/usr/bin/env python3
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from collections import deque
import sys
input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)
def solve():
    n=int(input())
    data=[list(map(int,list(input()))) for i in range(n)]
    fordfs=[[] for i in range(n)]
    for i in range(n):
        for j in range(n):
            if data[i][j]==1:
                fordfs[i].append(j)

    def dfs():
        V=[-1]*n
        V[0]=0
        que=deque()
        que.append(0)
        while que:
            now=que.popleft()
            nowv=V[now]
            for ne in fordfs[now]:
                if nowv==V[ne]:
                    print(-1)
                    exit()
                elif V[ne]==-1:
                    V[ne]=(nowv+1)%2
                    que.append(ne)
    
    dfs()
    # print(data)
    G=csgraph_from_dense(data)
    d = floyd_warshall(G)
    d.tolist()
    M=0
    for i in d:
        M=max(M,max(i))
    M=int(M)
    print(M+1)
    return



def main():

    solve()
    return
if __name__ == '__main__':
    main()


Measured memory_bytes: 28452
import java.util.Scanner;

public class Main {

	static int n;
	static int m;
	static int a[], b[];
	static boolean visited[];
	static boolean graph[][];

	static void DFS(int v) {
		visited[v] = true;
		for (int v2 = 0; v2 < n; v2++) {
			if (graph[v][v2] == false)
				continue;
			if (visited[v2] == true)
				continue;
			DFS(v2);
		}
		return;
	}

	public static void main(String[] args) {
		int count = 0;
		try (Scanner sc = new Scanner(System.in)) {
			n = sc.nextInt();
			m = sc.nextInt();
			visited = new boolean[n];
			graph = new boolean[n][n];
			a = new int[m];
			b = new int[m];

			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					graph[i][j] = false;
				}
			}

			for (int i = 0; i < m; i++) {
				a[i] = sc.nextInt() - 1;
				b[i] = sc.nextInt() - 1;
				graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
			}
			sc.close();
		}
		
		for (int i = 0; i < m; i++) {
			graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;
			for (int j = 0; j < n; j++) {
				visited[j] = false;
			}
			DFS(0);
			boolean eval = true;
			for (int j = 0; j < n; j++) {
				if (visited[j] == false) {
					eval = false;
					break;
				}
			}
			if (!eval) {
				count++;
			}
			graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
#define forn(i,p,n); for(long long i=p;i<n;++i)

void solve(){
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	if(c>b && b>a && c>a){
		cout<<"Yes";
		return ;
	}
	forn(i,0,k){
		if(c<=b){
			c = c*2;
			continue;
		}
		if(c<=a){
			c = c*2;
			continue;
		}
		if(b<=a){
			b = b*2;
			continue;
		}
	}
	if(c>b && b>a && c>a){
		cout<<"Yes";
		return ;
	}
	cout<<"No";
}

int main()
{
	fast;
	// int test;
	// cin >> test;
	// while(test--){
		solve();
	// 	cout<<"\n";
	// }
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include <stdlib.h>
using namespace std;
#define         rep(i,n)       for (int i = 0;i<(int)(n);i++)
#define         rep1(i,n)      for (int i = 1;i<=(int)(n);i++)
#define         sajo(str)      sort(str.begin(),str.end())
#define         rsajo(str)     reverse(str.begin(),str.end())
#define         pi             3.14159265359
#define         neli            printf("\n")
#define         gcd(a,b)       __gcd(a,b)
#define         lcm(a,b)       (a/gcd(a,b))*b
#define         yes            cout<<"Yes"<<"\n"
#define         no             cout<<"No"<<"\n"
#define         pf             printf
#define         sf             scanf
#define         pb             push_back
#define         ppb            pop_back
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5+5;
typedef long long int         lli;
typedef long long             ll;
typedef unsigned long long    ull;
typedef double                db;
typedef long double           ldb;

int pos(int arr[], int n, int x)
{
    for (int i = 0; i < n; i++)
        if (arr[i] == x)
            return i+1;
}

int main()
{
    FIO;
    ll a,b,x,y,ans,q,n,i,j;
    string s,t;

    cin>>a>>b;
    if((a*500)>=b)
        yes;
    else
        no;


    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll; ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);
ll fac(ll x){if(x==0) return 1;  return x*fac(x-1);}

int main(){
    ll r; cin>>r;
    if(r<1200) cout<<"ABC"<<endl;
    else if(r<2800) cout<<"ARC"<<endl;
    else cout<<"AGC"<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
l = [0]*N
r = [0]*N
gcds = [0]*N
def gcd(a,b):
    if (a < b):
        a,b = b,a
    if (b == 0):
        return a
    return gcd(b, a%b)

l[0] = A[0]
r[-1] = A[-1]
for i in range(1,N):
    l[i] = gcd(A[i],l[i-1])
    r[-1-i] = gcd(A[-1-i],r[-i])

for i in range(N):
    if i == 0:
        gcds.append(gcd(0,r[i+1]))
    elif i == N-1:
        gcds.append(gcd(0,l[i-1]))
    else:
        gcds.append(gcd(l[i-1],r[i+1]))
print(max(gcds))

Measured memory_bytes: 14436
#include <iostream>
#include <stack>
#include <queue>
#include <set>
#include <vector>
#include <iomanip>
#include <algorithm>
using namespace std;

typedef long long ll;

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

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

	sort(l.begin(), l.end(), greater<ll>());

	ll ans = 0;

	for (int i = 0; i < n; i++) {

		ll le = l[i];

		for (int j = n - 1; j > 0; j--) {

			ll se1 = l[j];

			for (int k = i + 1; k < j; k++) {

				ll se2 = l[k];
				ll sum = se1 + se2;

				if (le == se2 || se1 == se2) {
					continue;
				}

				if (sum > le) {
					ans++;
				}
				else {
					break;
				}
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>
#define MAX 200000
#define SENTINEL 2000000000
long long merge(int,int,int);
long long mergeSort(int,int);
int A[MAX];
int L[MAX / 2 + 2],R[MAX / 2 + 2];

int main(){
  int n,i;
  long long result;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }
  result = mergeSort(0,n);
  printf("%lu\n",result);
  return 0;
}

long long merge(int left,int mid,int right){
  long long count = 0;
  int i,j,k;
  int n1,n2;
  n1 = mid - left;
  n2 = right - mid;
  for(i = 0; i < n1; i++) L[i] = A[left + i];
  for(j = 0; j < n2; j++) R[j] = A[mid + j];
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  i = 0;
  j = 0;
  for(k = left; k < right; k++){
    if(L[i] <= R[j]){
      A[k] = L[i++];
    }
    else{
      A[k] = R[j++];
      count += n1 - i;
    }
  }
  return count;
}

long long mergeSort(int left, int right){
  int mid;
  long long a1,a2,a3;
  if(left + 1 < right){
    mid = (left + right)/2;
    a1 = mergeSort(left,mid);
    a2 = mergeSort(mid,right);
    a3 = merge(left,mid,right);
    return a1 + a2 + a3;
  }
  else return 0;
}

Measured memory_bytes: 2160
n=int(input())
a=list(map(int,input().split()))

arr=sorted([a[i]-i-1 for i in range(n)])

if len(arr)%2==0:
  tmp=[arr[len(arr)//2-1],arr[len(arr)//2]]
else:
  tmp=[arr[len(arr)//2]]

ans=10**20
for b in tmp:
  ans=min(ans,sum([abs(a[i]-b-i-1) for i in range(n)]))
print(ans)

Measured memory_bytes: 104092
#include <iostream>
using namespace std;
int main() {
    int A, B, C; cin >> A >> B >> C;
    for(int i = 1; i <= B; i++) {
        if((A*i-C)%B==0) {
            cout << "YES";
            return 0;
        }
    }
    cout << "NO";
}

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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, x, y) for(decltype(y) i = (x) - ((x) > (y)); i != (y) - ((x) > (y)); i += 1 - 2 * ((x) > (y)))
#define trav(i,a) for(auto& (i) : (a))
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())
#define clr(a,x) memset((a),(x),sizeof(a)) // array (0,-1)
#define dbg(x) cerr << "STDERR => " << __LINE__ << ": " << #x << " = " << (x) << "  :(\n";
#define pb push_back
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline void cpuTime() { cerr << "cpu time : " << double(clock())/CLOCKS_PER_SEC << "\n"; return; }
using ll = long long;
using ull = unsigned long long;
using F = float;
using D = double;
using vi = vector<int>;
using pii = pair<int,int>;



void solve(){

    int n = 0;
    cin >> n;

    vi a(n+1,0);
    rep(i,1,n+1) cin >> a[i];

    vector<ll> d(n+1,0);

    d[0] = 1000;
    rep(i,1,n+1){
        d[i] = d[i-1];
        rep(j,1,i){
            ll s = d[j]/a[j];
            ll w = d[j] + s*(a[i]-a[j]);

            d[i] = max(d[i], w);
        }
    }

    cout << d[n] << "\n";
    return;
}

/*
 read the question carefully ( what're the exact constraints? )
 look out for SPECIAL CASES (n=1?) and OVERFLOW (ll vs int?) ARRAY OUT OF BOUNDS
 Check datatypes
*/
int main(){

    fast_io;
    int t=1;
    // cin >> t;

    while(t--){
        solve();
    }

    cpuTime();
return 0;
}


Measured memory_bytes: 3832
#include<bits/stdc++.h>
#define rep(i, N) for(int i = 0; i < (N); i++)
#define repr(i, N) for(int i = N; i >= 0; i--)
#define all(v) v.begin(), v.end()
#define inf 1e9
#define idx(vec, element_iter) distance((vec).begin(), element_iter)
#define copy(vec1, vec2) copy(ALL(vec1), back_inserter(vec2)) //vec1をvec2にコピーする vec2は空にしておく必要がある

using namespace std;
typedef long long ll;


int main() {
    int l, r, d;
    cin >> l >> r >> d;
    int res = 0;
    for (int i = l; i < r+1; i++) {
        if (i%d == 0) res++;
    }
    cout << res << endl;
}

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

using namespace std;

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

  vector< vector<int> > e(n,vector<int>(n,0));
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      int k;cin >> k;
      e[i][j]=k-1;
    }
  }

  vector< vector<int> > f(3,vector<int>(c,0));
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      for(int k=0;k<c;k++){
        f[(i+j)%3][k]+=d[e[i][j]][k];
      }
    }
  }
  int m=1000000000;
  for(int i=0;i<c;i++){
    for(int j=0;j<c;j++){
      for(int k=0;k<c;k++){
        if(i!=j and j!=k and k!=i){
          m=min(m,f[0][i]+f[1][j]+f[2][k]);
        }
      }
    }
  }
  cout << m << endl;
}


Measured memory_bytes: 1280
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))

diff_list = []
for i in range(N):
    T_i = T - (0.006*H[i])
    diff = abs(A - T_i)
    diff_list.append(diff)
ans = diff_list.index(min(diff_list)) + 1
print(ans)

Measured memory_bytes: 9284
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<cstdio>
#define MAXA 100000
#define MAX 2000000000?
#define s(i) scanf("%d", &(i))
#define p(i) printf("%d", (i))
#define ps() printf(" ") 
#define rer(i,j,k) for((i)=(j);(i)<(k);++(i))
#define ret(i,j,k) for((i)=(j);(i)>(k);--(i))
using namespace std;
double num[MAXA] = {0}, ave;
int main(){
	int n, i;
	cin >> n;
	rer(i,0,n){
		cin >> num[i];
	}
	sort(num,num+n);
	ave = num[0];
	if(n!=1){
		rer(i,1,n){
			ave+=num[i];
			ave/=2;
		}
	}
	cout << ave << endl;
	return 0;
} 

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

void ball(int i, int N){ // ans[i+1]~ans[N-1]の箱の情報からans[i]の情報を得る
  int num=0, k=i+1;
  while(k<=N){
    num += ans[k-1];
    k += i+1;
  }
  if(num%2!=a[i]) ans[i] = 1;
  return;
}

int main(){
  int N; cin >>N;
  for(int i=0;i<N;i++){
    int x; cin >>x;
    a.push_back(x);
  }

  ans.assign(N,0);
  for(int i=N-1; i>=0; i--){
    ball(i,N);
  }

  int M=0;
  for(int i=0; i<N; i++){
    if(ans[i]==1) M++;
  }
  cout << M << endl;

  for(int i=0; i<N; i++){
    if(ans[i]==1) cout << i+1 << " ";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 2676
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = []
for i in range(N):
    S.append(INT())

S = sorted(S)

ans = sum(S)
if ans % 10 != 0:
    print(ans)
    exit()
for i in range(N):
    if S[i] % 10 != 0:
        ans = ans - S[i]
        print(ans)
        exit()

print(0)


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

int main(){
  long long x;
  cin >> x;
  long long g500, g5;
  long long happy = 0;
  if(x>=500){
    g500 = x/500;
    x %= 500;
    happy += 1000 * g500;
  }
  if(x < 500){
    g5 = x/5;
    happy += 5 * g5;
  }
  cout << happy << endl;
  return 0;
}
  


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const ll INF = 1e18;
const int N = 1e5;
ll a[N], b[N], mia, mib;
VI ea[N], eb[N];
VL sa[N], sb[N];

void dfsb(int);

void dfsa(int now){
    mia = min(mia, a[now]);
    REP(i,ea[now].size()){
        int next = ea[now][i];
        ll sum = sa[now][i];
        if (b[next] < INF) continue;
        b[next] = sum - a[now];
        dfsb(next);
    }
}

void dfsb(int now){
    mib = min(mib, b[now]);
    REP(i,eb[now].size()){
        int next = eb[now][i];
        ll sum = sb[now][i];
        if (a[next] < INF) continue;
        a[next] = sum - b[now];
        dfsa(next);
    }
}

int main(){
    int r, c, n;
    cin >> r >> c >> n;

    fill(a, a+r, INF);
    fill(b, b+c, INF);

    VI x(n), y(n), s(n);

    REP(i,n){
        int rr, cc, ss;
        scanf("%d %d %d", &rr, &cc, &ss);
        rr--;
        cc--;
        x[i] = rr;
        y[i] = cc;
        s[i] = ss;
        ea[rr].push_back(cc);
        sa[rr].push_back(ss);
        eb[cc].push_back(rr);
        sb[cc].push_back(ss);
    }

    REP(i,n){
        if (a[x[i]] < INF) continue;
        a[x[i]] = 0;
        mia = mib = INF;
        dfsa(x[i]);
        if (mia + mib < 0){
            cout << "No" << endl;
            return 0;
        }
    }

    REP(i,n){
        if (a[x[i]] + b[y[i]] != s[i]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 24832
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <set>
#include <unordered_map>
#include <cstring>

using namespace std ;

#define int long long 
#define endl "\n" 

const int size = 405 ;
int dp[size][size] , a[size] , pre[size] , n ;

int fun( int i , int j )
{
     if(i == j ) return 0 ;
     int &ans = dp[i][j] ;
     if(ans!=-1) return ans ;
     ans = 1e15 ;
     int adder  = pre[j] - pre[i-1] ;
     for(int k = i ; k < j ; k++ )
     {
         ans = min(ans,adder+fun(i,k)+fun(k+1,j));
     }
     return ans ;
}





int32_t main()
{
     /*#ifndef ONLINE_JUDGE 
     freopen("input.txt","r",stdin) ;
     freopen("output.txt","w",stdout) ;
     #endif*/ 
     memset(dp,-1,sizeof(dp));
     cin >> n ;
     for(int i = 1; i <= n ; i++ ) cin >> a[i] ;
     for(int i = 1; i <= n ; i++ ) pre[i] = pre[i-1] + a[i] ;
     /*for(int i = 1 ; i <= n ; i++ )
     {
         cout<<pre[i]<<" ";
     }cout<<endl;*/
     cout<<fun(1,n)<<endl;
     return 0 ;
}

Measured memory_bytes: 1664