akhauriyash/Code-Regression huggingface dataset:
#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 };

/* -----  2018/03/05  Problem: 086_arc_b / Link: https://arc086.contest.atcoder.jp/tasks/arc086_b?lang=en  ----- */
/* ------問題------

すぬけ君は長さ N の数列 a を持っています。a の (1-indexedでの) i 番目の数は ai です。
すぬけ君は以下の操作を何度でも行うことができます。
操作：1 以上 N 以下の整数 x,y を選び、ay に ax を加算する。
すぬけ君はこの操作を 0 回以上 2N 回以下行って a が下記の条件を満たすようにしたいです。そのような操作手順の一例を示してください。 なお、この問題の制約下で、条件を満たすような操作の手順が必ず存在することが証明できます。

条件：a1≤a2≤…≤aN

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

N-1回で整地


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

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];
	}
	LL Min = LINF;
	LL Max = -LINF;
	FOR(i, 0, N) {
		Min = min(Min, a[i]);
		Max = max(Max, a[i]);
	}
	cout << 2 * N - 1 << endl;
	if (abs(Max) > abs(Min)) {
		int pos; // 全部正
		FOR(i, 0, N) {
			if (Max == a[i])pos = i;
		}
		FOR(i, 0, N) {
			cout << pos + 1 << " " << i + 1 << endl;
		}
		FOR(i, 0, N - 1) {
			cout << i + 1 << " " << i + 2 << endl;
		}
	}
	else { //全部負
		int pos;
		FOR(i, 0, N) {
			if (Min == a[i])pos = i;
		}
		FOR(i, 0, N) {
			cout << pos + 1 << " " << i + 1 << endl;
		}
		FORR(i, N - 2, 0 - 1) {
			cout << i + 2 << " " << i + 1 << endl;
		}
	}

	return 0;
}


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


#define pi  acos(-1)
typedef  long long ll;
typedef  unsigned long long ull;
typedef  unsigned un;

//defined taking input;
#define sf           scanf
#define si(a)        sf("%d",&a)
#define sc(a)        sf("%c",&a)
#define sii(a,b)     sf("%d %d",&a,&b)
#define siii(a,b,c)  sf("%d %d %d",&a,&b,&c)
#define sl(a)        sf("%lld",&a)
#define sll(a,b)     sf("%lld %lld",&a,&b);
#define slll(a,b,c)  sf("%lld %lld %lld",&a,&b,&c);

#define pf           printf
#define pfi(a)       pf("%d\n",a)
#define pfl(a)       pf("%ld\n",a)
#define pfn          pf("\n")
#define pfyes        pf("YES\n")
#define pfno         pf("NO\n")
#define pfYes        pf("Yes\n")
#define pfNo         pf("No\n")

#define wh            while
#define wht(t)        while(t--)

int GCD(int a,int b){
    if(b==0)
        return a;

    return GCD(b,a%b);

}

int main(){
    //freopen("input","r",stdin);

    ll k,x,g=0;

    sl(k);
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int h=1;h<=k;h++){

              x = GCD(j,h);
              g+=GCD(i,x);

            }
        }
    }

    cout<<g<<endl;


    return 0;
}


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

using namespace std;

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

    int passed[4];
    for(int i = 0; i < 3; i++) {
        passed[i] = 0;
    }

    for(int i = 0; i < 3; i++) {
        passed[a[i]-1] += 1;
        passed[b[i]-1] += 1;
    }

    for(int i = 0; i < 4; i++) {
        if(passed[i] >= 3) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(void){ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////////////////
int n,sum=0;
cin >> n;
int d[n];
for(int i=0;i<n;i++){
    cin >> d[i];
}

for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
        sum=sum+d[i]*d[j];
    }
}
cout << sum << endl;
////////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    int N;
    cin >> N;
    int A[2][N];
    rep(i, 2) rep(j, N) cin >> A[i][j];
    //l[i]:=[0,i), r[i]:=[i,N)
    int l[N+1], r[N+1];
    l[0] = 0;
    rep2(i, 1, N) l[i] = l[i-1]+A[0][i-1];
    r[N] = 0;
    rep3(i, N-1, 0) r[i] = r[i+1]+A[1][i];
    int ans = 0;
    rep(i, N){
        ans = max(ans, l[i+1]+r[i]);
    }
    cout << ans << endl;
}

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

#define MaxN 100005

using namespace std;

long long S,N;
int main()
{
    cin>>N>>S;
    for(long long i=2;i*i<=N;i++)
    {
        long long X=N,sum=0;
        while(X)
        {
            sum+=X%i;
            X=X/i;
        }
        if(S==sum)
        {
            cout<<i;
            return 0;
        }
    }
    long long d;
    for(d=1;d*d<=(N-S);d++)
    {
        long long X=N,sum=0;
        while(X)
        {
            sum+=X%(d+1);
            X=X/(d+1);
        }
        if(S==sum)
        {
            cout<<d+1;
            return 0;
        }
    }
    d--;
    while(d)
    {
        long long X=N,sum=0,i=(N-S)/d+1;
        while(X)
        {
            sum+=X%i;
            X=X/i;
        }
        if(S==sum)
        {
            cout<<i;
            return 0;
        }
        d--;
    }
    if(N==S)cout<<N+1;
    else cout<<-1;
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
h = gets.split(' ').map(&:to_i)

max = 0
i=0
long=0

while i<=n-2
  if h[i]<h[i+1]
    if long>max
      max = long
      long = 0
      i+=1
    else
      i+=1
      long=0
    end
  else
    long += 1
    i+=1
  end
end

if long>max
  max = long
end
puts max


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;

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

  vector<int> c(4,0);

  rep(i,n){
    string s;
    cin >> s;

    if(s=="AC") c.at(0)++;
    if(s=="WA") c.at(1)++;
    if(s=="TLE") c.at(2)++;
    if(s=="RE") c.at(3)++;
  }

  cout << "AC x " << c.at(0) << endl;
  cout << "WA x " << c.at(1) << endl;
  cout << "TLE x " << c.at(2) << endl;
  cout << "RE x " << c.at(3) << endl; 
}

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

int main(){
  int n;
  cin >> n;
  vector<int> vec(1);
  int a = -1, b = -1, c = -1;
  int acount = 0, bcount = 0, ccount = 0;
  for(int i=0; i<n; i++){
    int num;
    cin >> num;
    if(i == 0) a = num;
    else if(a != num && b == -1) b = num;
    else if(a != num && b != num && c == -1) c = num;
    else if(a != num && b != num && c != num){
      cout << "No" << endl;
      return 0;
    }
    if(a == num) acount++;
    if(b == num) bcount++;
    if(c == num) ccount++;
  }
  if(a != -1 && b != -1 && c != -1 && acount == n/3 && bcount == n/3 && ccount == n/3 && (a ^ b) == c){
    cout << "Yes" << endl;
    return 0;
  }else if(c == -1 && ((a == 0 && bcount - acount == acount) || (b == 0 && acount - bcount == bcount))){
    cout << "Yes" << endl;
    return 0;
  }else if(a == 0 && b == -1 && c == -1){
    cout << "Yes" << endl;
    return 0;
  }else{
    cout << "No" << endl;
    return 0;
  }
}


Measured memory_bytes: 384
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader rd = new MyReader();        
        String S = rd.s();
        int N = S.length();
        int[] ans = new int[N];
        for(int i = 0; i < N;){
            int r, l;
            int j = i;
            while(S.charAt(j) == 'R'){
                j++;
            }
            r = j-1;
            l = j;
            while(j < N && S.charAt(j) == 'L'){
                j++;
            }
            for(int k = i; k < r; k++)
                ans[k] = 0;
            for(int k = l+1; k < j; k++)
                ans[k] = 0;
            int rn = r-i+1;
            int ln = j-l;
            ans[r] = (rn+1)/2+ln/2;
            ans[l] = rn/2+(ln+1)/2;            
            i = j;
        }
        for(int a : ans)
            print(a+" ");
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 36920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<vector<ll>>ar;
ll n,r,c;
bool bord(ll x,ll y){
    return x==r ||x==0||y==0||y==c;
}
ll ind(ll x,ll y){
    if(x==0)return y;
    if(y==c)return x+c;
    if(x==r)return (c-y)+r+c;
    return (r-x)+r+2*c;
}
int main()
{ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
    cin>>r>>c>>n;
    for(int i=1;i<=n;i++){
        ll x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        if(bord(x1,y1)&&bord(x2,y2)){
            vector<ll>v1={ind(x1,y1),x1,y1,i};
            vector<ll>v2={ind(x2,y2),x2,y2,i};
            ar.push_back(v1);
            ar.push_back(v2);
        }
    }
    sort(ar.begin(),ar.end());
    stack<int>st;
    for(auto el:ar){
        if(st.size()&&st.top()==el[3]){
            st.pop();
        }else{
            st.push(el[3]);
        }
    }
    if(st.empty())cout<<"YES"<<'\n';
    else cout<<"NO"<<'\n';
    return 0;
}


Measured memory_bytes: 17592
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define se second
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int main()
{
    fastio();
    set<string> s;
    string t;
    int n;
    cin>>n;
    for(int i=0;i<n;i++) {cin>>t;s.insert(t);}
    cout<<s.size()<<endl;
    return 0;
}


Measured memory_bytes: 19204
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    int n, m;
    cin >> n >> m;
    vector<ll> score(n, -(1ll<<60));
    score[0] = 0;
    vector<pair<pair<int,int>,int>> edge;
    int a, b, c;
    for(int i = 0; i < m; i++){
        cin >> a >> b >> c;
        a--, b--;
        edge.push_back({{a,b},c});
    }
    for(int loop = 1; loop < n; loop++){
        vector<ll> next = score;
        for(int i = 0; i < m; i++){
            int from = edge[i].first.first, to = edge[i].first.second;
            next[to] = max(next[to], score[from]+edge[i].second);
        }
        score = next;
    }

    // 本当はここの負閉路チェックが1回で終わってほしいんだけど、多分だめ
    // 腑に落ちないがひとまずもうn回ループして位置n-1におけるスコア上昇にのみ
    // 注意すれば良い(多分)
    bool valid = true;
    for(int loop = 0; loop < n; loop++){
        vector<ll> next = score;
        for(int i = 0; i < m; i++){
            int from = edge[i].first.first, to = edge[i].first.second;
            if(next[to] < score[from]+edge[i].second){
                next[to] = score[from]+edge[i].second;
                if(to == n-1)   valid = false;
            }
        }
        score = next;
    }
    if(valid)   cout << score[n-1] << endl;
    else        cout << "inf" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 1010101010;

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

    int N;
    cin >> N;
    vector<string> S(N);
    REP(i, N) cin >> S[i];
    int st = 0;
    bool f = true;
    REP(i, N){
        if(S[i] == "A") st++;
        else st--;
        if(st < 0){
            f = false;
            break;
        }
    }
    if(st != 0) f = false;
    cout << (f ? "YES" : "NO") << "\n";
    return 0;
}


Measured memory_bytes: 3244
#include<stdio.h>
int main(){
int a,b,c;
while(1){
scanf("%d %d %d",&a,&b,&c);
if(a==-1&&b==-1&&c==-1)
break;
if(a==-1||b==-1)
printf("F");
else{
if(a+b>=80)
printf("A");
else if(a+b>=65)
printf("B");
else if(a+b>=50)
printf("C");
else if(a+b>=30&&c>=50)
printf("C");
else if(a+b>=30)
printf("D");
else
printf("F");
}
printf("\n");
}
return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std; 
int main(){
  int n;
  cin >> n;
  if(195<=n){
    cout << 5;
  }else if(n>=189){
    cout << 4;
  }else if(n>=165){
    cout << 3;
  }else if(n>=135){
    cout << 2;
  }else if(n>=105){
    cout << 1;
  }else{
    cout << 0;
  }
}


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
// const ll mod = 1000000007;
const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};


bool solve(){
    ll n,m;cin>>n>>m;
    UnionFind uf(n);
    vector<ll>ans;
    vector<ll>_a(m);
    vector<ll>_b(m);
    rep(i,m)cin>>_a[i]>>_b[i];
    reverse(all(_a));
    reverse(all(_b));
    rep(i,m){
        ll a=_a[i],b=_b[i];a--;b--;
        ll an=uf.size(a)*uf.size(b);
        ans.push_back(uf.unite(a,b) ? an : 0);
    }
    reverse(all(ans));
    ll sum=0;
    rep(i,ans.size())cout<<(sum=sum+ans[i])<<endl;

    return false;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(30);
    solve();
}


Measured memory_bytes: 4212
h,w,k = gets.split.map(&:to_i)
a = []
h.times {a << gets.chomp!.split("")}

ans = Array.new(h){Array.new(w,0)}
l = 0
t = false

num = 0
h.times do |i|
    if a[i].include?('#')
        t = true
        count = 0
        w.times do |j|
            count += 1 if a[i][j] == '#'
            ans[i][j] = num + (count == 0 ? 1 : count)
        end
        num += count
    elsif t
        ans[i] = ans[i-1]
    else
        l += 1
    end
end

(l-1).downto(0) do |i|
    ans[i] = ans[i+1]
end

puts ans.map{|e| e.join(" ")}

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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

ll dx[4] = {1, 0, 0, -1};
ll dy[4] = {0, 1, -1, 0};
ll m, n, dp[90][90] = {0};

int dfs(int y, int x) {
  int sum = 0;
  dp[y][x] = 0;
  rep(i, 4) {
    int xx = x + dx[i], yy = y + dy[i];
    if(xx < 0 || xx >= m || yy < 0 || yy >= n) continue;
    if(dp[yy][xx]) sum = max(sum, dfs(yy, xx));
  }
  dp[y][x] = 1;
  return sum + 1;
}

signed main() {
	while(cin >> m >> n && (m || n)) {
    rep(i, n) rep(j, m) cin >> dp[i][j];
    int result = 0;
    rep(i, n) rep(j, m) {
      if(dp[i][j]) result = max(result, dfs(i, j));
    }
    cout << result << endl;
  }
	return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
const ll INF=1e9+7;
const ll N = 101;
ll h,w,alf[26];
ll aru421[3];
ll d=0;
char a;
ll need421[3];

int main(){
	cin>>h>>w;
	FOR(i,0,26)alf[i]=0;
	FOR(i,0,h){
		FOR(j,0,w){
			cin>>a;
			alf[a-'a']++;
		}
	}
	need421[0]=need421[1]=need421[2]=0;
	aru421[0]=aru421[1]=aru421[2]=0;
	if(w%2==1&&h%2==1){
		need421[0]=((w-1)*(h-1))/4;
		need421[2]=1;
		need421[1]=(h+w-2)/2;
	}else if(w%2==0&&h%2==0){
		need421[0]=(w*h)/4;
	}else{
		ll ki,gu;
		if(w%2==1){
			ki=w;
			gu=h;
		}else{
			ki=h;
			gu=w;
		}
		need421[0]=((gu)*(ki-1))/4;
		need421[1]=gu/2;
	}
	FOR(i,0,26){
		aru421[0]+=alf[i]/4;
		alf[i]%=4;
		aru421[1]+=alf[i]/2;
		alf[i]%=2;
		aru421[2]+=alf[i];
	}

	if(aru421[0]>=need421[0]){
		aru421[0]-=need421[0];
		aru421[1]+=aru421[0]*2;
	}else{
		cout<<"No"<<endl;
		return 0;
	}
	if(aru421[1]>=need421[1]){
		aru421[1]-=need421[1];
		aru421[2]+=aru421[1]*2;
	}else{
		cout<<"No"<<endl;
		return 0;
	}
	if(aru421[2]<need421[2]){
		cout<<"No"<<endl;
		return 0;		
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
def main():
    s = int(input())
    m = 10 ** 9
    s1 = s // m
    s2 = s % m
    if s1 == m:
        print('0 0 {0} {1} {2} {3}'.format(m, 0, 0, m))
    else:
        print('0 0 {0} {1} {2} {3}'.format(m, 1, m - s2, s1 + 1))


main()


Measured memory_bytes: 2940
import java.util.*;
import java.math.*;

class Main{       
   public static void main(String[] args){

      Scanner sc = new Scanner(System.in);
    
      int A = sc.nextInt();
      int B = sc.nextInt();
      int C = sc.nextInt();
      
      for(int a = 0; a < B;a++){
          if((A*a)%B == C){
             System.out.println("YES");   
             return;
          }          
      }
      
     System.out.println("NO");
      
   }
}
        
       

Measured memory_bytes: 23508
#include<cstdio>
#include<cstring>
#include<vector>
#include<map>
#include<functional>
#include<algorithm>
using namespace std;
int n, m;
int nails[2][5009];
int ans;
map<pair<int, int> , int> tops;
vector<pair<int, int> > toppoints;

int main(){
  scanf("%d%d", &n, &m);
  for(int i = 0;i < m;i++){
    int a, b, x;
    scanf("%d%d%d", &a, &b, &x);
    a--;b--;
    toppoints.push_back(make_pair(a, b));
    if(tops.find(make_pair(a, b)) == tops.end())tops[make_pair(a, b)] = 0;
    tops[make_pair(a, b)] = max(x + 1, tops[make_pair(a, b)]);
  }
  sort(toppoints.begin(), toppoints.end(), greater<pair<int, int> >());
  memset(nails, 0, sizeof(nails));
  for(int i = 0;i <= n;i++){
    memset(nails[(i + 1) % 2], 0, sizeof(int) * 5009);
    for(int j = 0;j <= n;j++){
      if(!toppoints.empty() && toppoints.back() == make_pair(i, j)){
	nails[i % 2][j] = max(tops[make_pair(i, j)], nails[i % 2][j]);
	while(!toppoints.empty() && toppoints.back() == make_pair(i, j)){
	  toppoints.pop_back();
	}
      }
      if(nails[i % 2][j] != 0)ans++;
      nails[(i + 1) % 2][j] = max(nails[(i + 1) % 2][j], nails[i % 2][j] - 1);
      nails[(i + 1) % 2][j + 1] = max(nails[(i + 1) % 2][j + 1], nails[i % 2][j] - 1);
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 36220
#!/usr/bin/env python3

N = int(input())
P = list(map(int, input().split()))
# print(N, P)

count = 0
min_prev = P[0] + 1
for i in range(N):
    if P[i] < min_prev:
        min_prev = P[i]
        count += 1

print(count)


Measured memory_bytes: 24744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define F first
#define S second
#define pb push_back
mt19937 rnd;

set<string> all;

void solve(string s, int n) {
    if (s.empty()) {
        s = "a";
        solve(s, n);
    }
    else if (s.size() == n) {
        all.insert(s);
    }
    else {
        char mx = 'a';
        for (char c : s) {
            mx = max(mx, c);
        }
        for (char c = 'a'; c <= min('z', char(mx + 1)); c++) {
            s += c;
            solve(s, n);
            s.pop_back();
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n;
    cin >> n;
    solve("", n);
    for (string s : all) {
        cout << s << "\n";
    }

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 14208
# -*- coding: utf-8 -*-
import sys

H,W=map(int, sys.stdin.readline().split())
A=[ map(int, sys.stdin.readline().split()) for _ in range(H) ]
B=[ map(int, sys.stdin.readline().split()) for _ in range(H) ]

for h in range(H):
    for w in range(W):
        A[h][w]=abs(A[h][w]-B[h][w])

dp=[ [ 0 for _ in range(W) ] for __ in range(H) ]

Center=80*80      #中心地のセット マイナスの値もセットできるようにbitsetのゼロを80*80+1桁目に置く

#初期化
r,c=0,0
val=A[r][c]
dp[r][c]=1<<val+Center

D=[(1,0),(0,1)]

for r in range(H):
    for c in range(W):
        for dr,dc in D: #下に1つ移動したマス、右に1つ移動したマス
            if r+dr<H and c+dc<W:   #下のマス or 右のマスが存在するならばif文内の処理を行う
                next_r=r+dr
                next_c=c+dc
                next_val=A[next_r][next_c]
                dp[next_r][next_c]|=dp[r][c]<<next_val  #次のマスの値が+の場合は、bitshift全体を左にシフト
                dp[next_r][next_c]|=dp[r][c]>>next_val  #次のマスの値が-の場合は、bitshift全体を右にシフト

ans=float("inf")
for i in range(Center*2):
    bit=dp[H-1][W-1]>>i&1
    if bit==1:
        ans=min(ans,abs(i-Center))

print ans


Measured memory_bytes: 44572
n, m, l = map(int, input().split())
a = [[0 for i in range(m)] for j in range(n)] 
b = [[0 for i in range(l)] for j in range(m)] 
c = [[0 for i in range(l)] for j in range(n)]

for i in range(n):
    tmpA = list(map(int, input().split()))
    for j in range(m):
        a[i][j] = tmpA[j]

for i in range(m):
    tmpB = list(map(int, input().split()))
    for j in range(l):
        b[i][j] = tmpB[j]

for i in range(n):
    for j in range(l):
        for k in range(m):
          c[i][j] += a[i][k]*b[k][j]

for i in range(n):
    for j in range(l):
        print(c[i][j], end='')
        if j != l - 1:
            print(' ', end="")
    print()


Measured memory_bytes: 7152
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18 * 5;

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

    int a, b, c;
    cin >> a >> b >> c;
    puts((a+b >= c ? "Yes" : "No"));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int main(){
    ll a;
    cin >> a;
    string s;
    cin >> s;
    int b = s[0] - '0'; // bの整数部分
    int c = (s[2] - '0') * 10 + (s[3] - '0'); // bの小数部分の100倍


    cout << (a * (100 * b + c)) / 100 << endl;

    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	lint n;
	cin>>n;
	vector<lint>a(n),b(n);
	rep(i,n)cin>>a[i]>>b[i];
	sort(all(a));
	sort(all(b));
	lint mmax,mmin;
	if(n%2==0){
		mmin=a[n/2-1]+a[n/2];
		mmax=b[n/2-1]+b[n/2];
		cout<<(mmax-mmin)+1<<endl;
	}else{
		mmin=a[n/2];
		mmax=b[n/2];
		cout<<(mmax-mmin)+1<<endl;
	}
}

Measured memory_bytes: 6368
def men(t):
    xmin = min(st + i * t for i, st in enumerate(mg[0]))
    xmax = max(st + i * t for i, st in enumerate(mg[1]))
    ymin = min(st + i * t for i, st in enumerate(ue[0]))
    ymax = max(st + i * t for i, st in enumerate(ue[1]))
    return (xmax - xmin) * (ymax - ymin)

n = int(input())
inf = 10**9
mg = [[inf, inf, inf], [-inf, -inf, -inf]]
ue = [[inf, inf, inf], [-inf, -inf, -inf]]
mg0=mg[0]
mg1=mg[1]
ue0=ue[0]
ue1=ue[1]
for _ in range(n):
    x, y, d = input().split()
    x = int(x)
    y = int(y)
    if d == "U":
        mv = 1
        uv = 2
    elif d == "D":
        mv = 1
        uv = 0
    elif d == "R":
        mv = 2
        uv = 1
    else:
        mv = 0
        uv = 1
    if x < mg0[mv]: mg0[mv] = x
    if x > mg1[mv]: mg1[mv] = x
    if y < ue0[uv]: ue0[uv] = y
    if y > ue1[uv]: ue1[uv] = y
t=set([0])
for lst in [mg0,mg1,ue0,ue1]:
    v0,v1,v2=lst
    for tk in [v0-v1,v1-v2,(v0-v2)/2]:
        if tk>=0:
            t.add(tk)
print(min(men(tk) for tk in t))

Measured memory_bytes: 3192
int main(){
       int a=0,b=0;
     int i=0;
     int j=0;
       scanf("%d %d",&a,&b);
       for(j=0;j<2;j++){
       if(a>=b)
       {
        i=i+a;
       	a=a-1;
       }
       else
       {
       	i=i+b;
       	b=b-1;
       }
       }
       printf("%d\n",i);
       return 0;
   }

Measured memory_bytes: 128
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)

ll l1,l2;
string s1,s2;
ll dp[2001][2001];//i,j???????????§?????????(I??????)

ll rec(ll x1,ll x2){
	ll res=1;
	if(dp[x1][x2]!=-1) return dp[x1][x2];
	if(x1==l1&&x2==l2) return dp[x1][x2]=0;
	if(x1==l1){
		if(x2<l2-1&&s2[x2]=='I'&&s2[x2+1]=='O') return dp[x1][x2]=rec(x1,x2+2)>0?rec(x1,x2+2)+2:1;
		else if(s2[x2]=='I') return dp[x1][x2]=1;
		else return dp[x1][x2]=0;
	}
	if(x2==l2){
		if(x1<l1-1&&s1[x1]=='I'&&s1[x1+1]=='O') return dp[x1][x2]=rec(x1+2,x2)>0?rec(x1+2,x2)+2:1;
		else if(s1[x1]=='I') return  dp[x1][x2]=1;
		else return dp[x1][x2]=0;
	}
	if(s1[x1]=='O'&&s2[x2]=='O') return dp[x1][x2]=0;
	ll g;
	if((s1[x1]=='I'&&s2[x2]=='O')||(s1[x1]=='O'&&s2[x2]=='I')){
		g=rec(x1+1,x2+1);
		if(g>0) res=max(res,g+2);
	}
	if(x1<l1-1&&s1[x1]=='I'&&s1[x1+1]=='O'){
		g=rec(x1+2,x2);
		if(g>0) res=max(res,g+2);
	}
	if(x2<l2-1&&s2[x2]=='I'&&s2[x2+1]=='O'){
		g=rec(x1,x2+2);
		if(g>0) res=max(res,g+2);
	}
	return dp[x1][x2]=res;
}

int main()
{
	ll ans=0;
	memset(dp,-1,sizeof(dp));
	cin>>l1>>l2;
	cin>>s1>>s2;
	rrep(i,l1){
		rrep(j,l2){
			ans=max(ans,rec(i,j));
		}
	}
	cout<<ans<<endl;
}

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

int main(){
    long long A, V, B, W, T;
    scanf("%lld%lld%lld%lld%lld", &A, &V, &B, &W, &T);

    if(V <= W){
        printf("NO");
        return 0;
    }

    if(abs(A-B) <= T*(V-W)){
        printf("YES");
    }else{
        printf("NO");
    }
}



Measured memory_bytes: 3752
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N, H, W = [ii(), ii(), ii()]
    print((N-H+1)*(N-W+1))


if __name__ == '__main__':
    main()

Measured memory_bytes: 9564
// kid_kb //

#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define ull unsigned long long int
#define lower(str) transform(str.begin(),str.end(),str.begin(),::tolower);
#define upper(str) transform(str.begin(),str.end(),str.begin(),::toupper);
#define mod 1000000007
#define SORT(vec) sort(vec.begin(),vec.end());
#define pb push_back
#define csb __builtin_popcount
#define msb(n) (ll)(log2(n))
#define DIG(n) floor(log10(n))+1
#define kb ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ptr(arr) for(auto i:arr)cout<<i<<" ";
#define ptr2(vec) for(auto i:vec){for(auto j: i){cout<<j<<" ";}cout<<endl;}
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,n,a) for (int i=n-1;i>=a;i--)
#define mem(a,val) memset(a,val,sizeof(a))
#define INF INT_MAX
#define inf INT_MIN

// cout<<fixed<<setprecision(8)<<endl;

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

ll lcm(ll a,ll b)
{    ll g=gcd(a,b); ll ans=(a*b)/g; return ans;    }

ll fastpower(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=fastpower(a,b/2,m); t=(t*t)%m; if(b&1)t=(t*a)%m; return t;}

ll modInverse(ll a, ll m) { return fastpower(a, m-2, m); }

//----------------------------------------Let's Fight-----------------------------------------------------------------

bool solve(){
    ll n,a,b;
    cin>>n;
    int c=0;
    rep(i,0,n){
        cin>>a>>b;
        if(a==b)c++;
        else c=0;
        if(c==3)return true;
    }
    return false;
}

int main()
{
    kb
//  clock_t tStart = clock();
    ll t;
     t=1;
//    cin>>t;
    while(t--){
        if(solve())cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
//  printf("%.2fs time lga\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

typedef long long ll;
typedef double D;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }



int cnt_func(int n) {
	int cnt = 0;
	do {
		cnt += n/5;
		n /= 5;
	} while(n!=0);
	return cnt;
}

int main() {
	int n;
	
	while (cin>>n) {
		if (n==0) break;
		
		cout << cnt_func(n) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime> 
#define full(a) a.begin(), a.end()

#define sz(x) ((ll)(x).size())
#define ll long long
using namespace std;

ll inp() {
    ll n; cin >> n;
    return n;
}

void prvc(vector<ll> vec) {
    for (auto i : vec)cout << i << " ";
    cout << endl;
}

pair<int, int> hat(pair<int, int> l, pair<int, int> r) {
    pair<int, int> ans;
    if (l.first > r.first)swap(l, r);
    if (r.first > l.second) {
        return pair<int, int>(-1, -1);
    }
    ans.first = r.first;
    ans.second = min(l.second, r.second);
    return ans;
}

ll cnm(ll n, ll m) {
    ll k = n - m;
    if (k < m)std::swap(k, m);
    ll l1 = 1;
    for (int i = k + 1; i <= n; i++) {
        l1 *= i;
        if (l1 % m == 0)l1 /= m, m--;
    }
    for (int i = 2; i <= m; i++)
    {
        l1 /= i;
    }
    return l1;
}

void solve() {
    ll n = inp(), x = inp(), t = inp();
    if (n % x) {
        cout << ((n / x) + 1) * t;
    }
    else cout << n / x * t;
    
}

int main()
{
    //ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    //ll n; cin >> n;
    //while (n--)
        solve();

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <map>
#include <cstdio>
#include <iomanip>
#include <list>
#include <set>
using namespace std;

int main(void) {
	int N;
	int a, buf;
	int res = 0;
	a = 100000;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &buf);
		if (buf == a) {
			res++;
			a = 100000;
		}
		else {
			a = buf;
		}

	}


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

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

//***********************************************************************
int MAXNUM = 5e3+5;
vector <int>vis(MAXNUM);
vector<int> pr;
void sieve() {
	pr.push_back(2);
	for(ll i=3;i<MAXNUM;i+=2) if(!vis[i]) {
		pr.push_back(i);
		for(ll j=i*i;j<MAXNUM;j+=2*i) vis[j]=true;
	}
}
//************************************************************************

void solve()
{
	ll n,x,y;
    cin >>n >> x >> y;
    vector<ll> v(n);
    v[n-1]=1;
    for(int i=n-2;i>0;i--)
    {
        v[i]=v[i+1]+1;

    }
   // for(int i=1;i<n;i++)
    //cout << v[i] << endl;
    for(int i=x;i>0;i--)
    {
        for(int j=y;j<=n;j++)
        {
            v[j-i]--;
            v[j-i-(y-x)+1]++;
        }
        for(int j=y-1;j>x;j--)
        {
            if(j-i>(x-i+1+y-j))
            {
                v[j-i]--;
                v[x-i+1+y-j]++;
            }
        }
    }
    for(int i=x+1;i<y;i++)

    {
        for(int j=i+1;j<=n;j++)
        {
            if(j-i>(i-x+1+abs(y-j)))
            {
                v[j-i]--;
                if(j>y)
                {
                    v[i-x+1+j-y]++;
                }
                else
                {
                    v[i-x+1+y-j]++;
                }
            }
        }
    }
    //cout << "check "<< endl;
    for(int i=1;i<n;i++)
    cout << v[i] << endl;
    //cout << "check 2 " << endl;
}


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

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
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; }

const long long INF = 1000000000000000;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n, m,k,l; string s;
char maze[60][60];
int dis[101][101];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main() {
	cin >> n;
	vector<ll> t(n);
	rep(i, n) {
		cin >> t[i];
	}
	cin >> m;
	vector<P> px(m);
	rep(i, m) {
		cin >> px[i].first >> px[i].second;
	}
	rep(i, m) {
		ll res = 0;
		rep(j, n) {
			if (j == px[i].first - 1)res += px[i].second;
			else res += t[j];
		}
		cout << res << endl;
	}
}

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

using namespace std;

int main() {
  string s;
  string t;
   cin>>s;
   cin>>t;
   int flag=0;
  for(int i=0;i<s.size();i++){
      if(s==t){
          flag=1;
          break;
      }
      s=s.back()+s.substr(0,s.size()-1);
  }
  if(flag==1)
  cout<<"Yes";
  else
  cout<<"No";
}


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

int main()
{
int a, b, c;
cin >> a >> b >> c;
for (int iter = 0; iter <= 100000; ++iter)
{
if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1)
{
cout << iter << endl;
return 0;
}
int d = (a + b)/2, e = (a + c)/2, f = (b + c)/2;
a = d, b = e, c = f;
}
cout << -1 << endl;
return 0;
}

Measured memory_bytes: 256
input = gets.chomp.split
r = input[0].to_i
g = input[1].to_i
b = input[2].to_i
n = input[3].to_i

cnt = 0
sum = 0
for i in 0..n/r do
    sum = n
    sum -= r*i
    if sum == 0 
        cnt += 1
    else
        for j in 0..sum/g do
            sum2 = sum
            sum2 -= g*j
            if sum2 == 0 
                cnt += 1
            elsif sum2 % b == 0
                cnt += 1
            end
        end
    end
end

p cnt

Measured memory_bytes: 1788
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U>
inline void cmax(T& a, U b) { if (a < b) a = b; }
template<class T, class U>
inline void cmin(T& a, U b) { if (a > b) a = b; }

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cerr << fixed << setprecision(15);
  }
} io_setup;

constexpr char el = '\n';

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U>& p) {
  os << p.first << " " << p.second;
  return os;
}
template<typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.first >> p.second;
  return is;
}
template<typename T>
ostream &operator<<(ostream &os, const vector< T > &v) {
  rep(i, v.size())
    os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T>
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}
#line 2 "a2.cpp"

int main() {
  ll n;
  cin >> n;
  vl a(n);
  cin >> a;

  a.push_back(a.back());
  ll ans = 0;
  rep(i, n) {
    bool up = a[i] <= a[i+1];
    bool down = a[i] >= a[i+1];
    while (i+1 < n and (up &= a[i] <= a[i+1], down &= a[i] >= a[i+1], up or down)) {
      i++;
    }
    ans++;
  }
  cout << ans << el;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> v(H);
  for(int i = 0; i < H; i++) cin >> v.at(i);
  
  for(int i = 0; i < W + 2; i++) cout << "#";
  cout << endl;
  
  for(int i = 0; i < H; i++) cout << "#" << v.at(i) << "#" << endl;
  
  for(int i = 0; i < W + 2; i++) cout << "#";
  cout << endl;
}
//vec.push_back(x)末尾

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>

using namespace std;

#define forn(i,n) for(int i=0;i<(int)(n); i++)
#define forsn(i,s,n) for(int i=(s);i<(int)(n); i++)

vector<int> parent, rango;

int find(int a){
	if(parent[a]!=a){
		parent[a] = find(parent[a]);
	}
	return parent[a];
}

void uni(int a, int b){
	int pa=find(a);
	int pb=find(b);
	if (rango[pa]>rango[pb]){
		parent[pb]=pa;
	}else{
		parent[pa]=pb;
	}
	if(rango[pb]==rango[pa]){
		rango[pa]++;
	}
}

int main(){
	int n, m;
	cin>>n>>m;
	forn(i, m){
		parent.push_back(i);
		rango.push_back(0);
	}
	bool aparece[m];
	forn(i, m){
		aparece[i]=false;
	}
	forn(i, n){
		int k;
		cin>>k;
		int lp;
		forn(j, k){
			int l;
			cin>>l;
			l--;
			aparece[l]=true;
			if(j==0){
				lp=l;
			}else{
				//cout<<"uno  "<<lp<<"  "<<l<<endl;
				uni(lp, l);
			}
		}
	}
	set<int> ss;
	forn(i, m){
		if(aparece[i]) {
			find(i);
			ss.insert(parent[i]);
		}
	}
	if(ss.size()==1){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
}


Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for(const auto& e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void yn(bool j){cout << (j ? "Yes" : "No") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> long long bcount(T1 v, T2 a){return upper_index(v, a) - lower_index(v, a);} 
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}

ll MAX = 400;

int main(){
    ll X; cin >> X;
    rep(i, MAX) rep(j, MAX){
        if (pow(i, 5) + pow(j, 5) == X){
            pt(i, -j);
            return 0;
        }
        if (pow(i, 5) - pow(j, 5) == X){
            pt(i, j);
            return 0;
        }
    }
}


Measured memory_bytes: 4104
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N,K;
  cin>>N>>K;
  VEC<int>snuke(N,0);
  REP(i,0,K){
    int d;
    cin>>d;
    VEC<int>A(d);
    REP(j,0,d){
      cin>>A[j];
      snuke[A[j]-1]++;
    }
  }
  int cnt=0;
  REP(i,0,N){
    if(snuke[i]==0)cnt++;

  }
  cout<<cnt<<endl;

  return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>
int sum(int money,int week){
	int i;
	int x;
	for(i=0;i<week;i++){
		money=money+money*0.05;
		x=(float)(money/1000.0);
		if(x*1000!=money)money=x*1000+1000;
	}
	return money;
}

main(){
	int week,debt;
	scanf("%d",&week);
	debt=sum(100000,week);
	printf("%d\n",debt);
	return 0;
}

Measured memory_bytes: 0
import Control.Monad
import Control.Applicative
import Data.List

main = do
  ss <- getLine
  putStrLn $ solve ss

solve :: String -> String
solve s = f s
  where
    f [] = []
    f ('p':'e':'a':'c':'h':ss) = 'a':'p':'p':'l':'e': (f ss)
    f ('a':'p':'p':'l':'e':ss) = 'p':'e':'a':'c':'h': (f ss)
    f (x:xs) = x : (f xs)

Measured memory_bytes: 3544