akhauriyash/Code-Regression huggingface dataset:
using System;

using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        //回答
        //Console.WriteLine(Math.Ceiling((double)N / X) * T);

        //整数の入力
        //int N = int.Parse(Console.ReadLine());

        // 複数の入力
        //string[] line = Console.ReadLine().Split(' ');
        //int N = int.Parse(line[0]);
        //int X = int.Parse(line[1]);
        //int T = int.Parse(line[2]);



        long N = int.Parse(Console.ReadLine());
        string[] A = Console.ReadLine().Split(' ');

        long h = long.Parse(A[0]);
        long dai_sum = 0;
        for(long i = 1; i < N; i++)
        {
            long ai = long.Parse(A[i]);
            //Console.WriteLine("-- " + i + "--");
            //Console.WriteLine("dai_sum : " + dai_sum);
            //Console.WriteLine("h : " + h);
            //Console.WriteLine("a[i] : " + ai);
            if (ai < h)
            {
                long dai = h - ai;
                dai_sum += dai;
                //Console.WriteLine("add dai : " + dai);
            }
            else
            {
                h = ai;
            }
        }

        Console.WriteLine(dai_sum);







        //==============
        //String N = Console.ReadLine();

        //int sum = 0;
        //for(int i =0;i< N.Length; i++)
        //{
        //    //Console.WriteLine("sum : " + sum);
        //    //Console.WriteLine("N[i] : " + (N[i] - '0'));
        //    sum += N[i] - '0';

        //}

        ////Console.WriteLine("sum : " + sum);

        //if (sum % 9 == 0)
        //{
        //    Console.WriteLine("Yes");
        //}
        //else
        //{
        //    Console.WriteLine("No");
        //}
        //=============



        //スペース区切りの整数の入力
        //string[] dates = Console.ReadLine().Split(' ');
        //string[] amounts = Console.ReadLine().Split(' ');

        //double date = double.Parse(input[0]);
        //double amount = double.Parse(input[1]);

        //double date = double.Parse(input[0]);
        //double amount = double.Parse(input[1]);

        //var L2 = L.Distinct().OrderBy(o => o);
        //var L2 = L.OrderBy(o => o).ToArray();

        //string input = Console.ReadLine();
        //int b = int.Parse(input[0]);
        //int c = int.Parse(input[1]);
        //文字列の入力
        //string s = Console.ReadLine();
        //出力




        //onsole.WriteLine(N);
        //Console.WriteLine(string.Join(" ", L));


        //for (int i = 1; i < N; i++)
        //{
        //    for (int j = i - 1; j > 0; j--)
        //    {
        //        if (amounts[i] >= amount)
        //        Console.WriteLine(double.Parse(amounts[i]));
        //    }
        //}

        //for (int i = 0; i < K; i++)
        //{
        //    if(D / 10  X)

        //    if(now > 0)
        //    {
        //        now -= D;
        //    }
        //    else
        //    {
        //        now += D;
        //    }

        //    //Console.WriteLine(now);
        //}

        //Console.WriteLine(Math.Abs(now));
    }
}




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

int main(){
  int N;
  cin >> N;
  vector<int>d(N);
  for( int i = 0; N > i ; i++){
    cin >> d.at(i);
  }
  for( int i = 0 ; N > i ; i++){
    for( int j = i + 1 ; N > j ; j++){
      if( d.at(j) < d.at(i) ){
        int tmp = d.at(j);
        d.at(j) = d.at(i);
        d.at(i) = tmp;
      }
    }
  }
  int run = 0,sum = 0;
  for( int i = 0 ; N > i ; i++ ){
    if( d.at(i) > run ){
      run = d.at(i);
      sum++;
    }
  }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  rep(i, 0, m) cin >> a[i];
  ll sum_val = accumulate(a.begin(), a.end(), 0);
  if (sum_val > n)
    cout << -1 << endl;
  else
    cout << n - sum_val << endl;
}


Measured memory_bytes: 3688
// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
//
// See the bottom of file for solution.
// -----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------
fn popcount(mut x: i64) -> i64 {
    let mut n = 0_i64;
    while x > 0 {
        n += x & 1;
        x >>= 1;
    }
    n
}

fn main() {
    let (N, A, B, C) = read!(usize, i64, i64, i64);
    let T = read![i64; N];

    let mut min_cost = 1_i64 << 60;

    let calc = |s: i64, L: i64| {
        let mut cost = 0;
        let mut len = 0;

        cost += (popcount(s) - 1) * 10;
        for i in 0..N {
            if s & (1 << i) != 0 {
                len += T[i];
            }
        }
        cost += (L - len).abs();
        cost
    };

    for c in 1..(1 << N) {
        let c_cost = calc(c, C);

        for b in 1..(1 << N) {
            if b & c != 0 {
                continue;
            }

            let b_cost = calc(b, B);

            for a in 1..(1 << N) {
                if a & b != 0 || a & c != 0 {
                    continue;
                }
                let a_cost = calc(a, A);

                min_cost = min(min_cost, a_cost + b_cost + c_cost);
            }
        }
    }

    println!("{}", min_cost)
}


