akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    a = root(a);
    return -Parent[a];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(a < b) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }

  bool issame(int a, int b){
    return root(a) == root(b);
  }
};

int main(){
  int n,x; cin >> n >> x;
  vi a(n); rep(i,n) cin >> a[i];
  sort(all(a));

  int ans = 0;
  rep(i,n) {
    if(i == n-1){
      if(x == a[i]) ans++;
      break;
    }
    if(x >= a[i]){
      x -= a[i];
      ans++;
    }
  }
  cout << ans << endl;
}

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

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

using namespace std;
using ll = long long;

int main(void)
{
  string n;
  cin >> n;
  cout << n << (n[n.size() - 1] == 's' ? "es" : "s") << endl; 
}

Measured memory_bytes: 3624
# -*- coding: utf-8 -*-

if __name__ == '__main__':

	l = input()
	S1, S2 = [], []
	
	sum = 0
	n = len(l)
	for i in range(n):
		if l[i] == "\\":
			S1.append(i)
		elif l[i] == "/" and S1:
			j = S1.pop()
			a = i - j
			sum += a
	
			while S2 and S2[-1][0] > j:
				a += S2.pop()[1]
			S2.append([j, a])
	
	print(sum)
	print(len(S2), *(a for j, a in S2))

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

int main(){
    string a, b;
    cin >> a >> b;
    for(int i = 0;i < a.size();i++){
        cout << a.at(i);
        if(i < b.size())cout << b.at(i);
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
#define inf 1<<30
#define il inline 
#define in1(a) read(a)
#define in2(a,b) in1(a),in1(b)
#define in3(a,b,c) in2(a,b),in1(c)
#define in4(a,b,c,d) in2(a,b),in2(c,d)
il void readl(ll &x){
    x=0;ll f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
il void read(int &x){
    x=0;int f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
using namespace std;
/*===================Header Template=====================*/
#define N 105
int n,m;
char map[N][N];
bool vis[N][N];
bool pd(){
	for(int i=1;i<=n;i++){
		bool flag=0;
		int cnt=0;
		for(int j=1;j<=m;j++){
			if(!vis[i][j]){
				if(map[i][j]=='#') flag=1;
			}
			else cnt++;
		}
		if(!flag&&cnt<m) return 0;
	}
	for(int i=1;i<=m;i++){
		bool flag=0;
		int cnt=0;
		for(int j=1;j<=n;j++){
			if(!vis[j][i]){
				if(map[j][i]=='#') flag=1;
			}
			else cnt++;
		}
		if(!flag&&cnt<n) return 0;
	}
	return 1;
}
int main(){
	int i,j;
	in2(n,m);
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			scanf(" %c",&map[i][j]);
		}
	}
	while(!pd()){
		for(i=1;i<=n;i++){
			bool flag=1;
			for(j=1;j<=m;j++){
				if(!vis[i][j]){
					if(map[i][j]=='#'){
						flag=0;
						break;
					}
				}
			}
			if(flag==1){
				for(j=1;j<=m;j++){
					if(!vis[i][j]) vis[i][j]=1;
				}
			}
		}
		for(i=1;i<=m;i++){
			bool flag=1;
			for(j=1;j<=n;j++){
				if(!vis[j][i]){
					if(map[j][i]=='#'){
						flag=0;
						break;
					}
				}
			}
			if(flag==1){
				for(j=1;j<=n;j++){
					if(!vis[j][i]) vis[j][i]=1;
				}
			}
		}
	}
	for(i=1;i<=n;i++){
		int cnt=0;
		for(j=1;j<=m;j++){
			if(!vis[i][j]) printf("%c",map[i][j]);
			else cnt++;
		}
		if(cnt<m) printf("\n");
	}
	return 0;
}

Measured memory_bytes: 128
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") # 無限

n = int(input())

data = {}
for _ in range(n):
    temp = "".join(sorted(input()))
    # print(temp)
    if temp in data.keys():
        data[temp] += 1
    else:
        data[temp] = 1
# print(data)

answer = 0
for num in data.values():
    answer += (num*(num-1))//2
print(answer)

Measured memory_bytes: 17852
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.stdio;
import std.string;
import std.typecons;

void log(A...)(A arg) {
    stderr.writeln(arg);
}

void main() {
    int N, M, K;
    scanf("%d %d %d\n", &N, &M, &K);
    auto D = readln.chomp.split(" ").map!((x) => x.to!int - 1).array;
    auto V = new int[][N];
    foreach (i; 0 .. N) {
        V[i] = readln.chomp.split(" ").map!((x) => x.to!int - 1).array;
    }

    auto darkRoomIndex = new int[N];
    darkRoomIndex[] = -1;
    foreach (int i, d; D) {
        darkRoomIndex[d] = i;
    }

    immutable int INF = 1<<28;
    auto dist = new int[1<<M]; dist[] = INF;
    DList!int Q; Q.insert( (1<<M) - 1 );
    dist[ (1<<M) - 1 ] = 0;
    while (!Q.empty) {
        int c = Q.front; Q.removeFront;
        foreach (k; 0 .. K) {
            int nextRooms = 0;
            foreach (i; 0 .. M) {
                if (! (c & (1 << i))) continue;
                int n = darkRoomIndex[ V[ D[i] ][k] ];
                if (n < 0) continue;
                nextRooms |= 1 << n;
            }
            if (dist[nextRooms] > dist[c] + 1) {
                dist[nextRooms] = dist[c] + 1;
                Q.insert(nextRooms);
            }
        }
    }
    writeln(dist[0]);


}

Measured memory_bytes: 4484
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define ll long long
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int A,B, cnt=0;

bool isKaibun(int num){
    string S = to_string(num);
    int N = S.size();

    for(int i = 0; i < N/2; i++){
        if(S[i]!=S[N-1-i]) return false;
    }
    return true;
}

void solve(){
    for(int i = A; i <= B; i++){
        if(isKaibun(i)) cnt++;
    }
    cout << cnt << endl;
}

int main(){
    cin >> A >> B;

    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	string S, T, U;
	int A, B;
	cin >> S >> T;
	cin >> A >> B;
	cin >> U;
	if (S == U) --A;
	else --B;
	cout << A << " " << B << endl;
	return 0;
}


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

using namespace std;

const int m=1e5+1;
long long dp[m],weight[100],profit[100];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n,size;
	cin >> n >> size;
	
	for(int i=0;i<n;i++)
		cin >> weight[i] >> profit[i];
	memset(dp,0,sizeof(dp));
	
	for(int i=0;i<n;i++){
		for(int j=size;j >= weight[i];j--){
			dp[j]=max(dp[j],profit[i]+dp[j-weight[i]]);
		}
	}
	cout<<dp[size]<<"\n";
}

Measured memory_bytes: 4372
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AABProblem solver = new AABProblem();
        solver.solve(1, in, out);
        out.close();
    }

    static class AABProblem {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints(), a = in.ints(), b = in.ints();
            long max = (n - 1L) * b + a;
            long min = (n - 1L) * a + b;
            out.println(Math.max(0, max - min + 1));
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

    }
}



