akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

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


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

	vector<vector<int>> colors;

	colors.push_back(vector<int>(1, a[0]));

	for(int i=1; i<N; i++) {
		//cout << "a[" << i << "] " << a[i] << ' '; 
		if(a[i]<=colors[colors.size()-1][colors[colors.size()-1].size()-1]) {
			colors.push_back(vector<int>(1, a[i]));
			//cout << "i: " << i << endl;
		} else {	
			//cout << "     i: " << i << ' ';
			int left=-1; 
			int right=colors.size();
			int mid;
			while(left+1<right) {
				mid = (left+right)/2;
				if(a[i]<=colors[mid][colors[mid].size()-1]) {
					left = mid;
				} else {
					right = mid;
				}
			}
			//cout << "mid " << right << endl;
			colors[right].push_back(a[i]);
		}
	}

	cout << colors.size() << endl;
  return 0;
}


Measured memory_bytes: 7220
a, b, c, d = gets.chomp.split('').map(&:to_i)
oprators = %w(+ -)
oprators.each do |op1|
  oprators.each do |op2|
    oprators.each do |op3|
      s = "#{a}#{op1}#{b}#{op2}#{c}#{op3}#{d}"
      if eval(s) == 7
        puts "#{s}=7"
        exit
      end
    end
  end
end


Measured memory_bytes: 1916
#include <iostream>

using namespace std;

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

    if (b - a > 2 && k - a + 1 >= 0) {
        cout << a + (b - a) * ((k - a + 1) / 2) + ((k - a + 1) % 2 == 1 ? 1 : 0) << endl;
    } else {
        cout << k + 1 << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back 
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef vector<ut> VI;
const int SIZE=1+1e+6;
LL getly[SIZE];
VI nums;
LL b[SIZE];
int main(){
	LL N,M,a,c;
	cin >> N;
	REP(i,N){
		scanf("%lld",&a);
		nums.PB(a);
	}
	sort(BE(nums));
	int now=0;
	while(now!=nums.size() && nums[now]==0) now++;
	FOR(i,1,SIZE){
		getly[i]=getly[i-1];
		while(now!=nums.size() && nums[now]==i) {
			getly[i]+=(LL)i;
			now++;
		}
	}
	cin >> M;
	REP(i,M)
		scanf("%lld",&b[i]);
	REP(i,M){
		scanf("%lld",&c);	
		if(getly[b[i]]>=c) printf("Yes\n");
		else printf("No\n");

	}
}

Measured memory_bytes: 17464
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x;i<=y;i++)
const int N=262144;
struct Node{int x,y;}a[N];
Node merge(Node x,Node y){
	if(x.x<y.x)std::swap(x,y);
	Node answer=x;answer.y=std::max(answer.y,y.x);
	return answer;
}
int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	int n;
	std::cin>>n;
	int p=1<<n;
	rep(i,0,p-1){
		int x;
		std::cin>>x;
		a[i]={x,-0x7f7f7f7f};
	}
	rep(j,0,n-1)rep(i,0,p-1)if(i>>j&1)a[i]=merge(a[i],a[i^(1<<j)]);
	int answer=a[0].x+a[0].y;
	rep(k,1,p-1){
		answer=std::max(answer,a[k].x+a[k].y);
		std::cout<<answer<<'\n';
	}
	return 0;
}

Measured memory_bytes: 5664
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a == b) {
            System.out.println(c);
        } else if (a == c) {
            System.out.println(b);
        } else {
            System.out.println(a);
        }
    }
}


Measured memory_bytes: 21844
N = int(input())
F = [list(map(int, input().split())) for i in range(N)]
P = [list(map(int, input().split())) for i in range(N)]

ans = -10 ** 10

def calc(b):
    p = 0
    for i in range(N):
        c = 0
        for j in range(10):
            c += F[i][j] * b[j]
        p += P[i][c]
    return p

def dfs(b):
    global ans
    if len(b) == 10:
        if max(b) == 0:
            return
        ans = max(ans, calc(b))
        return
    dfs(b + [0])
    dfs(b + [1])

dfs([0])
dfs([1])
print(ans)


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

ll pow(ll x,ll y){
    if(y<=0){return 1;}
    if(y%2==0){ll d = pow(x,y/2);return d*d;}
    else{return (x*pow(x,y-1));}
}