Measured memory_bytes: 4352
def factorial(a,n):
  # n*(n-1)*,,,,,*(n-a+1)
  ans=1
  for i in range(n,n-a,-1):
    ans=(ans*i)%M
  return ans


def pow(x, n):
  ans=1
  while n:
    if n % 2 == 1:
      ans = (ans*x)%M
    x = (x*x)%M
    n >>= 1
  return ans


def main():
  ans=pow(2,N) - 1
  ans-=(factorial(A,N)*pow(factorial(A,A),M-2))%M
  ans+= 0 if ans>=0 else M
  ans-=(factorial(B,N)*pow(factorial(B,B),M-2))%M
  print(ans if ans>=0 else ans+M)
  
  
if __name__=='__main__':
  N, A, B = map(int, input().split())
  M = 10**9 + 7
  main()


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

int main() {
  using LL = long long;
  struct Point {LL x, y;};

  LL N;
  cin >> N;
  vector<Point> P(N);
  for(auto& p: P) cin >> p.x >> p.y;

  auto parity = (abs(P[0].x)+abs(P[0].y))&1;
  for(const auto& p: P) if(((abs(p.x)+abs(p.y))&1) != parity) {
    cout << -1 << endl;
    exit(0);
  }

  auto m = 31ll;
  vector<LL> d;
  for(auto i=m-1; 0<=i; --i) d.emplace_back(1ll<<i);
  if(!parity) d.emplace_back(1ll), ++m;

  cout << m << endl;
  for(auto i: d) cout << (i==d.front() ? "" : " ") << i;
  cout << endl;
  for(const auto& p: P) {
    auto x = p.x;
    auto y = p.y;
    for(auto i: d) {
      if(abs(x)<abs(y)) {
        if(y<0) {y += i; cout << "D";}
        else    {y -= i; cout << "U";}
      } else {
        if(x<0) {x += i; cout << "L";}
        else    {x -= i; cout << "R";}
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n; cin >> n;
  bitset<200005> a;
  rep(i,n) {
    bool b; cin >> b; 
    a[i+1] = b;
  }

  auto factorize = [](ll n) {
    vi ret;
    ret.push_back(1);
    ret.push_back(n);
    for (int i=2; i*i<=n; i++) {
      if (i*i==n) {
        ret.push_back(i);
        return ret;
      }
      if (n%i==0) {
        ret.push_back(i);
        ret.push_back(n/i);
      }
    }
    return ret;
  };
int count = 0;
vi ans;
for (int i=n; i>0; i--) {
  if (a[i]) {
    count ++;
    ans.push_back(i);
    vi factors= factorize(i);
    for (int num: factors) {
      a[num] = !a[num];
    }
  }
}
reverse(ans.begin(), ans.end());
cout << ans.size() << endl;
rep(i,ans.size()) cout << ans[i] << endl;
 return 0;
}

Measured memory_bytes: 1784
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 2019

    S = input()[::-1]
    N = len(S)

    if N < 4:
        print(0)
        return

    R = [0] * 2019
    R[0] = 1 # '' の分
    t = 0
    b = 1
    for c in S:
        t += int(c) * b
        t %= 2019
        R[t] += 1
        b *= 10
        b %= 2019
    ans = 0
    for r in R:
        ans += r*(r-1)//2
    print(ans)
    




    

if __name__ == '__main__':
    main()

Measured memory_bytes: 68928
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    from collections import Counter
    C=Counter(map(int,input().split()))
    ans=0
    for k,v in C.items():
        ans+=v if v<k else v-k
    print(ans)
resolve()

Measured memory_bytes: 63984
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;


bool solve(){
	int n;
	cin>> n;
	if(!n) return false;

	int a=0,b=0;
	for(int i=0;i<n;i++){
		int x,y;
		cin>> x>> y;
		if(x==y){
			a+=x;
			b+=y;
			continue;
		}
		x>y ? a+=(x+y) : b+=(x+y);
	}
	cout<< a<< " "<< b<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	while(solve()){};

	return 0;
}

 

Measured memory_bytes: 1160
/* ex9_2
   TakayukiY*/

#include <stdio.h>
#include <stdlib.h>

//リストのノード（スタック内の各データ）の定義
typedef struct node
{
    char elem;
    struct node *next;
} node;

//スタックにデータを追加
void push(node **first, char elem)
{
    node *new = calloc(1, sizeof(node));
    if (new == NULL)
        exit(1);
    new->elem = elem;
    new->next = *first;
    *first = new;
}

//スタックからデータを取り出す
char pop(node **first)
{
    char elem;
    node *tmp = *first;
    if (tmp == NULL)
        return '\0';
    elem = tmp->elem;
    *first = tmp->next;
    free(tmp);
    return elem;
}

void free_stack(node **first)
{
    node *tmp = *first, *next;
    while (tmp != NULL)
    {
        next = tmp->next;
        free(tmp);
        tmp = next;
    }
}

int main(void)
{
    char input[100000 + 1], *ptr;
    node *first = NULL;
    int count = 0;

    scanf("%s", input);
    ptr = input;

    while (*ptr != '\0')
    {
        if (first==NULL)
        {
            push(&first, *ptr);
        }
        else
        {
            if (first->elem == *ptr)
            {
                push(&first, *ptr);
            }
            else
            {
                pop(&first);
                count+=2;
            }
        }
        ptr++;
    }

    printf("%d", count);

    free_stack(&first);

    return 0;
}

Measured memory_bytes: 4860
// Problem : B - Common Raccoon vs Monster
// Contest : AtCoder Beginner Contest 153
// URL : https://atcoder.jp/contests/abc153/tasks/abc153_b
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcount(x)
#define f first
#define se second
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int md=1000000007;
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}

 vi fact,inv;
void inverse(int n)
{inv.resize(n+1);inv[0]=1;
for(int i=1;i<=n;i++)inv[i]=Pow(fact[i],md-2);}
void factorial(int n)
{fact.resize(n+1);fact[0]=1;
for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%md;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}

void solve()
{
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n,m;
cin>>n>>m;
int sum=0;
for(int i=0;i<m;i++)
{
	int x;
	cin>>x;
	sum+=x;
}
if(sum>=n)
cout<<"Yes";else
cout<<"No";
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t;
//cin>>t;
t=1;
while(t--)
{
    solve();
}
}


Measured memory_bytes: 256
n=int(input())
s=[]
t=[]
ans=0
x=0
for i in range(n):
    s.append(input())
m=int(input())
for i in range(m):
    t.append(input())
for i in range(n):
    
    x=max(x,s.count(s[i])-t.count(s[i]))
    
print(x)


Measured memory_bytes: 9180
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

template <typename T>
bool chmax(T &a, T &b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, T &b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
}


ll A[110][110];

int main() {
  ll A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;
  ll ans = 0;
  if(A+B > 2*C) {
    ans += min(X,Y) * 2 * C;
    int x = X;
    int y = Y;
    X -= min(x,y);
    Y -= min(x,y);
    // cout << X << ":" << Y << endl;
    ans += min(X*A + Y*B,X*2*C + Y*2*C);
  }
  else {
    ans += X*A + Y*B;
  }
  cout << ans << endl;
  return 0;
}





Measured memory_bytes: 504
#include<bits/stdc++.h>
/*
CE 头文件 
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>

*/
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define mem(a,b) memset(a,b,sizeof (a))
#define ios std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0);
// ios和scanf,printf不能混用.即用ios必须全部cin,cout. 
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;

ll ksm(ll a,ll b){ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int n,m,k;
const int N=1e5+10;
char a[10][10];
int cnt[N];
int c[10],r[10];
int f[N];
int main(){
	scanf("%d%d%d",&n,&m,&k);
	int sum=0;
	rep(i,0,n-1){
		scanf("%s",a[i]);
		rep(j,0,m-1){
			if(a[i][j]=='#'){
				c[j]++;
				r[i]++;
				sum++;
			}
		}
	}
	int ans=0;
	for(int i=0;i<(1<<n);i++){
		for(int j=0;j<(1<<m);j++){
			int tmp=0;
			int visx[10],visy[10];
			rep(p,0,9){
				visx[p]=0;
				visy[p]=0;
			} 
			for(int p=0;p<n;p++){
				if((i>>p)&1){
					tmp+=r[p];
					visx[p]=1;
				}
			}
			for(int p=0;p<m;p++){
				if((j>>p)&1){
					tmp+=c[p];
					rep(q,0,n-1){
						if(a[q][p]=='#'&&visx[q]){
							tmp--;
							//printf("%d %d %d\n",q,p,tmp);
						}
					}
					visy[p]=1;
				}
			}
			if(sum-tmp==k){
				ans++;
				/*printf("x:");
				rep(p,0,n-1){
					if(visx[p])printf("%d ",p);
				}
				printf("\ny:");
				rep(p,0,m-1){
					if(visy[p])printf("%d ",p);
				}
				printf("\n");*/
			}
		}
	}
	printf("%d\n",ans);
    return 0;
}


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

#define llint long long int
#define pb push_back

using namespace std;

int fn(int a){
  if(a%2)
    return (3*a+1);
  else
    return a/2;
}

int main(){
  int n;
  cin >> n;
  vector<int> a;
  a.pb(n);
  int last = a.back();
  while(1){
    a.pb(fn(last));
    last = a.back();
    sort(a.begin(), a.end());
    for(int i = 1; i < a.size(); i++){
      if(a[i] == a[i-1]){
        cout << a.size();
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int n, a, b, ans;
  
  scanf("%d", &n);
  
  if(n==1){
    printf("Hello World");
  }else{
    scanf("%d", &a);
    scanf("%d", &b);
    
    ans = a + b;
    printf("%d", ans);
  }
  return 0;
}


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

int main() {
  string o,e;
  cin>>o>>e;
  if(o.size()==e.size()){
    for(int i=0;i<o.size();i++){
      if(i==o.size()-1){
        cout<<o.at(i)<<e.at(i)<< endl;
        return 0;
      }
      cout<<o.at(i)<<e.at(i);
    }
  }
  else{
    for(int i=0;i<e.size();i++){
      cout<<o.at(i)<<e.at(i);
    }
  }
  cout<<o.at(o.size()-1)<< endl;
  return 0;
}

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

int main(){
  double L;
  cin >> L;
  double ans = pow(L / 3, 3);
  cout << fixed << setprecision(20) << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){ //1??????n?????§???3????????°??¨3???????????°??????????????????
	int n, i,x,j,p,y;
	scanf("%d", &n);
	
	for (i = 1; i <= n; i++){
		x = i;
		if (i % 3 == 0){
			printf(" %d", i);
			continue;
		}
		
		for (j = 0;; j++){
			if (x % 10 == 3){
				printf(" %d", i);
                                break;
			}
			x = x / 10;
			if (x == 0){
				break;
			}
		}
		
	}
	printf("\n");



}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

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

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

    int n, m, q;
    cin>>n>>m>>q;
    vector<vector<int>> as(n, vector<int>(n));
    rep(i, m) {
        int l, r;
        cin>>l>>r; l--; r--;
        as[l][r]++;
    }
    rep(i, n) {
        for (int j = n - 1; j >= 1; --j) {
            as[j - 1][i] += as[j][i];
        }
    }
    rep(i, n) {
        rep(j, n - 1) {
            as[i][j + 1] += as[i][j];
        }
    }
    rep(i, q) {
        int l, r;
        cin>>l>>r; l--; r--;
        cout<<as[l][r]<<endl;
    }
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

inline int topbit(unsigned long long x){
    return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
    return __builtin_parity(x);
}

signed main(){
	int N;cin>>N;
	cout<<(N+1000-1)/1000*1000-N<<endl;
    return 0;
}



Measured memory_bytes: 3580
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

struct train{
    
    vector<lli> start,frame,cost;
    
    train(lli n){
        lli c,s,f,i;
        rep(i,0,n-1){
            cin>>c>>s>>f;
            cost.push_back(c);
            start.push_back(s);
            frame.push_back(f);
        }
    }
    
    lli search(lli a,lli n){
        lli t=0,i;
        rep(i,a,n-1){
//            cout<<"今は"<<t<<"秒で、"<<i<<"駅についている"<<endl;
            if(t<=start[i]){
                t=start[i];
            }
            else{
                if((t-start[i])%frame[i]!=0){
                    lli b=(t-start[i])/frame[i];
                    b++;
                    t=start[i]+b*frame[i];
                }
            }
            t+=cost[i];
        }
        return t;
    }
    
};

int main() {
    lli n;
    lli i,j,k;
    cin>>n;
    train daiya(n);
    rep(i,0,n){
        cout<<daiya.search(i,n)<<endl;
    }
}


Measured memory_bytes: 256
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

const int MAX_N=123456;
//vector<int> A;
int A[MAX_N];
int n;
int main(){
    CLR(A);
    cin>>n;
    //数が多すぎてPushbackできていない？？　というかいちいち格納しなくても解ける？？？？
    REP(i,n){ int a;cin>>a; A[a]++;}
    if(n==1){ cout<<1<<endl; return 0;}
    int max_=-1;
    int num=0;
    REP(i,n){
        num=0;
        int a=i;
        if(i-1<0){
            num=A[i]+A[i+1];
        }
        else{
        num=A[i-1]+A[i]+A[i+1];
        }
        max_=max(max_,num);
    }    

    cout<<max_<<endl;




}


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


int main(){
	int n, id;
    vector<int> a1(100), a2(100), sum(100,0);

    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a1[i];
    }
    for(int i=0;i<n;i++){
        cin >> a2[i];
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<=i;j++){
            sum[i] += a1[j];
        }
        for(int k=i;k<n;k++){
            sum[i] += a2[k];
        }
    }

    sort(sum.begin(), sum.end());
    cout << sum.back() << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
    int n;
    scanf("%d", &n);
    double x[n];
    char u[n][3];
    int i;
    double ans = 0;
    for (i = 0; i < n; i++)
    {
        scanf("%lf%s", &x[i], u[i]);
    }
    for (i = 0; i < n; i++)
    {
        if (u[i][0] == 'J')
        {
            ans += x[i];
        }
        else
        {
            ans += x[i] * 380000;
        }
    }
    printf("%lf\n", ans);
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
const int N = 2e5 + 10;
int n;
ii a[N];
int main() {
	int n; cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i].first; a[i].second = i; }
	sort(a+1, a + n + 1);
	for (int i = 1; i <= n; ++i) cout << a[i].second << " "; cout << endl;
}

Measured memory_bytes: 1536
/*! path:atcoder/abc154/e */!function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};e.__esModule=!0;var o=r(n(1)),u=n(2);o.default.readFile("/dev/stdin","utf8",(function(t,e){!function(t){var e=new u.Solver,n=e.parse(t),r=e.solve(n);e.print(r)}(e)}))},function(t,e){t.exports=require("fs")},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});e.__esModule=!0;var u=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e.prototype.nCk=function(t,e){return t<e?0:3===e?t*(t-1)/2*(t-2)/3:2===e?t*(t-1)/2:1===e?t:1},e.prototype.solve=function(t){var e=t.N,n=t.K,r=0;if(e.length<n)return{answer:r};for(var o=n,u=0;u<e.length&&o>0;u++)0!==e[u]&&o>0&&(r+=this.nCk(e.length-u-1,o)*Math.pow(9,o),r+=(e[u]-1)*this.nCk(e.length-u-1,o-1)*Math.pow(9,o-1),o--);return 0===o&&r++,{answer:r}},e.prototype.parse=function(t){for(var e=t.split(/\s+/),n=e[0],r=parseInt(e[1]),o=[],u=0;u<n.length;u++)o.push(parseInt(n[u]));return{K:r,N:o}},e.prototype.print=function(t){console.log(t.answer)},e}(n(3).SolverBase);e.Solver=u},function(t,e,n){"use strict";e.__esModule=!0;var r=function(){};e.SolverBase=r}]);
//# sourceMappingURL=main.js.map

