akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, $var:ident $($r:tt)*) => {
        let $var = parse_val!($it, usize);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

#[cfg(debug_assertions)]
macro_rules! debug {
    ($( $args:expr ),*) => { eprintln!( $( $args ),* ); }
}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($( $args:expr ),*) => {
        ()
    };
}

const K: usize = 26;

#[derive(Debug)]
struct Input {
    d: usize,
    c: Vec<i64>,
    s: Vec<Vec<i64>>,
}

fn get_input<'a>(it: &mut impl Iterator<Item = &'a str>) -> Input {
    parse!(it, d: usize, c: [i64; K]);
    let mut s = vec![];
    for _ in 0..d {
        parse!(it, sl: [i64; K]);
        s.push(sl);
    }
    Input { d, c, s }
}

fn calc_score(input: &Input, t: &[usize]) -> i64 {
    let mut score = 0;
    let mut last = vec![0; K];
    for i in 0..t.len() {
        score += input.s[i][t[i]];
        last[t[i]] = i + 1;
        for j in 0..K {
            score -= input.c[j] * ((i + 1 - last[j]) as i64);
        }
    }
    score
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let input = get_input(&mut it);
    debug!("{:?}", input); // DEBUG
    parse!(it, mut t: [u1; input.d], m: usize);
    for _ in 0..m {
        parse!(it, d: u1, q: u1);
        t[d] = q;
        println!("{}", calc_score(&input, &t));
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2676
import math

a, b = [int(i) for i in input().split(" ")]

def n_one(i, p):
    if i < 0:
        return 0
    a = 2**(p + 1)
    c = i // a
    m = i % a
    return c * (a // 2) + max(0, m + 1 - a // 2)

n = int(math.log2(max(1, b))) + 1

s = 0
for p in range(0, n):
    c = n_one(b, p) - n_one(a - 1, p)
    s += (c % 2) * 2**p
print(s)

Measured memory_bytes: 3064
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions

import copy

# import heapq
# from collections import deque
# import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n = ni()
    a = na()

    c = collections.Counter(a)

    e = sorted(c.items(), reverse=True)
    ans_e = []
    cnt = 0
    for k, v in e:
        if cnt >= 2:
            break
        if v > 1:
            if v < 4:
                ans_e.append(k)
                cnt += 1
            else:
                ans_e.append(k)
                ans_e.append(k)
                cnt += 2

    if cnt >= 2:
        print(ans_e[0] * ans_e[1])
    else:
        print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 22908
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
	long long int N;

	cin >> N;

	long long int ans;

	if (N == 1)
	{
		ans = 0;
	}
	else if ((N - 1) % 2 == 0)
	{
		ans = N * (N - 1) / 2;
	}
	else
	{
		ans = N * ((N - 1) / 2) + N / 2;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<vector<ll>> matrix;//matrix A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
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;}
#define MOD 998244353 //1000000007


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

    // solution comes here

    ll M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;
    cout << (M1 != M2) << nl;
}

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

int main()
{
    int N;
    std::cin >> N;
    
    std::set<std::string> names; 
    for(int i = 0; i < N; i++) {
        std::string name;
        std::cin >> name;
        names.insert(name);
    }
    std::cout << names.size() << std::endl;
}


Measured memory_bytes: 19120
#include <bits/stdc++.h>
using namespace std;
int main(){
  uint64_t n,i,max;
  cin >>n;
  vector<uint64_t> data(n);
  for(i=0;i<n;i++){
    cin >>data.at(i);
  }

  if(n==1){
    cout<<"Yes"<<endl;
  }else{

  max=data.at(0);

  for(i=0;i<n;i++){
    if(data.at(i)<max-1){
      cout<<"No"<<endl;
      break;
    }
    if(max<data.at(i)){
      max=data.at(i);
      }
  }

  if(i==n){
    cout<<"Yes"<<endl;
  }}



  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int, int> pii;  // pair<int, int> に pii という別名を付ける
typedef long long ll;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int N = S.size();
  int count = 0;
  for (int i = 0; i < ceil(N/2.0); i++){
    if(S.at(i) != S.at(N-1-i)){
      count ++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3604
def main():
    import sys
    from bisect import bisect_left, bisect_right
    def input(): return sys.stdin.readline().rstrip()

    n = int(input())
    a = list(map(int, input().split()))
    a = [x-i-1 for i, x in enumerate(a)]
    a.sort()
    mid = a[n//2]
    ans = sum([abs(x-mid) for x in a])
    print(ans)




                
if __name__ == '__main__':
    main()

Measured memory_bytes: 30912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(), (x).end()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end());
const long long INF = 1LL << 60;
// map<int,int> mp;

int main() {
  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;

  if ((v - w) * t >= abs(a - b)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3632
#[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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        x: i64,
        a: i64,
    }
    if x < a {
        println!("0")
    } else {
        println!("10")
    }
}


Measured memory_bytes: 4352
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {
	private static final int MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();

		System.out.println(N - K + 1);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public char nextChar() throws IOException {
			return (char) skip();
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

Measured memory_bytes: 22996
#include <iostream>
using namespace std;
int main(){
    int a,b,k;
    cin >> a >> b >> k;
    int nnum = min(b, a+k-1);
    int xnum = max(a, b-k+1);
    for(int i = a; i < b+1; i++){
        if(i <= nnum || xnum <= i) cout << i << endl;
        else continue;
    }
    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
int n, m , l;
const int inf = 1e9 + 7;
int ans[305][305];
bool vis[305];
vector<pair<int,int>> a[maxn];
using pii = pair<int,int>;
#define mp make_pair
bool cmp(const pii & x, const pii &y){
    if(x.first == y.first) return x.second > y.second;
    return x.first < y.first;
}
pair<int,int> dp[305];
void greedy(int start){
    struct S{
        int nod, cnt, val;
        S(int x,int y,int z) : nod(x) , cnt(y), val(z){}

        bool operator <(const S &x) const{
            if(cnt == x.cnt) return val < x.val;
            return cnt > x.cnt;
        }
    };
    priority_queue<S> q;
    for(int i = 1 ;i <= n + 1;i ++){
        dp[i] = mp(inf , -inf);
        vis[i] = false;
    }
    dp[start] = make_pair(0 , l);
    q.push(S(start, 0 , l));
    while(!q.empty()){
        auto p = q.top();
        q.pop();
        if(vis[p.nod]) continue;
        for(auto i:a[p.nod]){
            if(!vis[i.first] && p.val >= i.second && cmp(mp(p.cnt,p.val - i.second), dp[i.first])){
                q.push(S(i.first, p.cnt, p.val - i.second));
                dp[i.first] = mp(p.cnt, p.val - i.second);
            }
            else if(!vis[i.first] && p.val < i.second && cmp(mp(p.cnt + 1, l - i.second) , dp[i.first])){
                q.push(S(i.first, p.cnt + 1 , l - i.second));
                dp[i.first] = mp(p.cnt + 1, l  - i.second);
            }
        }
    }
    for(int i = 1 ;i <= n;i ++){
        if(i != start){
            if(dp[i] != mp(inf,-inf)){
                ans[start][i] = dp[i].first;
            }
            else ans[start][i] = -1;
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n >> m >> l;
    while(m -- ){
        int x, y, z;
        cin >> x >> y >> z;
        if(z > l) continue;
        a[x].push_back({y, z});
        a[y].push_back({x, z});
    }
    for(int i = 1 ;i<= n;i++){
        greedy(i);
    }
    int q,x,y;
    cin >> q;
    while(q -- ){
        cin >> x >> y;
        cout <<ans[x][y] << '\n';
    }
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 9088
mod=10**9+7
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()

a,b=mi()
if (a+b)%3!=0:
  print(0)
  sys.exit()
s=(a+b)//3
a-=s
b-=s
if a<0 or b<0:
  print(0)
  sys.exit()
fac=[1]*700000
for i in range(1,700000):
  fac[i]=(fac[i-1]*i)%mod
m=a+b
n=min(a,b)
c=1
for j in range(m,m-n,-1):
  c*=j
  c=c%mod
print((c*pow(fac[n],mod-2,mod))%mod)

Measured memory_bytes: 76308
import bisect
n=int(input())
l=sorted(list(map(int,input().split())))
cnt=0
for i in range(n-2):
  for j in range(i+1,n-1):
    k=bisect.bisect_left(l,l[i]+l[j])
    cnt+=max(0,k-j-1)
#    print(l)
#    print("i:",i,"j:",j,"l[i]+l[j]:",l[i]+l[j],"k:",k,"k-j:",k-j,"cnt:",cnt)
print(cnt)
    

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

map<ll, ll> prime;
void factrization(ll n) {
  for(ll i=2; i*i<=n; i++) {
    while(n%i==0) {
      prime[i]++;
      n/=i;
    }
  }
  
  if(n>1) prime[n]++;
}

ll moP(ll x, ll n) {
  ll res=1;
  while(n>0) {
    if(n&1) moC(res, *, x);
    moC(x, *, x);
    n>>=1;
  }
  return res;
}


int main(void) {
  ll N;
  cin >> N;
  ll i;
  ll a[MAX/10];
  
  priority_queue<P> q;
  ll cnt[MAX*10]={};
  
  for(i=0; i<N; i++) {
    cin >> a[i];
    
    prime.clear();
    factrization(a[i]);
    for(auto it=prime.begin(); it!=prime.end(); it++) {
      chmax(cnt[it->ft], it->sc);
    }
  }
  
  ll S=1;
  for(i=0; i<MAX*10; i++) {
    moC(S, *, moP(i, cnt[i]));
  }
  
  ll ans=0;
  for(i=0; i<N; i++) {
    moC(ans, +, S*moP(a[i], MOD-2)%MOD);
  }
  
  pt(ans);
}


Measured memory_bytes: 8192
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(a*b);
	}

}


Measured memory_bytes: 35768
#include <cstdio>
#include <cstring>
#define R register
int N;
long long A, B, a[100010], t;
int main()
{
	scanf("%d", &N);
	for(R int i = 1; i <= N; i++) scanf("%lld", &a[i]);
	
	B = a[N]; 
	if(B != 2)
	{
		puts("-1");
		return 0;
	}
	for(R int i = N - 1; i; i--) 
	{
		t = B;
		if(B <= a[i]) B = a[i];
		else if(B % a[i]) B = (B / a[i] + 1) * a[i];
		if(B >= t * 2)
		{
			puts("-1");
			return 0;
		}
	}
//	if(B < 0) while(1);
//	printf("%lld", B);
	A = a[N] + a[N] - 1; 
	for(R int i = N - 1; i; i--)
	{
		if(A % a[i]) A = A / a[i] * a[i] + a[i] - 1; 
		else A += a[i] - 1;
	}
	if(B > A){ puts("-1"); return 0;}
	printf("%lld %lld\n", B, A);
	return 0;
}

Measured memory_bytes: 896
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#include<iostream>
#include<vector>
#define pb push_back
#define mp make_pair
#define xx first
#define yy second
#define rep(i,a,b) for(int i=(a),i##_end_=(b);i<=i##_end_;i++)
#define dwn(i,a,b) for(int i=(a),i##_end_=(b);i>=i##_end_;i--)
using namespace std;
inline int read() {
    int x=0,f=1;char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar()) x=x*10+c-'0';
    return x*f;
}
typedef long long ll;
typedef pair<int,int> pii;
int main() {
	string a,b,e;
	int c,d;
	cin>>a>>b>>c>>d>>e;
	if(a==e) c--;
	else d--;
	printf("%d %d\n",c,d);
	return 0;
}


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

int x;
vector<int> v;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	for(int i=0;i<3;i++){
		cin>>x;
		v.push_back(x);
	}
	sort(v.begin(), v.end());

	cout<<v[2]*10 + v[1] + v[0];
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int S = sc.nextInt();
        
        int h = S / (60 * 60);
        int m = (S - 60 * 60 * h) / 60;
        int s = S % 60;
        
        System.out.printf("%d:%d:%d\n", h, m, s);
    }
}


Measured memory_bytes: 26452
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ll h, n; cin >> h >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];

	bool win = true;

	int sum = 0;
	rep(i, n) sum += a[i];

	if (sum < h) win = false;

	if (win) dunk("Yes");
	else dunk("No");
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define DIV 1000000007
using namespace std;

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

    vector<int> a(N);
    int cnt = 1;
    for (int i = 0; i < N; i++) {
        cin >> a[i];

    }
    bool plus = false, minus = false;
    for (int i = 1; i < N; i++) {       
        if (a[i - 1] < a[i]) {
            plus = true;
            if (minus) {
                cnt++;
                plus = false;
                minus = false;
            }

        }
        else if (a[i - 1] > a[i]) {
            minus = 1;
            if (plus) {
                cnt++;
                plus = false;
                minus = false;
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int ans = C - (A - B);

		if (ans < 0) {
			ans = 0;
		}

		System.out.println(ans);
		sc.close();

	}
}


Measured memory_bytes: 22996
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
#define MAX 510
int H, W;
int a[MAX][MAX] = {}, temp[MAX][MAX] = {};
int cnt;
bool flag[MAX][MAX] = {};

signed main() {
	cin >> H >> W;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> a[i][j];
			temp[i][j] = a[i][j];
		}
	}
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (a[i][j] % 2 == 1 && j != W) { 
				a[i][j + 1]++, a[i][j]--; cnt++; 
			}
		}
		if (a[i][W] % 2 == 1 && i != H) {
			a[i + 1][W]++, a[i][W]--; cnt++; 
		}
	}
	cout << cnt << endl;;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (temp[i][j] % 2 == 1 && j != W) {
				temp[i][j + 1]++, temp[i][j]--;
				cout << i << " " << j << " " << i << " " << j + 1 << endl;
			}
		}
		if (temp[i][W] % 2 == 1 && i != H) {
			temp[i + 1][W]++, temp[i][W]--;
			cout << i << " " << W << " " << i + 1 << " " << W << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 4096
#include <stdio.h>

const char dayName[ 7 ][ 7 ] = { "Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur" };

// int zeller( int, int );

int main(void){
	int m, d;
	for (;scanf("%d%d",&m,&d)*m;printf("%sday\n",dayName[(2488+(m<3?0:2)+((m+9)%12*13+47)/5+d)%7]));
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(i,a,b) for (int i=(a); i<(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for (int i=(n-1); i>=0; --i)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define SQ(x) (x)*(x)
#define MN(a,b) a = min(a,(__typeof__(a))(b))
#define MX(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#ifdef BALBIT
#define IOS()
#define bug(...) fprintf(stderr,"#%d (%s) = ",__LINE__,#__VA_ARGS__),_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define bug(...)
#endif

const int iinf = 1<<29;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;


void GG(){cout<<"-1\n"; exit(0);}

ll mpow(ll a, ll n, ll mo = mod){ // a^n % mod
    ll re=1;
    while (n>0){
        if (n&1) re = re*a %mo;
        a = a*a %mo;
        n>>=1;
    }
    return re;
}

ll inv (ll b, ll mo = mod){
    if (b==1) return b;
    return (mo-mo/b) * inv(mo%b) % mo;
}

const int maxn = 1e3+3;
int w = '.'-'a';
vector<vector<int> > a3 = {{0,0,w},{w,w,1},{w,w,1}};
vector<vector<int> > a4 = {{0,2,1,1},{0,2,3,3},{1,1,0,2},{3,3,0,2}};
vector<vector<int> > a5 = {{0,0,1,1,2},{3,4,w,w,2},{3,4,w,w,5},{7,w,6,6,5},{7,8,8,9,9}};
vector<vector<int> > a7 = {{0,0,1,1,0,0,w},{1,1,0,0,w,w,1},{0,0,1,1,w,w,1},
{w,w,w,w,0,1,0},{w,w,w,w,0,1,0},{w,w,w,w,1,0,1},{w,w,w,w,1,0,1}};

char g[maxn][maxn];
int at = 0;

void put(vector<vector<int> > &x) {
    int y = x.size();
    FOR(i,at,at+y) FOR(j,at,at+y) {
        g[i][j] = 'a'+x[i-at][j-at];
    }
    at += y;
}

main(){
    IOS();
    int n;
    cin>>n;
    REP(i,n) REP(j,n) g[i][j] = '.';
    int NN = n;
    if (n==1 || n== 2) {
        cout<<-1<<endl; return 0;
    }
    if (n%3==0) {
        REP(i,n/3) put(a3);
    }else{
        if (n==7 || n== 11) {
            put(a7); n-=7;
        }
        while (n % 5 !=0) {
            put(a4); n-=4;
        }
        while (n!=0) {
            put(a5); n-=5;
        }
    }
    REP(i,NN) REP(j,NN) {
        cout<<g[i][j];
        if (j==NN-1) cout<<"\n";
    }
}


Measured memory_bytes: 2176
#include<stdio.h>
int main(void){
    int m,f,r;
    while(scanf("%d %d %d", &m,&f,&r)==3){
        if(m==-1 && f==-1 && r==-1) {
            break;
            }
        if(m==-1 || f==-1){
            printf("F\n"); continue;
            }
        if((m+f)>=80){
            printf("A\n"); continue;
        }
        if(65<=(m+f) && (m+f)<80){ 
            printf("B\n");
            continue;
        }
        if(50<=(m+f) && (m+f)<65){
            printf("C\n");
            continue;
        }
        if(30<=(m+f) && (m+f)<50){
            if(r>=50){
                printf("C\n");
                continue;
            }
            printf("D\n");
        continue;
        }
        if(m+f<30){
            printf("F\n");
            continue;
        }
    }
    return 0;
}


Measured memory_bytes: 2064
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N;
  cin>>N;
  string S;
  cin>>S;
  int cnt=1;
  REP(i,0,N-1){
    if(S[i]!=S[i+1]){
      cnt++;
    }
  }
  cout<<cnt<<endl;

  return 0;
}


Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main(){

  int n;

  while(cin >> n){
    if(n == 0) break;

    int data[n];
    int sum = 0;

    for(int i = 0; i < n; i++){
      cin >> data[i];
    }
    int tmp;
    for(int j = 0; j < n; j++){
      for(int i = 0; i < n-1-j; i++){
	if(data[i] > data[i+1]){
	  tmp = data[i];
	  data[i] = data[i+1];
	  data[i+1] = tmp;
	  sum++;
	}
      }
    }

    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 0
def main():
    from collections import Counter
    P = 2019
    S = [int(s) for s in input()]
    N = len(S)
    ans = 0
    if P == 5 or P == 2:
        for i, s in enumerate(S, start=1):
            if s % P == 0:
                ans += i
    else:
        acc = [0]*(N+1)
        d = 1
        for i, s in enumerate(S[::-1], start=1):
            # print(i, s)
            acc[i] = (s * d + acc[i-1]) % P
            d *= 10
            d %= P
        c = Counter(acc)
        # print(acc, c)
        ans = sum(v*(v-1)//2 for v in c.values())
    print(ans)


if __name__ == '__main__':
    main()


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

int main() {

    int a[9];
    bool b[10] = {false};

    int input;

    for(int i=0;i<9;i++){
        cin >> input;
        a[i] = input;
        if(input != -1){
            b[input] = true;
        }
    }

    vector<int> ve;

    for(int i=1;i<=9;i++){
        if(!b[i]){
            ve.push_back(i);
        }
    }

    sort(ve.begin(),ve.end());

    int ans = 0;

    do{
        int  t[9],count=0;

        for(int i=0;i<9;i++){
            if(a[i] == -1){
                t[i] = ve[count++];
            }
            else{
                t[i] = a[i];
            }
        }

        if(t[0] + t[1]*10 + t[2] + t[3] * 100 + t[4] * 10 + t[5] == t[6] * 100 + t[7] * 10 + t[8]){
            ans++;
        }


    }while(next_permutation(ve.begin(),ve.end()));



    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3148
#include<iostream>
#include<stdio.h>
#include<vector>
#include<ctype.h>
#include<string>
#include<cmath>
#include<string.h>
#include<sstream>
#include<limits.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;

//最大公約数
int gcd(int a,int b){
    return b ? gcd(b,a%b):a;
}

//最小公倍数
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}

//素数判定
bool isPrime(int x){
    if(x<2)return 0;
    else if(x==2)return 1;
    if(x%2==0)return 0;
    for(int i=3;i*i<=x;i+=2){
        if(x%i==0)return 0;
    }
    return 1;
}

//桁ごとの足し算
int digsum(int n){
    int res=0;
    while(n>0){
        res+=n%10;
        n/=10;
    }
    return res;
}

//約数列挙
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i=1;i*i<=n;++i){
        if(n%i==0){
            ret.push_back(i);
            if(i*i !=n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

//累乗の計算とあまり,0で累乗そのまま出力
long long modpow(long long a,long long n,long long mod){
    if(mod==0)mod=__LONG_LONG_MAX__;
    long long res=1;
    while(n>0){
        if(n & 1)res=res*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}

long N,D;
long ans=0;
int main(){
    cin>>N>>D;
    for(int i=0;i<N;++i){
        long x,y;
        cin>>x>>y;
        if(x*x+y*y<=D*D)ans++;
    }    
    cout<<ans<<endl;
}

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

int main()
{
	std::size_t N;
	std::string str;
    std::cin >> N;
    std::cin >> str;
    for(auto& c: str)
    {
    	c += N;
        if(c > 'Z')
        {
        	c = c - 'Z' + 'A' - 1;
        }
    }
    std::cout << str;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int n;
        n=scan.nextInt();
        int linenum;
        linenum=scan.nextInt();
        int[] ans=new int[n];
        for(int i=0;i<n;i++){
            ans[i]=i+1;
        }
        int[][] sign=new int[linenum][2];
        String[] line=new String[linenum];
        for(int i=0;i<linenum;i++){
            line[i]=scan.next();
            String[] aaa=line[i].split(",",-1);
            sign[i][0]=Integer.parseInt(aaa[0]);
            sign[i][1]=Integer.parseInt(aaa[1]);
            int tmp=ans[sign[i][0]-1];
            ans[sign[i][0]-1]=ans[sign[i][1]-1];
            ans[sign[i][1]-1]=tmp;
        }
        for(int i=0;i<n;i++) System.out.println(ans[i]);
    }
}


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

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

int eval(int x) {
	int ret=0;
	while(1) {
		if(x%2) return ret;
		x/=2;
		ret++;
	}
}

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n,x,ret=2e9; cin>>n;
	for (int i=0; i<n; i++) {
		cin>>x; ret=min(ret,eval(x));
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import math
import collections

MOD = 1000000007  # type: int


def trial_division_sqrt(n):
    prime_count = collections.Counter()
    for i in range(2, int(math.sqrt(n)) + 2):
        while n % i == 0:
            n /= i
            prime_count[i] += 1
    if n > 1:
        prime_count[int(n)] += 1

    return prime_count


def cmb(n, r):
    r = min(r, n-r)
    if r == 0:
        return 1
    if r == 1:
        return n

    numer = [n - r + k + 1 for k in range(r)]
    denom = [k + 1 for k in range(r)]

    for p in range(2, r+1):
        pivot = denom[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1, r, p):
                numer[k - offset] /= pivot
                denom[k] /= pivot

    result = 1
    for k in range(r):
        if numer[k] > 1:
            result *= int(numer[k])

    return result


def solve(N: int, M: int):
    pc = trial_division_sqrt(M)
    ans = 1
    for c in pc:
        ans = (ans * cmb(pc[c]+N-1, pc[c])) % MOD
    print(int(ans))
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<cstdio>
int main(){
    double s;
    while(~scanf("%lf",&s)){
        double y=(4.9*(s/9.8)*(s/9.8))+5;
        if(y==(int)(y/5)*5) printf("%d\n",(int)y/5);
        else printf("%d\n",(int)y/5+1);
    }
}

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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n;
	cin >> n;

	vi b(n-1);
	rep(i, n-1) {
		cin >> b[i];
	}
	
	vi a(n);
	a[0]=b[0];
	a[n - 1] = b[n - 2];

	rep1(i, n - 2) {
		a[i] = min(b[i - 1], b[i]);
	}

	int ans = 0;
	rep(i, n) {
		ans += a[i];
	}

	cout << ans << endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N;
	cin >> N;
	vector<ll> T(N), A(N);
	REP(i, N) cin >> T[i];
	REP(i, N) cin >> A[i];

	vector<ll> val(N);
	vector<bool> fix(N);
	bool flag = true;
	REP(i, N){
		ll left, right;
		if(i==0){
			left = T[i];
			right = A[i] - A[i+1];
		}else if(i==N-1){
			left = T[i] - T[i-1];
			right = A[i];
		}else{
			left = T[i] - T[i-1];
			right = A[i] - A[i+1];
		}
		if(left==0&&right==0){
			val[i] = min(T[i], A[i]);
			fix[i] = false;
		}else if(left>0&&right==0){
			if(T[i]>A[i]) flag = false;
			val[i] = T[i];
			fix[i] = true;
		}else if(left==0&&right>0){
			if(T[i]<A[i]) flag = false;
			val[i] = A[i];
			fix[i] = true;
		}else{
			if(T[i]!=A[i]) flag = false;
			val[i] = T[i];
			fix[i] = true;
		}
	}
	ll res = 1;
	REP(i, N){
		if(!fix[i]){
			res *= val[i];
			res %= mod;
		}
	}
	if(!flag) cout << 0 << endl;
	else cout << res << endl;
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#define maxn 100020
#define ll long long
using namespace std;
ll n,x,t;
inline ll read(){
	char c=getchar();
	ll x=0,f=1;
	while(c<'0'||c>'9'){
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=x*10+c-'0';
		c=getchar(); 
	}
	return x*f;
}
int main(){
	n=read();
	x=read();
	t=read();
	if(n%x==0) cout<<(n/x)*t<<endl;
	else cout<<(n/x)*t+t<<endl;  
	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  int outlet = 1;
  int plug = 0;
  while(outlet < b) {
    outlet--;
    outlet += a;
    plug++;
  }
  cout << plug << endl;
}

Measured memory_bytes: 3576
A, B, C, D, E, F = map(int, input().split())
limwater = F // 100
waterdp = [False] * (limwater + 1)
waterdp[0] = True
for i in range(1, limwater + 1):
	if i >= A and waterdp[i - A]:
		waterdp[i] = True
	if i >= B and waterdp[i - B]:
		waterdp[i] = True
sugardp = [False] * (F + 1)
sugardp[0] = True
for i in range(1, F + 1):
	if i >= C and sugardp[i - C]:
		sugardp[i] = True
	if i >= D and sugardp[i - D]:
		sugardp[i] = True
waterans = 0
sugarans = 0
maxdensity = -1.0
for i in range(1, limwater + 1):
	for j in range(0, F + 1):
		if waterdp[i] and sugardp[j] and i * 100 + j <= F:
			density = j / (i * 100 + j)
			if density <= E / (100 + E) and density > maxdensity:
				maxdensity = density
				waterans = i
				sugarans = j
print(waterans * 100 + sugarans, sugarans)

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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp make_pair
#define pb push_back

const long long MOD = 1000000007;
const long long INF = 1LL<<60;


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

    ll n, m;
    cin >> n >> m;
    vector<ll> as(n);
    ll sum = 0;
    rep(i, n){
        cin >> as[i];
        sum += as[i];
        as[i] *= 4*m;
    }
    ll c = 0;
    rep(i, n){
        if(as[i] >= sum){
            c++;
        }
    }
    if(c >= m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (a > b) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

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

  string s; cin >> s;
  ll sum = 0;

  rep(i, si(s)) sum += s[i] - '0';

  if (sum % 9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

  return (0);
}


Measured memory_bytes: 3684
n = int(input())
dic = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}

for i in range(n):
    s = input()
    dic[s] += 1

print('AC x', dic['AC'])
print('WA x', dic['WA'])
print('TLE x', dic['TLE'])
print('RE x', dic['RE'])


Measured memory_bytes: 9216
#include <iostream>
#include <iomanip>
#include <algorithm>

using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  int p[200010];
  for(int i=0; i<N; i++) cin >> p[i];
  double sum[1010];
  for(int i=1; i<=1000; i++) sum[i]=sum[i-1]+i;
  double exp[200010];
  for(int i=0; i<K; i++) exp[0]+=sum[p[i]]/p[i];
  for(int i=1; i<=N-K; i++){
    exp[i]=exp[i-1]-sum[p[i-1]]/p[i-1]+sum[p[i+K-1]]/p[i+K-1];
  }
  double ans=0;
  for(int i=0; i<=N-K; i++) ans=max(ans,exp[i]);
  cout << setprecision(12) << ans << endl;
  
  return 0;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <valarray>
#include <vector>

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

using namespace std;

void solution()
{
    int64_t n, d;
    cin >> n >> d;
    int count = 0;
    int64_t d2 = d*d;
    rep(i,n){
        int64_t x, y;
        cin >> x >> y;
        if(x*x + y*y <= d2){
            count += 1;
        }
    }

    cout << count << '\n';
}

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


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

def bubble_sort(A):
    flag = 1  # if non-sorted element exist on side
    counter = 0
    while flag:
        flag = 0
        for i in range(1, len(A))[::-1]:
            if A[i] < A[i - 1]:
                counter += 1
                A[i], A[i - 1] = A[i - 1], A[i]
                flag = 1
    return (A,counter)


def main():
    _,k = [int(i) for i in input().strip().split()]
    l = [int(i) for i in input().strip().split()]
    _sorted, inner = bubble_sort(l)
    _, outer = bubble_sort(_sorted + _sorted)
    
    print((inner * k + (k * (k - 1) // 2) * outer) % (10 ** 9 + 7))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 73996
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
	cin>>n;
	set<int> c;
	int as=0;
	for(int i=0; i<n; i++){
		int a;
		cin>>a;
		as^=a;
		int ct=1;
		while(a%2==0){
			a/=2;
			ct++;
		}
		c.insert(ct);
	}
	int ans=0;
	int ct=0;
	while(as>0){
		if(as%2==1){
			as++;
			while(as%2==0){
				as/=2;
				ct++;
			}
			as--;
		}else{
			while(as%2==0){
				as/=2;
				ct++;
			}
		}
		if(c.find(ct)==c.end()){
			cout<<-1<<endl;
			return 0;
		}
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>

int main(void){
  int h, n;
  scanf("%d%d", &h, &n);
  int a[n];
  int S=0;
  int i;
  for(i=0; i<n; i++){
    scanf("%d", &a[i]);
    S+=a[i];
  }
  
  if(S<h){
    printf("No\n");
  }else{
    printf("Yes\n");
  }
  
  return 0;
}


Measured memory_bytes: 2000
from collections import deque
import sys


class mEdge():

    def __init__(self, _from, _to, _cost):
        self.From = _from
        self.to = _to
        self.cost = _cost


class bellman_ford():
    def __init__(self, V):
        self.G = []
        self._V = N
        self._E = 0

    def add(self, _from, _to, _cost):
        self.G.append(mEdge(_from, _to, _cost))
        self._E += 1

    def shortest_path(self, s):
        d = [10**20]*(self._V+1)
        d[s] = 0
        for _ in range(self._V):
            flag = False
            for edge in self.G:
                newlen = d[edge.From]+edge.cost
                if newlen < d[edge.to]:
                    flag = True
                    d[edge.to] = newlen
            if not flag:
                break
        return d

    def have_negative_circle(self):
        d = [10**20]*(self._V+1)
        d[1] = 0
        for i in range(1, self._V+1):
            flag = False
            for edge in self.G:
                newlen = d[edge.From]+edge.cost
                if newlen < d[edge.to]:
                    flag = True
                    d[edge.to] = newlen
            if not flag:
                break
            if i == self._V:
                return True
        return False


# Coins Respawn
sys.setrecursionlimit(10**7)
N, M, P = map(int, input().split())
graph = []
d = deque()


from_1 = [[] for i in range(N+1)]
from_N = [[] for i in range(N+1)]

for _ in range(M):
    a, b, c = map(int, input().split())
    from_1[a].append(b)
    from_N[b].append(a)
    d.append((a, b, P-c))


accessible_1 = [False for i in range(N+1)]
accessible_N = [False for i in range(N+1)]


def dfs_1(s):
    accessible_1[s] = True
    for node in from_1[s]:
        if accessible_1[node] == False:
            dfs_1(node)


def dfs_N(s):
    accessible_N[s] = True
    for node in from_N[s]:
        if accessible_N[node] == False:
            dfs_N(node)


dfs_1(1)
dfs_N(N)

isok = [False for i in range(N+1)]
for i in range(N+1):
    if accessible_1[i] and accessible_N[i]:
        isok[i] = True
G = bellman_ford(N)

while d:
    p, q, weight = d.popleft()
    if isok[p] and isok[q]:
        G.add(p, q, weight)

if G.have_negative_circle():
    print(-1)
else:

    print(max(0, -G.shortest_path(1)[N]))

Measured memory_bytes: 12260
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <limits.h>
using namespace std;

int main()
{
    int n;
    cin >> n;
    long long int sum = 0;
    for (int i = 1; i <= n; i++){
        for (int j = i; j <= n; j+=i){
            sum += j;
            
        }
        //cout << sum << endl;
    }
    cout << sum << endl;

    return 0;
}

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

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

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;
}

vector<vector<int>> dp(100010, vector<int>(3));
vector<int> a(100010);
vector<int> b(100010);
vector<int> c(100010);
int main()
{
    int N;
    cin >> N;
    rep2(i, 1, N + 1)
    {
        cin >> a.at(i);
        cin >> b.at(i);
        cin >> c.at(i);
    }

    dp.at(0).at(0) = 0;
    dp.at(0).at(1) = 0;
    dp.at(0).at(2) = 0;
    rep2(i, 1, N + 1)
    {
        chmax(dp.at(i).at(0), a.at(i) + dp.at(i - 1).at(1));
        chmax(dp.at(i).at(0), a.at(i) + dp.at(i - 1).at(2));
        chmax(dp.at(i).at(1), b.at(i) + dp.at(i - 1).at(0));
        chmax(dp.at(i).at(1), b.at(i) + dp.at(i - 1).at(2));
        chmax(dp.at(i).at(2), c.at(i) + dp.at(i - 1).at(0));
        chmax(dp.at(i).at(2), c.at(i) + dp.at(i - 1).at(1));
    }

    cout << max({ dp.at(N).at(0), dp.at(N).at(1), dp.at(N).at(2) }) << endl;
}

Measured memory_bytes: 6912
#include <iostream>

using namespace std;

int main(){
	int k;
	char* s = (char*)calloc(100, sizeof(char));
	cin >> k >> s;
	for(int i = 0; i < k; i++){
		if(s[i] == 0) break;
		cout << s[i];
	}
	int len = 0;
	while(*s != 0){
		s++;
		len++;
	}
	if(len > k) cout << "..." << endl;
}

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

int main() {
  int h,w,n,a,b,c,x,y,z,q;
  cin >> h>>w;
  
  // 点数データを受け取る
  x=w+2;
  y=h*w;
  q=h;
  z=w+2;
  while(x>0)
  {
  cout<< "#";
  x--;
  }
  
  
  for(int r=0;r<h;r++)
  {  vector<string> test(h); 
 cin>>test.at(r);
  cout<<endl; 
    cout<<"#"<<test.at(r)<<"#";
  }
  cout<<endl;
   while(z>0)
   {
  cout<< "#";
  z--;
   }
  cout<<endl;
}


Measured memory_bytes: 256
def bw(a):
    c=0
    if a=="#":
        c=1
    return c

def bw2(a,b): #b = now
    c=0
    if a=="." and b=="#":
        c=1
    return c

H,W = list(map(int,input().split()))

s=[ "" for i in range(H) ]
for i in range(H):
    s[i] = input()

M=[[1000 for j in range(W)] for i in range(H) ]

M[0][0] = bw(s[0][0])


for i in range(H-1):
    M[i+1][0] = M[i][0] + bw2(s[i][0],s[i+1][0]) 

    
for j in range(W-1):
    M[0][j+1] = M[0][j]+ bw2(s[0][j],s[0][j+1])

    

for i in range(H-1):
    for j in range(W-1):
        
        M[i+1][j+1] = min(M[i][j+1] + bw2(s[i][j+1],s[i+1][j+1]) , M[i+1][j]+ bw2(s[i+1][j],s[i+1][j+1]) )
print(M[H-1][W-1])
        

Measured memory_bytes: 3188
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;
const int inf = 1e9;
int dp[1000010];
struct node
{
    int a,b,c;
}p[50];

int gcd(int a,int b)
{
    if(b == 0)
        return a;
    return gcd(b,a%b);
}
int main(void)
{
    int n,A,B,i,j;
    while(scanf("%d%d%d",&n,&A,&B)==3)
    {
        int suma = 0,sumb = 0;
        for(i=0;i<n;i++)
        {
            scanf("%d%d%d",&p[i].a,&p[i].b,&p[i].c);
            suma += p[i].a;
            sumb += p[i].b;
        }
        int V = suma*1000+sumb;
        memset(dp,0x3f,sizeof(dp));
        dp[0] = 0;
        int minn = inf;
        for(i=0;i<n;i++)
        {
            int w = p[i].a*1000+p[i].b;
            for(j=V;j>=w;j--)
            {
                dp[j] = min(dp[j],dp[j-w] + p[i].c);
                int ta = j/1000,tb = j%1000;
                if(ta/gcd(ta,tb) == A && tb/gcd(ta,tb) == B)
                    minn = min(minn,dp[j]);
            }
        }
        if(minn == inf)
            printf("-1\n");
        else
            cout << minn << endl;
    }

    return 0;
}


Measured memory_bytes: 4096