akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int main(void){
	int  n; cin >> n;
	vector<int> v(n);
	rep(i, n)cin >> v[i];
	int k = 0;
	rep(i, n)if (v[i] != i + 1)k++;
	cout << (k > 2 ? "NO" : "YES") << endl;
	return 0;
}

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

int main(){
  int i,j,tmp;
  string s,t;
  cin>>s>>t;
  for(i=0;i<s.size()-1;i++){
    for(j=i+1;j<s.size();j++){
      if(s.at(i)>s.at(j)){
        tmp=s.at(i);
        s.at(i)=s.at(j);
        s.at(j)=tmp;
      }
    }
  }
  for(i=0;i<t.size()-1;i++){
    for(j=i+1;j<t.size();j++){
      if(t.at(i)<t.at(j)){
        tmp=t.at(i);
        t.at(i)=t.at(j);
        t.at(j)=tmp;
      }
    }
  }
  if(s<t){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int ans = 100000000;

int main(){
    vector<vector<int>> c(3,vector<int>(3));
    rep(i,3){
        rep(j,3){
            cin >> c[i][j];
        }
    }
    for (int a1 = 0; a1 <= 100; a1++){
        for (int a2 = 0; a2 <= 100; a2++){
            for (int a3 = 0; a3 <= 100; a3++){
                int b1 = c[0][0] - a1;
                int b2 = c[0][1] - a1;
                int b3 = c[0][2] - a1;
                vector<int> a = {a1,a2,a3};
                vector<int> b = {b1,b2,b3};

                bool isOK = true;
                rep(i,3){
                    rep(j,3){
                        if (c[i][j] != a[i]+b[j]){
                            isOK = false;
                        }
                    }
                }
                if (isOK){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


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

#define endl "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) {
        if (b & 1) res = (res * a) % m;
        a = (a * a) % m; b >>= 1;
    } return res;
}

int now() {
    return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()
    .time_since_epoch()).count();
}

int32_t main() { fastio;
    time_t start = now();

    int a, b;
    cin >> a >> b;
    for (double i = 0; i < 10000; i++) {
        if ((int)(i * 0.08) == a and (int)(i * 0.1) == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    cerr << "TIME => " << now() - start << endl;
    return 0;
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int main()
{
	int n, h, w;
	cin >> n >> h >> w;
	vector<int> a(n), b(n);
	rep(i,n) cin >> a[i] >> b[i];
	int ans = 0;
	rep(i,n){
		if(a[i] >= h && b[i] >= w) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3596
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(){
	int a, b;
	scanf("%d%d", &a, &b);
	if((a-2*b)>=0){
		printf("%d\n", a-2*b);
	}
	else printf("0");
	
	return 0;
}

Measured memory_bytes: 128
#D - Moving_piece
N,K = map(int,input().split())
P =[]
C =[]
P = list(map(int,input().split()))
C = list(map(int,input().split()))

score_output = -1000000000
i = 0
for i in range(N):
    ichi = i
    score = 0
    step  = 0
    loop  = 0
    score_max = -1000000000
    while True:
        step  += 1
        score += C[ichi]
        ichi   = (P[ichi] -1)
        if i ==  (P[ichi] -1):
            score += C[ichi]
            break
        
    path = 0
    cnt  = 0
    
    while True:
        cnt  += 1
        path += C[ichi]
        
        if cnt > K:
            break
        
        loop = int((K - cnt) / (step+ 1))
        if score > 0:
            score_max = path + loop * score
        else:
            score_max = path
        if score_max > score_output:
            score_output = score_max

        ichi   = P[ichi]-1
        if i == (P[ichi] -1):
            break
# 出力
print(score_output)


Measured memory_bytes: 73764
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int H, W;
    cin >> H >> W;
    vector<string>masu(H);
    for (int i=0; i<H; i++) {
        cin >> masu.at(i);
    }

    int x[4] = {0, 0, 1, -1};
    int y[4] = {1, -1, 0, 0};
    bool can_go = true;
    for (int i=0; i<H; i++) {
        for (int j=0; j<W; j++) {
            if (masu[i][j] == '.') continue;
            bool can_idou = false;
            for (int k=0; k<4; k++) {
                int new_y = i + y[k];
                int new_x = j + x[k];
                if (new_y >= H || new_y < 0) continue;
                if (new_x >= W || new_x < 0) continue;
                if (masu[new_y][new_x] == '#') can_idou = true;
            }

            if (!can_idou) {
                can_go = false;
                break;
            }
        }
    }

    if (can_go) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3648
while 1:
    s = input()
    if s == "#":
        break
    y, m, d = map(int, s.split()[1:])
    if (y, m) >= (31, 5):
        print("? {} {} {}".format(y-30, m, d))
    else:
        print("HEISEI {} {} {}".format(y, m, d))



Measured memory_bytes: 5600
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

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

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


int main(){
    int N;
    cin >> N;
    long long A[N],B[N];
    pair<long long,long long> p[N];
    REP(i,N) cin >> A[i] >> B[i],p[i]=make_pair(B[i],A[i]);
    sort(p,p+N);
    long long time=0;
    bool exist=true;
    for(int i=0;i<N;++i){
        time+=p[i].second;
        if(time>p[i].first){
            exist=false;
            break;
        }
    }
    if(exist){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}

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

int main() {
  // ここにプログラムを追記
  int N,A;
  cin >> N >> A;
  int ans;
  int yen = N%500;
  if(yen<=A){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

int main() {
  int H, W, i;
  cin >> H >> W;
  
  for (i = 0; i < W + 2; i++) {
  	cout << "#";
  }
  cout << endl;
  for (i = 0; i < H; i++) {
    string str;
    cin >> str;
    cout << "#" << str << "#" << endl;
  }
  for (i = 0; i < W + 2; i++) {
  	cout << "#";
  }
  cout << endl;
}
  

Measured memory_bytes: 256
def main():
    n=int(input())
    s=input()

    cnt=0
    for i in range(len(s)-2):
        tmp = s[i] + s[i+1] + s[i+2]
        if tmp == 'ABC':
            cnt +=1
    print(cnt)
if __name__=='__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
int main(){
  char name[11];
  int n;
  long int m=0,a=0,r=0,c=0,h=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%s",name);
    if(name[0]=='M'){
      m++;
    }else if(name[0]=='A'){
      a++;
    }else if(name[0]=='R'){
      r++;
    }else if(name[0]=='C'){
      c++;
    }else if(name[0]=='H'){
      h++;
    }
  }
  printf("%ld\n",m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h);
  return 0;
}

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


int main(){
  cout << fixed << setprecision(12);


  double r;
  cin>>r;


  double PI = acos(-1);
  double area = r * r * PI;
  double cir = (r + r) * PI;
  cout<<area<<" "<<cir<<endl;

  
  return 0;
}


Measured memory_bytes: 3288
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b){
    cout << c;
  }
   if(c==b){
    cout << a;
  }
   if(a==c){
    cout << b;
  }
}

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

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

  double sum = 0.0;
  for (int i = 0; i < N; i++) {
    double A = 0.0;
    cin >> A;
    sum += 1.0 / A;
  }

  double ans = 1.0 / sum;
  // 以下の出力方法もある
  cout << setprecision(16) << ans << endl;
  // printf("%.16f", ans);
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace program
{
    class Program
    {
        static void Main()
        {
          var n = Input.ScanIntArray();
          var a = Input.ScanIntArray();
          Array.Sort(a);
          
          int k = 0;
          for(int i=0;i<n[1];i++)
            k += a[a.Length - 1 - i];
          Out(k);
        }
        static public void Out(object s) { Console.WriteLine(s); }
    }
    
    static class Input {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(); }
    }

    static class MyMath {
        public static int DistanceL1(int[] a, int[] b){
            if(a.Length != b.Length) return -1;
            int[] c = new int[a.Length];
            for(int i=0;i<a.Length;i++)
              c[i] = Math.Abs(a[i]-b[i]);
            return c.Sum();
        }

        public static double DistanceL2(int[] a, int[] b){
            if(a.Length != b.Length) return -1;
            int[] c = new int[a.Length];
            for(int i=0;i<a.Length;i++)
              c[i] = (a[i]-b[i])*(a[i]-b[i]);
            return Math.Sqrt(c.Sum());
        }
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


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

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


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    string s; cin >> s;
    ll ans = 0;
    queue<ll> que;
    rep(i, (1 << (s.size()-1))) {
        que.push(-1);
        rep(j, s.size()) {
            if(i & (1 << j)) {
                que.push(j);
                ll t = que.front();
                que.pop();
                string tmp = s.substr(t+1, j-t);
                ans += stoll(tmp);
            }
        }
        ll t = que.front();
        que.pop();
        string tmp = s.substr(t+1, s.size()-t);
        ans += stoll(tmp);
    }
    cout << ans << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 3636
n, c = map(int, input().split())
data = [[0 for i in range(c+1)] for j in range(10**5+2)]
for i in range(n):
    s, t, channel = map(int, input().split())
    data[s][channel] += 1
    data[t+1][channel] -= 1
for i in range(c+1):
    for j in range(1,10**5+2):
        data[j][i] += data[j-1][i]
ans = 0
for i in range(10**5+2):
    sum_channel = 0
    for j in range(c+1):
        if data[i][j] == 1:
            sum_channel += 1
    ans = max(ans, sum_channel)
print(ans) 


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

#define MAX_E 1001
#define MAX_N 101

struct Edge {
  int u, v, cost;
};

Edge es[MAX_E];
int n, m;
int par[MAX_N], rank[MAX_N];

void init_union_find() {
  for(int i=0; i<n; i++) {
    par[i] = i;
    rank[i] = 0;
  }
}

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

bool issame(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;
  
  if(rank[x] < rank[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if(rank[x] == rank[y]) rank[x] ++;
  }
}

bool comp(const Edge &e1, const Edge &e2 ) {
  return e1.cost < e2.cost;
}

int kruskal() {
  sort(es, es + m, comp);
  init_union_find();
  int res = 0;
  for(int i=0; i<m; i++) {
    Edge e = es[i];
    if(!issame(e.u, e.v)) {
      unite(e.u, e.v);
      res += e.cost;
    }
  }
  return res;
}

int main() {
  while(cin >> n >> m && n+m) {
    for(int i=0; i<m; i++) {
      cin >> es[i].u >> es[i].v >> es[i].cost;
    }
    cout << kruskal() << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1184
D, N = map(int, input().split())
if D == 0:
    if N == 100:
        print(101)
    else:
        print(N)
elif D == 1:
    if N == 100:
        print(10100)
    else:
        print(100*N)
else:
    if N == 100:
        print(1010000)
    else:
        print(10000*N)

Measured memory_bytes: 38384
#include <cstdio>
#include <vector>
using namespace std;

const int maxn = 100;
vector<int> G[maxn + 5];
//int book[maxn + 5][maxn + 5];
int n;
int d[maxn + 5];
int f[maxn + 5];
int time = 0;


void dfs(int vertex) {
    d[vertex] = ++time;

    int len = G[vertex].size();
    for(int i = 0; i < len; i++) {
        if(!d[G[vertex][i]]) dfs(G[vertex][i]);
    }

    f[vertex] = ++time;
}

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

    for(int i = 1; i <= n; i++) {
        int num;
        scanf("%d", &num);
        int count;
        scanf("%d", &count);


        while(count--) {
            int temp; scanf("%d", &temp);
            G[num].push_back(temp);
        }
    }
    for(int i = 1; i <= n; i++) {
        if(!d[i]) dfs(i);
    }

    for(int i = 1; i <= n; i++) {
        printf("%d %d %d\n", i, d[i], f[i]);
    }
    return 0;
}

Measured memory_bytes: 2780
#include <iostream>
using namespace std;
int main()
{
    int A,B,C,X;
    int time=0;
    cin >> A >> B >> C >>X;
    for (int i=0;i<=A;i++)
    {
        for (int j=0;j<=B;j++)
        {
            for (int k=0;k<=C;k++)
            {
                if (X==500*i+100*j+50*k) time++;
            }
        }
    }
    cout << time << endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    int ans=0;
    rep(i,n){
      if(i+1<=n-1&&a[i]==a[i+1]){
        ans++;
        a[i+1]=-1;
      }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

int main(){
    char x, y;
    cin >> x >> y;

    if(x > y) cout << ">" << endl;
    else if(x < y) cout << "<" << endl;
    else cout << "=" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 1000000007;

struct UnionFind
{
  vector<int> par;
  vector<int> sz;
  vector<int> es;

  UnionFind(int n = 1)
  {
    init(n);
  }

  void init(int n = 1)
  {
    par.resize(n);
    sz.resize(n);
    es.resize(n);
    for (int i = 0; i < n; ++i)
    {
      par[i] = i;
      sz[i] = 1;
    }
  }

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

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

  void unite(int x, int y)
  {
    x = root(x);
    y = root(y);
    es[x]++;
    if (x == y)
      return;
    if (sz[x] > sz[y])
      swap(x, y);
    par[x] = y;
    sz[y] += sz[x];
    es[y] += es[x];
    return;
  }

  int size(int x)
  {
    return sz[root(x)];
  }

  int esize(int x)
  {
    return es[root(x)];
  }
};

int main()
{
  int64_t N, M, a, b;
  cin >> N >> M;
  UnionFind uf(N);
  for (int i = 0; i < M; i++)
  {
    cin >> a >> b;
    a--, b--;
    uf.unite(a, b);
  }
  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    ans = max(ans, uf.size(i));
  }
  cout << ans << endl;
}

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

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

long lcm(long m, long n) {
    if(m == 0 || n == 0) return(0);
    return((m * n) / gcd(m, n));
}

int main(void) {
    long a, b;
    while(scanf("%ld %ld", &a, &b) != EOF) {
        cout << gcd(a, b) << " " << lcm(a, b) << endl;
    }
    return(0);
}

Measured memory_bytes: 1208
import sys
input = sys.stdin.readline

n = int(input())
edge = {}
tree = [[] for i in range(n)]
color = [0] * (n - 1)
color_par = [-1] * n
for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    tree[a].append(b)
    edge[(a, b)] = i

for i in range(n):
    c = 1
    for v_child in tree[i]:
        if c == color_par[i]:
            c += 1
        color[edge[(i, v_child)]] = c
        color_par[v_child] = c
        c += 1

print(max(color))
print(*color, sep='\n')


Measured memory_bytes: 38520
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int N;
  	cin >> N;
  
  	int a = 0;
  	for(int i=0;i<=10;i++){
    	if(N <= 1000*i){
          a = 1000*i - N;;
        break;
        }
    }
  	
  	cout << a << endl; 
}

Measured memory_bytes: 3624
n = int(input())
a = [int(i) for i in input().split()]
x = 0
for i in range(n):
    if a[i] % 2 == 0:
        if a[i] % 3 != 0 and a[i] % 5 != 0:
            x = 1
            break

if x == 0:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
import java.util.Scanner;
import java.util.Stack;

/**
 * Created by ??\??? on 2016/12/6.
 */
public class Main {
    static boolean isNum(String s){
        char[] array = s.toCharArray();
        int flag = 0;
        if(array[0]=='-'&&s.length()>1)
            flag = 1;
        for (char c : array) {
            if(!Character.isDigit(c)){
                flag--;
            }
            if(flag<0)
                return false;
        }
        return true;
    }
    static int si(String s){
        if(isNum(s))
            return Integer.parseInt(s);
        else {
            return -1000000010;
        }
    }
    static int count(String s,String a,String b){
        if(s.equals("+"))
            return si(a)+si(b);
        if(s.equals("-"))
            return si(b)-si(a);
        if(s.equals("*"))
            return si(a)*si(b);
        if(s.equals("/"))
            return si(b)/si(a);
        return -1000000020;
    }
    static int run(String[] args){
        Scanner scan = new Scanner(System.in);
        String[] lines = scan.nextLine().split(" ");
        Stack<String> vs = new Stack<>();
        //Stack<String> os = new Stack<>();
        for (String s:lines) {
            if(isNum(s))
                vs.push(s);
            else{
                String o = s;
                String a = vs.pop();
                String b = vs.pop();
                String c = String.valueOf(count(o,a,b));
                //System.out.println(a+" "+b+" "+c);
                vs.push(c);
            }
        }
        System.out.println(vs.pop());
        return 0;
    }
    public static void main(String[] args){
        run(args);
        //System.out.println(Integer.parseInt("-1"));
    }
}

Measured memory_bytes: 26160
#x=int(input())
n,m=map(int,input().split())
#xl=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(m)]
pl=list(map(int,input().split()))
ans=0
for i in range(2**n):
    b=bin(i)
    switch=[0 for k in range(10)]
    for j in range(n):
        if ((i >> j) & 1):#二進数iの下から数えてj桁目が1か否か
            switch[j]=1
    flag=True
    for a in range(m):#それぞれのスイッチについてチェック
        templ=l[a]
        k=templ[0]
        count=0
        for t in range(k):
            s=templ[t+1]
            if switch[s-1]==1:
                count+=1
        if count%2!=pl[a]:
            flag=False
            break
    if flag:
        ans+=1
print(ans)

        




Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

int main() {
  int N;
  cin >> N;
  int a[N];
  rep(i,N) cin >> a[i];

  int brk = 0;
  int l = 1;
  rep(i,N) {
    if (l == a[i]) l++;
    else brk++;
  }
  int ans;
  if (l == 1) ans = -1;
  else ans = brk;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
dice = list(map(int, input().split()))
directions = input()


class Dice():
    def __init__(self, dice, directions):
        self.dice = dice
        self.directions = directions

    def get_top(self):
        for direction in self.directions:
            NS = [0, 1, 5, 4]
            WE = [0, 2, 5, 3]
            copy_dice = self.dice[:]

            if direction == 'N':
                for j in range(4):
                    self.dice[NS[j]] = copy_dice[NS[j-3]]
            elif direction == 'S':
                for j in range(4):
                    self.dice[NS[j]] = copy_dice[NS[j-1]]
            elif direction == 'W':
                for j in range(4):
                    self.dice[WE[j]] = copy_dice[WE[j-3]]
            else:
                for j in range(4):
                    self.dice[WE[j]] = copy_dice[WE[j-1]]

        return self.dice[0]

dice_roll = Dice(dice, directions)

print(dice_roll.get_top())


Measured memory_bytes: 5604
#include<iostream>
#include<algorithm>
using namespace std;
int value[1005];
int main() {
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> value[i];
    }
    sort(value, value + n);
    int sum = 0;
    for (int i = 0; i < k; i++) {
        sum += value[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3556
s=input()
if s=="SAT":
    print(1)
elif s=="SUN":
    print(7)
elif s=="MON":
    print(6)
elif s=="TUE":
    print(5)
elif s=="WED":
    print(4)
elif s=="THU":
    print(3)
else:
    print(2)





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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  int a,b,h; cin>>a>>b>>h;
  print((a+b)*h/2);

  return 0;
}

Measured memory_bytes: 256
#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++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
typedef priority_queue<p> pq;
typedef priority_queue<p, vector<p>, greater<p>> gpq;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    vi d(n);
    REP(i, n)
    {
        cin >> d[i];
    }

    ll ans = 0;

    REP(i, n - 1){
        FOR(j, i + 1, n)
        {
            ans += d[i] * d[j];
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,sum;char s[20];
int main(){
	cin>>a>>b>>s;
	if(s[a]!='-'){ cout<<"No";return 0;}
	for(int i=0;i<=a+b;i++){
		if(s[i]<'0'||s[i]>'9') sum++;
		if(sum>1) break;
	}
	if(sum>1) cout<<"No";
	else cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, x, t, ans = 0;
  cin >> n >> x >> t;
  for (int i = 1; i < 1001; i++){
    n = n - x;
    ans = i*t;
    if(n < 1) break;
  }
    cout << ans << endl; 
 
  return 0;
} 

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

int main() {
	int k,s;
	cin >> k >> s;
	int cnt=0;
	for(int i=k; i>=0; i--)
		for(int j=k; j>=0; j--)
			if(s-i-j <= k && s-i-j>=0)
				cnt++;
	cout << cnt;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
 
{
 
  int ai,n,i,b,s;
 
  double w;
 
 
  b=-1000000;
 
 
  s=1000000;
 
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++)
 
 
  {
 
 
    scanf("%d",&ai);
 
 
    if(ai<s)
 
 
    {
 
 
      s=ai;
 
 
    }
 
 
    if(b<ai)
 
 
    {
 
 
      b=ai;
 
 
    }
 
 
    w=w+ai;
 
 
  }
 
 
  printf("%d %d %0.lf\n",s,b,w);
 
 
  return 0;
 
 
}

Measured memory_bytes: 632
import java.util.*;
class Main{
    Scanner sc=new Scanner(System.in);
    void main(){
	int a=sc.nextInt();
	int b=sc.nextInt();
	int c=sc.nextInt();
	if(a==b&&a!=c)System.out.println("Open");
	else System.out.println("Close");
    }
    public static void main(String[]ag){
	new Main().main();
    }
}

Measured memory_bytes: 26288
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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



	string a, b,c;
	cin >> a >> b>>c;
	
	cout << a[0] << b[1] << c[2] << endl;
	return 0;
}



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


using namespace std;


int main() {
    int n;cin>>n;
    int ac = 0, wa = 0, tle = 0 , re = 0;
    for(int i = 0 ; i < n; ++i){
        string s;
        cin>>s;
        if(s == "AC")ac++;
        if(s == "WA")wa++;
        if(s == "TLE")tle++;
        if(s == "RE")re++;
    }
    cout<<"AC x "<<ac<<"\n";
    cout<<"WA x "<<wa<<"\n";
    cout<<"TLE x "<<tle<<"\n";
    cout<<"RE x "<<re<<"\n";





}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,i,k=1,a; scanf("%lld",&n);
  for(i=1;i<=n;i++)
  {
    scanf("%lld",&a); if(a==k)k++;
  }
  if(k==1)cout<<"-1"<<endl;
  else{cout<<n-(k-1)<<endl;}
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.util.function.*;

class Book {
	int cost;
	int[] a;

	Book(int cost, int[] a) {
		this.cost = cost;
		this.a = a;
	}
}

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		int M = Integer.parseInt(sc.get());
		int X = Integer.parseInt(sc.get());
		var references = new Book[N];
		for (int i = 0; i < N; i++) {
			int C = Integer.parseInt(sc.get());
			int[] A = new int[M];
			Arrays.setAll(A, $ -> Integer.parseInt(sc.get()));
			references[i] = new Book(C, A);
		}

		boolean flag = false;
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < 1 << N; i++) {
			var bitSet = BitSet.valueOf(new long[]{i});
			int[] sum = new int[M];
			int cost = 0;
			var iterator = bitSet.stream().iterator();
			while (iterator.hasNext()) {
				int bookIdx = iterator.nextInt();
				var book = references[bookIdx];
				cost += book.cost;
				for (int j = 0; j < M; j++) {
					sum[j] += book.a[j];
				}
			}

			if (Arrays.stream(sum).noneMatch(j -> j < X)) {
				min = Math.min(cost, min);
				flag = true;
			}
		}

		System.out.println(flag ? min : -1);
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

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

int main() {
  int x,n; cin >> x >> n;
  vector<bool> d(102);
  rep(i,n) {
    int p; cin >> p;
    d[p] = true;
  }

  P ans(102,0);
  int di = 102;
  int an = 0;
  rep(i,102) {
    if (d[i]) continue;
    int dif = abs(x-i);
    if (di > dif) {
      di = dif;
      an = i;
    }
  }
  cout << an << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main(){
  int K, A, B;
  bool flag = false;
  cin >> K;
  cin >> A >> B;
  for(int i=A; i<=B; i++){
    if(i%K == 0) flag = true;
  }
  if(flag) cout << "OK" << endl;
  else cout <<"NG" << endl;
  return 0;
}


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

#define REP(i,n)    for(int i = 0; i < (int)n; i++)
#define MAX_N   100000
#define MAX_M   100000


void solve(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    if(n % 2)
        cout << "No\n";
    else{
        REP(i,n/2){
            if(s[i] != s[i+n/2]){
                cout << "No\n";
                return;
            }
        }
        cout << "Yes\n";
    }
}

int main(){
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
//#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll x = n;
  if (x >= b - 1) x = b - 1;
  ll ans = a * x / b - a * (x / b);
  print(ans);
  return 0;
}

Measured memory_bytes: 3640
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

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

template <class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_mset;

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define F0R(i,a) for(int i = 0; i < a; i++)
#define F0Rd(i,a) for (int i = a - 1; i >=0 ; i--)
#define FORd(i,a,b) for (int i = b - 1; i >= a; i--)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define newl '\n'

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define print(x) cout << x << newl;
#define finish(x) return cout << x << "\n", 0;
#define bug(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " " << 

const int MXN = 2e5 + 5;
//const int MXN = 1e6 + 5;
const ll MOD = 998244353;
const ll INF = 1e9 + 7;

int N, A[MXN], B[MXN], C[MXN], dp[MXN][4];

int main(){ FAST
	//ifstream cin("/Users/konwoo/input.txt");
	//ofstream cout("/Users/konwoo/output.txt");

    cin >> N;
    FOR(i,1,N+1){
        cin >> A[i] >> B[i] >> C[i];
    }
    FOR(i,1,N+1){
        dp[i][1] = A[i] + max(dp[i-1][2],dp[i-1][3]);
        dp[i][2] = B[i] + max(dp[i-1][1],dp[i-1][3]);
        dp[i][3] = C[i] + max(dp[i-1][2],dp[i-1][1]);
    }
    finish(max(dp[N][1],max(dp[N][2],dp[N][3])));







	return 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int a; scanf("%d", &a);
	printf("%d\n", 10 - a/200);
}


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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

template<typename T> inline istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> inline ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

template<typename T> inline T min(vector<T>& v) {return *min_element(v.begin(), v.end());}

template<typename T> inline T max(vector<T>& v) {return *max_element(v.begin(), v.end());}

template<typename T> inline void sort(vector<T>& v) {sort(v.begin(), v.end());}

template<typename T, typename Function> inline void sort(vector<T>& v, Function func) {sort(v.begin(), v.end(), func);}

template<typename T> inline void rsort(vector<T>& v) {sort(v.rbegin(), v.rend());}

template<typename T> inline void reverse(vector<T>& v) {reverse(v.begin(), v.end());}

template<typename T> inline void unique(vector<T>& v) {v.erase(unique(v.begin(), v.end()), v.end());}

template<typename T> inline void nth_element(vector<T>& v, int n) {nth_element(v.begin(), v.begin() + n, v.end());}

template<typename T> inline bool next_permutation(vector<T>& v) {return next_permutation(v.begin(), v.end());}

template<typename T> inline int find(vector<T>& v, T t) {return find(v.begin(), v.end(), t) - v.begin();}

template<typename T> inline int in(vector<T> v, T t) {return find(v, t) != (int)v.size();}

template<typename T> inline int lower_bound(vector<T>& v, T t) {return lower_bound(v.begin(), v.end(), t) - v.begin();}

template<typename T> inline int upper_bound(vector<T>& v, T t) {return upper_bound(v.begin(), v.end(), t) - v.begin();}

template<typename T> inline T accumulate(const vector<T>& v, function<T(T, T)> func = plus<T>()) {return accumulate(v.begin(), v.end(), T(0), func);}

template<typename T> inline void adjacent_difference(vector<T>& v) {adjacent_difference(v.begin(), v.end(), v.begin());}

template<typename T> inline void adjacent_difference(vector<T>& v, vector<T>& u) {adjacent_difference(v.begin(), v.end(), u.begin());}

template<typename T> inline void partial_sum(vector<T>& v, vector<T>& u) {partial_sum(v.begin(), v.end(), u.begin());}

template<typename T> inline T inner_product(vector<T>& v, vector<T>& u) {return inner_product(v.begin(), v.end(), u.begin(), T(0));}

template<typename T, typename Function> inline int count_if(vector<T> v, Function func) {return count_if(v.begin(), v.end(), func);}

template<typename T, typename Function> inline void remove_if(vector<T>& v, Function func) {v.erase(remove_if(v.begin(), v.end(), func), v.end());}

template<typename T, typename Function> inline bool any_of(vector<T> v, Function func) {return any_of(v.begin(), v.end(), func);}

template<typename T> inline vector<T> subvector(vector<T>& v, int a, int b) {return vector<T>(v.begin() + a, v.begin() + b);}

int main() {
  vector<int> a(3);
  cin >> a;
  sort(a);
  cout << (a == vector<int>({5, 5, 7}) ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  int64 N, A, B;
  cin >> N >> A >> B;
  if (A == B) {
    cout << 1 << endl;
  } else if (A > B || N == 1) {
    cout << 0 << endl;
  } else {
    cout << (B - A) * (N - 2) + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def print_ans(A, B):
    """Test Case
    >>> print_ans(4, 12)
    16
    >>> print_ans(8, 20)
    12
    >>> print_ans(1, 1)
    2
    """
    if B % A == 0:
        print(A + B)
    else:
        print(B-A)

if __name__ == '__main__':
    A, B = map(int, input().rstrip().split())
    print_ans(A, B)




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

//
// atcoder ABC126 A - Changing a Character
//

void solve(long long N, long long K, std::string S){

    if (S[K-1] == 'A') S[K-1] = 'a';
    if (S[K-1] == 'B') S[K-1] = 'b';
    if (S[K-1] == 'C') S[K-1] = 'c';

    cout << S << "\n";
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::string S;
    std::cin >> S;
    solve(N, K, S);
    return 0;
}


Measured memory_bytes: 256