akhauriyash/Code-Regression huggingface dataset:
import sys
def input():
	return sys.stdin.buffer.readline()[:-1]

def floor_sum(n, m, a, b):
	ans = 0
	if a >= m:
		ans += (n - 1) * n * (a // m) // 2
		a %= m
	if b >= m:
		ans += (b // m) * n
		b %= m

	y_max = (a * n + b)//m
	x_max = y_max * m - b
	if y_max == 0:
		return ans
	ans += (n - (x_max + a - 1) // a) * y_max
	ans += floor_sum(y_max, a, m, (a - x_max % a) % a)
	return ans

for _ in range(int(input())):
	n, m, a, b = map(int, input().split())
	print(floor_sum(n, m, a, b))

Measured memory_bytes: 79896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll A, B , C, K;
    cin >> A >> B >> C >> K;
    for (int i = 0; i < K; i++) {
        if(A >= B){
            B = B * 2;
        }
        else if(B >= C){
            C = C * 2;
        }
    }
    if(A < B && B < C){
        Yes();
    }
    else{
        No();
    }


}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define ll long long
using namespace std;
using Graph=vector<vector<int>>;
int main() {
  int n;
  cin>>n;
  if(n%10==3){
    cout<<"bon"<<endl;
    return 0;
  }
  if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9){
    cout<<"hon"<<endl;
    return 0;
  }
  cout<<"pon"<<endl;
}

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

int main(){
    long long int A;
    cin >> A;
    long long int ans = 0;
    long long int count = 0;
    for(int i = 0; i <= A; i++){
        if(i%3 == 0){
            count += i;
        }
        else if(i%5 == 0){
            count += i;
        }
         ans += i;
    }
    cout << ans - count << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  vector<vector<int>> A(3, vector<int>(3));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> A.at(i).at(j);
    }
  }
  int N;
  cin >> N;
  vector<int> b(N);
  for (int i = 0; i < N; i++) {
    cin >> b.at(i);
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (A.at(i).at(j) == b.at(k)) {
          A.at(i).at(j) = 0;
        }
      }
    }
  }
  int ans = 0;
  bool ok = false;
  for (int i = 0; i < 3; i++) {
    if (0 == A.at(i).at(0) && 0 == A.at(i).at(1) && 0 == A.at(i).at(2)) {
      ok = true;
      break;
    }
    if (0 == A.at(0).at(i) && 0 == A.at(1).at(i) && 0 == A.at(2).at(i)) {
      ok = true;
      break;
    }
  }
  if (0 == A.at(0).at(0) && 0 == A.at(1).at(1) && 0 == A.at(2).at(2)) {
    ok = true;
  }
  if (0 == A.at(0).at(2) && 0 == A.at(1).at(1) && 0 == A.at(2).at(0)) {
    ok = true;
  }
  if (ok) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

using namespace std;

int main() {
    long long int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    long long int diff = b - a;
    for(int i = 0; i < n; i++)
    {
        long long int temp = -d * i + c * (n - 1 - i);
        if(temp <= diff)
        {
            long long int diff2 = diff - temp;
            if(diff2 <= (d - c) * (n - 1))
            {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long unsigned int ll;
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll max=0;
    ll temp;
    int n;
    ll count=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%llu",&temp);
        if(i==0)
        max=temp;
        else if(temp >= max)
        max=temp;
        else
        {
            count+=max-temp;
        }
    }
    printf("%llu\n",count);
    return 0;
}

Measured memory_bytes: 3832
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <string>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 100005
#define MOD 20190823
#define eps 1e-8
#define mp make_pair
#define INF 1000000000+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
template<class T> inline void read(T &f){
	f=0;
    T x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
}
ll a[10];
int main(){
	for(ll i=1;i<=5;i++){
		read(a[i]);
	}
	sort(a+1,a+6);
	ll ans=INF;
	do{
		ll time=0;
		for(ll i=1;i<=4;i++){
			time+=a[i];
			if(time%10!=0){
				ll p=time%10;
				time=time-p+10;
			}
		}
		time+=a[5];
//		cout<<time<<endl;
		ans=min(ans,time);
	}while(next_permutation(a+1,a+6));
	cout<<ans<<endl;
	return 0;
} 

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

int main() {
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    int xl[n], yl[m];
    for (int i = 0; i < n; i++)
        cin >> xl[i];
    for (int i = 0; i < m; i++)
        cin >> yl[i];
    
    sort(xl, xl+n);
    sort(yl, yl+m);
    if (xl[n-1]<yl[0] && x<yl[0] && y>xl[n-1])
        cout << "No War" << endl;
    else
        cout << "War" << endl;
}

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

#define forn(i,a,b) for(int i=(a);i<(b); ++i)
#define nfor(i,b,a) for(int i=(b-1);i>=a;--i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define ifile freopen("point1.in", "r", stdin)
#define ofile freopen("point1.out   ", "w", stdout)
#define fast ios_base::sync_with_stdio(0);\
             cin.tie(0);\
             cout.tie(0);
//#define mp make_pair
#define pb push_back
//#define mt make_tuple
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ll_min LONG_LONG_MIN
#define ll_max LONG_LONG_MAX
#define _1 first
#define _2 second
#define sqr(a) ((a)*(a))
const ld PI = 3.141592653589793238462643383279;
const ld EPS = 1e-6;
const int INF = 1e9 + 7;
const ll MOD = INF;
const ll maxn = 2e5+2;
const ll HASH_MODS[] = { 1000000007333,1000000009367, 1000000075747, 1000000158923, 1000000203119 };
//||||||||||||||||||||LOCAL||||||||||||||||||||||||||
int a[50];
int b[50];
int c[50];
int dp[50][500][500];
int main(){
    int n,ma,mb;
    cin>>n>>ma>>mb;
    forn(i,1,n+1){
        cin>>a[i]>>b[i]>>c[i];
    }
    forn(i,0,50)
        forn(j,0,500)
            forn(k,0,500)
                dp[i][j][k]=INF;
    dp[0][0][0]=0;
    for (int i=1; i<=n; ++i)
        for (int k=0; k<=400; ++k)
            for (int l=0; l<=400; ++l){
                if (dp[i-1][k][l]!=INF){
                    dp[i][k+a[i]][l+b[i]]=min(dp[i][k+a[i]][l+b[i]],dp[i-1][k][l]+c[i]);
                    dp[i][k][l]=min(dp[i][k][l],dp[i-1][k][l]);
                   // cout<<i<<" "<<k<<" "<<l<<" "<<dp[i][k][l]<<"\n";
                }
            }
    int ans=INF;
    int ca=ma;
    int cb=mb;
    while (max(ca,cb)<=400){
        ans=min(ans,dp[n][ca][cb]);
        ca+=ma;
        cb+=mb;
    }
    if (ans==INF)
        cout<<-1;
    else
        cout<<ans<<"\n";
}


Measured memory_bytes: 49024
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		List<Integer> list = new ArrayList<>();
		list.add(3*5*7);
		list.add(3*5*11);
		list.add(3*5*13);
		list.add(3*3*3*5);
		list.add(3*3*3*7);
		list.sort(Comparator.naturalOrder());
		for(int i=0;i<list.size();i++) {
			if(n<list.get(i)) {
				System.out.println(i);
				break;
			}
			if(i==list.size()-1) System.out.println(list.size());
		}
		in.close();

	}

}