Measured memory_bytes: 7372
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int W = scanner.nextInt();
        int H = scanner.nextInt();
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        int r = scanner.nextInt();
        String str = null;

        if (x+r<=W && x-r>=0 && y+r<=H && y-r>=0) str = "Yes";
        else str = "No";

        System.out.println(str);

    }
}


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

int main(){
    int a, b;
    cin >> a >> b;
    if( a > b ) {
        cout << "a > b" << endl;
    } else if ( a < b ) {
        cout << "a < b" << endl;
    } else {
        cout << "a == b" << endl;
    }
    return 0;
}


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

int s[1000], d[1000], t[1000][1000], y[1000];
P p[100000];
int main() {
	int n, m, h, k;
	while (scanf("%d%d%d%d", &n, &m, &h, &k), n) {
		rep(i, n)scanf("%d", &s[i]), d[i] = t[0][i] = i;
		rep(i, m) {
			int a, b; scanf("%d%d", &a, &b);
			p[i] = P(b, a);
		}
		sort(p, p + m);
		int u = 0;
		for (int i = 1; i < h; i++) {
			while (p[u].first == i)swap(d[p[u].second - 1], d[p[u].second]), u++;
			if (u >= m)break;
			rep(j, n)t[i][j] = d[j];
		}
		rep(i, n)y[d[i]] = i;
		int Min = 0;
		rep(i, n)if (d[i] < k)Min += s[i];
		rep(i, m) {
			int a = y[t[p[i].first - 1][p[i].second - 1]], b = y[t[p[i].first - 1][p[i].second]];
			swap(d[a], d[b]);
			int sum = 0;
			rep(i, n)if (d[i] < k)sum += s[i];
			Min = min(Min, sum);
			swap(d[a], d[b]);
		}
		printf("%d\n", Min);
	}
}

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