Measured memory_bytes: 23380
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn vec<T, F: FnMut(usize) -> T>(n: usize, mut f: F) -> Vec<T> {
    (0..n).map(|i| f(i)).collect()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let k: usize = scan(tokens);
    let mut a: Vec<usize> = vec(n, |_| scan(tokens));
    let mut f: Vec<usize> = vec(n, |_| scan(tokens));
    a.sort();
    f.sort();
    f.reverse();
    if a.iter().sum::<usize>() <= k {
        println!("0");
        return;
    }
    let mut l = 0;
    let mut u = (0..n).map(|i| a[i] * f[i]).max().unwrap();
    while l + 1 < u {
        let c = (l + u) / 2;
        let mut count = 0;
        for i in 0..n {
            if a[i] * f[i] > c {
                count += a[i] - c / f[i];
            }
        }
        if count > k {
            l = c;
        } else {
            u = c;
        }
    }
    println!("{}", u);
}


Measured memory_bytes: 14072
/*input
1 10
3 5
*/
#include <bits/stdc++.h>

using namespace std;

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


#define FileIn(file) freopen(file, "r", stdin)
#define FileOut(file) freopen(file, "w", stdout)
#define syso(n) cout<<n<<endl;
#define sysom(message, n) cout<<message<<n<<endl;
#define all(c) c.begin(), c.end() 
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define present(container, element) (container.find(element) != container.end())  //map, set
#define cpresent(container, element) (find(all(container),element) != container.end()) //vector
#define what_is(x) cout << #x << " is " << x << endl; 


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

ll lcm(ll fir, ll sec){
	return (fir*sec)/(gcd(fir, sec));
}


const int MOD = 1e9 + 7;
const string small_alphabets = "abcdefghijklmnopqrstuvwxyz";
const int month_days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
// --
// -- 
// -- 
// std::cout << std::fixed;
// std::cout << std::setprecision(5) << f << '\n';


