akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

void print_array(int *a, int size) {
    for (int i = 0; i < size; i++) {
        if (i != 0) std::cout << " ";
        std::cout << a[i];
    }
    std::cout << "\n";
}

void sort(int *a, int size) {
    int j, v;
    for (int i = 1; i < size; i++) {
        print_array(a, size);
        v = a[i];
        j = i - 1;
        while (j >= 0 && a[j] > v) {
            a[j + 1] = a[j];
            j--;
            a[j + 1] = v;
        }
    }
}

int main() {
    const int MAX = 100;
    int N;
    int a[MAX];
    std::cin >> N;
    for (int i = 0; i < N; i++) std::cin >> a[i];
    sort(a, N);
    print_array(a, N);
    return 0;
}


Measured memory_bytes: 3052
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  int n,i;
  int a[1000000];
  bool p[1000000];


  cin>>n;
  p[0]=false;

  for(i=1;i<=n;i++){
    cin>>a[i];
    p[i]=false;
  }

  for(i=1;i<=n;i++){
    if(a[a[i]]==i){
      p[i]=true;
      p[a[i]]=true;
    }
  }
  int ans=0;
  for(i=1;i<=n;i++)
    if(p[i])
      ans++;
  cout<<ans/2<<endl;
}


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

ll two(ll p) {
  ll i = 0;
  while(p % 2 == 0) {
    p /= 2;
    i++;
  }
  return i;
}

ll gcd(ll a, ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a,b);
  return (a/g)*(b/g)*g;
}