#define rep_(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)
#define rrep_(v, f, l) for (int v = (l), v##_ = (f); v >= v##_; --v)
#define rrep(v, n) rrep_(v, 0, n - 1)
#define rlep(v, n) rrep_(v, 1, n)
#define show_a(a, size) rep(a##_it, size) std::cout << a[a##_it] << " \n"[a##_it == a##_it_ - 1];
#define show_v(v) show_a(v, v.size())
#define eachv(v, i) rep(i, v.size())
#define reachv(v, i) rrep(i, v.size())
#define debug(x) std::cerr << #x << " = " << x << "\n";

using namespace std;

typedef long long int lint;
struct Edge {
    int src, dst, w;
    Edge(int src, int dst, int w) : src(src), dst(dst), w(w) {}
};
bool operator<(const Edge& a, const Edge& b){
    return a.w != b.w ? a.w > b.w : a.src != b.src ? a.src < b.src : a.dst < b.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

const int INF = 10000000;

void shortestPath(const Graph &g, int s, vector<int>& dist, vector<int>& prev){
    int n = g.size();
    dist.assign(n, INF);
    dist[s] = 0;
    prev.assign(n, -1);
    priority_queue<Edge> Q;
    for (Q.push(Edge(-2, s, 0)); !Q.empty();){
        Edge e = Q.top();
        Q.pop();
        if (prev[e.dst] != -1) continue;
        prev[e.dst] = e.src;
        eachv(g[e.dst], i){
            int new_dist = e.w + g[e.dst][i].w;
            int dest = g[e.dst][i].dst;
            int source = g[e.dst][i].src;
            if (dist[dest] > new_dist){
                dist[dest] = new_dist;
                Q.push(Edge(source, dest, new_dist));
            }
        }
    }
}

int main()
{
    int h, w, n;
    h = in();
    w = in();
    n = in();
    vector<string> field;
    rep(i, h){
        string s;
        cin >> s;
        field.push_back(s);
    }
    Graph g(h * w);
    vector<int> cheese(n + 1);
    const int dx[] = {1, -1, 0, 0};
    const int dy[] = {0, 0, 1, -1};
    rep(i, h){
        rep(j, w){
            if (isdigit(field[i][j])){
                cheese[field[i][j] - '0'] = i * w + j;
            }
            if (field[i][j] == 'S'){
                cheese[0] = i * w + j;
            }
            if (field[i][j] != 'X'){
                rep(k, 4){
                    int nx, ny;
                    nx = j + dx[k];
                    ny = i + dy[k];
                    if (nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
                    if (field[ny][nx] != 'X') g[i * w + j].push_back(Edge(i * w + j, ny * w + nx, 1));
                }
            }
        }
    }
    int total_time = 0;
    rep(i, n){
        vector<int> dist, prev;
        shortestPath(g, cheese[i], dist, prev);
        total_time += dist[cheese[i + 1]];
    }
    printf("%d\n", total_time);
    return (0);
}

Measured memory_bytes: 44344
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    string ans = "Yes";
    cin >> N;
    vector<int> t(N+1,0),x(N+1,0),y(N+1,0);
    for(int i = 1;i <= N;i ++){
        cin >> t[i] >> x[i] >> y[i];
    }
    for(int i = 1;i <= N;i ++){
        int judge = (t[i]-t[i-1])-abs(x[i]-x[i-1])-abs(y[i]-y[i-1]);
        if(judge < 0 || judge%2) ans = "No";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;
class Main{
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);
		int students = sc.nextInt();
		int total=0;
		for(int i=1;i<=students;i++) {
			total+=i;
		}
		System.out.println(total);
	}
}

Measured memory_bytes: 21844
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
    int n;
    while(scanf("%d",&n) && n != 0){
        int arr[n];
        for(int i = 0; i < n; i++){
            scanf("%d",&arr[i]);
        }
        int max_e = arr[0], max_s = arr[0];
        for(int cur = 1; cur < n; cur++){
            max_e = max(arr[cur], max_e + arr[cur]);
            max_s = max(max_s, max_e);
        }
        printf("%d\n",max_s);
    }
}