int main(){
	int n,h;
	cin>>n>>h;
	int a[n];
	int b[n];
	for (int i = 0; i < n; ++i){
		cin>>a[i];
		cin>>b[i];
	}
	std::vector<pii> v;
	for (int i = 0; i < n; ++i){
		v.push_back(make_pair(a[i], MOD));
		v.push_back(make_pair(b[i], 1));
	}
	sort(all(v));
	int top = 2*n-1;
	int ans = 0;
	int times = 0;
	while(h>0){
		// what_is(top);
		// what_is(v[top].second)
		if(v[top].second==MOD){
			times = h/v[top].first;
			// what_is(times);
			h-=times*v[top].first;
			ans+=times;
			if(h>0 && times==0){
				ans++;
				break;
			}
		}
		else if(v[top].second>0){
			v[top].second-=1;
			h-=v[top].first;
			ans++;
			top--;
		}		
	}
	syso(ans);
	return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
  
  
  struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
  int main(){
   ll n;  cin>>n ;
   vector<ll> A(n) ;rep(i,n) cin>>A[i] ;
   vector<ll> sa(n-1) ;rep(i,n-1) sa[i] =A[i+1]-A[i] ;
   mint pr=1 ;
   rep(i,n-1){
     pr*=i+1;
    }
   mint saki=0 ; mint ans= 0;
   rep(i,n-1){
     
     saki+=sa[n-2-i] ;
     ans +=saki*pr/(n-1-i) ;
   }
   cout <<ans <<endl ;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vii         vector<pair<ll int, ll int>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
//#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
#define N  1000000007 
#define MAXN   200005
ll int dp[1001][100005];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cout.precision(15);
ll int n,w;
cin>>n>>w;
vii v(n);
rep(i,0,n)
{
cin>>v[i].F>>v[i].S;
}

rep(i,0,n+1)
{rep(j,0,100002)
{dp[i][j]=1e15;}}
dp[0][0]=0;
rep(i,1,n+1)
{
rep(j,0,100002)
{
if(j-v[i-1].S>=0)
dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i-1].S]+v[i-1].F);
else
dp[i][j]=dp[i-1][j];
}
}
ll int maxx=0;
rep(i,0,n+1)
{rep(j,0,100002)
{
if(dp[i][j]<=w)
maxx=max(maxx,j);	
}}	
cout<<maxx;
}


Measured memory_bytes: 80128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ld long double
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rloop(i,a,b) for(ll i=a;i>b;i--)
const int inf=1e9+7;



int main()
{

ll n;
cin>>n;

ll a[n];
	loop(i,0,n)cin>>a[i];
	
	ll dp[n][n];
	rloop(l,n-1,-1)
	{
		loop(r,l,n)
		{
			if(r==l)dp[l][r]=a[l];
			else
			{
				dp[l][r]=max(a[r]-dp[l][r-1],a[l]-dp[l+1][r]);
			}
			
		
			
		}
	
	}
	
	cout<<dp[0][n-1];
	
	
}


Measured memory_bytes: 46464
#include <stdio.h>
 
int main(){
	
int angka,ratusan,puluhan,satuan;
	
scanf("%d", &angka);
	
ratusan = angka % 100;
puluhan = ratusan % 10;
satuan = puluhan;
puluhan = ratusan / 10;
ratusan = angka / 100;
		
if (ratusan == 7){
	printf("Yes\n");
}
	
else if(puluhan == 7){
	printf("Yes\n");
}
	
else if(satuan == 7){
	printf("Yes\n");
}
else{
	printf("No\n");
}

return 0;
}


Measured memory_bytes: 1636
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define pb push_back
int n,a,b;
int32_t main(){
  cin>>n>>a>>b;
  int s = n;
  for(int i=a;i<=b;i++){
    if(i%n==0){puts("OK");return 0;}
  }
  puts("NG");
    

 
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int G[9],n,a,c;
int main(){
	cin>>n;for(int i=0;i<n;i++){cin>>a;G[min(8,a/400)]++;}
	for(int i=0;i<8;i++){if(G[i]>=1)c++;}
	if(c>=1)cout<<c<<endl<<c+G[8]<<endl;
	else cout<<1<<endl<<n<<endl;
	return 0;
}

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

typedef long long ll;

const int MAX_N = 110;
const ll INF = 1e12;

vector<pair<ll, ll> > g[MAX_N];
ll d[MAX_N];
int n;

bool used[MAX_N][MAX_N];

int pr[MAX_N];

void dijkstra(int s){
    priority_queue<pair<ll, ll>, vector<pair<ll, ll> >, greater<pair<ll, ll> > > PQ;
    for(int i=1;i<=n;i++) d[i] = INF;
    for(int i=1;i<=n;i++) pr[i] = -1;
    d[s] = 0;
    PQ.push(make_pair(0, s));

    while(!PQ.empty()){
        pair<ll, ll> p = PQ.top(); PQ.pop();
        int v = p.second;
        if(d[v] < p.first) continue;
        for(auto gvi: g[v]){
            ll cost = gvi.first;
            int u = gvi.second;
            if(d[u] > d[v] + cost){
                d[u] = d[v] + cost;
                PQ.push(make_pair(d[u], u));
                pr[u] = v;
            }
        }
    }
}

// 頂点tへの最短路
void get_path(int t){
    for(; t != -1 && pr[t] != -1; t = pr[t]) {
        used[t][pr[t]] = true;
        used[pr[t]][t] = true;
    }
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int m; cin >> n >> m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            used[i][j] = true;
        }
    }
    for(int i=0;i<m;i++){
        int a, b;
        ll c; cin >> a >> b >> c;
        g[a].push_back(make_pair(c, b));
        g[b].push_back(make_pair(c, a));
        used[a][b] = false;
        used[b][a] = false;
    }
    for(int i=1;i<=n;i++){
        dijkstra(i);
        for(int j=i+1;j<=n;j++){
            get_path(j);
        }
    }
    int cnt = 0;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(used[i][j] == false) cnt++;
        }
    }
    cout << cnt << endl;
}


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