int main(){
  ll n, m;
  cin >> n >> m;
  ll a[n];
  rep(i,n) cin >> a[i];
  set<ll> s;
  ll b = two(a[0]);
  for(int i = 1; i < n; i++) {
    if(two(a[i]) != b) {
      cout << 0 << endl;
      return 0;
    }
  }
  ll g = a[0];
  for(int i = 1; i < n; i++) {
    g = lcm(g,a[i]);
    if(g > 2*m) {
      cout << 0 << endl;
      return 0;
    }
  }
  cout << (m-g/2)/g + 1 << endl;
  return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
res = 0
for i in range(n):
    kill = min(a[i],b[i])
    res += kill
    a[i] -= kill
    b[i] -= kill
    
    kill = min(a[i+1],b[i])
    res += kill
    a[i+1] -= kill
    b[i] -= kill
print(res)


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

int main() {
  int k;
  cin >> k;
  int mod = 0;
  for (int i = 1; i <= k; i++) {
    mod *= 10;
    mod += 7;
    mod %= k;
    if (mod == 0) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

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

using namespace std;

int main()
{
  while (true) {
    string s;
    cin >> s;
    if (s == "-") break;
    uint n;
    cin >> n;
    uint sum = 0;
    for (int i = 0; i < n; i++) {
      uint t;
      cin >> t;
      sum += t;
    }
    uint r = sum % s.size();
    cout << s.substr(r) << s.substr(0, r) << endl;
  }
}



Measured memory_bytes: 3040
// INCLUDES
#include <bits/stdc++.h>
#include <assert.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//DEFINES
#define MAX 1000001
#define pii pair<int, int>
#define c1 __builtin_popcount
#define F first
#define S second
#define all(s) begin(s), end(s)
#define MIN3POS(a, b, c) (a) = < (b) ? ((a) = < (c) ? 1 : 3) : ((b) = < (c) ? 2 : 3)
#define MAX3POS(a, b, c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2 : 3)
#define endl '\n'
#define int long long
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define IOS                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define error(args...)                           \
    {                                            \
        string _s = #args;                       \
        replace(_s.begin(), _s.end(), ',', ' '); \
        stringstream _ss(_s);                    \
        istream_iterator<string> _it(_ss);       \
        err(_it, args);                          \
    }
//NAMESPACES
using namespace __gnu_pbds;
using namespace std;
vector<string> vec_splitter(string s)
{
    s += ',';
    vector<string> res;
    while (!s.empty())
    {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
    vector<string> __attribute__((unused)) args,
    __attribute__((unused)) int idx,
    __attribute__((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T)
{
    if (idx > 0)
        cerr << ", ";
    else
        cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss;
    ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
int n;
vector<int> v;
int dp[404][404];
int func(int l, int r)
{
    if (l == r)
        return 0;
    int &res = dp[l][r];
    if (res == -1)
    {
        int ans = 1e18L + 5;
        int sum = 0;
        for (int i = l; i <= r; i++)
            sum += v[i];
        for (int i = l ; i < r; i++)
        {
            ans = min(ans, func(l, i) + func(i + 1, r) + sum);
        }
        res =  ans;
    }
    return res;
}
void solve()
{
    cin >> n;
    v.resize(n);
    FOR(i, 0, n)
        cin >> v[i];
    FOR(i,0,404) FOR(j,0,404) dp[i][j] = -1;
    int ans = func(0, n - 1);
    cout << ans;
}
int32_t main()
{
    IOS int t = 1;
    // cin>>t;
    while (t--)
    {
        solve();
    }
    return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring

Measured memory_bytes: 1536
#include <stdio.h>
int main(void){
    int a,b;
    a>=-1000;
    b<=1000;
    scanf("%d %d",&a,&b);
    if(a<b){
        printf("a < b\n");
    }
    else if(a>b){
        printf("a > b\n");
    }
    else{
    printf("a == b\n");
    }
return 0;
}



Measured memory_bytes: 2104
INT_MAX=10**11+7
MOD=10**9+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
#=======================================================================
n=int(input())
ans=0
x=1
while(n!=0):
    ans+=x
    x*=2
    n//=2
print(ans)


Measured memory_bytes: 38384
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;

template <typename T> inline constexpr bool chmin(T &a, T b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <typename T> inline constexpr bool chmax(T &a, T b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}
template <typename ite>
void print_ite(ite start, ite end, char sp = ' ', char en = '\n') {
  for (auto i = start; i != end; i++)
    cout << *i << sp;
  cout << en;
}
template <typename ite> void scan_ite(ite start, ite end) {
  for (auto i = start; i != end; i++)
    cin >> (*i);
}
inline void Yes(bool condition) { cout << (condition ? "Yes\n" : "No\n"); }

int main() {
  int n, m;
  cin >> n >> m;
  int sum = 0;
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    sum += a;
  }
  if (sum > n)
    cout << -1 << endl;
  else
    cout << n - sum << endl;
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
#define int long long
#define MOD 1e9+7
typedef pair<int,int> P;
typedef pair<int,P> PP;
int h,w,mi;
int m[22][22],si,sj;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};

void dfs(int x=si,int y=sj,int k=0){
  if(k==10)return;  
  for(int i=0;i<4;i++){
    int nx=x+dx[i];
    int ny=y+dy[i];
    if(nx<0||h<=nx||ny<0||w<=ny)continue;
    if(m[nx][ny]==1)continue;
    while(1){
	 if(m[nx][ny]==3){
	   mi=min(mi,k+1);
	   break;
	 }
	 if(m[nx][ny]==1){
	   m[nx][ny]=0;
	   dfs(nx-dx[i],ny-dy[i],k+1);
	   m[nx][ny]=1;
	   break;
	 }
	 nx+=dx[i];
	 ny+=dy[i];
	 if(nx<0||h<=nx||ny<0||w<=ny)break;
    }
  }
}

signed main(){
  while(1){
    cin>>w>>h;
    if(h+w==0)break;
    for(int i=0;i<h;i++){
	 for(int j=0;j<w;j++){
	   int k;
	   cin>>k;
	   m[i][j]=k;
	   if(k==2){
		si=i,sj=j;
		m[i][j]=0;
	   }
	 }
    }
    mi=11;
    dfs();
    if(mi==11)cout<<-1<<endl;
    else cout<<mi<<endl;
  }
  return 0;
}



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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 200005;

int main()
{
    LL num;
    cin >> num;
    if(num % 2) cout << 0 << endl;
    else{
        LL ans = 0;
        LL first = 10;
        while(num >= first){
            ans += num/first;
            first*=5;
        }


        cout << ans << endl;


    }


    return 0;
}


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




int main() {
  
 int A, B, ABC;
  A = 0;
  B = 0;
  ABC = 0;
  
  bool comit = false;
  
  cin >> A >> B;
  
  if(A < B) {
    
    for(int soezi0 = 0; soezi0 <= B; soezi0++) {
      
      if(soezi0 - A == B - soezi0) {
        
        comit = true;
        ABC = soezi0;
        break;
        
      }
      
    }
    
  } else {
    
    for(int soezi1 = 0; soezi1 <= A; soezi1++) {
      
      if(A - soezi1 == soezi1 - B) {
        
        ABC = soezi1;
        comit = true;
        break;
        
      }
      
    }
    
  }
  
  if(comit) {
    
    cout << ABC << endl;
    
  } else {
    
    cout << "IMPOSSIBLE" << endl;
    
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int n,m;
	cin >> m >> n;
	int sum=0,x;
	for(int i=0;i<n;i++){cin >> x;sum+=x;}
	if(sum>m)cout << "-1" << endl;
	else cout << m-sum << endl;
}


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

int main() {
  int n, y, m, d;
  cin>>n;
  while(n--) {
    cin>>y>>m>>d; m--,d--;
    int ans = 0;
    while(true) {
      if (y == 1000 && m == 0 && d == 0) break;
      ans++; d++;
      if ((d == 19 && m%2==1 && y%3 != 0) || d == 20) {
        m++, d = 0;
      }
      if (m == 10) {
        y++, m = 0, d = 0;
      }
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1160
#[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::{stdout, stdin, BufWriter, Write};

#[doc = " [l, r)"]
pub fn binary_search_by<F>(mut l: usize, mut r: usize, f: &F) -> usize
where
    F: Fn(usize) -> bool,
{
    assert!(l <= r);
    while r != l {
        let m = l + (r - l) / 2;
        if f(m) {
            r = m;
        } else {
            l = m + 1;
        }
    }
    r
}


fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      aa: [i64; n],
    }
    let mut dp = vec![-1; n];
    for a in aa {
        let idx = binary_search_by(0, n, &|mid| dp[mid] < a);
        dp[idx] = a;
    }
    // debug!(dp);
    for i in 0..n {
        if dp[i] < 0 {
            return puts!("{}\n", i);
        }
    }
    puts!("{}\n", n);
}


Measured memory_bytes: 6396
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#include<queue>
#define MAXN 200001
#define inf 1061109567

inline void read(int &T) {
	int x=0;bool f=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=!f;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	T=f?-x:x;
}

int n,m,to[MAXN];
int cnt,head[MAXN];
int vis[MAXN],dis[MAXN];
struct Edge {
	int next,to;
}pth[MAXN<<2];
std::queue<int> q;

void add(int from,int to) {
	pth[++cnt].to=to,pth[cnt].next=head[from];
	head[from]=cnt;
}

int main() {
	memset(dis,0x3f,sizeof dis);
	read(n),read(m);
	for(int i=1,u,v;i<=m;++i) {
		read(u),read(v);
		add(u,v),add(v,u);
	}
	q.push(1);dis[1]=0;
	while(!q.empty()) {
		int u=q.front();q.pop();
		for(int i=head[u];i;i=pth[i].next) {
			int v=pth[i].to;
			if(dis[v]>dis[u]+1) {
				dis[v]=dis[u]+1;
				to[v]=u;
			}
			if(!vis[v]) {
				q.push(v);
				vis[v]=1;
			}
		}
	}
	for(int i=2;i<=n;++i) {
		if(dis[i]==inf) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	for(int i=2;i<=n;++i) {
		printf("%d\n",to[i]);
	}
	return 0;
}

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

int main(){

  long long N,A;

  cin >> N;

  long long ans = 0,nsum = 0;

  map <long long,long long> dic;
  dic[0] = 1;

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

    cin >> A;

    nsum += A;

    ans += dic[nsum];

    dic[nsum] += 1;

  }

  cout << ans << endl;

  return 0;

}


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

int main() {
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    rep(i,m) cin >> b[i];
    int ct = 0;
    rep(i,n) {
        vector<int> a(m);
        rep(k,m) cin >> a[k];
        int sum = 0;
        rep(j,m) sum += a[j]*b[j];
        sum += c;
        if (sum > 0) ct++;
    }
    cout << ct << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    StringBuffer ans;
    String[] num = {"", "", "k", "s", "t", "n", "h", "m", "y", "r"};
    String[] b = {"a", "i", "u", "e", "o"};
    char[] st;

    void run(){
	while(sc.hasNext()){
	    st = sc.next().toCharArray();
	    ans = new StringBuffer();
	    solve();
	}
    }

    void solve(){
	int i=0;
	while(i<st.length){
	    char x = st[i++];
	    char y = st[i++];
	    ans.append(getChar(x, y));
	}
	System.out.println(ans.toString());
    }

    String getChar(char x, char y){
	if(x!='0'){
	    return (String)num[x-'0']+b[getB(y)];
	}
	else{
	    if(y=='T') return "wa";
	    else if(y=='D') return "wo";
	    else return "nn";
	}
    }

    int getB(char y){
	if(y=='T') return 0;
	else if(y=='L') return 1;
	else if(y=='U') return 2;
	else if(y=='R') return 3;
	else return 4;
    }
}

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

mt19937 mt(time(nullptr));
// uniform_int_distribution< int > rand_int(0, 10) // rand[0, 10] inclusive

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  string s;
  cin >> s;
  vector< int > ans(s.size(), 0);
  vector< int > r(s.size(), 0), l(s.size(), 0);
  int last_r = 0;
  for (int i=0; i<s.size(); ++i) {
    if (s[i]=='R') {
      last_r = i;
      continue;
    }
    r[i] = last_r;
  }
  int last_l = s.size()-1;
  for (int i=s.size()-1; i>=0; --i) {
    if (s[i]=='L') {
      last_l = i;
      continue;
    }
    l[i] = last_l;
  }
  for (int i=0; i<s.size(); ++i) {
    int tgt;
    if (s[i]=='R') {
      tgt = l[i];
      if ((l[i]-i)%2!=0) tgt--;
    }
    else {
      tgt = r[i];
      if ((i-r[i])%2!=0) tgt++;
    }
    ans[tgt]++;
  }
  for (int i=0; i<s.size(); ++i) cout << ans[i] << " ";
  cout << endl;
  return 0;
}


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

typedef long long ll;

int N, M;
vector<int> A, B;
vector<ll> ans;
vector<int> par;

void init_union_find(int n) {
	par.resize(n, -1);
}

int find(int x) {
	if (par[x] < 0) return x;
	return par[x] = find(par[x]);
}

bool same(int x, int y) {
	return find(x) == find(y);
}

int get_size(int x) {
	return -par[find(x)];
}

bool unite(int x, int y) {
	x = find(x); y = find(y);
	if (x == y) return false;
	if (get_size(x) < get_size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
	return true;
}

void input_init(void) {
	cin >> N >> M;
	A.resize(M);
	B.resize(M);
	for (int i = 0; i < M; ++i) {
		cin >> A[i] >> B[i];
		--A[i];
		--B[i];
	}
}

void solve(void) {
	ans.resize(M);
	init_union_find(N);
	ll cnt = (ll)N * (N - 1) / 2;
	for (int i = M - 1; i >= 0; --i) {
		ans[i] = cnt;
		if (same(A[i], B[i])) continue;
		int cnt_a = get_size(A[i]);
		int cnt_b = get_size(B[i]);
		cnt -= (ll)cnt_a * cnt_b;
		unite(A[i], B[i]);
	}
}

int main(void) {
	input_init();
	solve();
	for (int i = 0; i < M; ++i)
		cout << ans[i] << '\n';
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

void TorT()
{
  int n, a, b;
  cin >> n >> a >> b;
  if (n * a > b) cout << b << endl;
  else           cout << n * a << endl;
}

void cross9_9()
{
  int a, b;
  cin >> a >> b;
  if (a > 0 && a < 10 && b > 0 && b < 10) cout << a * b << endl;
  else cout << -1 << endl;
}
int main()
{
  //TorT();
  cross9_9();
}

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

int gcd(int x, int y) {
    if (x % y == 0) {
        return y;
    }

    else {
        return gcd(y, x % y);
    }
}

int gcd_3(int x, int y, int z) {
  return gcd(gcd(x, y), z);
}

int main () {
  int K;
  cin >> K;
  int count = 0;
  for (int i = 0; i < K; i++) {
    for (int j = 0; j < K; j++) {
      for (int k = 0; k < K; k++) {
        count += gcd_3((i + 1), (j + 1), (k + 1));
      }
    }
  }
  cout << count << endl;        
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
long ncrmodp(int n,int r,long p){
  long i;
  long ans = 1;
  for(i=n;i>n-r;i--){
    ans *= i;
    ans %= p;
  }
  long tmp = 1;
  for(i=2;i<=r;i++){
    tmp *= i;
    tmp %= p;
  }
  for(i=1;i<=p-2;i*=2){
    if(p-2 & i){
      ans *= tmp;
      ans %= p;
    }
    tmp = (tmp*tmp)%p;
  }
  return ans;
}
int main(){
  int n,k;
  cin >> n >> k;
  int i,j;
  long const mod = 1000000007;
  for(i=1;i<=k;i++){
    long ans = 1;
    ans *= ncrmodp(k-1,i-1,mod);
    ans %= mod;
    ans *= ncrmodp(n-k+1,i,mod);
    ans %= mod;
    cout << ans << endl;
  }

}


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

int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int ans = 0, answer=1e9;
	for (int i = 0; i <= 100000; i++) {
		if (x > i) {
			ans += a * (x - i);
		}
		if (y > i) {
			ans += b * (y - i);
		}
		ans += i * 2 * c;
		answer = min(answer, ans);
		ans = 0;
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SQ(a) (a)*(a)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define ll long long int 
typedef vector<ll> vi;
typedef pair<ll, ll> pi;

bool check(vector<int> freq, int n)
{
	while (n > 0)
	{
		int digit = n % 10;
		if (freq[digit] == 1)
			return false;
		n /= 10;
	}
	return true;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	cout.tie(NULL);
	int n, k;
	cin >> n >> k;
	vector<int> freq(10, 0);
	for (int i = 0; i < k; i++)
	{
		int temp;
		cin >> temp;
		freq[temp]++;
	}
	while (true)
	{
		if (check(freq, n))
			break;
		n++;
	}
	cout << n;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func search(in [9]byte) int {
	for i := 0; i < 9; i++ {
		if in[i] == byte(0) {
			return i
		}
	}
	panic("not found 0")
}

func Up(in [9]byte) (bool, [9]byte) {
	pos := search(in)
	if pos > 2 {
		in[pos], in[pos-3] = in[pos-3], in[pos]

	} else {
		return false, in
	}
	return true, in

}

func Down(in [9]byte) (bool, [9]byte) {
	pos := search(in)
	if pos < 6 {
		in[pos], in[pos+3] = in[pos+3], in[pos]
	} else {
		return false, in

	}
	return true, in

}

func Left(in [9]byte) (bool, [9]byte) {
	pos := search(in)
	// mod(pos, 3) == 0
	if pos != 0 && pos != 3 && pos != 6 {
		in[pos], in[pos-1] = in[pos-1], in[pos]
	} else {
		return false, in
	}
	return true, in

}
func Right(in [9]byte) (bool, [9]byte) {
	pos := search(in)
	// mod(pos, 3) == 2
	if pos != 2 && pos != 5 && pos != 8 {
		in[pos], in[pos+1] = in[pos+1], in[pos]
	} else {
		return false, in

	}
	return true, in

}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

var goal = [9]byte{1, 2, 3, 4, 5, 6, 7, 8, 0}

type item struct {
	d *[9]byte
	c int
}

var queue = []item{}
var closed = map[[9]byte]bool{}

func bfs(cost int) int {
	for {

		top := queue[0]
		queue = queue[1:]

		if *top.d == goal {
			return top.c
		}
		closed[*top.d] = true

		ok, ur := Up(*top.d)
		ok2, _ := closed[ur]
		if ok && !ok2 {
			queue = append(queue, item{&ur, top.c + 1})
		}
		ok, dr := Down(*top.d)
		ok2, _ = closed[dr]
		if ok && !ok2 {
			queue = append(queue, item{&dr, top.c + 1})
		}
		ok, lr := Left(*top.d)
		ok2, _ = closed[lr]
		if ok && !ok2 {
			queue = append(queue, item{&lr, top.c + 1})
		}
		ok, rr := Right(*top.d)
		ok2, _ = closed[rr]
		if ok && !ok2 {
			queue = append(queue, item{&rr, top.c + 1})
		}
	}

}

func main() {
	sc.Split(bufio.ScanWords)
	var state [9]byte
	for i := 0; i < 9; i++ {
		state[i] = byte(nextInt())
	}
	queue = append(queue, item{&state, 0})
	cost := bfs(0)
	fmt.Println(cost)
}



Measured memory_bytes: 23496
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
	
		// First input needs to be length
		int length = in.nextInt();
	
		// Create an array with that length
		int[] a = new int[length];
		
		// Fill in that array with the second input
		for (int i = 0; i < length; i++) {
			a[i] = in.nextInt();
		}
		
		// Prints the unsorted Array
		print(a);
		System.out.println();
		
		//Now time to sort it
		for (int i = 1; i < length; i++) {
			// the value of this specific index
			int ind = a[i];
			// index for the number before the index (i) now
			int j = i -1;
			// WHILE j is positive and it's value is greater than ind...
			while(j>=0 && a[j] > ind) {
				// The value will be pushed down away from ind
				a[j+1] = a[j];
				j = j-1;
			}
			// if they find a value less, than the ind is pushed so that value is before it
			a[j+1] = ind;
			//Show the array as it's sorted
			print(a);
			System.out.println();
		}
	
	
	}
	
	public static void print(int[] nums) {
		
		
		for (int i = 0; i < nums.length-1; i++) {
			System.out.print(nums[i]);
			System.out.print(" ");
		}
		System.out.print(nums[nums.length-1]);	
	}
	
}



Measured memory_bytes: 33768
#include <iostream>
#include <string>
using namespace std;
int main() {
  int n;
  cin >> n;
  string str;
  string s2;
  int left(0), right(0);
  while (n--) {
    char c;
    cin >> c;
    if (s2.empty() || !(s2.back() == '(' && c == ')')) {
      s2 += c;
      c == '(' ? left++ : right++;
    } else if (!s2.empty()) {
      s2.back() == '(' ? left-- : right--;
      s2.pop_back();
    }
    str += c;
  }
  cout << string(right, '(') << str << string(left, ')');
  return 0;
}


Measured memory_bytes: 256
N = int(input())
# works = 所要時間, 締め切り時間
works = [list(map(int, input().split())) for _ in range(N)]
# 終えられるか否かをチェックすればいい
# タスク締切の昇順＞タスクの所要時間の降順 でソートする
tmp = sorted(works, key=lambda x: x[0], reverse=True)
sorted_works = sorted(tmp, key=lambda x: x[1])

current_hour = 0
ans = "Yes"
for required_hour, dead_line in sorted_works:
    current_hour += required_hour
    if dead_line < current_hour:
        ans = "No"
print(ans)


Measured memory_bytes: 56556
h, w = list(map(int, input().split()))
maps = [list(input()) for i in range(h)]

def search(i, j):
  pts = set([ (max(0, i-1), j), (i, max(0, j-1)), 
        (min(h-1, i+1), j), (i, min(w-1, j+1))])
  
  for dh, dw in list(pts):
    if maps[dh][dw] == "#":
      return True
  return False

flag = True
for i in range(h):
  for j in range(w):
    if maps[i][j] == "#": 
      if not search(i, j):
        flag = False
        break
        
print("Yes" if flag else "No")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int a = scanner.nextInt();
    int b = scanner.nextInt();

    new Main().execute(a, b);
  }

  public void execute(int a, int b) {

    System.out.println(a * b % 2 == 0 ? "Even" : "Odd");

  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string.h>
#include <cstdio>
#include <algorithm>
#include <string>
#include <math.h>
#include <map>
using namespace std;
#define ll long long
ll n,m;
struct node{
    int x,y;
}a[100010];
bool cmp(node p1,node p2)
{
    return p1.x < p2.x;
}
int main()
{
    scanf("%lld%lld",&n,&m);
    int x1,y1;
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&x1,&y1);
        a[i].x = x1;
        a[i].y = y1;
    }
    sort(a+1,a+1+n,cmp);

    for(int i=1;i<=n;i++)
    {
        if(a[i].y >= m)
        {
            cout<<a[i].x<<endl;
            return 0;
        }
        else
        {
            m = m - a[i].y;
        }
    }

    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#define INFTY 2000000000
int n;
void mergesort(int*,int,int);
void merge(int*,int,int,int);
double sum=0;
int main(){
  int i,a[500000],left,right;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  left=0; right=n;
  mergesort(a,left,right);
  printf("%.0lf\n",sum);
  return 0;
}
void mergesort(int a[],int left, int right){
  int mid;
  if((left+1)<right){
    mid=(left+right)/2;
    mergesort(a,left,mid);
    mergesort(a,mid,right);
    merge(a,left,mid,right);
  }
}
void merge(int a[],int left,int mid,int right){
  int n1,n2,i,j,k,t;
  n1 = mid-left;
  n2 = right-mid;
  int l[n1+1],r[n2+1];
  for(i=0;i<n2;i++){
    r[i]=a[mid+i];
  }
  for(i=0;i<n1;i++){
    l[i]=a[left+i];
  }
  l[n1]=r[n2]=INFTY;
  i=j=0;
  t=0;
  for(k=left;k<right;k++){
    if(l[i]<=r[j]){
      a[k]=l[i];
      i++;
      sum+=t;
    }
    else{
      a[k]=r[j];
      j++;
      t++;
      
    }
  }
}



Measured memory_bytes: 3292
import Control.Monad

main = do
  (h:w:_) <- getLine >>= return . (map read) . words :: IO [Int]
  n <- readLn :: IO Int
  a <- getLine >>= return . (map read) . words :: IO [Int]

  let lst = func w (concat [take (a!!i) (repeat (i+1)) | i<-[0..length a-1]])
  let lst2 = map (unwords . (map show)) [if even i then (lst!!i) else reverse (lst!!i) | i<-[0..length lst-1]]

  mapM_ putStrLn lst2

  where
    func :: Int -> [a] -> [[a]]
    func _ [] = []
    func w xs = (take w xs) : (func w (drop w xs))



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

ll solve() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) cin >> A[i];
    ll x = 1000, s = 0;
    for ( int i = 0; i < N-1; i++ ) {
        if ( A[i] < A[i+1] ) {
            ll b = x/A[i];
            x -= b*A[i];
            s += b;
        } else {
            x += s*A[i];
            s = 0;
        }
    }
    if ( s > 0 ) {
        x += s*A[N-1];
    }
    ll ans = x;
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define lint long long
#define st first
#define nd second

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int n; lint k;
	cin>>n>>k;

	vector<int> a(n);
	vector<bool> vis(n,false);
	vector<int> loop;
	for(int &p:a){
		cin>>p; p--;
	}

	int u=0;

	while(!vis[u]){
		loop.push_back(u);
		vis[u]=1;
		u = a[u];
	//	cerr<<"\t"<<loop.back()+1<<"\n";
	}

	int ini=u;
	int p_ini=0;
	while(loop[p_ini] != ini) p_ini++;
	if(k <= p_ini){
		cout<<loop[k]+1<<"\n";
	}else{
		k -= p_ini;
		int lsz = loop.size() - p_ini;
	//	cerr<<"lsz "<<lsz<<"\n";
	//	cerr<<"p ini "<<p_ini<<"\n";
		k %= lsz; if(k<0) k += lsz;
		
		cout<<loop[p_ini+k]+1<<"\n";

	}

	return 0;	
}



Measured memory_bytes: 5068
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll cub(ll x) {
  return x*x*x;
}

int main() {
  int n,k; cin >> n >> k;
  ll ans = cub(n/k);
  if (k%2==0) ans += cub(n / (k/2) - n/k);
  COUT(ans);
  return 0;
}

Measured memory_bytes: 3624
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return ~n & 1; }
template<typename T> int len(const T &v) { return v.size(); }
template<typename T = int> T in() { T x; cin >> x; return x; }
template<typename T = int> T in(T &&x) { T z(forward<T>(x)); cin >> z; return z; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> istream &operator>>(istream &is, pair<A, B> &p) { return is >> p.first >> p.second; }
template<typename T> ostream &operator<<(ostream &os, const vector<vector<T>> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : "\n"); return os; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "" : " "); return os; }
template<typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << ' ' << p.second; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
// clang-format on

main() {
  int q = in();
  map<string, int> m;
  while (q--) {
    int t = in();
    if (t == 0) {
      string k;
      int x;
      cin >> k >> x;
      m[k] = x;
    }
    if (t == 1) {
      string s;
      cin >> s;
      cout << (m.count(s) ? m[s] : 0) << endl;
    }
    if (t == 2) m.erase(in<string>());
    if (t == 3) {
      string l, r;
      cin >> l >> r;
      for (auto it = m.lower_bound(l), end = m.upper_bound(r); it != end; it++) cout << *it << endl;
    }
  }
}



Measured memory_bytes: 27648
use std::cmp;

fn main(){
  let ntq: Vec<usize> = read_vec();
  let n = ntq[0];
  let t = ntq[1] as i64;
  let q = ntq[2];

  let mut va: Vec<i64> = Vec::new();
  let mut vd: Vec<u32> = Vec::new();

  for _ in 0 .. n {
    let t: Vec<i64> = read_vec();
    va.push(t[0]);
    vd.push(t[1] as u32);
  }

  let mut ny: usize = 0;
  let mut em: i64 = std::i64::MIN;

  for i in 0 .. n {
    if vd[i] == 2 {
      if i == ny {
        va[i] = cmp::max(va[i] - t, em);
      } else {
        let x = (va[i] + va[i-1]) / 2;
        if va[i] - t > x {
          va[i] -= t;
          for j in ny .. i {
            va[j] += t;
          }
          em = va[i-1];
        } else {
          va[i] = x;
          va[i-1] = x;
          em = x;
          for j in ny .. i-1 {
            va[j] = cmp::min(x, va[j] + t);
          }
        }
      }
      ny = i + 1;
    }
  }

  for i in ny .. n {
    va[i] += t;
  }

  for _ in 0 .. q {
    let i: usize = read();
    println!("{}", va[i-1]);
  }
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}



Measured memory_bytes: 7100
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;cin>>n>>k;
  int ans=0;
  int h=0;
  for(int i=0;i<n;++i){
    cin>>h;
    if(h>=k){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    map<int,int> t;
    REP(i,n) {
        int x; cin >> x;
        t[x]++;
    }
    vector<int> v1(1,0);
    vector<int> v2;
    for(auto p:t) {
        if (p.first == 12 || p.first == 0 ) {
            v1.emplace_back(p.first);
        } else if (p.second == 1){
            v2.emplace_back(p.first);
        }
        else if (p.second == 2) {
            v1.emplace_back(p.first);
            v1.emplace_back(24-p.first);
        } else { // p.second >= 3
            v1.emplace_back(p.first);
            v1.emplace_back(p.first);
            v1.emplace_back(24-p.first);
        }
    }

    //cerr << v2[0] << endl;
    int ans = 0;
    int to = pow(2,v2.size());
    REP(i,to) {
        int i2 = i;
        vector<int> v3(v1);
        REP(j,v2.size()) {
            if (i2 % 2 == 0) {
                v3.emplace_back(v2[j]);
            } else {
                v3.emplace_back(24-v2[j]);
            }
            i2 /= 2;
        }
        
        sort(ALL(v3));
        int tmp = 24;
        REP(k,v3.size()-1) tmp = min(tmp,v3[k+1] - v3[k]);
        tmp = min(tmp,24-v3.back());
        ans = max(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        String s = sc.nextLine();
        String[] str = new String[3];
        int count = 0;
        str = s.split("");
        for (int i = 0; i < str.length; i++)
            if (str[i].equals("1"))
                count++;
        System.out.println(count);
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define INF (1<<30)
#define INFLL (1ll<<60)
using namespace std;
map <int,int> mp;
typedef pair<int, int> P;
typedef long long ll;
static const int MAX=100000;

int main(){
    int a[3];

    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);

    if(a[0]==5&&a[1]==5&&a[2]==7)
        cout<<"YES"<<"\n";
    else 
        cout<<"NO"<<"\n";

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
    string s,t;
    cin >> s >> t;
    rep(i,t.size()){
        char tmp = s.front();
        s = s + tmp;
        s.erase(0,1);
        //cout << s << endl;
        if(s == t) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main(){
    
    // 1. 入力情報.
    char c[111];
    scanf("%s", c);
    string S(c);
    int l = S.size();
    
    // 2. "keyence" に 変換できるか？
    bool ok = false;
    if(S.substr(l - 7, 7) == "keyence")                         ok = true;
    if(S.substr(0, 1) == "k" && S.substr(l - 6, 6) == "eyence") ok = true;
    if(S.substr(0, 2) == "ke" && S.substr(l - 5, 5) == "yence") ok = true;
    if(S.substr(0, 3) == "key" && S.substr(l - 4, 4) == "ence") ok = true;
    if(S.substr(0, 4) == "keye" && S.substr(l - 3, 3) == "nce") ok = true;
    if(S.substr(0, 5) == "keyen" && S.substr(l - 2, 2) == "ce") ok = true;
    if(S.substr(0, 6) == "keyenc" && S.substr(l - 1, 1) == "e") ok = true;
    if(S.substr(0, 7) == "keyence")                             ok = true;
    
    // 3. 出力.
    if(ok) puts("YES");
    else   puts("NO");
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < n; ++i)
#define FORR(i, m, n) for (ll i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<int> a(n);
    map<int,int> mp;
    REP(i,n){
        cin >> a[i];
        mp[a[i]]++;
    }
    ll ans=0;
    REP(i,n){
        if(a[i]>mp[a[i]]){
            ans+=mp[a[i]];
            mp[a[i]]=0;
        }
        else{
            ans+=mp[a[i]]-a[i];
            mp[a[i]]=a[i];
        }
    }
    cout << ans << endl;
}

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

int main()
{
    int a; cin >> a;
    cout << a + a*a + a*a*a << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define MOD 1000000007
typedef long long ll;

int main(){
	ll n, a, b, ans, q, r;
	scanf("%lld%lld%lld", &n, &a, &b);
  	q = n / (a + b);
	r = n % (a + b);
	ans = a * q;
	if(r <= a) ans += r;
	else ans += a;
	printf("%lld", ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
    int N; cin >> N;
    vector<ll> T(N), A(N);
    for(int i=0; i<N; i++){
        cin >> T[i] >> A[i];
    }

    ll t = 1LL, a = 1LL;
    for(int i=0; i<N; i++){

        if(t <= T[i] && a <= A[i]){
            t = T[i]; a = A[i];
        }
        else{
            ll k = max(ceil((long double)t / T[i]), ceil((long double)a / A[i]));
            t = T[i] * k;
            a = A[i] * k;
        }
        
    }

    cout << t+a << endl;

}


Measured memory_bytes: 256
import Data.List

main = do
 [h,w] <- map read . words <$> getLine
 ss <- words <$> getContents
 let (Just i) = findIndex (== "snuke") ss
 let col = ['A'..'Z'] !! (mod i w)
 let low = div i w + 1
 putStrLn (col : show low)

Measured memory_bytes: 764
# include "algorithm"
# include "iostream"
# include "cstdio"
# include "vector"

using namespace std;

const int maxm=1e6+10;

int N,K,Top,Visit[maxm];
vector<int> LH[maxm];
int Top2,Top3;
long long A[maxm],B[maxm];

int main(){
	register int i,Kind;
	register long long j,Num,Ans=0;
	scanf("%d%d",&N,&K);
	for(i=1;i<=N;i++){
		scanf("%d%lld",&Kind,&Num);
		if(!Visit[Kind]) Visit[Kind]=++Top;
		LH[Visit[Kind]].push_back(Num);
	}
	for(i=1;i<=Top;i++){
		sort(LH[i].begin(),LH[i].end());
		A[++Top2]=LH[i][LH[i].size()-1];
		LH[i].pop_back();
		while(LH[i].size()){
			B[++Top3]=LH[i][LH[i].size()-1];
			LH[i].pop_back();
		}
	}
	sort(A+1,A+Top2+1);sort(B+1,B+1+Top3);
	reverse(A+1,A+1+Top2),reverse(B+1,B+1+Top3);
	for(i=1,j=1;i<=Top2;i++,j++) A[i]=(A[i]+j*j-(j-1)*(j-1));
	for(i=1;i<=Top2;i++) A[i]+=A[i-1];
	for(i=1;i<=Top3;i++) B[i]+=B[i-1];
	for(i=1;i<=Top2;i++){
		if(K-i<0) continue;
		Ans=max(Ans,A[i]+B[K-i]);
	}
	printf("%lld",Ans);
	return 0;
}

Measured memory_bytes: 34048
object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val n = Array.fill(sc.nextInt())(sc.next()).groupMapReduce(identity)(_ => 1)(_ + _)
  val m = Array.fill(sc.nextInt())(sc.next()).groupMapReduce(identity)(_ => 1)(_ + _)
  val ans = n.keys.map(key => n.getOrElse(key, 0) - m.getOrElse(key, 0)).max
  println(if (ans < 0) 0 else ans)
}


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

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

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s[k - 1] += -(int)'A' + 'a';
    cout << s << endl;
}


Measured memory_bytes: 3588
/*
https://atcoder.jp/contests/dp/tasks/dp_g
*/
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 1;
const int oo = 1e9 + 7;
vector <vector <int> > adj;
int n, m;
int f[N], ans = 0;
bool Visited[N];

void Init ()
{
    cin >> n >> m;
    for (int i = 0; i <= n; ++i)
    {
        adj.push_back(vector<int>());
    }
    int u, v;
    for (int i = 0; i < m; ++i)
    {
        cin >> u >> v;
        adj[u].push_back(v);
    }
}

void DFS (int pos)
{
    Visited[pos] = true;
    for (int i = 0; i < adj[pos].size(); ++i)
    {
        if (!Visited[adj[pos][i]]) DFS (adj[pos][i]);
        f[pos] = max (f[pos], f[adj[pos][i]] + 1);
    }
}

int main ()
{
    Init();
    int ans = 0;
    for (int i = 1; i <= n; ++i)
    {
        if (Visited[i]) continue;
        DFS(i);
    }
    for (int i = 1; i <= n; ++i)
    {
        ans = max (ans, f[i]);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 12684
/*
                        ********************
			**  MANAN DIYORA  **
			**    DA-IICT     **
			**   diyora13     **
			********************
*/
#include <bits/stdc++.h>
#include <time.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define inarr(a,n) for(int i=0;i<n;i++) cin>>a[i]
#define outarr(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl
#define maxa(a,n) *max_element(a,a+n)
#define mina(a,n) *min_element(a,a+n)
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(ll i=s;i<e;i++)
#define rf(i,s,e) for(ll i=s-1;i>=e;i--)
#define gcd(a,b) __gcd(a,b)
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define sz size()
#define len length()
#define all(v) v.begin(),v.end()

typedef long long int ll;
typedef long double ld;
typedef pair<long long, long long> pll;
typedef vector<long long> vll;
typedef vector<pair<long long,long long> > vpll;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// bool sortbysec(const pair<int,int> &a,const pair<int,int> &b) { return (a.second < b.second); }
#define PI 3.141592653589793
#define MOD 1000000007

bool flag=0,flag1=0,flag2=0;

int main()
{
	IOS
	ll t=1;
//		cin>>t;
	while(t--)
	{
		ll n; cin>>n;
		if(400<=n && n<=599) cout<<8;
		if(600<=n && n<=799) cout<<7;
		if(800<=n && n<=999) cout<<6;
		if(1000<=n && n<=1199) cout<<5;
		if(1200<=n && n<=1399) cout<<4;
		if(1400<=n && n<=1599) cout<<3;
		if(1600<=n && n<=1799) cout<<2;
		if(1800<=n && n<=1999) cout<<1;
	}
}

Measured memory_bytes: 3652
import sys
input = sys.stdin.readline


def main():
    N, A = map(int, input().split())
    X = list(map(int, input().split()))

    M = max(max(X), A)*N
    dp = [[[0 for k in range(M+1)] for j in range(N+1)] for i in range(N+1)]
    dp[0][0][0] = 1
    for i in range(N):
        for j in range(N):
            for k in range(M):
                if dp[i][j][k]:
                    dp[i+1][j][k] += dp[i][j][k]
                    dp[i+1][j+1][k+X[i]] += dp[i][j][k]
    ans = 0
    for j in range(1, N+1):
        ans += dp[N][j][A*j]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 65516