int main(){
    int n,p;
    cin >> n >> p;
    vector<int> a(n);
    REP(i,n){
        cin >> a[i];
    }
    ll res = 0;
    ll cnt0 = 0;
    ll cnt1 = 0;
    REP(i,n){
        if(a[i]%2==0)cnt0++;
        else cnt1++;
    }
    if(cnt1==0){
        if(p==0){
            res = pow(2,cnt0);
        }else{
            res = 0;
        }
    }else{
        res = pow(2,cnt0+cnt1-1);
    }
    put(res);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[1000000];
int main() {
	int n,k,ans = 0;
	cin >> n >> k;
	for(int i = 1;i <= n;i ++) {
		cin >> a[i];
	}
	sort(a + 1,a + n + 1);
	for(int i = n;i >= n - k + 1;i --) {
		ans += a[i];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(){
  long long n;
  scanf("%lld", &n);
  long long ans = 0;
  ans += n / 11 * 2;
  n %= 11;
  if (n > 0) {
    if(n <= 6) ans++;
    else ans += 2;
  } 
  printf("%lld\n", ans);
  return 0;
}


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

int main(){
  char b;
  cin >> b;

  switch(b){
    case 'A':
      cout << 'T' << endl;
      break;
    case 'G':
      cout << 'C' << endl;
      break;
    case 'C':
      cout << 'G' << endl;
      break;
    case 'T':
      cout << 'A' << endl;
      break;
  }
}

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

int main() {
    int N,K;cin>>N>>K;
    vector<int> H(N);
    for (int i = 0; i < N; i++){
        cin>>H[i];
    }
    sort(H.begin(),H.end());
    ll ans=0;
    for (int i = 0; i < N-K; i++){
        ans+=H[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4108
# include <algorithm>
# include <cmath>
# include <cstdio>
# include <iostream>
# include <vector>
using namespace std;

static const double eps = 1e-10;

int N;

bool eq(double a, double b) {return fabs(a - b) < eps;}
struct Point 
{
	double x, y;
};
Point operator -(Point a, Point b){return (Point) {a.x - b.x, a.y - b.y};}
int compx(const Point & a, const Point & b) {return eq(a.x, b.x) ? a.y < b.y : a.x < b.x;}
int compy(const Point & a, const Point & b) {return eq(a.y, b.y) ? a.x < b.x : a.y < b.y;}
double norm(Point a) {return a.x * a.x + a.y * a.y;}
double abs(Point a) {return sqrt(norm(a));}
Point p[100050];

double ClosestPair(Point * p, int n)
{
	if(n <= 1) return 1e9;
	int m = n / 2;
	double tx = p[m].x;
	double d = min(ClosestPair(p, m), ClosestPair(p + m, n - m));
	inplace_merge(p, p + m, p + n, compy);
	vector<Point> q;
	for(int i = 0; i < n; i++)
	{
		if(fabs(tx - p[i].x) >= d) continue;
		for(int j = q.size() - 1; ~ j; j--)
		{
			Point v = p[i] - q[j];
			if(v.y >= d) break;
			d = min(d, abs(v));
		}
		q.push_back(p[i]);
	}
	return d;
}

int main()
{
	scanf("%d", & N);
	for(int i = 0; i < N; i++) scanf("%lf%lf", & p[i].x, & p[i].y);
	sort(p, p + N, compx);
	printf("%.11lf\n", ClosestPair(p, N));
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  int d = N % 10;
  int c = (N - d)/10 % 10;
  int b = (N - d - 10 * c)/100 % 10;
  int a = (N - d - 10 * c - 100 * b)/1000 % 10;
  if ((a == b && b == c) || (b == c && c == d)){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

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

	int N;
	cin >> N;
	int cnt = 0;
	int ans = 0;
	int pre = -1;
	for (int i = 0; i < N; i++) {
		int h;
		cin >> h;
		if (h <= pre) {
			cnt++;
		}
		else {
			cnt = 0;
		}
		pre = h;
		ans = max(ans, cnt);
	}
	puts(ans);
	return 0;
}



Measured memory_bytes: 256
#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\n";
  else cout << "consonant\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    const char true_S[17] ="CODEFESTIVAL2016";
    char S[17]; cin >> S;
    int ans=0;
    for(int i=0;i<17;++i){
        if(S[i]!=true_S[i]) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s3=["abb","a.d","ccd"]

s = [["abcc", "abdd", "ddba", "ccba"],
["dccdd", "daa.c", "c..bc", "c..bd", "ddccd"],
["abbc..", "a.ac..", "bba.cc", "a..aab", "a..b.b", ".aabaa"],
["aba....","aba....","bab....","bab....","a..bbaa","a..aabb",".aabbaa"]]
if n == 2:
    print(-1)
elif n == 3:
    [print(x) for x in s3]
else:
    d, m = divmod(n, 4)
    d -= 1
    m += 4
    for i in range(d):
        [print("." * 4 * i + x + "." * (4 * (d - i - 1) + m)) for x in s[0]]
    [print("." * 4 * d + x) for x in s[m - 4]]


Measured memory_bytes: 39812
N, M = [int(s) for s in input().split()]

def main():
    n = N
    m = M
    d = 1000000007
    if abs(n - m) > 1:
        print(0)
        return
    n, m = (m, n) if n > m else (n, m)
    ans = 1
    for i in range(1, n + 1):
        ans *= i ** 2
        ans = ans % d
    last_n = 2 if n == m else m
    ans = ans * last_n % d
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
/* ***********************************************
Author        :Tisuama
Created Time  :2017年09月16日 星期六 20时05分51秒
File Name     :B.cpp
************************************************ */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
#define REPF( i , a , b ) for ( int i = a ; i <= b ; ++ i )
#define CLEAR( a , x ) memset ( a , x , sizeof a )  
const int INF=0x3f3f3f3f;
typedef long long LL; 
const int maxn=1e5+100;
int n,k;
int X[maxn/100];

int main()
{
    while(~scanf("%d%d",&n,&k))
    {
        for(int i=1;i<=n;i++)
            scanf("%d",&X[i]);
        sort(X,X+1+n);
        int sum=0;
        for(int i=1;i<=n;i++)
        {
            if(abs(X[i])<=abs(X[i]-k))
                sum+=2*X[i];
            else
                sum+=2*abs(X[i]-k);
        }
        printf("%d\n",sum);
    }
}


Measured memory_bytes: 256
from collections import deque
def bfs(n):
    ans = 0
    queue = deque([3,5,7])

    while queue:
        num = queue.popleft()

        if num > n:
            return ans

        for i in [3,5,7]:
            queue.append(num*10+i)

        st = str(num)
        if '3' in st and '5' in st and '7' in st:
            ans += 1


n = int(input())
print(bfs(n))

Measured memory_bytes: 12528
using System;
using System.IO;

class Solve
{
    static void Main(string[] args) {
        var S = Console.ReadLine();
        var answer = 0;
        var temp = 0;
        for (int i = 0; i < 3; i++) {
            if (S[i] == 'R') temp++;
            else {
                answer = Math.Max(answer, temp);
                temp = 0;
            }
        }
        answer = Math.Max(answer, temp);
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();
    }
}

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

struct Card {char suit, value;};

void bubble_sort(struct Card arr[], int n)
{
    int num=0, index=0;
    bool flag = true;

    while (flag) {
        flag = false;
        for (int j=n-1; j>=index+1; --j) {
            if (arr[j-1].value > arr[j].value) {
                swap(arr[j-1], arr[j]);
                num++;
                flag = true;
            }
        }
        index++;
    }
}
void selection_sort(struct Card arr[], int n)
{
    int
        result=0,
        minv;
    //print result!
    for (int i=0; i<n; ++i) {
            minv = i;
        for (int j=i; j<n; ++j) {
            if (arr[j].value < arr[minv].value) {
                minv = j;
            }
        }
        swap(arr[i], arr[minv]);
    }
}
void output(struct Card arr[], int n)
{
    for (int i=0; i<n; ++i) {
        if (i) cout << " ";
        cout << arr[i].suit << arr[i].value;
    }
    cout << endl;
}
bool isStable(struct Card C1[], struct Card C2[], int n)
{
    for (int i=0; i<n; ++i) {
        if (C1[i].suit != C2[i].suit) return false;
    }
    return true;
}

int main()
{
    Card
        C1[100],
        C2[100];
    int n;

    cin >> n;
    for (int i=0; i<n; ++i) {
        cin >> C1[i].suit >> C1[i].value;
    }

    for (int i=0; i<n; ++i) C2[i] = C1[i];

    bubble_sort(C1, n);
    selection_sort(C2, n);

    output(C1, n);
    cout << "Stable" << endl;
    output(C2, n);
    if (isStable(C1, C2, n)) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }

    return 0;
}



Measured memory_bytes: 3104
N, C = list(map(int, input().split()))
sushi = [list(map(int, input().split())) for i in range(N)]


def solve():
    normal = [sushi[0][1] - sushi[0][0]]
    n_append = normal.append
    cur = normal[0]
    n_max = normal[0]
    for (s1_pos, s1_cal), (s2_pos, s2_cal) in zip(sushi, sushi[1:]):
        cur += s2_cal - (s2_pos - s1_pos)
        if n_max < cur:
            n_max = cur
        n_append(n_max)

    reverse = [sushi[-1][1] - (C-sushi[-1][0])]
    r_append = reverse.append
    cur = reverse[0]
    r_max = max(0, reverse[0])
    for (s1_pos, s1_cal), (s2_pos, s2_cal) in zip(sushi[::-1], sushi[-2::-1]):
        cur += s2_cal - (s1_pos-s2_pos)
        if r_max < cur:
            r_max = cur
        r_append(r_max)

    result= 0
    for i, (pos, cal) in enumerate(sushi[:-1]):
        result = max(result, normal[i], normal[i]-pos+reverse[N-2-i])
    for i, (pos, cal) in enumerate(sushi[:0:-1]):
        result = max(result, reverse[i], reverse[i]-(C-pos)+normal[N-2-i])
    result = max(result, normal[-1], reverse[-1])

    print(result)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38228
/*بسم الله الرحمن الرحيم*/
/*“Dengan menyebut nama Allah yang Maha Pengasih lagi Maha Penyayang”*/
/*“In the name of Allah, Most Gracious, Most Merciful”*/
/********************************************************************************************************\__
                                                                                                          |
        author  :   Althafa Dhia Syauqi   ||    email   :    daltafa@gmail.com                              ||
        SMAN 10 Samarinda, Kalimantan Timur.                                                    ||
                                                                                                          ||
/********************************************************************************************************/
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define rep_k(i,n) for(int x=i;x<n;x++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_n(i,n) for(int i=1;i<=(n);i++)
#define rep_all(k) for(auto x:k)
#define endl '\n'
#define mod 1e9+7
#define pb push_back
#define READ(f)         freopen(f, "r", stdin)
#define WRITE(f)        freopen(f, "w", stdout)
#define maxSort         sort(all(v),greater<int>())
#define rSort           sort(v.rbegin(),v.rend())
#define FOREACH(i,c) for (typeof((c).end()) i = (c).begin(); i != (c).end(); ++i)
#define RESET(c,v) memset(c, v, sizeof(c))
#define sqr(x)          ((x)*(x))
#define qube(x)         ((x)*(x)*(x))
using namespace std;
void optimization()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
ll x,y,a,b;
int main()
{
	optimization();
	cin >> x>>y>>a>>b;
	cout <<(x-a)*(y-b)<<endl;
    return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

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

int main(){
  int w,a,b;cin >> w >> a >> b;
  if(b <= a+w && a <= b+w){
    cout << 0 << endl;
  } else if(a+w < b){
    cout << b - (a+w) << endl;
  } else {
    cout << a - (b+w) << endl;
  }
}



Measured memory_bytes: 3604
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
cand=a[1]
for i in range(1,n-1):
  if abs(a[0]/2 - a[i]) > abs(a[0]/2 - a[i+1]):
    cand = a[i+1]
  else:
    break
print(a[0], cand)

Measured memory_bytes: 19996
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         String lol = st.nextToken();
         if(lol.charAt(1) == 'B')
            System.out.println("ARC");
         else
            System.out.println("ABC");
      }
   }

Measured memory_bytes: 32432
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef unsigned long long ull;

const int MOD = 1000000007 ; //  , 1000000009 , 1000000023 ,998244353
const ll INF = ll(1e18);
const ld PI = 4*atan((ld)1);

ll power(ll x,ll n) {
  ll result=1;
  while(n>0){
    if(n&1)result = ((result) * (x));
    
    x=((x)*(x));
    
    n >>= 1;
  }
  return result;
}
ll gcd(ll a,ll b){
  if(a==0)return b;
  return gcd(b%a,a);
}

int main() {
  #ifdef AVI  
    freopen("input.txt" , "r" , stdin);
  #endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  
  ll n;
  cin >> n;
  string s;
  cin >> s;
  ll res = 1;
  for(ll i=1 ; i<n ; i++){
    res += (s[i]!=s[i-1]);
  }
  cout << res;
}

Measured memory_bytes: 512
#2次元配列の定義
H,W=input().split()
H=int(H)
W=int(W)
s = [[0 for c in range(W)] for r in range(H)]
#配列へ入力
for r in range(H):
    tempH=input()
    for c in range(W):
        s[r][c]=tempH[c]

for r in range(H):
    for c in range(W):
        if s[r][c]=='#': #黒塗りのマスなら、検証開始
            if r!=0:
                if s[r-1][c]=='#': #上のマスが黒塗りマスかどうか判定。
                    continue #このマスはOKなので、ループ続ける
            if r!=(H-1):
                if s[r+1][c]=='#': #下のマスが黒塗りマスかどうか判定。
                    continue #このマスはOKなので、ループ続ける
            if c!=0:
                if s[r][c-1]=='#': #左のマスが黒塗りマスかどうか判定。
                    continue #このマスはOKなので、ループ続ける
            if c!=(W-1):
                if s[r][c+1]=='#': #右のマスが黒塗りマスかどうか判定。
                    continue #このマスはOKなので、ループ続ける
            #途中でループを抜けられない=このマスはNG
            print('No')
            break
    else:
        continue
    break
else:
    #途中最後まで中断せずに検証できた=Yes判定
    print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) begin(x), end(x)
using namespace std;
typedef long long ll;
typedef pair <int,int> P;

int main(){
  int h,w,k;
  cin>>h>>w>>k;
  char c[10][10];
  int ans=0;
  rep(i,h) rep(j,w){
    cin>>c[i][j];
  }
  rep(bits1,1<<h){
    rep(bits2,1<<w){
      int cnt=0;
      rep(i,h){
	rep(j,w){
	  if(!((bits1>>i)&1) || ((bits2>>j)&1)) continue;
	  if(c[i][j]=='#') {
	    cnt++;
	  }
	}
      }
      if(cnt==k) {
	ans++;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3548
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}

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

解説=============================================================
累積和を想定する。
 
 全ての要素の符号が一致していれば累積和の要領で条件を満たすことができる
 
 符号を全て一致させるには、一番絶対値の大きい要素を全ての要素に足し合わせれば良い
 
 よって、足し合わせる作業、　累積和を作る作業で 2*N-1 回の操作となり条件を満たす
================================================================
*/

void solve(){
    ll N; cin >> N;
    vector<ll> a(N); for(auto &in:a) cin >> in;
    cout << 2*N-1 << endl;
    ll absmax = -1; bool Sign = false; ll loc = -1;
    for(int i = 0; i < N;i++){
        if(abs(a[i]) > absmax){
            absmax = abs(a[i]);
            Sign = (a[i] >= 0)?true:false;
            loc = i+1;
        }
    }
    for(int i = 1; i <= N; i++){
        cout << loc << " " << i << endl;
    }
    if(Sign){
        for(int i = 1; i < N;i++){
            cout << i << " " << i + 1 << endl;
        }
    }else{
        for(int i = N; i > 1; i--){
            cout << i << " " << i - 1 << endl;
        }
    }
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000007 //1000000000000000003
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  int N;
  cin >> N;

  int a[N],b[N],c[N-1];

  rep(i,N){
    cin>>a[i];
  }
  rep(i,N){
    cin>>b[i];
  }
  rep(i,N-1){
    cin>>c[i];
  }

  int ans=0;

  rep(i,N-1){
    ans+=b[i];
    if(a[i+1]==a[i]+1){
      ans+=c[a[i]-1];
    }
  }
  ans+=b[N-1];

  cout<< ans<<"\n";

}


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


Measured memory_bytes: 256
import numpy as np

def factorization(N):
    a = []
    for i in range(1,int(np.sqrt(N))+1):
        if N%i == 0:
            a.append(i)
    for j in range(len(a)):
        a.append(N//a[j])
    a.sort(reverse=True)
    return a

N,M = map(int,input().split())
f = factorization(M)
for i in f:
    if i <= M/N:
        print(i)
        exit()

Measured memory_bytes: 14516
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> R(M);
  for (int i = 0; i < M; i++){
    int A, B;
    cin >> A >> B;
    R[i] = make_pair(B, A);
  }
  sort(R.begin(), R.end());
  int c = 0;
  int ans = 0;
  for (int i = 0; i < M; i++){
    if (R[i].second >= c){
      c = R[i].first;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int W,H,i,j;cin>>W>>H;
	static int dp[1001][1001];
	//1001^2のメモリを確保するので実質square1001(は?)
	static int yk[1001][1001]={};
	static int te[1001][1001]={};
	for(i=0;i<H;i++){
		for(j=0;j<W;j++){cin>>dp[i][j];}
	}
	for(i=0;i<H;i++){
		int gen=0;
		for(j=W-1;j>=0;j--){gen+=dp[i][j];yk[i][j]=gen;}
	}
	for(j=0;j<W;j++){
		int gen=0;
		for(i=H-1;i>=0;i--){gen+=dp[i][j];te[i][j]=gen;}
	}
	for(i=0;i<=H;i++){dp[i][W]=0;}
	for(j=0;j<=W;j++){dp[H][j]=0;}
	for(i=H-1;i>=0;i--){
		for(j=W-1;j>=0;j--){
			if((i+j)%2==0){dp[i][j]=max(dp[i+1][j]+yk[i][j],dp[i][j+1]-te[i][j]);}
			else{		   dp[i][j]=min(dp[i+1][j]+yk[i][j],dp[i][j+1]-te[i][j]);}
		}
	}
	cout<<abs(dp[0][0])<<endl;
	return 0;
}



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

int main()
{
	int n, m; cin >> n >> m;
	int X, Y; cin >> X >> Y;

	vector<int> x(n); for (int i = 0; i < n; i++) cin >> x[i];
	vector<int> y(m); for (int i = 0; i < m; i++) cin >> y[i];

	string ans = "War";

	for (int i = -100; i <= 100; i++) {

		bool flag1 = false;
		bool flag2 = false;
		bool flag3 = true;
		bool flag4 = true;

		if (X < i) flag1 = true;

		if (i <= Y) flag2 = true;
	
		for (int j = 0; j < n; j++) {

			if (!(x[j] < i)) flag3 = false;

		}
		for (int j = 0; j < m; j++) {

			if (!(i <= y[j])) flag4 = false;
							
		}

		bool flagAll = flag1 && flag2 && flag3 && flag4;

		if (flagAll) {
			ans = "No War";
			break;
		}

	}

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

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
def factor(n, m=None):
    # mを与えると、高々その素因数まで見て、残りは分解せずにそのまま出力する
    arr = {}
    temp = n
    M = int(-(-n**0.5//1))+1
    if m is not None:
        M = min(m+1, M)
    for i in range(2, M):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt

    if temp!=1:
        arr[temp] = 1

    if not arr:
        arr[n] = 1

    return arr
from collections import defaultdict
d = defaultdict(int)
for i in range(2, n+1):
    dd = factor(i)
    for k,v in dd.items():
        d[k] += dd[k]
n74 = sum(v>=74 for v in d.values())
n2 = sum(v>=2 for v in d.values())
n24 = sum(v>=24 for v in d.values())
n14 = sum(v>=14 for v in d.values())
n4 = sum(v>=4 for v in d.values())
ans = n74 + (n2-1)*n24 + (n4-1)*n14 + (n4*(n4-1)//2 * (n2-2) if n4>=1 else 0)
print(ans)

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

int main() {
        int n;
        scanf("%d", &n);
        vector<pair<int, int>> val;
        long long as = 0, bs = 0;
        rep(i, n) {
                int a, b;
                scanf("%d%d", &a, &b);
                val.emplace_back(a, i);
                val.emplace_back(b, i);
                as += a;
                bs += b;
        }
        long long ans = min(as, bs);
        sort(val.begin(), val.end());
        long long sum = 0;
        rep(i, n) {
                sum += val[i].first;
        }
        vector<int> idx(n, -1);
        vector<int> pos(2 * n);
        bool ok = false;
        rep(i, 2 * n) {
                int p = val[i].second;
                if (idx[p] == -1) {
                        idx[p] = i;
                } else {
                        int j = idx[p];
                        pos[i] = j;
                        pos[j] = i;
                        if (i < n && j < n) {
                                ok = true;
                        }
                }
        }
        if (ok) {
                ans = min(ans, sum);
        } else {
                rep(i, n) {
                        if (pos[i] != n) {
                                ans = min(ans, sum - val[i].first + val[n].first);
                        } else {
                                ans = min(ans, sum - val[i].first + val[n + 1].first);
                        }
                }
        }
        printf("%lld\n", ans);
        return 0;
}


Measured memory_bytes: 2928
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
before = None
ans = 0
for ai in a[::-1]:
    i = ai-1
    ans += b[i]
    if i+1 == before:
        ans += c[i]
    before = i
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <math.h>
#include <cmath>
#include <limits>
#include <iostream>
#include <assert.h>

#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=10000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	int x,y,cost;
};
int main(){

	ll a,b,k;
	cin>>a>>b>>k;

	if(a>=k)cout<<a-k<<" "<<b<<endl;
	else if(b>=(k-a))cout<<"0"<<" "<<b-k+a<<endl;
	else cout<<"0"<<" "<<"0"<<endl;

	return 0;

}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <deque>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#define ll              long long
#define PII             pair<int, int>
#define rep(i,a,b)      for(int  i=a;i<=b;i++)
#define dec(i,a,b)      for(int  i=a;i>=b;i--)
using namespace std;
int dir[4][2] = { { 0,1 } ,{ 0,-1 },{ 1,0 },{ -1,0 } };
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf = 0x3f3f3f3f;
const double pi = 3.14159265358979323846;
const double eps = 1e-6;
const int mod =1e9+7;
const int N = 1e5+5;
//if(x<0 || x>=r || y<0 || y>=c)

inline ll read()
{
	ll x = 0; bool f = true; char c = getchar();
	while (c < '0' || c > '9') { if (c == '-') f = false; c = getchar(); }
	while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
	return f ? x : -x;
}
ll gcd(ll m, ll n)
{
	return n == 0 ? m : gcd(n, m % n);
}
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}
bool prime(int x) {
    if (x < 2) return false;
    for (int i = 2; i * i <= x; ++i) {
        if (x % i == 0) return false;
    }
    return true;
}
ll qpow(ll m, ll k, ll mod)
{
    ll res = 1, t = m;
    while (k)
    {
        if (k & 1)
            res = res * t % mod;
        t = t * t % mod;
        k >>= 1;
    }
    return res;
}      

int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>> a(n+1);
    vector<int> in(n + 1),dp(n+1);
    rep(i, 1, m)
    {
        int u, v;
        cin >> u >> v;
        a[u].push_back(v);
        in[v]++;
    }
    queue<int> q;
    rep(i, 1, n)
    {
        if (!in[i])
            q.push(i);
    }
    while (!q.empty())
    {
        int f = q.front();
        q.pop();
        for (int i = 0; i < a[f].size(); i++)
        {
            int to = a[f][i];
            in[to]--;
            if (!in[to])
            {
                dp[to] = dp[f] + 1;
                q.push(to);
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
        ans = max(ans, dp[i]);
    cout << ans << endl;
    return 0;
}



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

using namespace std;

int N, L;
vector<pair<int, int> > IciclesInfo;
int DpTime[100002];

void solve() {
	int curId;

	for (int i = 0; i < N; ++i) {
		curId = IciclesInfo[i].second;
		if (DpTime[curId - 1] == 0 && DpTime[curId + 1] == 0) {
			DpTime[curId] = L - IciclesInfo[i].first;
			continue;
		}
		if (DpTime[curId - 1] > DpTime[curId + 1]) {
			DpTime[curId] = DpTime[curId - 1] + L - IciclesInfo[i].first;
		}
		else {
			DpTime[curId] = DpTime[curId + 1] + L - IciclesInfo[i].first;
		}
	}
}

int main() {
	int a;

	memset(DpTime, 0, sizeof(DpTime));
	cin >> N >> L;
	for (int i = 0; i < N; ++i) {
		cin >> a;
		IciclesInfo.push_back({ a,i + 1 });
	}
	sort(IciclesInfo.begin(), IciclesInfo.end(), greater<pair<int,int> >());
	
	solve();
	cout << *max_element(DpTime + 1, DpTime + N + 1) << endl;

	return 0;
}


Measured memory_bytes: 4208
import java.util.*;
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if(a <= b){
            System.out.println(a);
        }else{
            System.out.println(a-1);
        }

    }
}

Measured memory_bytes: 22996
# python 3.4.3
import sys
input = sys.stdin.readline
# import numpy as np
from collections import Counter

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
W = input().rstrip()

C = Counter(W).most_common()

ans = "Yes"
for _,cnt in C:
    if cnt%2 == 1:
        ans = "No"
        break

print(ans)

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  for (int i = 1; i < 1000; i++) {
    if (i * A % B == C) {

      puts("YES");
      return 0;
    } else
      continue;
  }
  puts("NO");
}

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

namespace program
{
    class Program
    {
        static void Main()
        {
          var s = Input.ScanStr();
          
          Out($"{s[0]}{s.Length-2}{s[s.Length-1]}");
        }
        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: 13140
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int a_count = 0;
  ll ans = 0;
  rep(i, n-2){
    if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){ 
      ans += a_count + 1;
      s[i+2] = 'A';
      i++;
    }else if(s[i] == 'A'){ 
      a_count++;
    }else { 
      a_count = 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

// Most important thing in CP - Have Fun :)

void solve(){
	//write here
    ll d,t,s;
    cin>>d>>t>>s;
    if (s*t>=d)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return;
}

int main(){
	cin.tie(NULL);
	ios::sync_with_stdio(false);
	//insert code
	
		solve();
	return 0;
}

Measured memory_bytes: 3652
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>

using namespace std;

int main (void) {
	int N, K, re, i;
	while (~scanf (" %d %d", &N, &K)) {
		re = K;
		K--;
		for (i = 1; i < N; i++) {
			re *= K;
		}
		printf ("%d\n", re);
	}

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;


struct UnionFindTree {
  std::vector<int> data;

  UnionFindTree(int size) : data(size, -1) { }
  bool Unite(int x, int y) {
    x = Root(x); y = Root(y);
    if (x != y) {
      if (data[y] < data[x]) std::swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool IsSameRoot(int x, int y) {
    return Root(x) == Root(y);
  }
  int Root(int x) {
    return data[x] < 0 ? x : data[x] = Root(data[x]);
  }
  int Size(int x) { return -data[Root(x)]; }
};

int main() {
  int N, M; cin >> N >> M;
  UnionFindTree tree(N + 1);
  for (int i = 0; i < M; ++i) {
    int X, Y, Z; cin >> X >> Y >> Z;
    tree.Unite(X, Y);
  }

  set<int> s;
  for (int i = 1; i <= N; ++i) {
    s.insert(tree.Root(i));
  }
  cout << s.size() << endl;
}


Measured memory_bytes: 8280
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPL(i,f,n) for(int i=f, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

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

	set<int> s;
	int N,d;
	cin >> N;
	REP(i, N) {
		cin >> d;
		s.insert(d);
	} 

	cout << s.size() << endl;
	return 0;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
template<typename T> using uset = unordered_set<T>;
template<typename T, typename S> using umap = unordered_map<T, S>;
const int inf = 1000000000;

void solve() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int x = k - a;
    int ans = 0;
    if (k >= a) {
        ans = a;
        if (x > 0) {
            x -= b;
            if (x > 0) ans -= x;
        }
    } else ans = k;
    cout << ans;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    cout<<fixed;
    solve();
    return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main()
{
    int a, b, c;
    cin>>a>>b>>c;
    if(a+b+c>=22) cout<<"bust"<<endl;
    else cout<<"win"<<endl;
    return 0;
}

Measured memory_bytes: 764
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str1 = sc.next();
    String str2 = sc.next();
    boolean test = false;

    for(int i=0; i<str2.length(); i++){
      if(str2.equals(str1)){
      test = true;
      break;
    }else{
        str1 = str1.charAt(str1.length()-1) + str1;
        str1 = str1.substring(0,str1.length()-1);
      }
    }
      if(test){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
  }
}

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

int main () {
  int A,B;
  cin >> A >> B;
  if (A < B) {
    cout << 2*B-1 << endl;
  }
  else if (A > B) {
    cout << 2*A-1 << endl;
  }
  else {
    cout << 2*A << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>

#define PI 3.14159265359

#define INF 99999999;

#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)

typedef long long ll;

using namespace std;



/*
class LightSwitchingPuzzle
{
public:
	int minFlips(string s)
	{

	}
}
*/


int rank[100000];
int par[10000];

void init(int n)
{
	REP(n)
	{
		rank[i] = 0;
		par[i] = i;
	}
}

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

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 same(int x, int y)
{
	return find(x) == find(y);
}

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

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

edge es[100000];

int main()
{
	int V, E;
	
	cin >> V >> E;
	REP(E)
	{
		cin >> es[i].u >> es[i].v >> es[i].cost;
	}
	
	sort(es, es + E, comp);
	init(V);
	int res = 0;
	for (int i=0; i<E; i++)
	{
		edge e = es[i];
		if (!same(e.u, e.v))
		{
			unite(e.u, e.v);
			res += e.cost;
		}
	}
	
	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 2428
#include<iostream>
#include<cstdio>
using namespace std;
int x;
int gcd(int a,int b)
{
	return b==0?a:gcd(b,a%b);
}
int main()
{
	scanf("%d",&x);
	printf("%d",360/gcd(x,360));
	return 0;
}

Measured memory_bytes: 3780
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

var sc *bufio.Scanner

const BufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

type bc struct {
	num   int
	value int
}

type bcs []bc

func (b bcs) Len() int           { return len(b) }
func (b bcs) Less(i, j int) bool { return b[i].value < b[j].value }
func (b bcs) Swap(i, j int)      { b[i], b[j] = b[j], b[i] }

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+6)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	s := make([]bc, n)

	for i := range s {
		s[i].num = i
		s[i].value = nextInt()
	}

	sort.Sort(bcs(s))

	for i := range s {
		_, _ = fmt.Fprintf(writer, "%d", s[i].num+1)
		if i < n-1 {
			_, _ = fmt.Fprintf(writer, " ")
		}
	}

}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


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

int main () {
  char S ;
  cin >> S ;
  
  vector<char> boin = { 'a' , 'i' , 'u' , 'e' , 'o' } ;
  
  int score ;
  
  for ( int i = 0 ; i < 5 ; i++ ){
    if ( S ==  boin.at(i) ){
      score ++ ;
    }
  }
  
  if ( score == 1 ){
    cout << "vowel" << endl ;
  } else {
    cout << "consonant" << endl ;
  }
}

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

int main() {
    int n;cin>>n;
    map<int,int> m;
    for (int i=0;i<n;i++) {
        int a;cin>>a;
        m[a]++;
    }
    int ans=0;
    for (auto p:m) {
        if (p.second<p.first) {
            ans+=p.second;
        } else if (p.first<p.second) {
            ans+=p.second-p.first;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4736
# -*- coding: utf-8 -*-

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

ans=0
for i in range(N-2):
    for j in range(i+1,N-1):
        if L[i]!=L[j]:
            for k in range(j+1,N):
                if L[i]!=L[k] and L[j]!=L[k]:
                    l=[L[i],L[j],L[k]]
                    M=max(l)
                    S=sum(l)
                    if S-M > M: 
                        ans+=1
                        #print(i,j,k)

print(ans)

Measured memory_bytes: 9116