Measured memory_bytes: 592
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner io = new Scanner(System.in);
		String S = io.next();
		boolean[] alph = new boolean[26];
		for (int i = 0; i < S.length(); i++) {
			boolean cha = alph[S.charAt(i)-97];
			if(cha){
				System.out.println("no");
				return;
			}
			alph[S.charAt(i)-97] = true;
		}
		
		System.out.println("yes");
		
	}	
}	

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

template<class T> struct rge { T b, e; };
template<class T> rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
    ~debug(){cerr<<endl;}
    template<class T> debug& operator<<(T x){cerr<<boolalpha<<x; return *this;}
    template<class B, class C> debug& operator<<(pair<B, C> x){return *this<<"("<<x.first<<", "<<x.second<<")";}
    template<class T> debug& operator<<(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}return *this<<"]";}
    template<class T> debug& operator<<(vector<T> x){ return *this<<range(x.begin(),x.end());}
#else
    template<class T> debug& operator <<(const T&){return *this;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;

#define forn(i, n) for(int i = 0; i < int(n); i++)
#define ford(i, n) for(int i = n-1; i >= 0; i--) 

template<typename T> 
void min_self(T& a, T b) { 
    a = min(a, b); 
}
template<typename T>
void max_self(T& a, T b) { 
    a = max(a, b); 
}

struct Edge {
    int from, to, len;
};

void solve_all_ones(int L) {
    int n = 32 - __builtin_clz(L);
    vector<Edge> edges;
    int w = 1<<(n-1);
    for(int i = 1; i <= n; i++) {
        edges.push_back({i, i+1, 0});
        edges.push_back({i, i+1, w});
        w /= 2;
    }
    int m = edges.size();
    cout << n + 1 << ' ' << m << '\n';
    for(Edge e : edges) {
        cout << e.from << ' ' << e.to << ' ' << e.len << '\n';
    }
    exit(0);
}

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

    int L;
    cin >> L;
    L--;
    int memo_L = L;
    for(int i = 0; i < 21; i++) {
        if((1<<i)-1 == L) {
            solve_all_ones(L);
        }
    }
    
    vector<int> bin;
    while(L > 0) {
        bin.push_back(L%2);
        L /= 2;
    }
    reverse(bin.begin(), bin.end());
    debug() nav(bin);
    int n = bin.size();
    assert(n <= 20 && n > 1);
    int w = 1<<(n-2);
    vector<Edge> edges;
    for(int i = 1; i < n; i++) {
        edges.push_back({i, i+1, 0});
        edges.push_back({i, i+1, w});
        w /= 2;
    }
    
    int cur = (1<<(n-1));
    while(1) {
        int i = -1;
        while((cur|((1<<(i+1))-1)) <= memo_L) {
            i++;
        }
        debug() nav(cur) nav(i);
        edges.push_back({1, n-i, cur});
        cur |= (1<<(i));
        //$ cur--;
        debug() nav(cur);
        if(cur > memo_L) {
            break;
        }
    }
    int m = edges.size();
    cout << n << ' ' << m << '\n';
    for(Edge e : edges) {
        cout << e.from << ' ' << e.to << ' ' << e.len << '\n';
    }
}













// Those who say they can, and those who say they can't - are both usually right.

// Read statement carefully
// Solve on paper first!
// Overflows (long long)

// Author: blondie


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define rep(i, l, r) for(int i = l; i <= r; ++i)
int n, m, x, ans, cnt, now;
signed main(){
    cin >> n, x = n;
    rep(i, 2, sqrt(1.0 * x)) if(n % i == 0){
        cnt = 0, m;
        while(n % i == 0) cnt++, n /= i;
        rep(j, 1, 100){
            now = (1 + j) * j / 2, m = j - 1;
            if(now > cnt) break;
        }
        ans += m;
    }
    if(n != 1) ans++;
    printf("%lld", ans);
    return 0;
}

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

// for loop
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

// abbreviati
#define PB(v) push_back(v)
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

// constant
const int INF = 1<<30;
const ll INFLL = 1LL << 60;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