Measured memory_bytes: 2608
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

vector<vector<P>> graph;

void dij(ll s, vector<ll>& d, vector<ll>& cnt) {
	d[s]=0;
	cnt[s]=1;
	priority_queue<P,vector<P>,greater<P>> q;
	q.push(P(0,s));
	while(!q.empty()) {
		ll dir=q.top().first;
		ll p=q.top().second;
		q.pop();
		if(d[p]!=dir) continue;
		ll buf=0;
		REP(i,(ll)graph[p].size()) {
			ll np=graph[p][i].first;
			ll cost=graph[p][i].second;
			if(d[np]+cost==d[p]) {
				buf+=cnt[np];
				buf%=MOD;
			}
			if(d[np]>d[p]+cost) {
				d[np]=d[p]+cost;
				q.push(P(d[np],np));
			}
		}
		if(p!=s) cnt[p]=buf;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m,s,t;
	cin>>n>>m>>s>>t;
	s--; t--;
	graph.resize(n);
	REP(i,m) {
		ll u,v,d;
		cin>>u>>v>>d;
		u--;
		v--;
		graph[u].pb(P(v,d));
		graph[v].pb(P(u,d));
	}
	vector<ll> dFromS(n,INF*INF);
	vector<ll> dFromT(n,INF*INF);
	vector<ll> cntFromS(n,0);
	vector<ll> cntFromT(n,0);

	dij(s,dFromS,cntFromS);
	dij(t,dFromT,cntFromT);
	ll diam=dFromS[t];

	ll ans=cntFromS[t]*cntFromS[t];
	ans%=MOD;

	if(diam%2==0) {
		REP(i,n) if(dFromS[i]==diam/2&&dFromS[i]+dFromT[i]==diam) {
			ans-=((cntFromS[i]*cntFromT[i])%MOD)*((cntFromS[i]*cntFromT[i])%MOD);
			ans%=MOD;
		}
	}
	REP(i,n) {
		REP(j,(ll)graph[i].size()) {
			ll a=i,b=graph[i][j].first;
			ll cost=graph[i][j].second;
			if(a>b) continue;
			if(dFromS[a]==dFromS[b]) continue;
			if(dFromS[a]>dFromS[b]) swap(a,b);
			if(dFromS[a]+cost+dFromT[b]==diam&&(dFromS[a]<diam/2&&dFromS[b]>diam/2)) {
				ans-=((cntFromS[a]*cntFromT[b])%MOD)*((cntFromS[a]*cntFromT[b])%MOD);
				ans%=MOD;
			}
		}
	}
	cout<<(ans+MOD)%MOD<<endl;
}


Measured memory_bytes: 18772
import java.util.Scanner;

class Main{
	
	public static void main(String[] args){
		
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		
		if(a > b){
			int temp = a;
			a = b;
			b = temp;
		}
		if(a > c){
			int temp = a;
			a = c;
			c = temp;
		}
		if(b > c){
			int temp = b;
			b = c;
			c = temp;
		}
		
		System.out.println(a + " " + b + " " + c);
		
	}
	
}

Measured memory_bytes: 17300
#include<cstdio>
#include<iostream>
int main()
{ int a,b,c;
  while(scanf("%d%d%d",&a,&b,&c)==3)
    {  int x=a*100+b*10+c;
	   if(x%4==0) printf("YES\n");
	   else printf("NO\n"); 
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rem(i, m, n) for (int i = m; i < (n); i++)
#define eps (1e-7)
#define inf (1e9)
#define pi (acos(-1))
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

    string s;
    cin >> s;
    ll k;
    cin >> k;

    bool flag = true;
    rep(i, k)
    {
        if (s[i] > '1')
        {
            cout << s[i] << "\n";
            flag = false;
            break;
        }
    }

    if (flag)
        cout << 1 << "\n";

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder
{
    class AC
    {
        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };
        

        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            var p = cin.SplitReadL();
            List<long> ans = new List<long>();
            for(var i = 1; i <= Max(p[0], p[1]); i++)
            {
                if (p[0] % i == 0 && p[1] % i == 0)
                {
                    ans.Add(i);
                }
            }

            ans.Sort();
            Console.WriteLine(ans[ans.Count() - (int)p[2]]);
            //Console.Out.Flush();
        }
        
        
    }
    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
        static public long Modulo(long value, long mod)
        {
            long r = value % mod;

            if (r * mod < 0)
            {
                r += mod;
            }
            return r;
        }
    }

    

}


Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int a[3];
  int K;
  cin >> a[0] >> a[1] >> a[2] >> K;
  sort(a,a+3);
  reverse(a,a+3);
  a[0] *= pow(2,K);
  cout << a[0]+a[1]+a[2] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
