akhauriyash/Code-Regression huggingface dataset:
#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>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    while(1){
        int n; cin>>n;
        if(n == 0) return 0;
        vector<int> a(n);
        for(int i=0; i<n; i++) cin>>a[i];
        sort(a.begin(), a.end());

        int ans=1e9;
        for(int i=0; i<n-1; i++){
            chmin(ans, a[i+1] - a[i]);
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  const long mod=1000000007;
  long int N,M;
  cin>>N>>M;
  vector <long int> den (M);
  vector <long int> vec (N+1,true);
  for (long int i=0;i<M;i++){
    cin>>den.at(i);
    vec.at(den.at(i))=false;
  }
  
  vec.at(0)=1;
  if(vec.at(1))
    vec.at(1)=1;
  
  long ans;
  if (N==1)
    ans=vec.at(N);
  
  else{
     for(long int i=0;i<N-1;i++){
       if(vec.at(i+2)==false)
         vec.at(i+2)=0;
       
       else
         vec.at(i+2)=vec.at(i+1)+vec.at(i);
       vec.at(i + 2) %= mod;
       
       ans=vec.at(i+2)%mod;
     }
  }
    
  cout<<ans<<endl;
}
    
  
  
    
  
  


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    bool a = false;
    if (s[0] == 'A') {
        a = true;
    }

    bool b = false;
    bool isf = true;
    int ind = 0;
    for (int i = 2; i <= s.size() - 2; i++) {
        if (s[i] == 'C') {
            if (isf) {
                b = true;
                isf = false;
                ind = i;
            } else {
                b = false;
                break;
            }
        }
    }

    bool c = true;
    for (int i = 0; i < s.size(); i++) {
        if (!(i == 0 || i == ind)) {
            if ('A' <= s[i] && s[i] <= 'Z') {
                c = false;
                break;
            }
        }
    }

    if (a && b && c) {
        cout << "AC\n";
    } else {
        cout << "WA\n";
    }

    return 0;
}


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

ll dp[2100][2100];
ll b[2100];
int a;

ll calc(int l, int r, int s)
{
    // すでに記録されている場合
    if (dp[l][r] != -1)
        return dp[l][r];
    if (l == r)
    {
        if (s)
            return dp[l][r] = 0;
        return dp[l][r] = b[l];
    }

    // 相手のターン
    if (s)
    {
        if (b[l] > b[r])
        {
            return dp[l][r] = calc((l + 1) % a, r, 0);
        }
        else
        {
            return dp[l][r] = calc(l, (r + a - 1) % a, 0);
        }
    }

    // 自分のターン
    return dp[l][r] = max(calc((l + 1) % a, r, 1) + b[l], calc(l, (r + a - 1) % a, 1) + b[r]);
}

int main()
{
    cin >> a;

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

    // dpの初期化
    for (int i = 0; i < 2100; i++)
    {
        for (int j = 0; j < 2100; j++)
        {
            dp[i][j] = -1;
        }
    }

    ll ret = -1;
    for (int i = 0; i < a; i++)
    {
        ret = max(ret, calc((i + 1) % a, (i + a - 1) % a, 1) + b[i]);
    }

    cout << ret << endl;
    return 0;
}


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