Measured memory_bytes: 22740
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int counter=0;
		final int N=sc.nextInt();
		final int K=sc.nextInt();
		int[] h=new int[N];
		for(int i=0;i<N;i++){
			h[i]=sc.nextInt();
		}
		for(int i:h){
			if(i>=K){
				counter++;
			}
		}
      	System.out.println(counter);
	}
}

Measured memory_bytes: 50292
import java.util.Scanner;

public class Main {
    private static Scanner sc;

    public Main() {
    }

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

    }

    private void solve() {
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        System.out.println(Math.min(N * A, B));
    }
}


Measured memory_bytes: 21844
#include<stdio.h>
#define inf 1145141919

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

int main(void){
    int a,b,c,n,i;
    scanf("%d",&n);
    scanf("%d",&a);
    b=a;c=a;
    for(i = 2;i <= n;i++){
        scanf("%d",&a);
        b=min(b,a);c=max(c,a);
    }
    printf("%d\n",c-b);
    return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#include<string>
#include<stdlib.h>
#include<stdio.h>

typedef long long ll;
using namespace std; 
int main(){
	int n;
	cin>>n;
	int a[n];
	ll odd=1;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]%2==1){
			odd*=1;
		}
		
		if(a[i]%2==0){
			odd*=2;
		}
	}
	ll sum=pow(3,n),ans;
	ans=sum-odd;
	cout<<ans;
}

Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll k,n;cin >> n >>k;
    vl a(n),b(n);
    rep(i,n)cin >> a[i] >> b[i];
    ll res=0;
    rep(i,30){
        if((1<<i)&k){
            ll t=1<<i;
            t--;
            ll p=k-(1<<i)|t;
            ll sum=0;
            rep(j,n){
                if(p==(p|a[j]))sum+=b[j];
            }
            chmax(res,sum);
        }
    }
    ll sum=0;
    rep(j,n){
        if(k==(k|a[j]))sum+=b[j];
    }
    chmax(res,sum);
    cout << res <<endl;
}   

