akhauriyash/Code-Regression huggingface dataset:
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7

class Combination:
    def __init__(self, size, mod=10**9 + 7):
        self.size = size + 2
        self.mod = mod
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % self.mod
            self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % self.mod

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod

    def factN(self, n):
        if n < 0:
            return 0
        return self.fact[n]

comb = Combination(N + 100)

ans = 1
dis = 0
for num, a in enumerate(A, start=1):
    nowRobot = num - dis
    maxRobot = -(-a // 2)

    if maxRobot >= nowRobot:
        continue
    else:
        ans *= comb.npr(nowRobot, nowRobot - maxRobot)
        ans %= MOD
        dis += nowRobot - maxRobot

ans *= comb.factN(N - dis)
ans %= MOD

print(ans)

Measured memory_bytes: 20204
n, a, b = map(int, input().split())
total_val = 0
for i in range(1, n+1):
    i_str = str(i)
    digits = list(i_str)
    sum_digit = sum([int(digit) for digit in digits])
    if sum_digit >= a and sum_digit <= b:
        total_val += i
print(total_val)

Measured memory_bytes: 3060
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants
#define INF 1e9

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval<newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin


// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!
int fastest(const vi &a){
  int cum = 0;
  rep(i,a.size()){
    if(cum%10==0){
      cum += a[i];
    } else {
      cum += 10-(cum%10);
      cum += a[i];
    }
  }
  return cum;
}
// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin

  vi a(5);
  rep(i,5) cin >> a[i];
  int m = INF;
  perm(a){
    int cum = fastest(a);
    if(cum<m) m=cum;
  }
  cout << m << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

ll n;
vector<ll> ret;



void cul(vector<ll> &ret,const vector<ll> &A,const vector<ll> &B){
    for(int i=0;i<n;i++){ret[i]=B[A[i]];}
}

void rev(vector<ll> &ret,vector<ll> A){
    for(int i=0;i<n;i++){ret[A[i]]=i;}
}

void Out(vector<ll> ans){
    for(int i=0;i+1<n;i++){cout<<ans[i]+1<<" ";}
    cout<<ans.back()+1<<endl;
}

vector<ll> operator * (const vector<ll> &A,const vector<ll> &B){cul(ret,A,B); return ret;}

vector<ll> & operator *= (vector<ll> &A,const vector<ll> &B){cul(ret,A,B); return A=ret;}

vector<ll> & operator /= (vector<ll> &A,const vector<ll> &B){cul(ret,B,A); return A=ret;}


int main(){
    ll k;
    cin>>n>>k;
    vector<ll> P(n);
    vector<ll> Q(n);
    for(auto &I:P){cin>>I; I--;}
    for(auto &I:Q){cin>>I; I--;}
    
    ret.resize(n);
    vector<ll> PI(n);
    vector<ll> QI(n);
    rev(PI,P);
    rev(QI,Q);
    vector<ll> O=P*QI*PI*Q;
    vector<ll> A(n);
    for(int i=0;i<n;i++){A[i]=i;}
    
    if(k==1){
        Out(P);
        return 0;
    }
    else if(k==2){
        Out(Q);
        return 0;
    }
    else if(k==3){
        Out(PI*Q);
        return 0;
    }
    
    k-=3;
    ll Z=k/6;
    while(Z>0){
        if(Z&1){A*=O;}
        Z>>=1;
        O*=O;
    }
    
    if(k%6){A/=Q;}
    if(k%6>1){A/=PI;}
    if(k%6>3){A/=QI;}
    if(k%6==5){A/=P;}
    
    rev(O,A);
    
    if(k%3==1){
        QI=PI;
    }
    else if(k%3==2){
        QI=QI;
    }
    else{
        cul(QI,PI,Q);
    }
    if((k/3)&1){rev(QI,QI);}
    if(k%6==3){rev(QI,Q); QI=P*QI;}
    O*=QI;
    O*=A;
    Out(O);
    
    
    return 0;
}


Measured memory_bytes: 7028
#include<iostream>
using namespace std;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int A[101]={0};
    for(int i=a;i<=b;i++) A[i]++;

    for(int i=c;i<=d;i++) A[i]++;

    int ans=0;
    for(int i=0;i<=100;i++){
        if(A[i]==2) ans++;
    }
    if(ans==0) cout<<ans;
    else cout<<ans-1;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define MOD 1000000007
#define cmin(_a, _b) (_a > (_b) ? _a = (_b) : 0)
#define cmax(_a, _b) (_a < (_b) ? _a = (_b) : 0)
struct Intv{
	int l, r;
	inline bool operator <(const Intv &x) const {
		return l == x.l ? r < x.r : l < x.l;
	}
}itv[200007];
int c[200007], x[200007], vl[200007], id[200007], rev[200007], p[200007], ord[200007], en, n;
long long y9[200007];
void Modify(register int pos, register int val){
	//fprintf(stderr, "->%d %d\n", pos, val);
	for (; pos <= n + 1; pos += pos & -pos) (c[pos] += val) %= MOD;
	return ;
}
int Query(register int pos){
	register int val;
	for (val = 0; pos; pos ^= pos & -pos) (val += c[pos]) %= MOD;
	return val;
}
inline bool Cmpx(const int &u, const int &v){
	return x[u] < x[v];
}
inline bool Cmpy(const int &u, const int &v){
	return y9[u] < y9[v];
}
int main(){
	register int i, pos, sum;
	scanf("%d", &n);
	for (i = 1; i <= n; ++i) {
		scanf("%d %d", &x[i], &vl[i]);
		y9[i] = 2000000000ll * vl[i] + x[i];
		id[i] = ord[i] = i;
	}
	sort(id + 1, id + n + 1, Cmpx);
	sort(ord + 1, ord + n + 1, Cmpy);
	//for (i = 1; i <= n; ++i) fprintf(stderr, "%d%c", id[i], " \n"[i == n]);
	//for (i = 1; i <= n; ++i) fprintf(stderr, "%d%c", ord[i], " \n"[i == n]);
	for (i = 1; i <= n; ++i) rev[ord[i]] = i;
	for (i = 1; i <= n; ++i) p[i] = rev[id[i]];
	pos = 0;
	for (i = 1; i <= n; ++i) {
		cmax(pos, p[i]);
		itv[i].r = pos;
	}
	for (i = n; i; --i) {
		cmin(pos, p[i]);
		itv[i].l = pos;
	}
	sort(itv + 1, itv + n + 1);
	//for (i = 1; i <= n; ++i) fprintf(stderr, "%d %d\n", itv[i].l, itv[i].r);
	Modify(1, 1);
	for (i = 1; i <= n; ++i) {
		++itv[i].r;
		Modify(itv[i].r, (Query(itv[i].r) + MOD - Query(itv[i].l - 1)) % MOD);
	}
	printf("%d\n", (Query(n + 1) + MOD - Query(n)) % MOD);
	return 0;
}

Measured memory_bytes: 8704
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	private static final boolean TEST = false;

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		do {
			String s = in.next();
			System.out.println(solve(s));
		} while (TEST);
	}

	private static String solve(String s) {
		if (s.equals("Sunny"))
			return "Cloudy";
		else if (s.equals("Cloudy"))
			return "Rainy";
		else
			return "Sunny";
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 1000100
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{
  int r,c,k;
  cin>>r>>c>>k;
  vector<vector<int> > goods (r,vector<int>(c,0));
  for (int i = 0; i < k; i++)
  {
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    goods[a][b] = c;
  }
  vector<vector<vector<int> > > dp (r+1,vector<vector<int> >(c+1,vector<int>(4,-1*INF)));

    for (int j = 0; j <=c; j++)
    {
      dp[0][j][0] = 0;
    }


  for (int i = 1; i <= r; i++)
  {
    for (int j = 0; j <= c; j++)
    {
      dp[i][j][0] = max(max(dp[i-1][j][0],dp[i-1][j][1]),max(dp[i-1][j][2],dp[i-1][j][3]));
    }




      for (int j = 1; j <= c; j++)
      { 
      for (int l = 3; l >= 0; l--)
      {
        chmax(dp[i][j][l],dp[i][j-1][l]);
        if(l == 0)continue;
        chmax(dp[i][j][l],dp[i][j-1][l-1] + goods[i-1][j-1]);
        if(l == 1) chmax(dp[i][j][l],dp[i][j][l-1] + goods[i-1][j-1]);
      }
      
    }
  }

  // DEBUG(dp[2]);

  cout<< max(max(dp[r][c][0],dp[r][c][1]),max(dp[r][c][2],dp[r][c][3]))<<endl;

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 707272
n=int(input())
a=[0] + list(map(int,input().split())) + [0]
dif = [abs(x-y) for x,y in zip(a,a[1:])]
total = sum(dif)
for i in range(1,n+1):
    ans = total - dif[i-1] - dif[i] + abs(a[i-1]-a[i+1])
    print(ans)

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

int main(){
    long long N;
    cin >> N;
    for(long double i = 1;i<3501;i++){
        for(long double j = 1;j<3501;j++){
            if(4 * i * j - N * i - N * j == 0) continue;
            long double k = N * i * j / (4 * i * j - N * i - N * j);
            if(k > 0 && k == ceil(k)){
                cout << setprecision(20) << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int n, m, q;
vi a, b, c, d;
int ans;

void calc(vi A) {
    int tmp = 0;
    rep(i, q) if(A[b[i]] - A[a[i]] == c[i]) tmp += d[i];
    ans = max(ans, tmp);
    return;
}

void dfs(vi A) {
    if(A.size() == n) {
        calc(A);
        return;
    }

    int last = (A.empty() ? 1 : A.back());
    for(int add = last; add <= m; add++) {
        A.push_back(add);
        dfs(A);
        A.pop_back();
    }
}

int main()
{
    cin >> n >> m >> q;
    a = b = c = d = vi(q);
    rep(i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }
    
    vi A;
    dfs(A);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <tuple>
#include <algorithm>

int main() {
  int X, Y, Z, K;
  std::cin >> X >> Y >> Z >> K;

  std::vector<long long> A(X);
  std::vector<long long> B(Y);
  std::vector<long long> C(Z);

  for (int i=0; i<X; i++) std::cin >> A[i];
  for (int i=0; i<Y; i++) std::cin >> B[i];
  for (int i=0; i<Z; i++) std::cin >> C[i];

  std::sort(A.begin(), A.end(), std::greater<long long>());
  std::sort(B.begin(), B.end(), std::greater<long long>());
  std::sort(C.begin(), C.end(), std::greater<long long>());

  std::priority_queue<std::tuple<long long, int, int, int>> que;

  que.emplace(A[0]+B[0]+C[0], 0, 0, 0);

  std::set<std::tuple<int, int, int>> log;

  for (int n=0; n<K; n++) {
    long long ans, i, j, k;
    std::tie(ans, i, j, k) = que.top();
    que.pop();

    std::cout << ans << '\n';

    if (i+1 < X && log.count(std::make_tuple(i+1, j, k)) == 0) {
      que.emplace(A[i+1]+B[j]+C[k], i+1, j, k);
      log.emplace(i+1, j, k);
    }
    if (j+1 < Y && log.count(std::make_tuple(i, j+1, k)) == 0) {
      que.emplace(A[i]+B[j+1]+C[k], i, j+1, k);
      log.emplace(i, j+1, k);
    }
    if (k+1 < Z && log.count(std::make_tuple(i, j, k+1)) == 0) {
      que.emplace(A[i]+B[j]+C[k+1], i, j, k+1);
      log.emplace(i, j, k+1);
    }
  }

  return 0;
}


Measured memory_bytes: 896
n = input()
n = int(n)

Taro = []
Hanako = []

for a in range(n):
    x,y = input().split()
    Taro.append(x)
    Hanako.append(y)

point_Taro = 0
point_Hanako = 0

for a,b in zip(Taro,Hanako):
    if a<b:
        point_Hanako += 3
    elif a>b:
        point_Taro += 3
    else:
        point_Hanako += 1
        point_Taro += 1
print('{} {}'.format(point_Taro,point_Hanako))



Measured memory_bytes: 5624
// E - Second Sum

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int P[100000];
int pos[100001];

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

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

	ll ans = 0;
	multiset<int> pos_set;

	pos_set.insert(-1);
	pos_set.insert(-1);
	pos_set.insert(N);
	pos_set.insert(N);

	for (int i=N; i>=1; i--) {
		int k = pos[i];
		pos_set.insert(k);
		auto itr = pos_set.lower_bound(k);

		auto itr_l = itr;
		itr_l--;
		ll l1 = *itr_l;
		itr_l--;
		ll l2 = *itr_l;

		auto itr_r = itr;
		itr_r++;
		ll r1 = *itr_r;
		itr_r++;
		ll r2 = *itr_r;

		//cout << "X=" << i << " " << l2 << " " << l1 << " " << k << " " << r1 << " " << r2 << endl; // **** debug ****

		ans += i * ((l1 - l2) * (r1 - k) + (r2 - r1) * (k - l1));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5760
#include <stdio.h>
#include <string.h>

int main() {
  char str[255];
  scanf("%[^\n]", str);
  int count = 0;

  for(int i = 0; str[i] != '\0'; i++) {
    if(str[i] == ' ' && str[i+1] == str[i-1]) {
      count++;
    }
  }

  (count == 2) ? puts("YES") : puts("NO");
  return 0;
}



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

#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed(x) fixed<<setprecision(x)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
const lol Mod=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k,r;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>n>>k;
  vector<int> a(n+3);
  int ans[n+3];
  memset(ans,-1,sizeof(ans));
  for(int i=1;i<=n;i++){
    cin >>a[i];
  }
  ans[1]=0;
  int now=1;
  n=0;
  while(k){
    k--;
    n++;
    if(ans[a[now]]!=-1){
      k%=n-ans[a[now]];
    }
    if(now==a[now]){
      cout <<now<<'\n';
      return 0;
    }
    ans[a[now]]=n;
    now=a[now];
  }
  cout <<now<<'\n';
  return (0);
}


Measured memory_bytes: 4748
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		
		// 計算
		String result = "Yes";
		HashMap<Character, Integer> hm = new HashMap<Character, Integer>();
		for(int i = 0; i < s.length(); i++){
		    hm.put(s.charAt(i), hm.getOrDefault(s.charAt(i), 0) + 1);
		}
		for(Integer i : hm.values()){
		    if(i != 2) result = "No";
		}

		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 21844
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[]
cnt=0
sum=0

for i in range(n):
  a.append(list(map(int,input().split())))

for i in range(n):
  for j in range(m):
    sum+=a[i][j]*b[j]
  if sum+c>0:
    cnt+=1
  sum=0
print(cnt)

Measured memory_bytes: 3064
import math

a,b,x=map(int,input().split())

if (a*a*b)/2>=x:
  print(math.degrees(math.atan((a*b*b)/(2*x))))
  
else:
  print(math.degrees(math.atan((2*a*a*b-x-x)/(a*a*a))))


Measured memory_bytes: 61964
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S; cin >> S;
  int64_t K; cin >> K;
  int check=100;
  for(int i=0;i<S.size();i++){
    if(S.at(i)!='1'){
      check=i;
      break;
    }
  }
  if(check==100){
    cout << 1 << endl;
    return 0;
  }
  if(K<check+1){
    cout << 1 << endl;
    return 0;
  }
  cout << S.at(check) << endl;
}
  

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n,m,l,i,j,k,a[100][100],b[100][100];
	long long int c[100][100];
	scanf("%d %d %d",&n,&m,&l);
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	for(i=0;i<m;i++)
	{
		for(j=0;j<l;j++)
		{
			scanf("%d",&b[i][j]);
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<l;j++)
		{
			c[i][j]=0;
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<m;j++)
		{
			for(k=0;k<l;k++)
			{
				c[i][k] += a[i][j]*b[j][k];
			}
		}
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<l;j++)
		{
			printf("%lld",c[i][j]);
			if(j<l-1)
			{
				printf(" ");
			}
		}
	printf("\n");
	}
	return 0;
}

Measured memory_bytes: 756
from collections import Counter
import itertools as it

N=int(input())
l=[]
for i in range(N):
    l.append(tuple(map(int,input().split())))
l.sort()

if N==1:
    ans=1
else:
    d=[(c[1][0]-c[0][0],c[1][1]-c[0][1]) for c in it.combinations(l,2)]
    ans=N-max(dict(Counter(d)).values())

print(ans)

Measured memory_bytes: 39920
N=int(input())
*A,=map(int,input().split())
d={}
for a in A:
    d[a] = d.get(a, 0)+1
s=sorted([(k,v) for k,v in d.items() if 2<=v], reverse=True)

if len(s)<2:
    print(0)
else:
    if 4<=s[0][1]:
        print(s[0][0]**2)
    else:
        print(s[0][0]*s[1][0])

Measured memory_bytes: 21972
#include<cstdio>
#include<cstring>
int f[14],a,b;
int main()
{
	scanf("%d%d",&a,&b);
	f[1]=13;
	for(int i=2;i<=13;++i)
	f[i]=i-1;
	if(f[a]>f[b]) printf("Alice");
	if(f[a]==f[b]) printf("Draw");
	if(f[a]<f[b]) printf("Bob");
	return 0;
}

Measured memory_bytes: 128
// AOJ 1302 Twenty Questions
// 2018.2.6 bal4u
 
#include <stdio.h>
#include <string.h>

int m, n;
int s[129];
char memo[20148][2048];

//#define getchar_unlocked()  getchar()
int in()
{
    int n = 0;
    int c = getchar_unlocked();
    do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
    while (c >= '0');
    return n;
}
 
int calc(int k, int yes)
{
	int i, f, x, t, t2, ans;

	if (memo[k][yes] >= 0) return memo[k][yes];
   
	f = 0;
	for (i = 0; i < n; i++) if ((s[i] & k) == yes) f++;
	if (f <= 1) return memo[k][yes] = 0;

    ans = m;
	for (i = 0; i < m; i++) {
		if ((x = k|(1<<i)) == k) continue;
		t = calc(x, yes|(1<<i)), t2 = calc(x, yes);
		if (t < t2) t = t2;
		if (ans > t+1) ans = t+1;
    }
    return memo[k][yes] = ans;
}

int main()
{
	int i, t;
	char buf[15], *p;

	while (m = in()) {
		n = in();
		for (i = 0; i < n; i++) {
			fgets(p=buf, 15, stdin);
			t = 0; while (*p > ' ') t = (t<<1) + (*p++ & 1);
			s[i] = t;
		}

		memset(memo, -1, sizeof(memo));
		printf("%d\n", calc(0, 0));
	}
	return (0);
}


Measured memory_bytes: 42040
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int h,w;
  cin>>h>>w;
  vector<string> st(h);
  for(Int i=0;i<h;i++) cin>>st[i];
  
  using P = pair<Int, Int>;
  vector<vector<P> > G(26);
  for(Int i=0;i<h;i++){
    for(Int j=0;j<w;j++){
      if(st[i][j]=='.') continue;
      G[st[i][j]-'A'].emplace_back(i,j);
    }
  }
  
  Int ans=0;
  for(Int t=0;t<26;t++){
    for(Int i=0;i<26;i++){
      if(G[i].empty()) continue;
      Int a,b,c,d;
      tie(a,b)=G[i][0];
      tie(c,d)=G[i][1];
      if(st[a][b]=='.') continue;

      assert(a<=c);
      if(a==c){
        assert(b<d);
        if(b+1==d) continue;
        Int flg=1;
        for(Int k=b+1;k<d;k++)
          flg&=st[a][k]=='.';
        if(!flg) continue;
        ans++;
        st[a][b]=st[c][d]='.';
        continue;
      }
      
      if(b==d){
        assert(a!=c);
        if(a+1==c) continue;
        Int flg=1;
        for(Int k=a+1;k<c;k++)
          flg&=st[k][b]=='.';
        if(!flg) continue;
        ans++;
        st[a][b]=st[c][d]='.';
        continue;
      }
      
      if(b<d){
        {
          Int flg=1;
          for(Int k=b+1;k<=d;k++)
            flg&=st[a][k]=='.';
          for(Int k=a;k<c;k++)
            flg&=st[k][d]=='.';
          
          if(flg){
            ans++;
            st[a][b]=st[c][d]='.';
            continue;
          }
        }
        
        {
          Int flg=1;
          for(Int k=a+1;k<=c;k++)
            flg&=st[k][b]=='.';
          for(Int k=b;k<d;k++)
            flg&=st[c][k]=='.';
          
          if(flg){
            ans++;
            st[a][b]=st[c][d]='.';
            continue;
          }
        }        
      }else{

        {
          Int flg=1;
          for(Int k=d;k<b;k++)
            flg&=st[a][k]=='.';
          for(Int k=a;k<c;k++)
            flg&=st[k][d]=='.';
          
          if(flg){
            ans++;
            st[a][b]=st[c][d]='.';
            continue;
          }
        }
        
        {
          Int flg=1;
          for(Int k=a+1;k<=c;k++)
            flg&=st[k][b]=='.';
          for(Int k=d+1;k<=b;k++)
            flg&=st[c][k]=='.';
          
          if(flg){
            ans++;
            st[a][b]=st[c][d]='.';
            continue;
          }
        }        
      }
    }
  }
  
  ans*=2;
  cout<<ans<<endl;
  return 0;
}



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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

    ll a,b,x;
    cin>>a>>b>>x;
    ll ans=0;
    ans=b/x-a/x;
    if(a%x==0)ans++;

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
x,y,z=map(int,input().split())
def lcd(a,b):
    if b==0: return 1
    else: return lcd(a%b,a)
def gcm(a,b):
    return a//lcd(a,b)*b
m=gcm(x,y)//x
ans=False
for i in range(m):
    if i*x % y==z:
        ans=True
        break
    else:continue
print(["NO","YES"][ans])

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

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

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

	ll R;
	cin >> R;

	cout << (double)R * 2 * 3.14159265358979323846264338327950288 << endl;
}


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


int main(){
    int n, k, num = 1;
    cin >> n >> k;

    while(n--){
        if(num < k) num *= 2;
        else num += k;
    }
    cout << num << endl;
}


Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
 
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}
int d(int n)
{
    int count=0;
    while(n)
    {
        n=n/10;
        count++;
    }
    return count;
}
int32_t main()
{
    IOS
    
    
    
    int n;
    cin>>n;
    int ans=0;

    for(int i=1;i<=n;++i)
    {
        int x=d(i);
        if(x%2!=0)
            ans++;
    }
    cout<<ans;
}



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

int main(){
    int n;
    cin >> n;
    vector<int> b(n-1);
    rp(i,n-1) cin >> b.at(i);
    int ans=b[0]+b[n-2];
    rp(i,n-2) ans+=min(b[i],b[i+1]);
    cout << ans <<endl;
}

Measured memory_bytes: 256
--{-# LANGUAGE OverloadedStrings #-}
--{-# LANGUAGE OverloadedLists   #-}
{-# LANGUAGE BangPatterns      #-} --引数に!
{-# LANGUAGE MultiWayIf        #-}
{-# LANGUAGE TupleSections     #-}

import Data.Bits
import Data.Foldable (foldlM,foldrM)
import Data.Maybe (fromJust)
import Data.List
--import Data.Matrix.Unboxed
import Data.Array  --変数衝突
import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.ST
import Data.Graph
--import Data.Vector as V　--変数衝突
import qualified Data.Vector.Unboxed as V
import Control.Monad
import Control.Monad.State
import Control.Monad.ST
import qualified Data.ByteString.Lazy.Char8 as B
--import Debug.Trace

type Ans = Int
type DP s = STUArray s Int Int

modifyArray :: (MArray a e m ,Ix i) => a i e -> i -> (e -> e) -> m ()
modifyArray arr i f =  readArray arr i >>= writeArray arr i . f

dp_i :: DP s -> Int -> Int -> [Int] -> ST s ()
dp_i dparr n i [] | i >= n = return ()
                  | otherwise = do
                    v <- readArray dparr i
                    modifyArray dparr (i+1) (\x -> mod' $ x+v)
                    modifyArray dparr (i+2) (\x -> mod' $ x+v)
                    dp_i dparr n (i+1) []
dp_i dparr n i (a:as) = do
  if (i == a) then dp_i dparr n (i+1) as
    else do
      v <- readArray dparr i
      modifyArray dparr (i+1) (\x -> mod' $ x+v)
      modifyArray dparr (i+2) (\x -> mod' $ x+v)
      dp_i dparr n (i+1) (a:as)

solve :: Int -> Int -> [Int] -> ST s Ans
solve n m as = do
  dparr <- newArray (0,n+1) 0
  writeArray dparr 0 1
  dp_i dparr n 0 as
  readArray dparr n

main :: IO ()
main = do
  [n,m] <- map read.words <$> getLine
  as <- replicateM m $ readLn

  print $ mod' $ runST $ solve n m as

mod' :: Int -> Int
mod' n = if n < 1000000007 then n else mod n 1000000007


Measured memory_bytes: 32636
# coding=utf-8


def list_swap(given_list: list, swap_number1: int, swap_number2: int)-> list:
    return_list = given_list[:]
    memo = given_list[swap_number1 - 1]
    return_list[swap_number2 - 1] = memo
    memo = given_list[swap_number2 - 1]
    return_list[swap_number1 - 1] = memo
    return return_list


if __name__ == '__main__':
    w = int(input())
    amida_number = [i for i in range(1, w+1)]
    n = int(input())
    for j in range(n):
        a, b = map(int, input().split(','))
        amida_number = list_swap(amida_number[:], a, b)
    [print(amida_number[k]) for k in range(w)]

Measured memory_bytes: 5600
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
 
using namespace std;
 
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
 
const int INF=1<<29;
const double EPS=1e-9;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
bool flag[55];
// bool bad[55][55];
int booat[55][55];
int n,k;
void show(){
	for(int i =0;i < 50;i++){
		for(int j = 0;j < 50;j++){
			cout<<booat[i][j]<<endl;
		}
	}
}
bool check(int x,int y){
	for(int i =1;i <= k;i++){
		if(booat[i][x]&&booat[i][y]){
			return true;
		}
	}
	return false;
}


int main(){
	for(int i =0;i < 55;i++){
		flag[i] =false;
		for(int j =0;j < 55;j++){
			booat[i][j] =0;
			// bad[i][j] =false;
		}
	}
	cin>>n>>k;
	// vector<int> boat[55];
	for(int i =1;i <= k;i++){
		int m;
		cin>>m;
		for(int j =0;j < m;j++){
			int y;
			cin>>y;
			booat[i][y] =1;
			// cout <<booat[i][y]<<endl;
			// cout <<"hoge"<<endl;
		}
	}
	// show();
	int r;
	cin>>r;
	for(int i =0;i < r;i++){
		int x,y;
		cin>>x>>y;
		// cout <<"hoge"<<endl;
		if((!flag[x]||!flag[y])&&check(x,y)){
			flag[x]=true;
			flag[y] =true;
			// cout <<"hoge"<<endl;
		}
	}
	int sum = 0;
	for(int i =1;i <= n;i++){
		if(flag[i]){
			sum++;
		}
	}
	cout <<sum<<endl;
	return 0;
}

Measured memory_bytes: 1176
import math

N = int(input())

def soinsuu(N):
    d = 2
    divs = set()
    while d*d <= N:
        if N%d == 0:
            divs.add(d)
            while N%d == 0: N //= d
        d += 1
    if N != 1:
        divs.add(N)
    return divs

divs = list(soinsuu(N))

L = len(divs)
ans = 0
for bit in range(1<<L):
    tmp = 1
    cnt = 0
    for b in range(L):
        if bit & (1<<b):
            tmp *= divs[b]
            cnt += 1

    if cnt%2 == 1:
        ans -= N//tmp
    else:
        ans += N//tmp

print(ans)



Measured memory_bytes: 5660
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    def dfs(v):
        for u in edge[v]:
            if visited[u]:
                continue
            else:
                visited[u] = True
                dfs(u)

    n, m = map(int, input().split())
    edge = [[] for _ in range(n + m)]
    for i in range(n):
        _, *L = map(int, input().split())
        for l in L:
            edge[i].append(n + l - 1)
            edge[n + l - 1].append(i)

    visited = [False] * (n + m)
    dfs(0)
    for i in range(n):
        if not visited[i]:
            print("NO")
            break
    else:
        print("YES")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 39624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

constexpr int MAX = 5001;
vector<VI> g;
VI x;
bool solve(int now, int& b) {
    int m = g[now].size();
    if (m == 0) {
        b = 0;
        return true;
    }
    vector<bitset<MAX>> dp(m + 1);
    dp[0][0] = true;
    int a = x[now], sum = 0;
    FOR(i, 0, m) {
        int s = x[g[now][i]], t;
        if (!solve(g[now][i], t))return false;
        sum += s + t;
        FOR(j, 0, MAX) {
            if (!dp[i][j])continue;
            if (j + s < MAX)dp[i + 1][j + s] = true;
            if (j + t < MAX)dp[i + 1][j + t] = true;
        }
    }
    rFOR(j, 0, min(MAX, a + 1))if (dp[m][j]) {
        b = sum - j;
        return true;
    }
    return false;
}

int main() {
    init();

    int n; cin >> n;
    g.resize(n);
    FOR(i, 1, n) {
        int p; cin >> p;
        g[p - 1].push_back(i);
    }
    x.resize(n); cin >> x;

    int ate = INF;
    cout << (solve(0, ate) ? "POSSIBLE" : "IMPOSSIBLE") << "\n";
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>n>>a;
  cout<<(n*a)/(__gcd(n,a));
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
   //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3664
fun main() {
    var (th, ta, ah, aa) = readLine()!!.split(" ").map { it.toInt() }
    var idx = 0

    while (th > 0 && ah > 0) {
        if(idx == 0) {
            ah -= ta
            if(ah <= 0) {
                print("Yes")
                return
            }
        } else {
            th -= aa
            if(th <= 0) {
                print("No")
                return
            }
        }
        idx = (idx + 1) % 2
    }




}

Measured memory_bytes: 36324
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>
#include <time.h>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

const double PI = 3.14159265358979;
/******変数定義start******/
ll n;
vector<string> s;
/*******変数定義end*******/

ll solve(){
    cin >> n;
    s.resize(n);
    REP(i, n){
        cin >> s[i];
    }
    vl ae;
    vl bs;
    vl abtwo;
    ll ans = 0;
    REP(i, n){
        if(s[i].substr(0, 1) == "B"){
            bs.push_back(i);
        }
        if(s[i].substr(s[i].size()-1, 1) == "A"){
            ae.push_back(i);
        }
        if(s[i].substr(0, 1) == "B" && s[i].substr(s[i].size()-1, 1) == "A"){
            abtwo.push_back(i);
        }
        REP(j, s[i].size()-1){
            if(s[i].substr(j, 1) == "A" && s[i].substr(j+1,1) == "B"){
                ans++;
            }
        }
    }
    
    if(abtwo.size() != 0 && ae.size() == abtwo.size() && bs.size() == abtwo.size()){
        ans += min(bs.size(), ae.size())-1;
    }else{
        ans += min(bs.size(), ae.size());
    }
    cout  << ans << endl;
    return 0;
}
int main(){

    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */
    return end;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	int h, w; cin >> h >> w;
	vector<string> C(h);
	rep(i, h) cin >> C[i];
	rep(i, h) {
		cout << C[i] << endl;
		cout << C[i] << endl;
	}
}


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

#define int long long
#define rep(i, n) for (int i = 0; (int) (i) < n; i++)
#define reps(i, n) for (int i = 1; (int) (i) <= n; i++)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << x << endl
typedef vector<int> vint;
typedef pair<int, int> pint;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
inline int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> inline bool chmax(T1 &a, const T2 &b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, const T2 &b) { return b < a && (a = b, true); }
struct SetUp { SetUp() { cout << fixed << setprecision(20); }; } setUp;

int N;
pint Ai[110000];
signed main() {
    cin >> N;
    reps(i, N) {
        int A;
        cin >> A;
        Ai[i] = {A, i};
    }
    sort(Ai + 1, Ai + N + 1);
    reps(i, N) { cout << Ai[i].second << endl; }
}

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

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long

//typedef
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

int main() {
	int h, w;
	cin >> h >> w;
	int resh, resw;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			string s;
			cin >> s;
			if (s == "snuke") {
				resh = i;
				resw = j;
			}
		}
	}
	cout << char('A' + resw) << resh+1 << endl;
	return 0;
}



Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
map<string,int>mp;
int main(){
	string a;
	int n,ans=0;
	cin >> n;
	getchar();
	while( n -- ){
		getline( cin, a );
		if( !mp[a] ) mp[a] = 1, ans++;
	}
	printf("%d\n",ans);
	return 0;
}

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

int n,m;
vector<int> g[100005];
int fa[100005];

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    queue<int> q;
    fa[1]=1;
    q.push(1);
    while(!q.empty()){
        int x=q.front();
        q.pop();
        for(int &y:g[x]){
            if(!fa[y]){
                fa[y]=x;
                q.push(y);
            }
        }
    }
    for(int i=2;i<=n;i++){
        if(!fa[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    for(int i=2;i<=n;i++){
        cout<<fa[i]<<endl;
    }

    return 0;
}

Measured memory_bytes: 10528
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <tuple>
#include <cassert>
#include <memory>
using namespace std;
typedef long long ll;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

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

    set<int> used;
    for (int i = 0; i < K; i++) {
        int d; cin >> d;
        for (int j = 0; j < d; j++) {
            int A;
            cin >> A;
            used.insert(A);
        }
    }

    cout << N - used.size() << endl;

    return 0;
}


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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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;
}
///////////////////////////////////////////////
/*(._.)*/
const long long INF = 9223372036854775000;
const int VMAX = 3000;
const int EMAX = 5000;

struct Edge{
	int from;
	int to;
	int cost;
};

int main() { // 1 --> N minimum cost
	ll N,M,P; cin >> N >> M >> P;
	struct Edge e[EMAX];
	long long d[VMAX];
	bool negcycle[VMAX] = {};

	REP(i,M){
		ll a,b,c;
		cin >> a >> b >> c;
		e[i].from = b;
		e[i].to = a; //reverse
		e[i].cost = -c+P; // -1
	}

	REP(i,VMAX){
		d[i] = INF;
	}

	d[N] = 0;

	REP(i,N-1){ // loop V times --> NEGCYCLE

		bool update = false;
		REP(j,M){
			int u = e[j].from;
			int v = e[j].to;
			int c = e[j].cost;

			if ((d[u] + c < d[v]) and (d[u] != INF)) { //s-->uへ現状行けないときを弾く
				d[v] = d[u] + c;
				update = true;
			}
		}
	}

	ll ans = d[1];

	REP(i,N){
		REP(j,M){
			int u = e[j].from;
			int v = e[j].to;
			int c = e[j].cost;

			if (d[u] == INF) continue;

			if (d[v] > d[u] + c){
				d[v] = d[u] + c;
				negcycle[v] = true;
			}

			if (negcycle[u] == true){
				negcycle[v] = true;
			}
		}
	}


	if (negcycle[1]) {
		printf("-1");
		return 0;
	}

	cout << max(0LL,-ans) << endl;


	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int m1= scan.nextInt();
        int d1= scan.nextInt();
        int m2= scan.nextInt();
        int d2= scan.nextInt();
        if(m1!=m2&&d2==1)System.out.println("1");
        else System.out.println("0");
        scan.close();
    }
}

Measured memory_bytes: 22996
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define maxn 100009
using namespace std;

ll dp1[10009];
ll dp2[10006];
char s[25];

int num[105];

int main()
{
    int n,m,x,y;
    while(scanf("%d",&n)!=EOF)
    {
        if(n==0)break;
        for(int i=0; i<n; i++)
            scanf("%d",&num[i]);
        sort(num,num+n);
        memset(dp1,0,sizeof dp1);
        memset(dp2,0,sizeof dp2);
        scanf("%d",&m);
        bool flag=0;
        for(int i=0; i<m; i++)
        {
            scanf("%s",s);
            scanf("%d",&x);
            scanf("%s",s);
            scanf("%d",&y);
            if(x==0&&y>0)flag=1;
//        printf("%d %d\n",x,y);
            if(s[0]=='S')
            {
                for(int j=x; j<=10000; j++)
                    dp1[j]=max(dp1[j],dp1[j-x]+y);//single
            }
            else
            {
                for(int j=x; j<=10000; j++)
                    dp2[j]=max(dp2[j],dp2[j-x]+y);//all
            }
        }
        if(flag)
        {
            puts("0");
            continue;
        }
        ll ans=1ll<<60,sum;
        for(int i=0; i<ans; i++)
        {
//            sum=lower_bound(dp2,dp2+10000,num[i])-dp2;
//            ll tmp=sum;
            sum=i;
//        printf("%d\n",tmp);
            for(int j=0; j<n; j++)
            {
                sum+=lower_bound(dp1,dp1+10000,num[j]-dp2[i])-dp1;
            }
            ans=min(ans,sum);
        }
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1220