int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        int a;
        scanf("%d", &a);
        mp[a]++;
    }

    int even = 0;
    for (auto&& i : mp) {
        even += ~(i.second & 1);
    }
    
    cout << mp.size() - (even & 1) << endl;

    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	int N, M;
	cin >> N >> M;
	vector<pair<int, int>> v(M);
	for(int i = 0; i < M; i++) cin >> v[i].second >> v[i].first;
	sort(v.begin(), v.end());

	int ans = 1, cut = v[0].first;
	for(int i = 1; i < M; i++) {
		if(cut <= v[i].second) {
			ans++;
			cut = v[i].first;
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 4036
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    int N;
    List<Tuple<int, int>>[] es;

    long ans;

    void calc()
    {
        cin = new Scanner();
        N = cin.nextInt();
        es = new List<Tuple<int, int>>[N];
        for (int i = 0; i < N; i++)
        {
            es[i] = new List<Tuple<int, int>>();
        }
        for (int i = 0; i < N - 1; i++)
        {
            int A = cin.nextInt() - 1;
            int B = cin.nextInt() - 1;
            int C = cin.nextInt();
            es[A].Add(Tuple.Create(B, C));
            es[B].Add(Tuple.Create(A, C));
        }
        int start = 0;
        for (int i = 0; i < N; i++)
        {
            if (es[i].Count <= 1) start = i;
        }
        dec = 999999999;
        num = new int[N];
        center = -1;
        maxDep = -1;
        maxPos = -1;
        ans = 0;
        dfs(start, -1, 0);

        if (need != -1) dec = need;
        else
        {
            foreach (var item in es[center])
            {
                dec = Math.Min(dec, item.Item2);
            }
        }
        Console.WriteLine(ans - dec);
    }

    int[] num;
    int dec;
    int maxDep;
    int maxPos;
    int need = -1;
    int center = -1;

    int dfs(int now, int pre, int d)
    {
        if (num[now] != 0) return num[now];
        if (maxDep < d)
        {
            maxDep = d;
            maxPos = now;
        }
        int ret = 1;
        bool check = true;
        foreach (var item in es[now])
        {
            if (item.Item1 == pre) continue;
            int sum = dfs(item.Item1, now, d + 1);
            ret += sum;
            if (sum * 2 >= N) check = false;
        }
        num[now] = ret;
        if (num[now]  * 2 < N) check = false;
        foreach (var item in es[now])
        {
            if (item.Item1 == pre) continue;
            int down = num[item.Item1];
            int up = N - down;
            ans += Math.Min(down * 2, up * 2) * (long)item.Item2;

            if (Math.Min(down * 2, up * 2) == N) need = item.Item2;
        }
        if (check) center = now;
        return ret;
    }



}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();

        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c) cout << "1";
	else if (a == b || b == c || c == a) cout << "2";
	else cout << "3";
	return 0;
}


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