Measured memory_bytes: 4744
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;
list<long long int> Prime(int M) {
	list<long long int>P;
	P.push_back(2);
	P.push_back(3);
	for (int i = 5; i <= M; i += 6) {
		bool flag = true;
		for (auto j : P) {
			if (i%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i);
		flag = true;
		for (auto j : P) {
			if ((i + 2) % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i + 2);
	}
	return P;
}

long long int N, M, K, Q, W, H;
long long int ans;

int main() {
	ios::sync_with_stdio(false);
	bool flag[101][101] = {};
	cin >> W >> H >> N;
	for (int i = 0; i < N; i++) {
		int x, y, c;
		cin >> x >> y >> c;
		if (c == 1) {
			for (int j = 0; j < x; j++) {
				for (int k = 0; k < H; k++)flag[k][j] = true;
			}
		}
		if (c == 2) {
			for (int j = x; j < W; j++) {
				for (int k = 0; k < H; k++)flag[k][j] = true;
			}
		}
		if (c == 3) {
			for (int j = 0; j < y; j++) {
				for (int k = 0; k < W; k++)flag[j][k] = true;
			}
		}
		if (c == 4) {
			for (int j = y ; j < H; j++) {
				for (int k = 0; k < W; k++)flag[j][k] = true;
			}
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++)if (!flag[i][j])ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//ALLAH bachiye naw plz,amr 1400+ rating tulai daw plzz
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define ll long long
#define testcase ll T; cin >> T; for (ll tc = 1; tc <= T; tc++)
int main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  //testcase {
    char c;
    cin>>c;
    if(c>='A' && c<='Z') { cout<<'A'; }
    else { cout<<'a'; }
  //}
  return 0;
} 

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

bool prime[55556];
vector<int> p;

void MakePrimeArray(int n){

    prime[0] = prime[1] = false;
    for(int i=2;i<n;i++){
        prime[i] = true;
    }

    for(int i=2;i<n;i++){
        if(prime[i]){
            p.push_back(i);
            for(int j=i*2;j<n;j+=i){
                prime[j] = false;
            }
        }
    }
}

int main() {

    MakePrimeArray(55556);

    int n;

    cin >> n;

    for(auto a : p){
        if(a >= 10 && a%5 == 1){
            cout << a;
            n--;
            if(n == 0){
                cout << endl;
                break;
            }
            cout << ' ';
        }
    }

    return 0;
}

Measured memory_bytes: 384
//! ----------------------------------------------
//! 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();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (r, D, X) = read!(i64, i64, i64);

    let mut x = X;
    for _ in 2001..2011 {
        x = r * x - D;
        println!("{}", x)
    }
}


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

const long long MOD = 1000000007;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    string S;
    cin >> S;

    vector<int> count(4, 0);
    for(int i=0;i<S.size();i++){
        switch (S[i]) {
            case 'N':
            count[0]++;
            break;

            case 'S':
            count[1]++;
            break;

            case 'W':
            count[2]++;
            break;

            case 'E':
            count[3]++;
            break;
        }
    }

    bool ok = true;
    if ((count[0] == 0 && count[1] > 0) || (count[0] > 0 && count[1] == 0)){
        ok = false;
    }

    if ((count[2] == 0 && count[3] > 0) || (count[2] > 0 && count[3] == 0)){
        ok = false;
    }

    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int X, Y, Z;
    cin >> X >> Y >> Z;

    swap(X, Y);
    swap(X, Z);

    printf("%d %d %d\n", X, Y, Z);
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define IREP(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define IMAX INT_MAX
#define IMIN INT_MIN
#define LMAX LLONG_MAX
#define LMIN LLONG_MIN
template<typename T> inline void chmin(T &a, T b){ if(a > b) a = b; }
template<typename T> inline void chmax(T &a, T b){ if(a < b) a = b; }
template<typename T> inline void xch(T &a, T &b){ T w = a; a = b; b = w; }


int main() {
    string S, T;
    cin >> S >> T;
    cout << T << S << endl;
    return 0;
}


Measured memory_bytes: 256
//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
#pragma comment(linker,"/STACK:33554432") /*32Mb*/

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <cmath>
#include <list>
#include <iomanip>
#include <set>
#include <map>
#include <sstream>
using namespace std;

typedef  long long LL;
typedef  unsigned long long ULL;
typedef  long double LD;
typedef  pair<int, int> PII;
typedef vector<int> VI;
#define For(i,a,b) for(int (i)=(a);i<(b);++(i))
#define FoR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i)) 
#define MP make_pair
#define MOD 1000000007
#define INF 1000000000
#define PB push_back
#define y0 kihrbdb
#define y1 ugvrrtgtrg
#define eps 1e-5
#define X first
#define Y second

int arr[100010];
int n;

int main()
{
	cout.setf(ios::fixed, ios::floatfield);
	cout.precision(4);

	cin >> n;
	For(i, 0, n)
	{
		int a;
		cin >> a;
		arr[a]++;
	}

	int ans = n;
	bool was3 = false;
	int st = 0;
	For(i, 0, 100010)
	{
		if (!arr[i]) continue;
		//if (arr[i] >= 3 && arr[i] % 2 == 1) was3 = 1;
		int tt = (arr[i] - 1) / 2;
		ans -= tt * 2;
		if (arr[i] % 2 == 0) st++;
	}
	int tt = st / 2;
	ans -= tt * 2;

	if (st % 2 == 1)
		ans -= 2;

	cout << ans << endl;

	return 0;
}

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

using namespace std;

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

        int w, h;
        cin >> w >> h;


        vector<vector<bool> > field( w, vector<bool>( h, false ) );
        for( int i=0; i<n; ++i ) {
            int x, y;
            cin >> x >> y;

            field[x-1][y-1] = true;
        }


        int s, t;
        cin >> s >> t;

        int result = 0;
        for( int bx=0; bx<=w-s; ++bx ) {
            for( int by=0; by<=h-t; ++by ) {

                int num = 0;
                for( int x=bx; x<bx+s; ++x ) {
                    for( int y=by; y<by+t; ++y ) {
                        if ( field[x][y] )
                            ++num;
                    }
                }

                if ( num > result )
                    result = num;

            }
        }

        cout << result << endl;
    }
}

Measured memory_bytes: 1224
#include <stdio.h>


int main () {

	int dataset=0;
	int count=0;

	int point[1000]={};
	int max=0;
	int sma=0;
	int cul=0;


	


	while(1){

		scanf("%d",&dataset);

		if(dataset ==0){
			break;
		}

		
		count=0;
		for ( count=0; count < dataset; count++){
				scanf("%d",&point[count]);
				if(count==0){
					max = point[count];
					sma = point[count];
				}
				if(max < point[count]){
					max = point[count];
				}
				if(sma > point[count]){
					sma = point[count];
				}
				cul += point[count];


		}		
		cul -= max;
		cul -= sma;
		cul = cul/(dataset-2);
		printf("%d\n",cul );
		max=0;
		sma=0;
		cul=0;

		
	}
		


	return 0;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX
#define yn(f) cout << (f ? "Yes" : "No") << endl;

int n,m;

signed main() {
    cin >> n >> m;
    cout << n*max(0LL,(n-1))/2 + m*max(0LL,(m-1))/2 << endl;
}

Measured memory_bytes: 764
#include<stdio.h>
#include<stdlib.h>
int main(void){
  int n;
  scanf("%d",&n);
  int i,S[n];
  for(i=0; i<n; i++){
    scanf("%d",&S[i]);
  }
  int q;
  scanf("%d",&q);
  int j,T[q];
  for(j=0; j<q; j++){
    scanf("%d",&T[j]);
  }
  int same[n];
  int cnt=0;
  int sum=0;
  for(j=0; j<q; j++){
    cnt=0;
    for(i=0; i<n; i++){
	if(S[i]>T[j]){
	  break;
	}else{
	  if(S[i]==T[j]){
	    cnt=1;
	    break;
	  }
	}
    }
    sum+=cnt;
  }
  printf("%d\n",sum);
  return 0;
}



Measured memory_bytes: 2312
def defPrint(s,e):
  global str
  print(str[s:e+1])

def defReverse(s,e):
  global str
  strList = list(str)
  rStrList = strList[s:e+1][::-1]
  for i,x in enumerate(rStrList) :
    strList[s + i] = x
  str = "".join(strList)  
  
def defReplace(s,e,r):
  global str
  if s == 0:
    str = r + str[e+1:]
  else:
    str = str[0:s] + r + str[e+1:]

str = input()
q = int(input())

for i in range(q):
  cmd = list(input().split(" "))
  if cmd[0] == 'print' :
    defPrint(int(cmd[1]),int(cmd[2]))
  if cmd[0] == 'reverse' :
    defReverse(int(cmd[1]),int(cmd[2]))
  if cmd[0] == 'replace' :
    defReplace(int(cmd[1]),int(cmd[2]),cmd[3])
  


Measured memory_bytes: 5624
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 5 * 105000;

int n;
long long l;
string s;
int go[MAXN][2];
bool endsHere[MAXN];
int nodeNum = 1;
long long ans = 0;

void add(string s) {
  int cur = 0;
  for (int i = 0; i < sz(s); i++) {
    int num = (int) (s[i] - '0');
    if (go[cur][num] == 0) {
      go[cur][num] = nodeNum;
      nodeNum++;
    }
    cur = go[cur][num];
  }
  endsHere[cur] = true;
}

long long f(long long x) {
  long long res = 1;
  while (x % 2 == 0) {
    res *= 2;
    x /= 2;
  }
  return res;
}

void dfs(int v, int len) {
  if (endsHere[v] || len == l) {
    return;
  }
  if (go[v][0] != 0) {
    dfs(go[v][0], len + 1);
  } else {
    ans ^= f(l - len); 
  }
  if (go[v][1] != 0) {
    dfs(go[v][1], len + 1);
  } else {
    ans ^= f(l - len);
  }
}

int main() { 

  scanf("%d %lld\n", &n, &l);
  for (int i = 0; i < n; i++) {
    getline(cin, s);
    add(s);
  }

  /* vector <int> g = {0, 1};
  for (int i = 2; i <= 20; i++) {
    set <int> st;
    st.insert(0);
    int x = 0;
    for (int j = i - 1; j >= 1; j--) {
      x ^= g[j];
      st.insert(x);
    }
    for (int j = 0; ; j++) {
      if (st.count(j) == 0) {
        g.push_back(j);
        break;
      }
    }
  }

  for (int i = 0; i < sz(g); i++) {
    cerr << i << " " << g[i] << endl;
  } */

  dfs(0, 0);

  if (ans) {
    puts("Alice");
  } else {
    puts("Bob");
  }

  return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void) {
    string s, t;
    cin >> s >> t;
    vector<ll> ss(27, 0), ts(27, 0);
    for(ll i = 0; i < s.length(); i++){
        char a = s[i], b = t[i];
        ss[a-97]++; ts[b-97]++;
    }
    sort(ss.begin(), ss.end());
    sort(ts.begin(), ts.end());
    bool ok = true;
    for(ll i = 0; i < 27; i++){
        if(ss[i]!=ts[i])
            ok = false;
    }
    if(ok==true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 776
// Template
#include <bits/stdc++.h>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <class T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <class T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET {IOSET() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main Code
int main() {
    int a, b;
    cin >> a >> b;
    if (a + b == 15) cout << "+\n";
    else if (a * b == 15) cout << "*\n";
    else cout << "x\n";
    return 0;
}


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

int main(){
  int N,ans = 0;
  string A,B,C;
  cin >> N >> A >> B >> C;
  for(int i=0; i<N; i++){
    if((A[i] != B[i]) || (B[i] != C[i]) || (C[i] != A[i])){
      if((A[i] == B[i]) || (B[i] == C[i]) || (C[i] == A[i])){
        ans++;
      }
      else{
        ans += 2;
      }
    }
  }
  cout << ans << endl;
} 


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


int main() {
  int N, K;
  cin >> N >> K;
  int a[N];
for (int i=0; i < N; i++) cin >> a[i];

int lot_length=0;
sort(a, a+N, greater<int>());

for(int i=0; i<K; i++){
  lot_length += a[i];
}
  cout << lot_length << endl;
}



Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] Args){
        Scanner scan = new Scanner(System.in);
        int A =  Integer.parseInt(scan.next());
        int B =  Integer.parseInt(scan.next());
        scan.close();
        int number_power_strips = 0;
        int power_outlet = 1;
        while(power_outlet < B){
            number_power_strips++;
            power_outlet += A - 1;
        }
        System.out.println(number_power_strips);
    }
}

Measured memory_bytes: 21716
import sys
import functools
import operator

def main():
   s = sys.stdin.readline().strip()
   h = int(len(s) / 2)
   n = functools.reduce(operator.add, map(lambda x: 0 if(s[x] == s[-1-x]) else 1, range(0, h)), 0)
   print(n)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3572
import heapq
from collections import defaultdict
N = int(input())
P = list(map(int,input().split()))

d_r = defaultdict(lambda:N+1)
h_r = []
d_r2 = defaultdict(lambda:N+1)
h_r2 = []
for i in range(N):
    p = P[i]
    while h_r2:
        q = heapq.heappop(h_r2)
        if q < p:
            d_r2[q] = p
        else:
            heapq.heappush(h_r2,q)
            break
    while h_r:
        q = heapq.heappop(h_r)
        if q < p:
            d_r[q] = p
            heapq.heappush(h_r2,q)
        else:
            heapq.heappush(h_r,q)
            break
    heapq.heappush(h_r,p)


d_l = defaultdict(lambda:0)
h_l = []
d_l2 = defaultdict(lambda:0)
h_l2 = []
for i in range(N-1,-1,-1):
    p = P[i]
    while h_l2:
        q = heapq.heappop(h_l2)
        if q < p:
            d_l2[q] = p
        else:
            heapq.heappush(h_l2,q)
            break
    while h_l:
        q = heapq.heappop(h_l)
        if q < p:
            d_l[q] = p
            heapq.heappush(h_l2,q)
        else:
            heapq.heappush(h_l,q)
            break
    heapq.heappush(h_l,p)

d = {}
for i in range(N):
    d[P[i]] = i
d[N+1] = N
d[0] = -1
ans = 0
for i in range(N):
    x = d[d_l2[P[i]]]
    y = d[d_l[P[i]]]
    z = d[d_r[P[i]]]
    w = d[d_r2[P[i]]]
    ans += P[i]*((y-x)*(z-i)+(w-z)*(i-y))
print(ans)

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

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

using namespace std;

int main ()
{
    int N,cnt,res;

    scanf("%d",&N);
    
    res = 0;
    for (int i=1;i<=N;i++)
    {
        cnt = 0;
        for (int j=1;j<=i;j++)
        {
            if (i%j == 0)
                cnt++;
        }
        if (cnt == 8)        
            res++;
            
        i++;
    }

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

Measured memory_bytes: 3840
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

Measured memory_bytes: 3132
x,y,z,k=map(int,input().split())
a=sorted(list(map(int,input().split())),reverse=True)
b=sorted(list(map(int,input().split())),reverse=True)
c=sorted(list(map(int,input().split())),reverse=True)
ans=[]
for ai in a:
  for bi in b:
    ans.append(-ai-bi)
ans.sort()
ans=ans[:k] if len(ans)>=k else ans+[0]*(k-len(ans))
ans1=[]
from heapq import heapify,heappop,heappush
for ci in c:
  for ansi in ans:
    heappush(ans1,ansi-ci)
for i in range(k):
  print(-heappop(ans1))



Measured memory_bytes: 186316
/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_10_C
 */
#include <iostream>
#include <iomanip>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>

using namespace std;

int
main()
{
    ios::sync_with_stdio(false);

    cout << setprecision(8) << fixed;
    while (true) {
        int n;
        cin >> n; cin.ignore();

        if (n == 0) { break; }
        vector<double> S(n);
        for (int i = 0; i < n; i++) {
            cin >> S[i]; cin.ignore();
        }
        double m = accumulate(S.cbegin(), S.cend(), 0.0) / n;

        for_each(S.begin(), S.end(), [&](double &x) mutable { x = (x - m) * (x - m); });
        cout << sqrt( accumulate(S.cbegin(), S.cend(), 0.0) / n) << endl;
    }

    return 0;
}

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

//{{{
typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;
template<class T> inline bool amax (T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool amin (T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> ostream& operator << (ostream &os, const vector<T> &v) { os << "["; for (typename vector<T>::const_iterator it = v.begin(); it != v.end(); it++) { os << (it != v.begin() ? ", " : "") << *it; } os << "]"; return os; }
template<class T> ostream& operator << (ostream &os, const set<T> &s) { os << "{"; for (typename set<T>::const_iterator it = s.begin(); it != s.end(); it++) { os << (it != s.begin() ? ", " : "") << *it; } os << "}"; return os; }
template<class K, class V> ostream& operator << (ostream &os, const map<K, V> &m) { os << "{"; for (typename map<K, V>::const_iterator it = m.begin(); it != m.end(); it++) { os << (it != m.begin() ? ", " : "") << it->first << "->" << it->second; } os << "}"; return os; }
template<class T, class S> ostream& operator << (ostream &os, const pair<T, S> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <class T> istream& operator >> (istream &is, vector<T> &v) { for (size_t i = 0; i < v.size(); i++) is >> v[i]; return is; }
template <class T, class S> inline T lexical_cast (const S &s) { T t; stringstream ss; ss << s; ss >> t; return t; }
 
//> v < ^ (clock wise)
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
const int INFI = 1<<28;
const long long int INFL = 1LL<<60;
const float INFF = 1e+100;
const double INFD = 1e+300;
const double EPS = 1e-8;
const long long int MOD = 1000000007;
//}}}

//{{{
void solve ();
int main () {
    cout.setf(ios::fixed); cout.precision(10);
    ios_base::sync_with_stdio(false);
    solve(); 
    /*
    cin >> T;
    for (int i = 0; i < T; i++) {
        cout << "Case #" << i + 1 << ": ";
        solve();
    }
    //*/
    return 0;
}
//}}}
 
void solve () {
    int N;
    cin >> N;
    N *= 2;
    vector<int> a(N);
    cin >> a;
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < N; i+=2) {
        ans += a[i];
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
/*
[dwacon5th-prelims] A - Thumbnail
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 100;

int N;
int a[MAX_N];

int solve() {
    double avg = 0;
    for (int i = 0; i < N; i++) {
        avg += a[i];
    }
    avg /= N;

    int ans = -1;
    double val = 1000;
    for (int i = 0; i < N; i++) {
        double tmp = abs(1.0 * a[i] - avg);
        if (val > tmp) {
            val = tmp;
            ans = i;
        }
    }

    return ans;
}

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

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[200005];
int main(){
    int n,k;
    cin>>n>>k;
    long long s=0;
    for(int i=1;i<=n;i++) a[i % k]++;
    s = a[0] * a[0] * a[0];
    if(k % 2 == 0) s += a[k >> 1 ] * a[k >> 1] * a[k >> 1];
    cout<<s;
    return 0;
}

Measured memory_bytes: 4372
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}



int main()
{
	int n, q;
	cin >> n >> q;
	vector<queue<int>> a(n);
	rep(_,q){
		int c;
		cin >> c;
		if(c == 0){
			int t, x;
			cin >> t >> x;
			a[t].push(x);
		} else if (c == 2){
			int t;
			cin >> t;
			if (a[t].size())
				a[t].pop();
		} else {
			int t;
			cin >> t;
			if (a[t].size())
				cout << a[t].front() << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 4432
#include<iostream>

#include<string>

using namespace std;

int main(){
  int A,B,C;
  int D=0;

  cin>>A>>B>>C;

  for(int x = A;x <= B; x++){
    if(C%x==0){
      D++;
    }
  }

cout<<D<<endl;

    return 0;
}


Measured memory_bytes: 3120
n,y=map(int,input().split( ))
 
flag=True

def fcn():
    for i in range(n+1):
        for j in range(n-i+1):
            if y==10000*i+5000*j+1000*(n-i-j):
                return [i,j,n-i-j]
    return [-1,-1,-1]

print(' '.join(list(map(str,fcn()))))


Measured memory_bytes: 3060
use strict;
use warnings;
use bigint;

my ($a, $b, $c, $d) = split /\s/, <>;

my $g = gcd($c, $d);
my $cd = $c * $d / $g;

my $div_c =  div_num($a, $b, $c);
my $div_d =  div_num($a, $b, $d);
my $div_cd =  div_num($a, $b, $cd);

my $num = $b - $a + 1;
my $div = $div_c + $div_d - $div_cd;

print $num - $div, "\n";

sub div_num {
	my ($s, $e, $d) = @_;
	my $z = $s % $d;
	my $s2;
	if ($z == 0) {
		$s2 = $s;
	} else {
		$s2 = $s + ($d - ($s % $d));
	}
	if ($s2 > $e) {
		return 0;
	}
	
	my $num = $e - $s2 + 1;
	return int(($num - 1) / $d) + 1;
}

sub gcd {
	my ($a, $b) = @_;
	my $c = $a % $b;
	return $b if $c == 0;
	return gcd($b, $c);
}


Measured memory_bytes: 4992
#include<stdio.h>
#include<queue>
#include<algorithm>
using namespace std;
int x1[1000],x2[1000],y1[1000],y2[1000];
int x[3001];
int y[3001];
int table[3002][3002];
int n;
int w,h;
void bfs(int a,int b){
	queue<pair<int,int> > Q;
	Q.push(make_pair(a,b));
	table[a][b]=-1;
	while(Q.size()){
		int A=Q.front().first;
		int B=Q.front().second;
		if(A>0&&table[A-1][B]==0){
			table[A-1][B]=-1;
			Q.push(make_pair(A-1,B));
		}
		if(B>0&&table[A][B-1]==0){
			table[A][B-1]=-1;
			Q.push(make_pair(A,B-1));
		}
		if(A<3*n&&table[A+1][B]==0){
			table[A+1][B]=-1;
			Q.push(make_pair(A+1,B));
		}
		if(B<3*n&&table[A][B+1]==0){
			table[A][B+1]=-1;
			Q.push(make_pair(A,B+1));
		}
		Q.pop();
	}
	return;
}
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		scanf("%d",&n);
		w=a;
		h=b;
		for(int i=0;i<3002;i++)
			for(int j=0;j<3002;j++)
				table[i][j]=0;
		for(int i=0;i<n;i++){
			scanf("%d%d%d%d",x1+i,y1+i,x2+i,y2+i);
			x2[i]--;
			y2[i]--;
			x[i*3]=x1[i];
			x[i*3+1]=x2[i];
			x[i*3+2]=x2[i]+1;
			y[i*3]=y1[i];
			y[i*3+1]=y2[i];
			y[i*3+2]=y2[i]+1;
		}
		x[n*3]=y[n*3]=0;
		std::sort(x,x+n*3+1);
		std::sort(y,y+n*3+1);
		for(int i=0;i<n;i++){
			int X1=lower_bound(x,x+n*3+1,x1[i])-x;
			int X2=upper_bound(x,x+n*3+1,x2[i])-x-1;
			int Y1=lower_bound(y,y+n*3+1,y1[i])-y;
			int Y2=upper_bound(y,y+n*3+1,y2[i])-y-1;
			table[X1][Y1]++;
			table[X2+1][Y1]--;
			table[X1][Y2+1]--;
			table[X2+1][Y2+1]++;
		}
		for(int i=0;i<n*3+1;i++){
			int now=0;
			
			for(int j=0;j<n*3+1;j++)
				table[i][j]=(now+=table[i][j]);
		}
		for(int i=0;i<n*3+1;i++){
			int now=0;
			for(int j=0;j<n*3+1;j++)
				table[j][i]=(now+=table[j][i]);
		}
		int ret=0;
		for(int i=0;i<n*3+1;i++){
			for(int j=0;j<n*3+1;j++){
				if(x[i]>=a||y[j]>=b){
					table[i][j]=-1;
				}
			}
		}

		//printf("   ");
		//for(int i=0;i<n*3+1;i++)printf("%2d",y[i]);
		//printf("\n");
		/*for(int i=0;i<n*3+1;i++){
			//printf("%2d",x[i]);
			for(int j=0;j<n*3+1;j++){
				printf(table[i][j]?"*":".");
			}
			printf("\n");
		}*/

		for(int i=0;i<n*3+1;i++){
			for(int j=0;j<n*3+1;j++){
				if(table[i][j]==0&&x[i]<a&&y[j]<b){
					bfs(i,j);
					ret++;
				}
			}
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 35000
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#define MOD 1000000007LL

using namespace std;
typedef long long int ll;

struct edge{
	int u, v;
	ll cost;
};

bool comp(const edge& e1, const edge& e2){
	return e1.cost<e2.cost;
}

int par[1002];
int rk[1002];
 
void init(int n){
	for(int i=0; i<n; i++){
		par[i]=i;
		rk[i]=0;
	}
}
 
int find(int x){
	if(par[x]==x){
		return x;
	}else{
		return par[x]=find(par[x]);
	}
}
 
void unite(int x, int y){
	x=find(x);
	y=find(y);
	if(x==y) return;
	if(rk[x]<rk[y]){
		par[x]=y;
	}else{
		par[y]=x;
		if(rk[x]==rk[y]) rk[x]++;
	}
}
 
bool same(int x, int y){
	return find(x)==find(y);
}

int main()
{
	int n, m;
	ll x;
	scanf("%d %d", &n, &m);
	scanf("%lld", &x);
	edge e[2000];
	vector<int> ver[1000]; 
	for(int i=0; i<m; i++){
		int u, v;
		ll w;
		scanf("%d %d %lld", &u, &v, &w);
		u--;
		v--;
		e[i].u=u, e[i].v=v, e[i].cost=w;
	}
	sort(e, e+m, comp);
	for(int i=0; i<m; i++){
		ver[e[i].u].push_back(i);
		ver[e[i].v].push_back(i);
	}
	init(n);
	ll res=0;
	bool used[2000]={};
	for(int i=0; i<m; i++){
		if(!same(e[i].u, e[i].v)){
			unite(e[i].u, e[i].v);
			used[i]=1;
			res+=e[i].cost;
		}
	}
	if(res>x){
		printf("%d\n", 0);
		return 0;
	}
	ll ans1=1, ans2=1;
	int e1=0, e2=0;
	for(int i=0; i<m; i++){
		if(used[i]==0){
			int u=e[i].u, v=e[i].v;
			ll w=e[i].cost;
			queue<int> bfs;
			int dist[1000];
			fill(dist, dist+n, -1);
			bfs.push(u);
			dist[u]=0;
			while(1){
				int v0=bfs.front();
				if(v0==v) break;
				bfs.pop();
				for(int i=0; i<ver[v0].size(); i++){
					int num=ver[v0][i], v1;
					if(used[num]==0) continue;
					if(e[num].u==v0){
						v1=e[num].v;
					}else{
						v1=e[num].u;
					}
					if(dist[v1]<0){
						dist[v1]=dist[v0]+1;
						bfs.push(v1);
					}
				}
			}
			int duv=dist[v], v2=v;
			ll max=0;
			while(duv>0){
				for(int i=0; i<ver[v2].size(); i++){
					int num=ver[v2][i], v3;
					if(e[num].u==v2){
						v3=e[num].v;
					}else{
						v3=e[num].u;
					}
					if(dist[v3]==duv-1){
						if(e[num].cost>max) max=e[num].cost;
						v2=v3;
						duv--;
						break;
					}
				}
			}
			if(res-max+w>x){
				ans1=ans1*2%MOD;
			}else{
				e1=1;
			}
			if(res-max+w>=x){
				ans2=ans2*2%MOD;
			}else{
				e2=1;
			}
		}else{
			if(res>x){
				ans1=ans1*2%MOD;
			}else{
				e1=1;
			}
			if(res>=x){
				ans2=ans2*2%MOD;
			}else{
				e2=1;
			}
		}
	}
	if(e1==0){
		ans1=(ans1-2+MOD)%MOD;
	}else{
		ans1=(ans1+MOD-1)*2%MOD;
	}
	if(e2==0){
		ans2=(ans2-2+MOD)%MOD;
	}else{
		ans2=(ans2+MOD-1)*2%MOD;
	}
	ll ans=(ans2-ans1+MOD)%MOD;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
using namespace std;

int main(){
    int H, W;
    cin >> H >> W;
    vs(a, H);
    rep(i, H) cin >> a[i];

    rep(i, W){
        bool d=1;
        rep(j, H){
            if(d){
                if(a[j].at(i) == '#'){
                    d=0;
                    break;
                }
            }
        }
        if(d){
            rep(j,H){
                erc(a[j],i);
            }
            i--;
            W--;
            
        }
    }

    string t;
    rep(i,W) t.psb('.');
    bool d[H];
    rep(i,H) d[i] = true;
    rep(i,H) if (a[i] == t) d[i] = false;

    rep(i,H) if(d[i]) cout << a[i] << endl;
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;

template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}

template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==v.size()?"":" ");
    return os;
}


signed main(){
    ll x;cin>>x;
    if(x>=30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3648
w, h, n = list(map(lambda x: int(x), input().split()))

xr = [0]
xl = [w]
yu = [h]
yd = [0]

for i in range(n):
    x, y, a = list(map(lambda x: int(x), input().split()))

    if a == 1:
        xr.append(x)
    elif a == 2:
        xl.append(x)
    elif a == 3:
        yd.append(y)
    elif a == 4:
        yu.append(y)


x_1 = max(xr) or 0
x_2 = min(xl) or w
y_1 = max(yd) or 0
y_2 = min(yu) or h


ans = (x_2 - x_1) * (y_2 - y_1)

if ans < 0:
    ans = 0

print(ans)


Measured memory_bytes: 3064
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i

cnt = 0
for i in 0 .. a
  for j in 0 .. b
    left = x - (500 * i + 100 * j)
    if left >= 0 && left % 50 == 0 && left / 50 <= c
      cnt += 1
    end
  end
end

puts cnt

Measured memory_bytes: 1788
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

s = input()
t = input()
ans = "Yes"
d1 = {}
d2 = {}
for i in range(len(s)):
    if s[i] in d1:
        if d1[s[i]] != t[i]:
            ans = "No"
            break
    else:
        d1[s[i]] = t[i]
    if t[i] in d2:
        if d2[t[i]] != s[i]:
            ans = "No"
            break
    else:
        d2[t[i]] = s[i]
print(ans)


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

using namespace std;

int main()
{
    #ifdef HOME
    freopen("input.txt", "rt", stdin);
    #endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int h, w, n;
    cin >> h >> w >> n;
    vector <int> c(n);
    for (int i = 0; i < n; i++)
        cin >> c[i];
    int id = 0;
    int row = 0;
    vector <vector <int> > ans(h, vector <int> (w));
    while(row != h){
        if (row % 2 == 0){
            for (int i = 0; i < w; i++){
                ans[row][i] = id;
                c[id]--;
                if (c[id] == 0)
                    id++;
            }
        }
        else{
            for (int i = w - 1; i >= 0; i--){
                ans[row][i] = id;
                c[id]--;
                if (c[id] == 0)
                    id++;
            }
        }
        row++;
    }
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            cout << ans[i][j] + 1 << ' ';
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))
A.sort()
minNum = A[0]
maxNum = A[N - 1]
countList = [0]*(10**6 + 1)
answer = 0

# Aにnがm個あるときcountList[n] = m
for i in A:
  countList[i] += 1

for j in range(minNum, maxNum + 1):
  # Aにjが含まれていれば、jの倍数をすべてcountListから除外
  # jの倍数pはjで割り切れるので除外可能
  # pの倍数qはjでも割り切れるのでjの時の処理によって除外される
  if countList[j] > 0:
    for k in range(2 * j, maxNum + 1, j):
      countList[k] = 0
  # jが2個以上ある場合にはそれを正解としてカウントしない
  if countList[j] == 1:
      answer += 1

print(answer)

Measured memory_bytes: 32352