akhauriyash/Code-Regression huggingface dataset:
#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 VRSORT(v) sort(v.rbegin(), v.rend());//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define OUT(x) cout << x << endl
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};

//Union-Find木
template<size_t NODE_MAX>
struct UnionFindTree
{
    static const int MAX = NODE_MAX;
    int par[NODE_MAX];

    void init(int N)
    {
        //初めはすべて孤立したグループとしてみなす
        for(int i=0; i<N; ++i) {
            par[i] = i;
        }
    }

    int find(int x)
    {
        if(par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }

    bool same(int x, int y)
    {
        return find(x) == find(y);
    }

    void unite(int x, int y)
    {
        x = find(x);
        y = find(y);
        if(x == y) return;
        else par[x] = y;
    }
};

UnionFindTree<2*100000> road,train;
int main(){
  int n,k,l;
  cin >> n >> k >> l;

  road.init(n);
  train.init(n);
  REP(i,k){
    int p,q;
    cin >> p >> q;
    p--;q--;
    road.unite(p,q);
  }

  REP(i,l){
    int r,s;
    cin >> r >> s;
    r--;s--;
    train.unite(r,s);
  }

  map<pair<int,int>, int> cnt;

  for(int i=0;i<n;++i){
    auto p = make_pair(road.find(i),train.find(i));
    cnt[p]++;
  }

  for(int i=0;i<n;++i){
    auto p = make_pair(road.find(i),train.find(i));
    cout << cnt[p] << endl;
  }

  return 0;
}

Measured memory_bytes: 13568
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class AFrog1 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int h[] = new int[n + 1];
            for (int i = 1; i <= n; i++)
                h[i] = in.nextInt();
            int dp[] = new int[n + 1];
            dp[2] = Math.abs(h[2] - h[1]);
            for (int i = 3; i <= n; i++) {
                int cost1 = Math.abs(h[i - 1] - h[i]) + dp[i - 1];
                int cost2 = Math.abs(h[i - 2] - h[i]) + dp[i - 2];
                dp[i] = Math.min(cost1, cost2);
            }
            out.println(dp[n]);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21972
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

ll gcd(ll a,ll b){
    ll temp,m=a*b;
    while(b>0){
        temp=b;
        b=a%b;
        a=temp;
    }
    return m/a;
}

int main(){
    ll a,b,c,d,e; cin>>a>>b>>c>>d;
    e=gcd(c,d);
    cout<<b-a+1-(b/c-(a+c-1)/c+1)-(b/d-(a+d-1)/d+1)+(b/e-(a+e-1)/e+1)<<endl;
}

Measured memory_bytes: 256
// 以下のソースを勉強する.
// zscoder氏.
// https://atcoder.jp/contests/dp/submissions/3937003
#include <bits/stdc++.h>
using namespace std;
using LL = long long;

int dp[3111][3111];
pair<LL, LL> par[3111][3111];

int main(){
    
    // 1. 入力情報取得.
    char s[3111], t[3111];
    scanf("%s %s", s, t);
    int M = strlen(s);
    int N = strlen(t);
    
    // 2. dp更新.
    for(int i = 1; i <= M; i++){
        for(int j = 1; j <= N; j++){
            dp[i][j] = 0;
            if(dp[i - 1][j] >= dp[i][j]) par[i][j] = {i - 1, j}, dp[i][j] = dp[i - 1][j];
            if(dp[i][j - 1] >= dp[i][j]) par[i][j] = {i, j - 1}, dp[i][j] = dp[i][j - 1];
            if(s[i - 1] == t[j - 1] && dp[i - 1][j - 1] + 1 >= dp[i][j]) dp[i][j] = dp[i - 1][j - 1] + 1, par[i][j] = {i - 1, j - 1};
        }
    }
    // for(int i = 0; i <= M; i++){
    //     for(int j = 0; j <= N; j++){
    //         printf("%d ", dp[i][j]);
    //     }
    //     printf("\n");
    // }
    
    // 3. dp情報から, 出力文字を作成.
    pair<LL, LL> cur = {M, N};
    string ans;
    while(cur.first > 0 && cur.second > 0){
        pair<LL, LL> tmp = par[cur.first][cur.second];
        if(tmp.first == cur.first - 1 && tmp.second == cur.second - 1) ans += s[tmp.first];
        cur = tmp;
    }
    reverse(ans.begin(), ans.end());
    
    // 4. 出力.
    printf("%s\n", ans.c_str());
    return 0;
}

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

int main()
{
    char c;
    cin >> c;
    if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')cout << "vowel" << endl;
    else cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

void swap(int *i, int *j)
{
	*i += *j;
	*j = *i - *j;
	*i -= *j;
}

int main(void)
{
	int h[10];
	int i, j;
	
	for (i = 0; i < 10; i++){
		scanf("%d", &h[i]);
	}
	
	for (i = 0; i < 3; i++){
		for (j = i + 1; j < 10; j++){
			if (h[i] < h[j]){
				swap(&h[i], &h[j]);
			}
		}
		printf("%d\n", h[i]);
	}
	
	return (0);
}

Measured memory_bytes: 600
#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) std::sort(v, v+n);
#define VSORT(v) std::sort(v.begin(), v.end());
#define VRSORT(v) std::sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define ALL(obj) (obj).begin(),(obj).end()

using namespace std;

const int INF = 99999999;
const ll LINF = 9999999999999;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


ll n;
vector<ll> a;


int main() {
	cin >> n;
	REP(i, n) {
		ll tmp;
		cin >> tmp;
		a.push_back(tmp);
	}

	VRSORT(a)

	ll alice = 0, bob = 0;

	REP(i, n) {
		if (i % 2 == 0) alice += a[i];
		else bob += a[i];
	}

	cout << alice - bob << endl;

	return 0;
}

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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<vector<pair<int, ll>>> t(n + 1, vector<pair<int, ll>>());

    int a, b;
    ll c;
    for (int i = 0; i < n - 1; i++) {
        cin >> a >> b >> c;
        t[a].push_back(make_pair(b, c));
        t[b].push_back(make_pair(a, c));
    }

    int q, k;
    cin >> q >> k;

    vector<ll> length(n + 1, -1);
    length[k] = 0;

    deque<tuple<int, ll, ll>> deq;
    for (const auto x : t[k]) {
        deq.emplace_back(x.first, x.second, 0);
    }

    while (!deq.empty()) {
        auto x = deq.back(); deq.pop_back();
        length[get<0>(x)] = get<1>(x) + get<2>(x);
        for (const auto y : t[get<0>(x)]) {
            if (length[y.first] < 0) {
                deq.emplace_back(y.first, y.second, length[get<0>(x)]);
            }
        }
    }

    int x, y;
    for (int i = 0; i < q; i++) {
        cin >> x >> y;
        cout << length[x] + length[y] << endl;
    }
}


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

int n;
int ks[114514];
char buf[114514];
char ans[114514];
vector<char> cs;
map<char, int> rev;

int main() {
  for (int i=0; i<26; i++) cs.push_back('a'+i);
  for (int i=0; i<26; i++) cs.push_back('A'+i);
  for (int i=0; i<52; i++) {
    rev[cs[i]] = i;
  }

  while (1) {
    scanf("%d", &n);
    if (n == 0) return 0;

    for (int i=0; i<n; i++) {
      scanf("%d", &ks[i]);
    }
    scanf(" %s", buf);

    int k = strlen(buf);
    for (int i=0; i<k; i++) {
      int idx = rev[buf[i]];
      ans[i] = cs[(52+idx-ks[i%n])%52];
    }
    ans[k] = '\0';
    puts(ans);
  }
}

Measured memory_bytes: 3244
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N, M; cin >> N >> M;
    cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>

using namespace std;

int main() {
    int N;
    cin >> N;
    long long sum = 0;
    for(int i = 1; i <= N; i++) {
        if(i % 3 != 0 && i % 5 != 0) {
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3632
n, k = list(map(int, input().split()))

mae1 = 0
mae2 = 0
mae3 = 0

def calc(n, k):
    return abs(n-k)

if n > k:
    n = n % k

while(mae1!=n):
    n = calc(n, k)
    mae1 = mae2
    mae2 = mae3
    mae3 = n
    
print(min(mae1, mae2))

Measured memory_bytes: 38256
#!/usr/bin/python3
# -*- coding: utf-8 -*-


N = int(input())
Bn = list(map(int, input().split()))

An = [10**5 for _ in range(N)]
An[0] = Bn[0]
An[-1] = Bn[-1]
for i in range(1,N-1):
  An[i] = min(Bn[i],Bn[i-1])
print(sum(An))

Measured memory_bytes: 38256
#include <iostream>
#include <stdio.h>

class Dice4{
public:
    int number[6];

    void roll(char dst){
        switch(dst){
        case 'E':
            setNumber(number[3],number[1],number[0],number[5],number[4],number[2]);
            break;
        case 'N':
            setNumber(number[1],number[5],number[2],number[3],number[0],number[4]);
            break;
        case 'S':
            setNumber(number[4],number[0],number[2],number[3],number[5],number[1]);
            break;
        case 'W':
            setNumber(number[2],number[1],number[5],number[0],number[4],number[3]);
            break;
        }
    };

    bool isSameDice(int inputed[]){
        char order[25] = "NNNNWNNNWNNNENNNENNNWNNN";
        for(int i = 0; i < 24; i++){
            roll(order[i]);
            for(int j = 0; j < 6; j++){
                if(inputed[j] != number[j])
                    break;
                if(j == 5)
                    return true;
            }
        }
        return false;
    }

private:
    void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
        number[0] = n0;
        number[1] = n1;
        number[2] = n2;
        number[3] = n3;
        number[4] = n4;
        number[5] = n5;
    }

};

int main(int argc, const char * argv[]) {
    int n, k, j;
    scanf("%d",&n);
    Dice4 array[n];
    for(int i = 0; i < n; i++){
        scanf("%d %d %d %d %d %d", &array[i].number[0], &array[i].number[1], &array[i].number[2],
                &array[i].number[3], &array[i].number[4], &array[i].number[5]);
    }
    for(k = 0; k < n-1; k++){
        for(j = k+1; j < n; j++){
            if(array[k].isSameDice(array[j].number))
                break;
        }
        if(j < n) break;
    }
    if(k == n-1){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 3132
n = int(input())
a, b = map(int, input().split())
li_p = list(map(int, input().split()))

print(
    min(
        len(list(filter(lambda x: x <= a, li_p))),
        len(list(filter(lambda x: (a + 1) <= x <= b, li_p))),
        len(list(filter(lambda x: (b + 1) <= x, li_p))),
    )
)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll A, B;
    cin >> A >> B;
    cout << max(0ll, A-2*B) << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{

    class Program
    {
        static void Main(string[] args)
        {
            var N = RL();
            var cnt = 0;
            if (N.Contains("R")) cnt = 1;
            if (N.Contains("RR")) cnt = 2;
            if (N.Contains("RRR")) cnt = 3;

            Console.WriteLine(cnt);
            Console.ReadLine();

        }

        static IEnumerable<int> RL2IE() { return spr(RL()).Select(x => (int)c2i(x)); }
        static string RL() { return Console.ReadLine().Trim(); }
        static IEnumerable<string> spr(string s) { return s.Split(' '); }
        static Int64 c2i(string c) { return Int64.Parse(c); }
        //static double c2d(string c) { return double.Parse(c); }
        static string bool2ret(bool b) { return b ? "Yes" : "No"; }
    }
}


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

typedef long long ll;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define INF (1<<30)

int main() {
	int N;
	cin >> N;
	vector<double> x(N);
	vector<string> u(N);
	string btc = "BTC";
	double ans=0;
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> u[i];
		if (u[i] == btc) {
			ans += 380000 * x[i];
		}
		else {
			ans += x[i];
		}
		cerr << ans << endl;
	}

	printf("%.10f\n", ans);

}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))

for n_iter in range(k):
    b = [0] * n
    for i in range(n):
        left = max(0, i - a[i])
        right = min(n-1, i + a[i])
        b[left] += 1
        if right + 1 < n: 
            b[right + 1] -= 1

    a[0] = b[0]
    for i in range(1, n):
        b[i] += b[i-1]
        a[i] = b[i]
    
    if n_iter >= 50:
        break

print(*a)

Measured memory_bytes: 168172
N = int(input())
P = list(map(int, input().split()))

ans  = 0

for i in range(N-2):
	if (P[i] < P[i+1] and P[i+1] < P[i+2]) or (P[i] > P[i+1] and P[i+1] > P[i+2]):
		ans += 1

print(ans)

Measured memory_bytes: 3060
print_cnt = int(input())

result = [0] * 10000

for x in range(100):
  for y in range(100):
    for z in range(100):
      if x*y*z == 0:
        continue
      tmp = x*x + y*y + z*z + x*y + y*z + z*x
      if tmp <= 10000:
        result[tmp-1] += 1

for i in range(print_cnt):
  print(result[i])

Measured memory_bytes: 9244
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define mo 974711
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N,M,S,T;
struct node {
    int to,next;
    int64 val;
}E[MAXN * 2];
int head[MAXN],sumE,id[MAXN],on,dp[2][MAXN],ans;
int64 dis[2][MAXN];
bool vis[MAXN];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void add(int u,int v,int64 c) {
    E[++sumE].to = v;
    E[sumE].next = head[u];
    E[sumE].val = c;
    head[u] = sumE;
}
priority_queue<pair<int64,int> > Q;
void dijkstra(int u,int64 *d) {
    for(int i = 1 ; i <= N ; ++i) d[i] = 1e18;
    memset(vis,0,sizeof(vis));
    d[u] = 0;
    Q.push(mp(-d[u],u));
    while(!Q.empty()) {
	pair<int64,int> now = Q.top();Q.pop();
	if(vis[now.se]) continue;
	int u = now.se;
	vis[u] = 1;
	for(int i = head[u] ; i ; i = E[i].next) {
	    int v = E[i].to;
	    if(!vis[v] && d[v] > d[u] + E[i].val) {
		d[v] = d[u] + E[i].val;
		Q.push(mp(-d[v],v));
	    }
	}
    }
}
bool cmp(int a,int b) {
    return dis[on][a] < dis[on][b];
}
void Process() {
    for(int i = 1 ; i <= N ; ++i) id[i] = i;
    sort(id + 1,id + N + 1,cmp);
    dp[on][id[1]] = 1;
    for(int i = 1 ; i <= N ; ++i) {
	int u = id[i];
	for(int j = head[u] ; j ; j = E[j].next) {
	    int v = E[j].to;
	    if(dis[on][v] - dis[on][u] == E[j].val) {
		dp[on][v] = inc(dp[on][v],dp[on][u]);
	    }
	}
    }
}
void Solve() {
    read(N);read(M);
    read(S);read(T);
    int u,v;int64 d;
    for(int i = 1 ; i <= M ; ++i) {
	read(u);read(v);read(d);
	add(u,v,d);add(v,u,d);
    }
    dijkstra(S,dis[0]);
    dijkstra(T,dis[1]);
    on = 0;Process();
    on = 1;Process();
    ans = mul(dp[0][T],dp[0][T]);
    for(int u = 1 ; u <= N ; ++u) {
	for(int i = head[u] ; i ; i = E[i].next) {
	    int v = E[i].to;
	    if(dis[0][u] + dis[1][v] + E[i].val == dis[0][T]) {
		if(dis[1][v] + E[i].val - dis[0][u] > 0 && dis[1][v] + E[i].val - dis[0][u] < 2 * E[i].val) {
		    ans = inc(ans,MOD - mul(mul(dp[0][u],dp[1][v]),mul(dp[1][v],dp[0][u])));
		}
	    }
	}
	if(dis[0][u] == dis[1][u]) {
	    ans = inc(ans,MOD - mul(mul(dp[0][u],dp[1][u]),mul(dp[0][u],dp[1][u])));
	}
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 13808
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, m; cin >> n >> m;
	
	ll ans = 1 << m;
	cout << ans * (1900 * m + 100 * (n - m)) << endl;
	
	return 0;
}

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

class Point{
	public:
		int x;
		int y;
};

class Treasure : public Point{
	public:
		bool get;
		Treasure();
};

Treasure::Treasure(){
	get = false;
}

int main(){
	int N;	//# of treasure
	int M;	//# of command
	char direction;
	int move;	//移動距離
	int num; //見つけた宝の数

	do	{
		cin >> N;
		if (N == 0){
			break;
		}

		Point Robot;
		Robot.x = 10;
		Robot.y = 10;
		
		int oldx;
		int oldy;

		Treasure* T = new Treasure[N];

		for (int i = 0; i < N; i++){
			cin >> T[i].x >> T[i].y;
		}

		num = 0;

		cin >> M;
		// 命令を読んで宝を探す
		for (int j = 0; j < M; j++){
			cin >> direction >> move;
			switch (direction){
				case 'N':
					oldy = Robot.y;
					Robot.y += move;
					for (int i = 0; i < N; i++){
						if (T[i].get == false && T[i].x == Robot.x && oldy <= T[i].y && T[i].y <= Robot.y){
							T[i].get = true;
							num++;
						}
					}
					break;
				case 'E':
					oldx = Robot.x;
					Robot.x += move;
					for (int i = 0; i < N; i++){
						if (T[i].get == false && T[i].y == Robot.y && oldx <= T[i].x && T[i].x <= Robot.x){
							T[i].get = true;
							num++;
						}
					}
					break;
				case 'S':
					oldy = Robot.y;
					Robot.y -= move;
					for (int i = 0; i < N; i++){
						if (T[i].get == false && T[i].x == Robot.x && oldy >= T[i].y && T[i].y >= Robot.y){
							T[i].get = true;
							num++;
						}
					}
					break;
				case 'W':
					oldx = Robot.x;
					Robot.x -= move;
					for (int i = 0; i < N; i++){
						if (T[i].get == false && T[i].y == Robot.y && oldx >= T[i].x && T[i].x >= Robot.x){
							T[i].get = true;
							num++;
						}
					}
					break;
				default:
					break;
			}
		}

		if (num == N){
			cout << "Yes" << endl;
		}
		else{
			cout << "No" << endl;
		}

	} while (N != 0);
	
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <limits>
#include <map>
#include <stack>
#include <queue>

using namespace std;
using ll = long long;

int main() {

    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int moves_t = (C + B - 1) / B;
    int moves_a = (A + D - 1) / D;

    if (moves_t <= moves_a) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 3640
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//
//

#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 ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__

int dN(int a){
  int n=0;
  while(a>0){
    n++;
    a /=10;
  }
  return n;
}

void solve(void){
  
  int N;
  cin >> N;
  
  vector<int> H(N);
  
  bool flag=true;
  
  REP(i,N){
    cin >> H[i];
  }
  H[0]--;
  REP2(i,1,N){
    if(H[i]-H[i-1]>=1){
      H[i]--;
    }
    else if(H[i]-H[i-1]<0)
    {
      flag=false;
      break;
    }
  }

  puts(flag?"Yes":"No");
 
  
  return;
   
}

#define TESTCASES	1

int main(int argc, const char * argv[]) {

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

  	REP(i,TESTCASES){
    	solve();
    } 
  
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
using ll = long long;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<int> aa(a), bb(b), cc(c);
	for (auto& v: aa) {
		cin >> v;
	}
	for (auto& v: bb) {
		cin >> v;
	}
	for (auto& v: cc) {
		cin >> v;
	}
	sort(aa.begin(), aa.end(), greater<int>());
	sort(bb.begin(), bb.end(), greater<int>());
	sort(cc.begin(), cc.end(), greater<int>());
	multiset<int> st;
	for (int i = 0; i < x; ++i) {
		st.insert(aa[i]);
	}
	for (int i = 0; i < y; ++i) {
		st.insert(bb[i]);
	}
	for (auto v: cc) {
		if (v > (*st.begin())) {
			st.erase(st.begin());
			st.insert(v);
		}
	}
	ll ans = 0;
	for (auto v: st) {
		ans += v;
	}
	cout << ans << endl;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 3050;
int r,c,k,x,y,val;
ll dp[MAX][MAX][4];
ll room[MAX][MAX];
int main() {
    cin>>r>>c>>k;
    while(k--){
        cin>>x>>y>>val;
        room[x][y]=val;
    }
    for(int i=1;i<=r;i++){
        for(int j=1;j<=c;j++){
            for(int k=1;k<=3;k++){
                dp[i][j][k]=max(max(room[i][j]+dp[i-1][j][3],dp[i][j-1][k]),room[i][j]+dp[i][j-1][k-1]);
            }
        }
    }
    cout<<dp[r][c][3];
    return 0;
}


Measured memory_bytes: 361052
import functools

N = int(input())
l = [None] * N

def cmp1(l, r):
   
    if l[0] < r[0]:
        return -1
    elif l[0] == r[0]:
        if l[1] == r[0]:
            return 0
        elif l[1] < r[1]:
            return 1 
        else:
            return -1
    else:
        return 1
        
    
for i in range(N):
    city, rate = input().split()
    l[i] =  city, int(rate), i+1


l.sort(key=functools.cmp_to_key(cmp1))

for _, _, idx in l:
    print(idx)

Measured memory_bytes: 38256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())
    M = 61
    C = [0] * M
    for a in A:
        a = str(format(a, 'b'))
        for i, d in enumerate(reversed(a)):
            if d == '1':
                C[i] += 1

    ans = 0
    p = 1
    for c in C:
        ans = (ans + c * (N - c) * p) % MOD
        p = p * 2 % MOD

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 136452
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define repi(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,a) repi(i,0,a)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define repit(i,a) for(__typeof((a).begin()) i=(a).begin();i!=(a).end();i++)

#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)),(u).end())

#define pb push_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define PI acos(-1.0)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
string s;
int pos;
int and2(int a, int b) {
    if( a==2 and b == 2) return 2;
    if(a == 0 or b == 0) return 0;
    return 1;
}

int or2(int a, int b) {
    if(a==2 or b==2) return 2;
    if(a==0 and b==0) return 0;
    return 1;
}

int form() {
    if(s[pos] == '-') {
        pos++;
        return 2 - form();
    } else if(s[pos] == '(') {
        pos++;
        int a = form();
        char ope = s[pos];
        pos++;
        int b = form();
        pos++;
        if(ope == '*') return and2(a, b);
        else return or2(a, b);
    } else {
        return s[pos++] - '0';
    }
}

int main()
{
    string rs;
    while(getline(cin, rs), rs != ".") {
        int ans = 0;
        rep(p, 3) rep(q, 3) rep(r, 3) {
            pos = 0;
            s = rs;
            rep(i, s.size()) {
                if(rs[i] == 'P') s[i] = p + '0';
                else if(rs[i] == 'Q') s[i] = q + '0';
                else if(rs[i] == 'R') s[i] = r + '0';
            }
            if(form() == 2) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1192
A,B,M=gets.split.map(&:to_i)
as=gets.split.map(&:to_i)
bs=gets.split.map(&:to_i)

min = as.min + bs.min
M.times do
    x,y,c=gets.split.map(&:to_i)
    t = [as[x-1] + bs[y-1] - c,0].max
    min = t if t < min
end

puts min


Measured memory_bytes: 18572
#include "bits/stdc++.h"

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define FORV(a, A) for (auto &a : A)

using namespace std;
using ll = long long;
using P = pair<int, int>;

void Main() {
  int n;
  cin >> n;
  int mn = n + 1;
  int ans = 0;
  rep(i, n) {
    int p;
    cin >> p;
    if (p > mn) continue;
    ans++;
    mn = p;
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define ll long long
#define ll long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int k;
    cin >> k;
    if(k == 1) 
    {
        cout << "0\n";
        return 0;
    }
    else if(k == 2)
    {
        cout << "1\n";
        return 0;
    }
    map<int, int> m;
    int z = k-1;
    for(int i=2;i<=(int)sqrtl(k+ 10);i++)
    {
        while(z%i == 0)
        {
            m[i]++;
            z/=i;
        }
    }
    if(z > 1) m[z]++;
    int num = 1;

    for(auto i: m)
        num *= (i.second + 1);
    num--; // remove 1
    for(int i=2;i<=(int)sqrtl(k+10);i++)
    {
        if(k%i == 0)
        {
            int temp = k/i;
            while(temp%i == 0)
                temp/=i;
            if(temp%i == 1)
            {
                num++;
            }
        }
    }
    num++; // for number itself
    cout << num << "\n";


    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <set>
using namespace std;
typedef long long ll;
set<long long> s[2];
ll solve(ll n,ll k){
    if(n<k) return n;
    if(n%k==0) return solve(n/k,k);
    return n%k;
}

int main(){
    long long i,n,cnt = 0;
    cin >> n;
    for(i=1;i*i<=n;i++){
        if(n%i==0){
            s[0].insert(i); s[0].insert(n/i);
        }
    }
    for(i=1;i*i<=n - 1;i++){
        if((n - 1)%i==0){
            s[1].insert(i); s[1].insert((n - 1)/i);
        }
    }
    for(long long x:s[1]){
        if(s[0].count(x)==0){
            cnt++;
        }
    }
    for(long long x:s[0]){
        if(x==1) continue;
        if(solve(n,x)==1) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 512
/*input

*/
#include<bits/stdc++.h>
//priority_queue<ll, vector<ll>, std::greater<ll> > q;
//gcc 1.cpp -lstdc++ -o main.o
#define ull                 unsigned long long
#define ll                         long long
#define M                         1000000007
#define pb                         emplace_back
#define p_q                 priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define all(a)      (a).begin(),(a).end()
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b))/gcd((a),(b))
#define ios                    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp                         make_pair
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define F first
#define S second
#define N 200005
using namespace std;


int main(void)
{
        ios
        ll n;
        cin>>n;
        char c1;
        string s1 = "";
        ll t1;
        while (n > 0){
                //cout<<n%26<<"\n";
                n--;
                t1 = n%26;
                // if (t1 == 0)
                //         t1 = 26;


                c1 = 'a' + (t1);
                s1.push_back(c1);
                n = n/26;
        }
        reverse(all(s1));
        cout<<s1;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    string S;
    cin >> S;
    
    if(S.length() == 2)     cout << S << "\n";
    if(S.length() == 3){
        reverse(S.begin(), S.end());
        cout << S << "\n";
    }
}

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


int tab[N][N],K1[N][N],K2[N][N];
int PT[N][N],PK[N][N];
int PZ[N][N],PN[N][N];

 int main()
 {
	int n,m,i,j,q;
	char k;
	scanf("%d%d%d",&n,&m,&q);
	scanf("%c",&k);

	for(i=1;i<=n;i++)
	{
		PZ[i][0]=0;

		for(j=1;j<=m;j++)
		{
			PN[0][j]=0;

			scanf("%c",&k);
			tab[i][j]=k-'0';
		}

		scanf("%c",&k);
	}

	int z;
	for(i=1;i<=n;i++)
	{
		//printf("\n");
		for(j=1;j<=m;j++)
		{	
			z=0;	
			if(tab[i][j]==1&&tab[i-1][j]==1) z+=1, PZ[i][j]=PZ[i][j-1]+1;
			else PZ[i][j]=PZ[i][j-1];
			
			if(tab[i][j]==1&&tab[i][j-1]==1) z+=1, PN[i][j]=PN[i-1][j]+1;
			else PN[i][j]=PN[i-1][j];

			PK[i][j]=PK[i][j-1]-PK[i-1][j-1]+z+PK[i-1][j];

			PT[i][j]=PT[i][j-1]+PT[i-1][j]+tab[i][j]-PT[i-1][j-1];

		//	printf("|%d| ",PZ[i][j]);
		}
		//printf("\n");
	}

	int a,b,c,d,wn;
	while(q--)
	{
		scanf("%d%d%d%d",&a,&b,&c,&d);
		if(b>d) swap(b,d);
		if(a>c) swap(a,c);

		wn=0;
		wn=PK[c][d]-PK[c][b-1]-PK[a-1][d]+PK[a-1][b-1];

		//printf("!%d %d %d %d %d!\n",wn,a,b,c,d);

		wn-=(PN[c][b]-PN[a-1][b]);
		wn-=(PZ[a][d]-PZ[a][b-1]);

		printf("%d\n",PT[c][d]-PT[c][b-1]-PT[a-1][d]+PT[a-1][b-1]-wn);
	}
 }


Measured memory_bytes: 82816
/*starting with the name of almighty ALLAH*/
/*solved by RAKIB JOY*/
// Practice is the only shortcut to improve
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define vc vector
#define vi vc<int>
#define vl vc<ll>
#define dbg(x) cout<<x<<endl;
#define mp(x,y) make_pair(x,y)
#define yes dbg("YES")
#define no dbg("NO")
#define tst int t;cin>>t;while(t--)
#define srt(v) sort(v.begin(),v.end());
#define rsrt(v) sort(v.begin(),v.end(),greater<int>());
#define rj ios::sync_with_stdio(false);cin.tie(0);
#define rvs(v) reverse(v.begin(),v.end());
#define F first
#define S second
#define mod 1000000007
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define PI 2*acos(0.0)
#define pii pair<int,int>
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define coutv(v) for(auto it:v)cout<<it<<' ';cout<<endl;
#define cinv(v) for(auto &it:v)cin>>it;
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using ordered_set =tree<T, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>;
*/
//sieve bool b[1000005];void primenire(){int i, j;b[0]=true;b[1]=true;for(i=4; i<=1000000; i+=2){b[i]=true;}for(i=3; i<=1001; i+=2){if(!b[i]){for(j=i*i; j<=1000001; j+=2*i){b[j]=true;}}}}
//power ll power(ll a,ll b){if(b==0) return 1LL;if(b&1) return a*power(a,b-1);else return power(a,b/2)*power(a,b/2);}
//bigmod long long int m(long long int a,long long int b,long long int c){if(b==0)return 1;if(b%2==0){long long int  tmp=m(a,b/2,c);return ((tmp%c)*(tmp%c))%c;}elsereturn ((a%c)*(m(a,b-1,c)%c))%c;}
//MaxSubarraySum ll mss(vector<ll>v){ll mx=v[0];ll sz=v.size();for(int i=1;i<=sz;i++){ll t=v[i]+v[i-1];if(t>=v[i]) v[i]=t;mx=max(mx,v[i]*1LL);}return mx;}
//combination ll com[1001][1001];void combination(){com[1][1]=1;com[1][0]=1;for(ll i=2; i<=1000; i++){com[i][0]=1;for(ll j=1; j<=i; j++){com[i][j]=com[i-1][j]+com[i-1][j-1];}}}
///--------------Graph Moves--------------------------------------
///const int fx[] = {+1,-1,+0,+0};
///const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

void solve()
{
   ll a;
   cin>>a;
   cout<<(a^1)<<endl;
}
int main()
{
    rj
    solve();



    return 0;
}



Measured memory_bytes: 3632
import math
def I():
  return input()
def II():
  return int(input())
def MII():
  return map(int, input().split())
def LMII():
  return list(map(int, input().split()))
def P(s):
  return print(s)

a,b = MII()
h,w=MII()
P((a-h)*(b-w))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>

using namespace std;

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

	for (int i = 0; i < 9; ++i) {
		if (N % (9 - i) == 0) 
			if (N / (9 - i) < 10) {
				cout << "Yes" << endl;
				return 0;
			}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
#include <cstdio>

const int kMaxn = 1e5 + 10;

int n;
int con[kMaxn];

int main() {
	scanf("%d", &n);

	int k = 0, pw = 1;
	for (; pw < n; ++k, pw <<= 1);
	if (pw == n) {
		puts("No");
		return 0;
	} else puts("Yes");

	puts("1 2");
	puts("2 3");
	printf("3 %d\n", n + 1);
	printf("%d %d\n", n + 1, n + 2);
	printf("%d %d\n", n + 2, n + 3);
	con[2] = n + 2, con[3] = 3;
	if (n == 3) return 0;
	for (int i = 4; i < n; i += 2) {
		printf("%d %d\n", i, i + 1);
		printf("%d %d\n", i, n + 1);
		printf("%d %d\n", n + 1, n + i + 1);
		printf("%d %d\n", n + i + 1, n + i);
		con[i] = i, con[i + 1] = n + i + 1;
	}
	if (n & 1 ^ 1) {
		for (int i = 2; i < n; i++) {
			if ((n ^ 1 ^ i) < n) {
				printf("%d %d\n", n, con[i]);
				printf("%d %d\n", con[n ^ 1 ^ i], n + n);
				break;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 3072
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
from collections import Counter

def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    m = max(a)
    s = sorted(a)[-2]
    for i in a:
        if i == m:
            print(s)
        else:
            print(m)

if __name__=="__main__":
    main()


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

int main() {
    int n;cin>>n;
    vector<int> dp(3);
    // dp[i] - the total cost such that we did activity i on the last considered day
    for(int day = 0; day < n; ++day) {
        vector<int> new_dp(3, 0);
        vector<int> c(3);
        for(int i = 0; i < 3; ++i) {
            scanf("%d", &c[i]);
        }
     for(int i = 0; i < 3; ++i) {
            for(int j = 0; j < 3; ++j) {
                if(i != j) {
                    new_dp[j] = max(new_dp[j], dp[i] + c[j]);
                }
            }
        }
        dp = new_dp;
    }
   cout<<max({dp[0], dp[1], dp[2]});
}

Measured memory_bytes: 256
n, m, p = list(map(int, input().split()))
# a = list(map(int, input().split()))
#
#  abc = [int(input()) for i in range(5)]
# a = int(input())
# w = list(map(int, input().split()))
# n, k = list(map(int, input().split()))
# a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# q = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
# bc = [list(map(int, input().split())) for i in range(q)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))
arui = [0]
for i in range(n):
    arui.append(arui[i]+a[i])

brui = [0]
for i in range(m):
    brui.append(brui[i]+b[i])

ans = 0
j = m
for i in range(n+1):
    if arui[i] > p:
        break
    bmax = p-arui[i]
    while brui[j] > bmax:
        j -= 1
    if ans <= i+j:
        ans = i+j


print(ans)


Measured memory_bytes: 47432
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    H, W = map(int, input().split())
    S = stdin.read().splitlines()

    grid = [[0] * W for _ in [0] * H]
    if S[0][0] == '#':
        grid[0][0] = 1

    for c in range(1, W):
        if S[0][c] == '#' and S[0][c-1] == '.':
            grid[0][c] = grid[0][c-1] + 1
        else:
            grid[0][c] = grid[0][c-1]

    for r in range(1, H):
        if S[r][0] == '#' and S[r-1][0] == '.':
            grid[r][0] = grid[r-1][0] + 1
        else:
            grid[r][0] = grid[r-1][0]

    for r in range(1, H):
        for c in range(1, W):
            if S[r][c] == '#':
                if S[r-1][c] == '.':
                    a = grid[r-1][c] + 1
                else:
                    a = grid[r-1][c]
                if S[r][c-1] == '.':
                    b = grid[r][c-1] + 1
                else:
                    b = grid[r][c-1]
                grid[r][c] = min(a, b)
            else:
                grid[r][c] = min(grid[r-1][c], grid[r][c-1])
    print(grid[-1][-1])


main()


Measured memory_bytes: 3188
# import numpy as np

A_init = 500
B_init = 100
C_init = 50

A_n = int(input())
B_n = int(input())
C_n = int(input())

X = int(input())

cnt = 0
for a in range(A_n+1):
    if A_init * a <= X:
        for b in range(B_n+1):
            if (A_init * a + B_init * b) <= X:
                for c in range(C_n+1):
                    if (A_init * a + B_init * b + C_init * c) == X: cnt += 1
            else:
                break
    else:
        break
# print(np.count_nonzero([k+[i for i in All_list] == X for k in All_list]))
print(cnt)

Measured memory_bytes: 9108
#include <iostream>
#include <sstream>
#include <fstream>

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>

#include <algorithm>
#include <numeric>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
// #include <unordered_map>
#include <set>
#include <utility>
#include <bitset>
#include <limits>
#include <climits>
using namespace std;

#ifdef DEBUG
#define NDEBUG
#include "cout11.h"
#endif
#undef NDEBUG
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

int solve(int K) {
    priority_queue<ii> pq;

    vector<int> vis(K, 0);

    pq.push(ii(-1, 1));
    while (!pq.empty()) {
        ii p = pq.top(); pq.pop();
        int cnt = -p.first, curr = p.second;
        if (curr == 0) return cnt;

        vis[curr] = 1;
        int next = (curr + 1)% K;
        if (vis[next] == 0)
            pq.push(ii(-(cnt+1), next));

        next = (curr * 10) % K;
        if (vis[next] == 0)
            pq.push(ii(-cnt, next));
    }
}

int main() {

    int K; cin >> K;

    cout << solve(K) << endl;
    return 0;
}


Measured memory_bytes: 9324
N=int(input())
A=input()
B=input()
C=input()
cnt=0
for i in range(N):
    if A[i]!=B[i]and B[i]!=C[i]and C[i]!=A[i]:
        cnt+=2
    if A[i]==B[i]and C[i]!=A[i] and C[i]!=B[i]:
        cnt+=1
    if B[i]==C[i]and A[i]!=B[i] and A[i]!=C[i]:
        cnt+=1
    if C[i]==A[i]and B[i]!=A[i] and B[i]!=C[i]:
        cnt+=1
print(cnt)

Measured memory_bytes: 3064
#include<algorithm>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<stack>
#include<string>
#include<deque>
#include<queue>
#include<vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll mod = 1e9+7;
const double PI = acos(-1);  // PI = 3.141593...

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

    rep(i, S.size()) {
        if (i%2 == 0 && S[i] == 'L') {
            cout << "No" << endl;
            return 0;
        }
        else if(i%2 == 1 && S[i] == 'R') {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A, B;
    for (int i = 0; i < M; ++i)
    {
        int a, b;
        cin >> a >> b;
        A.push_back(a);
        B.push_back(b);
    }
    int *ans = new int[N]{0};
    for (int i = 0; i < M; ++i)
    {
        ++ans[A[i] - 1];
        ++ans[B[i] - 1];
    }
    for (int i = 0; i < N; ++i)
    {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 3616