int main()
{
	int h1,m1,h2,m2,k;
	
	cin>>h1>>m1>>h2>>m2>>k;
	
	int wake = ((h1 * 60 ) + m1),sleep = ((h2 * 60 ) + m2 - k);
	
	
	cout<<(sleep - wake);
	
	return 0;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

int main() {
//  freopen("../Console/1.txt", "rb", stdin);
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int N;
  cin >> N;

  map<int, int> D;
  for (int i = 0; i < N; ++i) {
    int d;
    cin >> d;

    ++D[d];
  }

  int M;
  cin >> M;
  map<int, int> T;
  for (int i = 0; i < M; ++i) {
    int t;
    cin >> t;

    ++T[t];
  }

  for (const auto& t : T) {
    auto it = D.find(t.first);
    if (it == D.end() || it->second < t.second) {
      cout << "NO" << '\n';
      return 0;
    }
  }

  cout << "YES" << '\n';

  return 0;
}


Measured memory_bytes: 19072
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9 + 7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W;
typedef long long ll;
typedef pair<ll, ll> Pa;

int main()
{
	cin >> N;
	for(int a=-1000;a<=1000;a++){
		for(int b=-1000;b<=1000;b++){
			if(pow(a, 5) - pow(b, 5) == N){
				cout << a << " " << b;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 4100
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <climits>
#include <map>
#include <vector>
using namespace std;



int main()
{
    int a, b;
    cin >> a >> b;

    if(a <= 9 and b <= 9)
    {
        cout << a * b << endl;
    }
    else
    {
        cout << -1 << endl;
    }
    
    return 0;
}

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

                //1  2  3  4  5  6  7  8  9 10 11 12
int mdays[12] = {31,28,31,30,31,30,31,31,30,31,30,31};

int main(void) {
  int a, b, c, d;

  std::string str;

  std::cin >> str;
  a = std::stoi(str);
  std::cin >> str;
  b = std::stoi(str);
  std::cin >> str;
  c = std::stoi(str);
  std::cin >> str;
  d = std::stoi(str);

  if(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
    std::cout << "Yes" << std::endl;
    return 0;
  }

  std::cout << "No" << std::endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

int a[6]={10,10,10,10,10,10};
int d[10]={0};

bool check(int value){
  bool ans= true;
  int i=1;
  a[0] = value % 10;
  while(value /= 10){
    a[i] = (value % 10);
    i++;
  }
  for(int j=0;j<i;j++){
    if(d[a[j]]) ans=false;
  }
  return ans;
}

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

  int n,k;
  cin >> n >> k;
  for(int i=0;i<k;i++){
    int n;
    cin >> n;
    d[n] =1;
  }
  for(int i=0;;i++){
    if(check(n+i)){
      cout << n+i << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
l, r = (int(i) for i in input().split())

if r-l > 2030: 
    print(0)
    exit()

min_mod = 10000

for i in range(l, r+1):
    for j in range(i+1, r+1):
        min_mod = min(min_mod, (i*j)%2019)

print(min_mod)

Measured memory_bytes: 40940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
int main(){
  int A[3];
  rep(i,3) cin>>A[i];
  sort(A,A+3);
  int ans=0;
  if((A[1]-A[0])%2) ans+=2+(A[1]-A[0]-1)/2+A[2]-A[1];
  else ans+=(A[1]-A[0])/2+A[2]-A[1];
  cout<<ans<<endl;
}

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

int main() {
  int n;
  string s;
  bool flg = false;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (s == "Y") {
      flg = true;
      break;
    }
  }
  if (flg) cout << "Four" << endl;
  else cout << "Three" << endl;
  
}

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

int main(int argc, char **argv) {
  int N;
  cin >> N;

  vector<int> A(N), B(N), C(N - 1);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    --A[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> B[i];
  }
  for (int i = 0; i < N - 1; i++) {
    cin >> C[i];
  }

  int ans = 0, prev = -1;
  for (int i = 0; i < N; i++) {
    ans += B[A[i]];

    if (prev != -1) {
      if (A[i] == (prev + 1))
        ans += C[prev];
    }

    prev = A[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
ll h;
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> h;
 	ll x = 1, y = h, cnt = 0;
 	while(y>1)
 	{
 		y /= 2;
 		cnt += x;
 		x *= 2;
 	}
 	cnt += x;
 	cout << cnt;
	return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        N: usize,
        CSFs: [(i64, i64, i64); N-1],
    }

    for i in 0..N - 1 {
        // このforの内側が10^5程度で捌ければOK

        let mut time: i64 = 0;
        for current_station in i..=N - 2 {
            let (C, S, F) = CSFs[current_station];

            // まだSに達していない場合は、Sになるまで待たないといけない
            if time <= S {
                time = S + C;

                // 次の駅へ
                continue;
            } else {
                // Sを過ぎている場合は、S + k * F秒になるまで待つ
                // S % F == 0 なので、つまりFの倍数になるまで待てばOK

                if time % F == 0 {
                    time += C;
                    continue;
                } else {
                    let n = time / F + 1;
                    time = F * n + C;
                    continue;
                }
            }
        }

        println!("{}", time);
    }

    println!("0");
}


Measured memory_bytes: 2200
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 2000000000;
// const ll MOD = 1000000007;

int N;
string S;

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

  vector<int> b_sum(N + 1, 0);
  vector<int> w_sum(N + 1, 0);
  for (int i = 1; i <= N; i++) {
    if (S[i - 1] == '#') {
      b_sum[i] = b_sum[i - 1] + 1;
    } else {
      b_sum[i] = b_sum[i - 1];
    }

    if (S[i - 1] == '.') {
      w_sum[i] = w_sum[i - 1] + 1;
    } else {
      w_sum[i] = w_sum[i - 1];
    }
  }

  int ans = INF;
  for (int i = 0; i <= N; i++) {
    int tmp = 0;
    tmp += (b_sum[i] - b_sum[0]);
    tmp += (w_sum[N] - w_sum[i]);
    ans = min(ans, tmp);
  }

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
long long s[200 * 10000];
int main () {
    long long n , m , ans = 0;
    cin >> n >> m;
    for (long long i = 0; i < n; i++)
        cin >> s[i];
    sort(s , s + n);
    for (long long i = 0; i < n - m; i++)
        ans += s[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
    string s;
    int k;
    cin >> s >> k;
    set<string> v;

    REP(i, s.size()){
        FOR(j, 1, k+1){
            if(i+j <= s.size()) v.insert(s.substr(i, j));
            else break;
        }
    }

    int i=1;

    for(set<string>::iterator itr=v.begin(); itr!=v.end(); ++itr){
        if(i==k){
            cout << *itr << endl;
            break;
        }
        i++;
    }
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s; cin >> s;
    int ans = INF,res;
    rep(i,s.size() - 2){
        res = abs(stoi(s.substr(i,3)) - 753);
        ans = min(ans,res);
    }
    ANS;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <cstring>

using namespace std;

const int INF = 1000000;
int cap[500][500];

int maximumFlow(int n, int s, int t, bool first = false){
	int res = 0;
	int prev[500];
	while(true) {
		queue<int> qu; qu.push(s);
		memset(prev, -1, sizeof(prev)); prev[s] = s;
		while(!qu.empty()&&prev[t]<0){
			int u = qu.front(); qu.pop();
			for(int i=0;i<n;i++){
				if(prev[i]<0&&cap[u][i]>0){
					prev[i] = u;
					qu.push(i);
				}
			}
		}
		if(prev[t] < 0) return res;
		for(int j=t;prev[j]!=j;j=prev[j])
			cap[prev[j]][j]--, cap[j][prev[j]]++;
		res++;
		if(!first) return res;
	}
	return 0;
}

int main(){
	int N, E, Q;
	while(cin >> N >> E >> Q){
		memset(cap, 0, sizeof(cap));
		for(int i=0;i<E;i++){
			int F, T; scanf("%d %d", &F, &T);
			cap[F-1][T-1] = 1;
			cap[T-1][F-1] = 1;
		}
		int cur = maximumFlow(N, 0, N-1, true);
		for(int i=0;i<Q;i++){
			int M, A, B; scanf("%d %d %d", &M, &A, &B);
			if(M==1){
				cap[A-1][B-1] = 1;
				cap[B-1][A-1] = 1;
				cur += maximumFlow(N, 0, N-1);
			}
			if(M==2){
				int s = A-1, t = B-1;
				for(int k=0;k<2;k++){
					if(cap[t][s] == 2){
						cap[t][s] = 0;
						int tmp = maximumFlow(N, s, t); 
						if(tmp==0){
							maximumFlow(N, s, 0);
							maximumFlow(N, N-1, t);
							cur--;
						}
					}
					swap(s, t);
				}
				cap[s][t] = cap[t][s] = 0;
			}
			cout << cur << endl;
		}
	}
}

Measured memory_bytes: 1928
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

print(-(-N//2))

Measured memory_bytes: 5332
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int m,n;
vector<int> each[100000+20];
int fa[100000+20],vis[100000+20];
void dfs(int now,int prev){
	fa[now]=prev;
	vis[now]=1;
//	cout<<
	for(auto it:each[now]) if(!vis[it]) dfs(it,now);
}
int degree[100000+20];
void dfs2(int now){
	for(auto it:each[now]){
		dfs2(it);
	}
	if(now!=1){
		if(degree[now]){
			degree[now]=0;
			cout<<now<<" "<<fa[now]<<endl;
		}
		else{
			degree[fa[now]]^=1;
			cout<<fa[now]<<" "<<now<<endl;
		}
	}
}
int main(){
	fastio;
	cin>>n>>m;
	if(m&1){
		cout<<-1;
		return 0;
	}
	rb(i,1,m){
		int u,v;
		cin>>u>>v;
		each[u].PB(v);
		each[v].PB(u);
	}
	dfs(1,-1);
	rb(i,1,n){
		for(auto it:each[i]){
			if(it<i){
				if(fa[it]!=i&&fa[i]!=it){
					cout<<it<<" "<<i<<endl;
					degree[it]^=1;
				}
			}
		}
	}
	rb(i,1,n)
		each[i].clear();
	rb(i,2,n)
		each[fa[i]].PB(i);
	dfs2(1);
	
	return 0;
}


Measured memory_bytes: 12800
#include <stdio.h>

int main(){
	int A1,A2,A3;
	
	scanf("%d%d%d", &A1, &A2, &A3);
	if (A1+A2+A3 >= 22){
		printf("bust\n");
	}else{
		printf("win\n");
	}
	return 0;
}

Measured memory_bytes: 2088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define CHMIN(a,b) (a) = min((a),(b))
#define CHMAX(a,b) (a) = max((a),(b))

int main()
{
    char x[5]={};
    scanf("%s",x);
    int ans=0;
    REP(i,4)
    {
        if(x[i]=='+')ans++;
        else ans--;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
/*input
ABCACCBABCBCAABCB
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int main(){
	string s;
	cin>>s;
	int cnt=0;
	ll ans=0;

	for(int i=SZ(s)-1;i>=0;i--){
		if(s[i]=='A'){
			ans+=cnt;
		}
		else if(s[i]=='B'){
			cnt=0;
		}
		else{
			if(i&&s[i-1]=='B'){
				i--;
				cnt++;
			}
			else cnt=0;
		}
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main(){

	int n;
	cin>>n;
	
	
	while(n!=0){
		if(n%10==7)
		{
			cout<<"Yes";
			return 0;
		}
		n/=10;
	}
	cout<<"No";
	return 0;
}




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

#define ll long long

int main() {
   ll n,i;
   cin>>n;
   ll a[n];
   int flag=0;
   for(i=0;i<n;i++)
   {
       cin>>a[i];
   }
    for(i=0;i<n;i++)
   {
       if(a[i]%2==0)
       {
           if(a[i]%3==0 || a[i]%5==0)
           {
               continue;
           }
           else
           {
               flag=1;
               break;
           }
       }
   }
   if(flag) cout<<"DENIED";
   else cout<<"APPROVED";
    return 0;
}

Measured memory_bytes: 3608
//author : raghav_0901
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define int long long int
#define f(i,s,e) for(i=s;i<e;++i)
#define fr(i,s,e) for(i=s;i>=e;i--)
#define all(x) (x).begin(),(x).end()
#define _in(v) for(auto &x:v) cin>>x;
#define ff(i,s,e,f) for(i=s;i<e && f;++i)
#define mem(arr,val) memset(arr, val, sizeof(arr));
#define _out(v) for(auto x:v) cout<<x<<' '; cout<<'\n';
#define ARENA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
typedef vector<int> vec;
typedef pair<int,int> pr;

const int lim = 1000000;
const int mod = 1000000;

inline int num(char c)
{
    return ((c=='R')?0:((c=='G')?1:2));
}

signed main()
{
    ARENA
    int n,i,j,ans=0;cin>>n;
    string s;cin>>s;
    vector<vec> v(n+1, vec (3,0));
    f(i,1,n+1)
    {
        v[i][0]=v[i-1][0]+(s[i-1]=='R');
        v[i][1]=v[i-1][1]+(s[i-1]=='G');
        v[i][2]=v[i-1][2]+(s[i-1]=='B');
        //_out(v[i]);
    }
    f(i,1,n+1)
        f(j,i+3,n+1)
        {
            if(s[i-1]!=s[j-1])
            {
                int t=3-num(s[i-1])-num(s[j-1]);
                ans+=(v[j][t]-v[i-1][t]);
                if((j-i)%2==0)
                    ans-=((s[i-1]!=s[(i+j-2)/2]) && (s[j-1]!=s[(i+j-2)/2]));
            }
        }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18;

/*--------------------------------------------------------------------*/

signed main(){
	int k;cin>>k;
	if(k%2==0){
		cout<<-1<<endl;
		return 0;
	}
	
	int now=0;
	for(int i=1;i<1e7;i++){
		now=(now*10+7)%k;
		if(now==0){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	

	return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

const ll MOD = 1e9+7;
ll dp[101][8];

int main(){
    ll h, w, k; cin >> h >> w >> k;
    
    if(w == 1){ cout << 1 << endl; return 0; }
    
    dp[0][0] = 1;
    rep(i,h){
        rep(j,1<<(w-1)){
            vector<bool> count(w-1,false);
            rep(k,w-1) if(j & 1<<k) count[k] = true;
            bool check = false;
            rep(k,w-2) if(count[k] && count[k+1]) check = true;
            if(check) continue;

            rep(k,w-1){
                if(count[k]){
                    dp[i+1][k+1] += dp[i][k];
                    dp[i+1][k+1] %= MOD;
                    dp[i+1][k] += dp[i][k+1];
                    dp[i+1][k] %= MOD;
                }
                else if(k == 0){
                    dp[i+1][0] += dp[i][0];
                    dp[i+1][0] %= MOD;
                }
                else if(!count[k-1]){
                    dp[i+1][k] += dp[i][k];
                    dp[i+1][k] %= MOD;
                }
                if(!count[k] && k == w-2){
                    dp[i+1][w-1] += dp[i][w-1];
                    dp[i+1][w-1] %= MOD;
                }
            }
        }
    }

    cout << dp[h][k-1] << endl;
}



Measured memory_bytes: 3664
import java.util.*;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();

        long gcd = get_great_common_divisor(a,b);
        //System.out.println(gcd);
        int count = prime_factorization(gcd);
        System.out.println(count);
    }

    //最大公約数を返すメソッド
    public static long get_great_common_divisor(long a,long b) {
        long gcd=0;
        /*if (a < b) {
            int tmp = a;
            a = b;
            b = tmp;
        }*/

        //余りがでなければ終了
        if (a % b == 0) {
            return b;
        }

        gcd = a % b;
        return get_great_common_divisor(b,gcd);
        
    }

    //素因数分解するメソッド
    public static int prime_factorization(long n) {
        long y = n;
        int count = 1;

        //切り上げのため+1
        n = (int)Math.sqrt(n) + 1;
        for(int i=2; i<=n; i++){
            if(y % i == 0) count++;
            while(y % i == 0){
                y /= i;  
            }
            //yが√nより早めに割り切れた場合、無駄削減
            if(y == 1) {
                break;
            }

            if(i == n) {
                count++;
            }
        }
        return count;
    }
}

Measured memory_bytes: 23892
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
        a: i32,
        b: i32,
        c: i32
    );
    
    println!("{}", 
        if a + b < c {
            a + b * 2 + 1
        } else {
            b + c
        }
    );
}

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

int main() {
  string base = "ACTGAC";
  char b;
  cin >> b;
  for(int i=0;i<4;i++){
    if(b == base.at(i)){
      cout << base.at(i+2) << endl;
      return 0;
    }
  }
  
  
        
  
  return 0;
}


Measured memory_bytes: 256
use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::cmp::*;
use std::collections::HashSet;
use std::iter::Iterator;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
    a: f64,
    b: f64,
    }

    let b10 = b * 10_f64;

    for plus in 0..10000 {
        let tmp = b10 + plus as f64;
        if (tmp * 0.1).floor() >= b + 1.0 {
            break;
        }
        if (tmp * 0.08).floor() == a {
            println!("{}", tmp);
            return;
        }
       
    }

    println!("{}", "-1");
}


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

#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define vll vector<ll>
#define pll pair<ll , ll>
#define vpll vector<pair<ll, ll> >
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define N 100001
#define HOLE 1000000007

ll fn(ll x,ll rn[])
{
    if(rn[x]==x) return x;
    else return rn[x]=fn(rn[x],rn);
}

void un(ll x,ll y,ll rn[],ll sz[])
{
    x=fn(x,rn);
    y=fn(y,rn);
    if(x==y) return;
    if(sz[x]<sz[y]) swap(x,y);
    sz[x]+=sz[y];
    rn[y]=x;
    return;
}

ll power(ll x,ll y)
{
    ll res = 1; // Initialize result

    while (y > 0) {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res * x)%HOLE;

        // n must be even now
        y = y >> 1; // y = y/2
        x = (x * x)%HOLE; // Change x to x^2
    }
    return res;
}

vector <ll> adjl[N];
ll marked[N]={0};
vector <ll> order;

void dfs (ll x){

    if(marked[x])
        return;
    marked[x]=1;

    REP(i,0,adjl[x].size()){

    }

    return;
}

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

    ll q=1;
    //cin>>q;
    while(q--){

        ll n;
        cin>>n;

        string s;
        cin>>s;

        ll r=0;
        ll b=0;
        ll g=0;

        REP(i,0,n){
            if(s[i]=='R')r++;
            else if(s[i]=='B')b++;
            else g++;
        }

        ll ans=r*b*g;

        //cout<<r<<" r "<<b<<" b "<<g<<" g "<<endl;

        REP(i,0,n){

            REP(j,i+1,n){

                if(s[i]=='R'){

                    if(s[j]=='B'){
                        if((2*j-i)<n && s[2*j-i]=='G'){
                            ans--;
                        }
                    }

                    if(s[j]=='G'){
                        if((2*j-i)<n && s[2*j-i]=='B'){
                            ans--;
                        }
                    }

                }

                if(s[i]=='B'){

                    if(s[j]=='R'){
                        if((2*j-i)<n && s[2*j-i]=='G'){
                            ans--;
                        }
                    }

                    if(s[j]=='G'){
                        if((2*j-i)<n && s[2*j-i]=='R'){
                            ans--;
                        }
                    }

                }

                if(s[i]=='G'){

                    if(s[j]=='B'){
                        if((2*j-i)<n && s[2*j-i]=='R'){
                            ans--;
                        }
                    }

                    if(s[j]=='R'){
                        if((2*j-i)<n && s[2*j-i]=='B'){
                            ans--;
                        }
                    }

                }

            }

        }

        cout<<ans<<endl;


    }

return 0;
}


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

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

    int tmp = n * 100 / 108;

    int ans = 0;
    if ((int)(tmp * 1.08) == n) {
        ans = tmp;
    }
    if ((int)((tmp+1) * 1.08) == n) {
        ans = tmp + 1;
    }

    if (ans != 0) {
        cout << ans << endl;
    }
    else {
        cout << ":(" << endl;
    }
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <stdio.h>
#include <cmath>
#include <string.h>
#include <vector>

#define ll long long
#define inf 0x3f3f3f3f
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    string s;
    int n;
    int i, cnt = 0;
    cin >> n >> s;
    while(i < n -1)
    {
      if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
      {
            cnt++;
            i+=3;
      }
      else i++;
    }
    cout << cnt << endl;
    return 0;
}

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

bool check_int(string S){
  try{
    int n=stoi(S);
  }
  catch(...){
    return false;
  }
  return true;
}
int main()
{
  int A,B;
  cin>>A>>B;
  string S;
  cin>>S;
  string c=S;
  bool flag=true;
  S.erase(S.begin()+A);
  for(auto itr=S.begin();itr!=S.end();itr++){
    if(*itr=='-'){
      flag=false;
    }
  }
  if(c[A]!='-') flag=false;
  
  cout<<((flag)? "Yes":"No");
  
}

Measured memory_bytes: 256
//#include <GOD>

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define si size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define E end()
#define B begin()
#define pi pair<int, int>
#define en cout << endl
#define cn const
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

cn int maxn = 1e5 + 10;
ll dp[maxn];
ll h[maxn];

int main(){
	fast_io;
	int n, k;
	cin >> n >> k;
	
	for(int i = 0; i < n; i ++)
		cin >> h[i];
	memset(dp, 64, sizeof(dp));
	
	dp[0] = 0;
	for(int i = 0; i < n; i ++){
		for(int j = i - 1; j >= max(0, i - k); j --){
			dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
		}
	}
	
	cout << dp[n - 1];
	
	return 0;
}



Measured memory_bytes: 1792
import sys, re
from math import ceil, floor, sqrt, pi#, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_rpw_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 7)
INF = float('inf')
MOD = 10 ** 9 + 7

def dfs(current, parent, edges, ans_list):
    for child in edges[current]:
        if child == parent:
            continue
        ans_list[child] += ans_list[current]
        dfs(child, current, edges, ans_list)

def main():
    n, q = i_map()

    edges = [[] for _ in range(n)]
    for i in range(n-1):
        a, b = i_map()
        edges[a-1].append(b-1)
        edges[b-1].append(a-1)

    ans_list = [0] * n
    for i in range(q):
        p, x = i_map()
        ans_list[p-1] += x

    dfs(0, -1, edges, ans_list)

    print(*ans_list)

if __name__ == '__main__':
    main()

Measured memory_bytes: 231728
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

ll isPrime(ll n)
{
    for(ll i=2;i<n;i++)
    {
        if(n%i==0)
        {
            return 0;
        }
    }
    return 1;
}

int main()
{
   ll n,i;
   cin>>n;

   for(i=n;i>=0;i++)
   {
       if(isPrime(i))
       {
           return(cout<<i<<endl,0);
       }
   }
}


Measured memory_bytes: 256
N, Y = map(int, input().split())

if Y >= N*1000:
    for i in range(N+1):
        if (Y / 1000 - N) - 9 * i >= 0 and int(((Y / 1000 - N) - 9 * i) % 4) == 0:
            y =((Y / 1000 - N) - 9 * i) / 4
            if int(N-i-y)>= 0 and 10000*i+5000*int(y)+1000*int(N-i-y) == Y:
                print(i, int(y), int(N-i-y))
                break
        elif i == N:
            print('-1 -1 -1')
else:
    print('-1 -1 -1')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll a,b,k;
    cin >> a >> b >> k;
    for(ll i=0;i<k;i++){
        if(i%2==0){
            if(a%2==1) a--;
            a/=2;
            b+=a;
        }
        else {
            if(b%2==1) b--;
            b/=2;
            a+=b;
        }
    }
    cout << a << " " << b << endl;
}

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

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int n, m;
string str[10];

int main() {
    while (cin >> n >> m) {
        for (int i = 0; i < n; ++i) cin >> str[i];
        int con = 0;
        for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) {
            if (str[i][j] == '#') {
                ++con;
            }
        }
        if (con == n + m - 1) puts("Possible");
        else puts("Impossible");
    }
}





Measured memory_bytes: 764
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
#include<math.h>

using namespace std;

int main(void)
{

	int D, N;

	int ans = 0;

	cin >> D >> N;



	if (D == 0) 
	{
		if (N==100)
		{
			cout << N+1 << endl;
		}
		else if (N < 100)
		{
			cout << N << endl;
		}
	}
	else if (D >= 1)
	{
		if (N == 100)
		{
			cout << (N+1) * (int)pow(100, D) << endl;
		}
		else
		{
			cout << N * (int)pow(100, D) << endl;
		}
		
	}



	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ull unsigned long long 

int main(){
  vector<string>data(2);
  string s="YES";
  for(int i=0;i<2;i++){
    cin>>data.at(i);
  }
  for(int i=0;i<2;i++){
    for(int j=0;j<3;j++){
      if(data.at(i).at(j)!=data.at(1-i).at(2-j))
        s="NO";
    }
  }
  cout<<s;
}
        
  

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

int main() {
    int n;
    while (cin >> n, n) {
        int c1,m1,s1,m2,s2,m3,s3,m4,s4;
        vector<pair<int,int> > data;
        for (int i=0; i<n; ++i) {
            cin>>c1>>m1>>s1>>m2>>s2>>m3>>s3>>m4>>s4;
            data.push_back(make_pair((m1+m2+m3+m4)*60+(s1+s2+s3+s4),c1));
        }
        sort(data.begin(), data.end());
        cout << data[0].second << endl;
        cout << data[1].second << endl;
        cout << data[data.size()-2].second << endl;
    }
    return 0;
}

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

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

  int sum=0;
  sum = sum + abs(a[0]);
  for(int i=1;i<n;i++){
    // cout << sum << endl;                                                                                       
    sum = sum + abs(a[i] - a[i-1]);
  }
  sum = sum + abs(a[n-1]);

  // cout << sum << endl;                                                                                         

  for(int k=0;k<n;k++){
    int sum_k = sum;
    if(k==0){
      sum_k = sum_k - abs(a[0]) - abs(a[1] - a[0]) + abs(a[1]);
    }
    else if(k==n-1){
      sum_k = sum_k - abs(a[n-1]) - abs(a[n-1] - a[n-2]) + abs(a[n-2]);
    }
    else{
      sum_k = sum_k - abs(a[k] - a[k-1]) - abs(a[k+1] - a[k]) + abs(a[k+1] - a[k-1]);
    }

    cout << sum_k << endl;
  }



  return 0;
}


Measured memory_bytes: 2172
#!/usr/bin/env python3
import sys


def solve(N: int, K: int):
    # print(N-K-1)
    if(K==1):
        print(0)
    else:
        print(N-K)
    return


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

if __name__ == '__main__':
    main()


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/12/16  Problem: ARC 087 A / Link: http://arc087.contest.atcoder.jp/tasks/arc087_a  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	cin >> N;
	VL a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	SORT(a);
	map<LL, LL>m;
	FOR(i, 0, N) {
		m[a[i]]++;
	}
	UNIQ(a);

	FOR(i, 0, SZ(a)) {
		if (m[a[i]]<a[i])ans += m[a[i]];
		if(m[a[i]]>a[i])ans += m[a[i]]-a[i];
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 7040
#include<iostream>
#include<string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include<iomanip>
using namespace std;

int main()
{
    int N,K;
    cin >> N >> K;
    if(K==1)cout << 0 << endl;
    else{
        cout << N-K << endl;
    }
}

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

int main() {
  int N, M;
  map<string,int> ma;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    string S;
    cin >> S;
    ma[S]++;
  }
  cin >> M;
  for (int i = 0; i < M; ++i) {
    string S;
    cin >> S;
    ma[S]--;
  }
  int res = 0;
  for (auto it : ma) res = max(res, it.second);
  cout << res << endl;
}

Measured memory_bytes: 3576
#include<stdio.h>

int main(void)
{
	int i,x=0,y=0;
	
	for(i=0;i<3000;i++)
	{
		scanf("%d%d",&x,&y);
		if((x==0)&&(y==0))
		{
			return 0;
		}
		else if(x<=y)
		{
			printf("%d %d\n",x,y);
		}
		else if(y<x)
		{
			printf("%d %d\n",y,x);
		}
	}
	return 0;
}


Measured memory_bytes: 600