/***Snippet***************************************************
ifelse, isprime, torad, todeg, lcm, bfs,chmin,chmax
**************************************************************/

// adjacency list
vector<int> to[100005];

// Graph
using Graph = vector<vector<int>>;

// Grid
int H,W;
vector<vector<int>> field;

// 4方向への移動ベクトル
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int p,q,r; cin >> p >> q >> r;
    cout << min(p+q,min(q+r,p+r)) ENDL;
    
    return 0;
}

Measured memory_bytes: 5996
#include <stdio.h>

long long int l_min(long long int*A){
    long long int ans=A[0];
    for (size_t i = 1; i < 5; i++){
        if (ans>A[i]){
            ans=A[i];
        }
    }
    return ans;
}

int main(int argc, char const *argv[])
{
    long long int N;
    long long int A[5];
    scanf("%lld",&N);
    for (size_t i = 0; i < 5; i++){scanf("%lld",&A[i]);}
    long long int min=l_min(A);
    long long int ans;

    ans=(long long int)((N-1)/min)+5;

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


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c,i,j;
    int nm=0;
    cin>>a;
    int x[a],y[a];
    for(i=0;i<a;i++)
    cin>>x[i];
    for(i=0;i<a;i++)
    cin>>y[i];
    for(i=0;i<a;i++){
        if(x[i]-y[i]>0)
        nm = nm+x[i]-y[i];
    }
    cout<<nm<<endl;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N, M, Q; cin >> N >> M >> Q;
    vector<int> A(Q), B(Q), C(Q), D(Q);
    for(int i=0; i<Q; i++) {
        cin >> A[i] >> B[i] >> C[i] >> D[i];
        A[i]--, B[i]--;
    }

    queue< vector<int> > que;
    que.emplace(vector<int>(1, 0));
    for(int i=0; i<N; i++) {
        queue< vector<int> > n_que;
        while(que.size()) {
            vector<int> vec = que.front(); que.pop();
            int lb = (vec[0] == 0 ? 1 : vec.back());
            int ub = M;
            if(vec[0] == 0) vec.pop_back();
            for(int k=lb; k<=ub; k++) {
                vec.emplace_back(k);
                n_que.emplace(vec);
                vec.pop_back();
            }
        }
        swap(n_que, que);
    }
    fprintf(stderr, "# que.size() = %zu\n", que.size());

    int ans = 0;
    while(que.size()) {
        vector<int> vec = que.front(); que.pop();
        int sum = 0;
        for(int i=0; i<Q; i++) {
            if(vec[ B[i] ] - vec[ A[i] ] == C[i]) sum += D[i];
        }
        chmax(ans, sum);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 9776
N = int(input())
S = input()
min = N
clm_sum = [0]
for s in S:
    if s == '#':
        clm_sum.append(clm_sum[-1] + 1)
    else:
        clm_sum.append(clm_sum[-1])
for i in range(1,len(clm_sum)):
    if clm_sum[i-1] + ((N - i) - (clm_sum[-1] - clm_sum[i])) < min:
        min = clm_sum[i-1] + ((N - i) - (clm_sum[-1] - clm_sum[i]))
print(min)

Measured memory_bytes: 11136
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;

int main()
{
    int n, m, p;
    cin >> n;
    long long ans = 0, number;
    vector<long long> t;
    for(int i = 0; i < n; i++){
        long long temp;
        cin >> temp;
        t.push_back(temp);
        ans += temp;
    }
    cin >> m;
    for(int i = 0; i < m; i++){
        cin >> p >> number;
        cout << ans - (t[p-1] - number) << endl;
    }
    return 0;
}


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

typedef struct node_s node;

struct node_s{
  int key;
  node *prev;
  node *next;
};

node *head;

void insert(int x){
  node *t=malloc(sizeof(node));
  t->key=x;
  t->next=head->next;
  t->prev=head;
  head->next->prev=t;
  head->next=t;
}
void delete(node *n){
  if (n==NULL)return;
  n->prev->next=n->next;
  n->next->prev=n->prev;
  free(n);
}

node *find(int key){
  node *p;
  for (p=head->next;p->key!=-1;p=p->next){
    if (p->key==key){
      return p;
    }
  }
  return NULL;
}

int main(){
  int i,n,x;
  char cmd[16];
  node *tp;
    
  head = malloc(sizeof(node));
  head->key=-1;
  head->prev=head;
  head->next=head;
  
  scanf("%d",&n);

  for (i=0;i<n;i++){
    if(i<n)break;
  }

  for (i=0;i<n;i++){
    scanf("%s", &cmd);
    if (cmd[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }else if (cmd[0]=='d'&&cmd[6]=='\0'){
      scanf("%d",&x);
      delete(find(x));
    }else if (cmd[0]=='d'&&cmd[6]=='F'){
      delete(head->next);
    }else if (cmd[0]=='d'&&cmd[6]=='L'){
      delete(head->prev);
    }
  }
  for (tp=head->next;tp->next->key!=-1;tp=tp->next)
    printf("%d " ,tp->key);
  printf("%d\n" ,tp->key);
  
  return 0;
}



Measured memory_bytes: 33020
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
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(){
    string s;
    cin >> s;
    int cnt = 0;
    rep(i, s.length()){
        if(s.at(i) == 'D') cnt++;
        if(i != s.length()-1){
            if(s.at(i) == 'P' && s.at(i+1) == 'D') cnt++;
        }
        if(s.at(i) == '?') {
            if(i != 0){
                if(s.at(i-1) == 'P') {
                    cnt += 2;
                    s.at(i) = 'D';
                }
                else {
                    cnt++;
                    s.at(i) = 'D';
                }
            }
            else {
                cnt++;
                s.at(i) = 'D';
            }
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 3764
($%,@D)=<>;
$_=[glob]for@D;
for(2..2*(@s=(_,0,(-1e15)x$%))){
	$s[$$_[1]]+=$-=$s[$$_[0]]+$$_[2]-$s[$$_[1]]for@D;$_-$%or$s=$s[-2]
}
print$s<$s[-2]?inf:$s


Measured memory_bytes: 1664
fun main() {
    val n = readInt()
    val a = readIntList()

    val ans = Array(n) { 0 }
    for (i in 0 until n - 1) {
        ans[a[i] - 1]++
    }
    for (i in ans.indices) {
        println(ans[i])
    }

}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

Measured memory_bytes: 77032
<?php

class Answer
{
    public $data_stacked = array();
    public $data_arr;
    public $top;

    public function __construct()
    {
        $this->top = 0;
        $data = trim(fgets(STDIN));
        $this->data_arr = explode(' ', $data);
    }

    public function isEmpty()
    {
        return $this->top == 0;
    }

    public function isFull()
    {
        return $this->top > 10**6 - 1;
    }

    public function push($data)
    {
        if ($this->isFull()) {
            echo 'overflow';
        }

        $this->top++;
        $this->data_stacked[$this->top] = $data;
    }

    public function pop()
    {
        if ($this->isEmpty()) {
            echo 'underflow';
        }

        $this->top--;
        return $this->data_stacked[$this->top + 1];
    }
   
    public function getAnswer()
    {
        $data_arr = $this->data_arr;
        while (current($data_arr) != false) {
            if ($data_arr[key($data_arr)] == "+") {
                $tmp = $this->pop();
                $this->data_stacked[$this->top] = $this->data_stacked[$this->top] + $tmp;
            } elseif ($data_arr[key($data_arr)] == "-") {
                $tmp = $this->pop();
                $this->data_stacked[$this->top] = $this->data_stacked[$this->top] - $tmp;
            } elseif ($data_arr[key($data_arr)] == "*") {
                $tmp = $this->pop();
                $this->data_stacked[$this->top] = $this->data_stacked[$this->top] * $tmp;
            } else {
                $this->push($data_arr[key($data_arr)]);
            }

            next($data_arr);
        }
        echo $this->data_stacked[1] . "\n";
    }
}

$answer = new Answer();
$answer->getAnswer();



Measured memory_bytes: 9420
W, H, N = map(int, input().split())
x = 0
y = 0

for i in range(N):
    xi, yi, ai = map(int, input().split())
    if ai == 1 and xi > x:
        x = xi
    elif ai == 2 and xi < W:
        W = xi
    elif ai == 3 and yi > y:
        y = yi
    elif ai == 4 and yi < H:
        H = yi
if W <= x or H <= y:
    ans = 0
else:
    ans = (W-x)*(H-y)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
  
  

int main(){
    ll y,m,d;
    char x,v;
    cin>>y>>x>>m>>v>>d;
    
    if(m<=4)puts("Heisei");
    else puts("TBD");
        
}



Measured memory_bytes: 256
/*input
RRR
SSS
*/
/**
    Author: Kristopher Paul
    Date Created: 01-09-2019
    Contest Name:
                _/    _/   _/_/_/_/   _/   _/_/_/_/
               _/  _/     _/    _/   _/   _/
              _/_/       _/_/_/_/   _/   _/_/_/_/
             _/  _/     _/  _/     _/         _/
            _/    _/   _/    _/   _/   _/_/_/_/
**/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
#define mp make_pair
const double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define umap unordered_map
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define itr :: iterator it
#define all(v) v.begin(),v.end()
#define WL(t) while(t--)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define out(x) cout << #x << " is " << x << endl
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
//using namespace __gnu_pbds;

//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // set
//typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> pbds; // multiset

int ModExp(int x,int y,int m){
    int res = 1;
    x = x % m;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % m;

        y = y>>1;
        x = (x*x) % m;
    }
    return res;
}

void solve(){
    string s;
    cin >> s;
    string t;
    cin >> t;
    int ans = 0;
    FOR(i,0,s.length()){
        if(s[i] == t[i]){
            ans++;
        }
    }
    cout << ans << endl;
}

signed main(){
    FastIO;
    int t = 1;
//    cin >> t;
    WL(t){
        solve();
    }
}


Measured memory_bytes: 256
//  cd Desktop/Atcoder
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define rep(i,n) for(i=0;i<(n);i++)
#define ll long long
#define ull unsigned long long
#define MOD 1000000007

int compare_smallorder(const void *a, const void *b){return *(int*)a - *(int*)b;}

int main(){
    int k,min=0,max=0,n=0,l[2002]={},i,j,count=0,left,right;
    scanf("%d",&n);
    rep(i,n) scanf("%d",&l[i]);
    qsort(l,n,sizeof(l[0]),compare_smallorder);
    rep(i,n-2){
        for(j=i+1;j<n-1;j++){
            min=abs(l[i]-l[j]);max=l[i]+l[j];
            for(k=j+1;k<n;k++) if(min<l[k]) break;
            left=k;
            for(k=n-1;k>j;k--) if(max>l[k]) break;
            right=k;
            count+=right-left+1;
        }
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 1740
/*
    STARK_BOY
*/
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repe(i,a,b) for(ll i=a;i<=b;i++)
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef vector< ll > vi;
typedef vector<pair<ll,ll> > vpii;
typedef pair<ll,ll> pii;
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define setbitc(x) __builtin_popcount(x)
#define init(x,a) memset(x,a,sizeof(x))
#define PI           3.14159265358979323846  /* pi */
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
#define N 100005
//Variables Start
ll inf=1e18,MOD=1e9+7;
ll n,m,k,in[N],dp[N];
string s,s1;
vi adj[N];
//Variables End


ll compute(ll ver)
{
	if(dp[ver]!=-1)return dp[ver];
	ll ret=0;
	for(auto i:adj[ver])
	{
		ret=max(ret,1+compute(i));
	}
	return dp[ver]=ret;
}
int main()
{
    ios
    int ti=1;
    //cin>>ti;
    while(ti--)
    {
		cin>>n>>m;
		rep(i,0,m)
		{
			ll x,y;
			cin>>x>>y;
			adj[x].pb(y);
			in[y]++;
		}
		ll ans=0;
		vi pos;

		rep(i,1,n+1)
		{
			if(in[i]==0)pos.pb(i);
			dp[i]=-1;
		}

		for(auto i:pos)
		{
			ans=max(ans,compute(i));
		}

		cout<<ans<<endl;

    }
    return 0;
        
}

Measured memory_bytes: 12032
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int N, A;
    std::cin >> N >> A;

    if (N % 500 == 0 || N % 500 <= A) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No"  << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <array>
#include <vector>

using namespace std;

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

  int ans = 0;
  char state = 'J';
  int jc = 0, oc = 0, ic = 0;
  int token_count = 10000000;
  for ( const char ch : input + "J" ) {
	if ( state == ch ) {
	  if ( state == 'J' ) jc++;
	  if ( state == 'O' ) oc++;
	  if ( state == 'I' ) ic++;
	  // cerr << ch << "1111: " << ans << endl;
	} else {
	  if ( ( state == 'J' and ch == 'O' ) or
			 ( state == 'O' and ch == 'I' ) ){
		
		state = ch;
		if ( state == 'O' ) oc = 1;
		if ( state == 'I' ) ic = 1;
		// cerr << ch << "2222: " << ans << endl;
	  } else {
		if ( state == 'I' and oc <= ic and oc <= jc ) {
		  ans = max( ans, oc );
		}
		state = 'J';
		ic = oc = 0;
		jc = ( ch == 'J' ? 1 : 0 );
		// cerr << ch << "3333: " << ans << endl;
	  }
	}
  }
  cout << ans << endl;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;
constexpr int INF = 1000000000;

int main()
{
  int h,w;
  cin>>h>>w;
  vector<string> t(h);
  REP(i,h) cin>>t[i];
  vector<vecint> d(h, vecint(w, INF));
  queue<pair<int,int>> q;
  REP(i,h)REP(j,w) {
    if(t[i][j] == '#') {
      d[i][j] = 0;
      q.emplace(i,j);
    }
  }
  while (!q.empty()) {
    int i,j;
    tie(i,j) = q.front();
    q.pop();
    int di[] = {1, 0, -1, 0};
    int dj[] = {0, 1, 0, -1};
    REP(k,4) {
      int ni = i+di[k];
      int nj = j+dj[k];
      if(ni<0||ni>=h||nj<0||nj>=w) continue;
      if(d[ni][nj] > d[i][j]+1) {
        d[ni][nj] = d[i][j]+1;
        q.emplace(ni,nj);
      }
    }
  }
  int mx = 0;
  REP(i,h) mx=max(mx,*max_element(ALL(d[i])));
  cout << mx << endl;
  return 0;
}


Measured memory_bytes: 13456
#include <iostream>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void){
    ll n;
    cin >> n;
    
    for (ll i = 1; i <= 3500; i++) {
        for (ll j = 1; j <= 3500; j++) {
            ll low = 0, high = 3500;
            while (high - low > 1) {
                int k = (low + high) / 2;
                if (4 * i * j * k >= n * (i*j + j*k + k*i)) high = k;
                else low = k;
            }
            
            //cout << i << " " << j << " " << high << endl;
            if (4 * i * j * high == n * (i*j + j*high + high*i)) {
                cout << i << " " << j << " " << high << endl;
                return 0;
            }
        }
    }
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main(){
	int n;
  	cin>>n;
  	for(int i=0;i<n;i++)
    {
      	cin>>a[i];
    }
    int x=a[0];
    for(int i=1;i<n;i++)
    {
    	x=__gcd(x,a[i]);
	}
    cout<<x;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a, b, c;
    cin >> a >> b >> c;
    if (a.back() != b.front() || b.back() != c.front())
        cout << "NO";
    else
        cout << "YES";
}


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

int main()
{
    char b;
    cin >> b;
    switch (b)
    {
    case 'A':
        cout << "T" << endl;
        break;
    case 'T':
        cout << "A" << endl;
        break;
    case 'C':
        cout << "G" << endl;
        break;
    case 'G':
        cout << "C" << endl;
        break;
    default:
        break;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int main()
{
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  int n;
  lli ans=0;
  cin>>n;
  reps(i,1,n){
      ans+=(n-1)/i;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3648
if __name__ == '__main__':
    x, n = map(int, input().strip().split())
    p = input().strip()

    if not p == "":
        p = list(map(int, p.split()))
        p.sort()

        if x not in p:
            print(x)
        else:
            i = 0
            while True:
                if not x - i in p:
                    print(x-i)
                    break
                if not x + i in p:
                    print(x+i)
                    break
                i += 1

    else:
        print(x)


Measured memory_bytes: 9192
#include<bits/stdc++.h>
#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define inf         1e9+5
#define mp          make_pair
#define ll          long long
#define pii         pair<int,int >
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define mem(x,i)    memset(x,i,sizeof x)
#define PI          acos(-1.0)
#define ff          first
#define ss          second
#define all(x)      x.begin(),x.end()
#define Case(t)     for(int ks=1;ks<=t;ks++)
#define sf          scanf
#define pf          printf
/*------------------------------Graph Moves----------------------------*/
//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/
using namespace std;
//
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//
//template <typename T>  using orderedSet =
//    tree<T, null_type, less_equal<T>,
//    rb_tree_tag, tree_order_statistics_node_update>;//find_by_order,order_of_key
////

int main()
{
    int n;
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        if(i%3 && i%5) sum=sum+i;
        //cout<<sum<<endl;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3632
MOD = 10**9 + 7


def main():
    N, K = (int(i) for i in input().split())
    ans = 0
    for i in range(K, N+2):
        lower = (i-1)*i//2
        upper = N*(N+1)//2 - (N-i)*(N-i+1)//2
        ans += upper - lower + 1
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()


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

int main()
{
	int A[100002];
	long i,N,sum=0;
	scanf("%ld",&N);
	
	A[0] = 0;
	A[N+1] = 0;
	for(i=1;i<=N;i++)
	{
		scanf("%d",&A[i]);
		sum += abs(A[i-1]-A[i]);
	}
	sum += abs(A[N]-A[N+1]);
	
	for(i=1;i<=N;i++)
	{
		printf("%ld\n",sum-abs(A[i]-A[i-1])-abs(A[i]-A[i+1])+abs(A[i-1]-A[i+1]));
	}
	return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>

int main(void){
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  int x=c-a,y=d-b;
  printf("%d %d %d %d",c-y,d+x,a-y,b+x);
  return 0;
}

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

int main()
{
    int t;
    cin>>t;
   
    
    int l=0;
    
    long long s=0;
    
    for(int i=1;i<=t;i++)
    {
        for(int j=1;j<=t;j++)
        {
            for(int k=1;k<=t;k++)
            {
                s+=__gcd(i,__gcd(j,k));
            }
        }
    }
    cout<<s;
    
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int main(){
	LL n;
	cin>>n;
	LL ans=100000;
	REP(i,n){
	    ans*=1.05;
	    if(ans%1000!=0){
	       ans/=1000;
	       ans++;
	       ans*=1000;
	    }
	}
        cout<<ans<<endl;
	return(0);
}

Measured memory_bytes: 3064