using namespace std;
int main()
{
    int i,a,b,c,ans;
    scanf("%d %d %d",&a,&b,&c);
    for(i=0;i<=1000;i++)
    {
        ans=a*i;
        if(ans%b==c)
        {
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main() {
  int N,M;
  cin>>N>>M;
  int64_t cnta=0,cntw=0;
  vector<int64_t>wa(100005);
  vector<bool>ok(100005,false);
  for(int i=0;i<M;i++){
    int p;
    string S;
    cin>>p>>S;
    if(ok[p]){continue;}
    else{
     if(S=="AC"){cnta++;cntw+=wa[p];ok[p]=true;}
     if(S=="WA"){wa[p]++;}
    }
  }
  cout<<cnta<<" "<<cntw<<endl;
  return 0;
}

Measured memory_bytes: 4056
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int read() {
	int q=0;char ch=' ';
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') q=q*10+ch-'0',ch=getchar();
	return q;
}
const int N=100005;
int n,tot,ans;
int h[N],ne[N<<1],to[N<<1],f[N][22];
void add(int x,int y) {to[++tot]=y,ne[tot]=h[x],h[x]=tot;}
void dfs(int x,int las) {
	for(RI i=h[x];i;i=ne[i]) {
		if(to[i]==las) continue;
		dfs(to[i],x);
		for(RI j=0;j<=20;++j) f[x][j]+=f[to[i]][j];
	}
	int p=0;
	for(RI i=20;i>=0;--i) if(f[x][i]>=2) {p=i+1;break;}
	while(f[x][p]) ++p;
	++f[x][p];for(RI i=0;i<p;++i) f[x][i]=0;
	ans=max(ans,p);
}
int main()
{
	int x,y;
	n=read();
	for(RI i=1;i<n;++i) x=read(),y=read(),add(x,y),add(y,x);
	dfs(1,0),printf("%d\n",ans);
	return 0;
}

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


int main(){
    int n,m;
    cin >> n >> m;
    int edge[n][n];
    for(int i=0; i<n; i++){
        fill(edge[i],edge[i]+n,0);
    }
    for(int i=0; i<m; i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        edge[a][b] = 1;
        edge[b][a] = 1;
    }
    queue<pair<int, int* >> que;
    int *vec = new int[n];
    fill(vec,vec+n,0);
    vec[0] = 1;
    que.push(make_pair(0,vec));
    int ans = 0;
    while(!que.empty()){
        pair<int,int*> s = que.front();
        que.pop();
        int v = s.first;
        int* used = s.second;
        int check=1;
        for(int i=0; i<n; i++){
            check*=used[i];
        }
        if(check==1){
            ans++;
            continue;
        }
        for(int i=0; i<n; i++){
            if(i==v) continue;
            if(used[i]==1) continue;
            if(edge[v][i]==0) continue;
            int *vv = new int[n];
            copy(used,used+n,vv);
            vv[i]=1;
            que.push(make_pair(i,vv));
        }
        delete used;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Scanner;

public class Main {
    public static class Set {
        int a,b;
        Set(int a, int b) {
            this.a = a;
            this.b = b;
        }

        public boolean isSamePattern(int a, int b) {
            if (this.a == a) if (this.b == b) return true;
            if (this.a == b) if (this.b == a) return true;
            return false;
        }
    }
    public static void main(String[] args) {
        ArrayList<Byte> Takoyaki = new ArrayList<>();
        readLine();
        for (String s : readLine().split(" ")) {
            Takoyaki.add(Byte.parseByte(s));
        }

        //Set, result
        LinkedHashMap<Set, Integer> Map = new LinkedHashMap<>();
        for (int index1 = 0; index1 < Takoyaki.size(); index1++) {
            for (int index2 = 0; index2 < Takoyaki.size(); index2++) {
                if (index1 == index2) continue;
                int Takoyaki1 = Takoyaki.get(index1);
                int Takoyaki2 = Takoyaki.get(index2);

                boolean flag = false;
                for (Set s : Map.keySet()) {
                    if (s.isSamePattern(index1, index2)) flag = true;
                }
                if (flag) continue;

                Map.put(new Set(index1, index2), Takoyaki1 * Takoyaki2);
            }
        }

        int result = 0;
        for (int i : Map.values()) result += i;
        Print(result);

    }

    private static final Scanner __in = new Scanner(System.in);
    private static String readLine() {
        return __in.nextLine();
    }

    private static void Print(int m) {
        System.out.println(m);
    }
}


Measured memory_bytes: 24260
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pi 3.141592653
#define pb push_back
#define pp pop_back
#define mp make_pair
#define in insert
#define ff first
#define ss second
#define mod 1000000007
#define rep(i,n) for(int i = 0 ; i<n ; i++)
#define repr(i,n) for(int i = n-1 ; i>=0 ; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define SORT(v) sort(v.begin(),v.end())
void solve();
ll gc(ll a,ll b)
{
    if(b==0) return a;
    return gc(b,a%b);
}
signed main()
{
    fast;
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}
void solve() 
{
    ll n,d,a;
    cin>>n>>d>>a;
    map<ll,pair<ll,ll>> g;
    for(int i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        y = ceil(((double)(y))/((double)(a)));
        g[x] = mp(y,0);
    }
    ll ans =0;
    ll b=0;
    for(auto i = g.begin();i!=g.end();i++){
        if((i->ss.ff)<=b)b= b - ((*i).ss.ss);
        else{
            ll x= (i->ss.ff)-b;
            ans+=x;
            
            if(g.find((i->ff)+2*d)==g.end())g[(i->ff)+2*d]=mp(0,x);
            else g[(i->ff)+2*d].ss+=x;
            b+= x-(i->ss.ss);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 19072
n,m,k = map(int,input().split())
mod = 998244353
ans = 0
now = m
c = 1
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2] != 1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]
def mod_inv(a,mod):
    x = extgcd(a,mod)[0]
    return (mod + x % mod)% mod
def comb(n,k,mod):
    c = 1
    for i in range(k):
        c = c*(n-i)%mod
        c = c*mod_inv(i+1,mod)%mod
    return c
for i in range(n):
    if n-i-1 <= k:
        ans += now*c
        ans %= mod
    now *= (m-1)
    now %= mod
    c = c*(n-1-i)%mod
    c = c*mod_inv(i+1,mod)%mod
print(ans%mod)

Measured memory_bytes: 9284