akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		sa = br.readLine().split(" ");
		int[] p = new int[n];
		for (int i = 0; i < n; i++) {
			p[i] = Integer.parseInt(sa[i]) - 1;
		}
		UnionFind uf = new UnionFind(n);
		for (int i = 0; i < m; i++) {
			sa = br.readLine().split(" ");
			int x = Integer.parseInt(sa[0]) - 1;
			int y = Integer.parseInt(sa[1]) - 1;
			uf.union(x, y);
		}
		br.close();

		int ans = 0;
		for (int i = 0; i < n; i++) {
			if (uf.same(i, p[i])) {
				ans++;
			}
		}
		System.out.println(ans);
	}

	static class UnionFind {
		int[] parent;

		UnionFind(int n) {
			parent = new int[n];
			for (int i = 0; i < n; i++) {
				parent[i] = i;
			}
		}

		void union(int x, int y) {
			int px = find(x);
			int py = find(y);
			if (px != py) {
				parent[px] = py;
			}
		}

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

		/**
		 * xとyが同一連結成分か
		 */
		boolean same(int x, int y) {
			return find(x) == find(y);
		}
	}
}


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

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

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main(void){
    long long  a,b,r,x,tmp;
    int cnt;
    char str[100];
    
    for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
        sscanf(str,"%lld %lld",&a,&b);
        if(a==0 && b==0) break;
        x=a*b; cnt=1;
        if(a<b){
            tmp=a;
            a=b;
            b=tmp;
        }
        r=a%b;
        while(r!=0){
            a=b;
            b=r;
            r=a%b;
            cnt++;
        }
        printf("%lld %d\n",b,cnt);
    }
    return 0;
}

Measured memory_bytes: 2564
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

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();

		List<Integer> list = new ArrayList<Integer>();

		list.add(a);
		list.add(b);
		list.add(c);

		Collections.sort(list);

		int min = list.get(0);
		int mid = list.get(1);
		int max = list.get(2);

		int sub1 = max - mid;
		int sub2 = max - min;

		int sum = sub1 + sub2;

		if (sum % 2 == 0) {
			System.out.println(sum / 2);
		} else {
			System.out.println(sum / 2 + 2);
		}
		sc.close();

	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
#define F first
#define S second
const int inf=1001001001; const long long INF=1001001001001001001;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
using priority_queue_small = priority_queue<int, vector<int>, greater<int> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};

string s;
int main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> s;
  int n = s.size();
  vii sum(n);
  rep(i, 0, n) {
    if (s[i] == 'B') sum[i]++;
  }
  rep(i, 0, n-1) sum[i+1] += sum[i];
  ll ans = 0;
  rep(i, 0, n) {
    if (s[i] == 'W') ans += sum[i];
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1428
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
const ll mod=1e9+7;
ll dp[110][4][4][4];
bool check(int x,int y,int z,int w)//agct
{
	if((y==0&&z==1&&w==2)||(y==0&&z==2&&w==1)||(y==1&&z==0&&w==2)||(x==0&&z==1&&w==2)||(x==0&&y==1&&w==2))
	{
		return 0;
	}
	return 1;
}
int main()
{
	int i,j,k,n,m,x,y,z;
	scanf("%d",&n);
	for(i=0;i<4;i++)
		for(j=0;j<4;j++)
			for(k=0;k<4;k++)
				if((i==0&&j==1&&k==2)||(i==0&&j==2&&k==1)||(i==1&&j==0&&k==2))
					dp[3][i][j][k]=0;
				else
					dp[3][i][j][k]=1;
	for(i=4;i<=n;i++)
		for(x=0;x<4;x++)
			for(y=0;y<4;y++)
				for(z=0;z<4;z++)
					for(j=0;j<4;j++)
						if(check(x,y,z,j))
						{
							dp[i][y][z][j]+=dp[i-1][x][y][z];
							dp[i][y][z][j]%=mod;
						}
	ll sum=0;
	for(i=0;i<4;i++)
		for(j=0;j<4;j++)
			for(k=0;k<4;k++)
			{
				sum+=dp[n][i][j][k];
				sum%=mod;
			}
	printf("%lld",sum);
	return 0;
}


Measured memory_bytes: 3848
import kotlin.math.pow
import kotlin.math.sqrt

fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main() {
    val (n, d) = intList()
    var c = 0
    repeat(n) {
        val (x, y) = intList()
        if (d.toDouble() >= sqrt((x.toDouble().pow(2) + y.toDouble().pow(2)))) {
            c++
        }
    }
    println(c.toString())
}

Measured memory_bytes: 64396
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<PP,vector<PP>,greater<PP>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
bool chmin(auto &a,auto b){if(a>b){a=b;return true;}return false;}
bool chmax(auto &a,auto b){if(a<b){a=b;return true;}return false;}
void outvi(vi v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
void outvvi(vvi v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

int main(){
  ll a,b;cin>>a>>b;
  
    cout<<6-a-b<<endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
ruiseki=[0 for i in range(n)]
ruiseki[0]=a[0]
sum=0
for i in range(1,len(a)):
    ruiseki[i]=ruiseki[i-1]+a[i]
for i in range(n-1):
    sum+=a[i]*(ruiseki[n-1]-ruiseki[i])
    sum%=(10**9+7)

print(sum)



Measured memory_bytes: 31540
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    int N;
    string s;

    scan(N);
    scan(s);

    auto r = new long[](N + 1);
    auto g = new long[](N + 1);
    auto b = new long[](N + 1);

    foreach (i ; 1 .. N + 1) {
        r[i] = r[i - 1] + (s[i - 1] == 'R');
        g[i] = g[i - 1] + (s[i - 1] == 'G');
        b[i] = b[i - 1] + (s[i - 1] == 'B');
    }

    long ans;

    foreach (i ; 0 .. N) {
        if (s[i] == 'R') {
            ans += g[i] * (b[N] - b[i + 1]);
            ans += b[i] * (g[N] - g[i + 1]);
        }
        if (s[i] == 'G') {
            ans += r[i] * (b[N] - b[i + 1]);
            ans += b[i] * (r[N] - r[i + 1]);
        }
        if (s[i] == 'B') {
            ans += r[i] * (g[N] - g[i + 1]);
            ans += g[i] * (r[N] - r[i + 1]);
        }

        foreach (j ; 1 .. N) {
            if (i - j < 0 || i + j >= N) break;
            if (s[i - j] != s[i] && s[i] != s[i + j] && s[i - j] != s[i + j]) {
                ans--;
            }
        }
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


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

long long n;
vector<long long> l;

long long solve();

int main() {
  cin >> n;
  l.resize(n);
  for (int i = 0; i < n; ++i) cin >> l[i];

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

long long solve() {
  sort(l.begin(), l.end());
  long long res = 0;
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n; ++j) {
      long long now = lower_bound(l.begin(), l.end(), l[i] + l[j]) - l.begin();
      res += max(0LL, now - j - 1);
    }
  return res;
}


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

// test
using namespace std;

using int64 = long long;

int N, K;

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

   // Kの倍数である数値の個数を数える
   int64 a = 0;
   for (int x = 1; x <=N; x++) {
      if (x % K == 0) {
         a++;
      }
   }

   // 余りがKの半分となる数値の個数を数える
   int64 b = 0;
   for (int x = 1; x <=N; x++) {
      if (x % K == K/2) {
         b++;
      }
   }

   // 全ての要素がKの倍数の場合を足す
   int64 ans = a * a * a;
   // Kが偶数なら余りがK/2の場合も考慮する
   if (K % 2 == 0) {
      // 全ての要素がK/2の場合を足す
      ans += b * b * b;
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

const int MAX_H = 10004;
const int MAX_N = 1003;
int dp[MAX_N][MAX_H];

int main() {
	int h, n;
	cin >> h >> n;
	vector<int> a(n), b(n);
	rep(i,n) cin >> a[i] >> b[i];
	fill(dp[0], dp[0]+h, INF);
    dp[0][0] = 0;
	rep(i,n)rep(j,h){
		if(j>=a[i]) dp[i+1][j] = min(dp[i+1][j-a[i]]+b[i], dp[i][j]);
		else dp[i+1][j] = dp[i][j];
	}
	int ans = INF;
	rep(i,n){
		int lim = h-a[i];
		for(int j = lim; j < h; j++){
			chmin(ans, dp[n][j]+b[i]);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 39424
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T = double>
using point = complex<T>; // 2D point only

using ll = long long;
using ull = unsigned long long;
using ldob = long double;

template <typename T = int>
using ii = pair<T,T>;
template <typename T = int>
using iii = pair<T,ii<T>>;
template <typename T = int>
using ii_i = pair<ii<T>,T>;
template <typename T = int>
using vi = vector<T>;
template <typename T = int>
using vvi = vector<vi<T>>;
template <typename T = int>
using vii = vector<ii<T>>;
template <typename T = int>
using viii = vector<iii<T>>;
template <typename T = int>
using lim = numeric_limits<T>;

#define re real()
#define im imag()
#define fi first
#define se second
#define sz(v) (v).size()
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

// OST
template <typename T>
using ordered_set = __gnu_pbds::tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// from: https://codeforces.com/blog/entry/62393
// struct custom_hash {
// 	static uint64_t splitmix64(uint64_t x) {
// 		// http://xorshift.di.unimi.it/splitmix64.c
// 		x += 0x9e3779b97f4a7c15;
// 		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
// 		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
// 		return x ^ (x >> 31);
// 	}

// 	size_t operator()(uint64_t x) const {
// 		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
// 		return splitmix64(x + FIXED_RANDOM);
// 	}
// };

const int INF = ~(1<<31);
const ll LINF = (1LL << 60);
const long double EPS = 1e-9;
const long double PI = acos(-1);

const int N = 200005;
const int NN = 1;
const int MOD = 998244353;
const int IMAX = 1e9+7;
const ll LMAX = 1e15+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};
const int dx8[8] = {-1,-1,-1,0,0,1,1,1};
const int dy8[8] = {-1,0,1,-1,1,-1,0,1};

// used editorial

void solution() {
	string s; cin >> s;
	int n = sz(s);

	// (1) of editorial
	vector<vector<int>> next(n+1, vector<int>(26, n));
	for (int i = n-1; i >= 0; --i) {
		for (char c = 'a'; c <= 'z'; ++c) {
			next[i][c-'a'] = next[i+1][c-'a'];
		}
		next[i][s[i]-'a'] = i;
	}

	// (2) of editorial
	vector<int> dp(n+1, N);
	dp[n] = 1;
	for (int i = n-1; i >= 0; --i) {
		for (char c = 'a'; c <= 'z'; ++c) {
			if (next[i][c-'a'] >= n)
				dp[i] = 1;
			else
				dp[i] = min(dp[i], dp[next[i][c-'a']+1]+1);
		}
	}

	// tracing
	int idx = 0;
	while (dp[idx] > 1) {
		for (char c = 'a'; c <= 'z'; ++c) {
			if (dp[idx] == dp[next[idx][c-'a']+1]+1) {
				cout << c;
				idx = next[idx][c-'a']+1;
				break;
			}
		}
	}

	for (char c = 'a'; c <= 'z'; ++c) {
		if (next[idx][c-'a'] >= n) {
			cout << c << endl;
			break;
		}
	}
}

void pregen() {

}

void prepare() {
	
}

int main () {
	ios_base::sync_with_stdio(false); cin.tie(0); // cout.tie(0);
	// cout.precision(2); cout << fixed;

	int T = 1;
	// cin >> T;
	pregen();
	for (int i = 1; i <= T; ++i) {
		prepare();
		solution();
	}

	return 0;
}

Measured memory_bytes: 30828
#include <bits/stdc++.h>
using namespace std;
int main() {
	int x;
	cin >> x;
	if(x % 10 == 9 || x / 10 == 9){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;
using pii = pair<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
int binary_search_index(Int Y, vi &q){
    int left = 0, right = q.size() - 1;
    while (right >= left) {
        int mid = left + (right - left) / 2;
        if (q[mid] == Y) return mid;
        else if (q[mid] > Y) right = mid - 1;
        else if (q[mid] < Y) left = mid + 1;
    }
    return -1;
}


Int combination(Int n, Int r) {
    if(n == 1){return 0;}
    if ( r * 2 > n ) r = n - r;
    uintmax_t dividend = 1;
    uintmax_t divisor  = 1;
    for ( unsigned int i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

unsigned GetDigit(Int num){
    return std::to_string(num).length();
}
int ctoi(char c) {
    if (c >= '0' && c <= '9') {
        return c - '0';
    }
    return 0;
}



int main() {
    Int N;
    Int ans = 1;
    cin >> N;

    mapii counts;

    rep(i,N){
        Int a;
        cin >> a;
        counts[a]++;
    }

    Int mod = 1000000000+7;



    if(N%2==1){
        if(counts[0]!=1){
            cout << 0 << endl;
            return 0;
        }
        Int tmp = 0;
        while(tmp<N){
            if(tmp==0){
                if (counts[tmp]!=1){
                    cout << 0 << endl;
                    return 0;
                }
            }else{
                if(counts[tmp]!=2){
                    cout << 0 << endl;
                    return 0;
                }
                ans*=2;
                ans%=mod;
            }
            tmp+= 2;
        }

        cout << ans << endl;

    }else{
        Int tmp = 1;
        while(tmp<N){
            if(counts[tmp]!=2){
                cout << 0 << endl;
                return 0;
            }

            ans*=2;
            ans%=mod;
            tmp += 2;
        }

        cout << (ans)%mod << endl;
    }



    return 0;
}

Measured memory_bytes: 3596
import sys
N, M = map(int, input().split())

start = [0] * M
end = [0] * M

s_middle = []
middle_e = []

for m in range(M):
    line = list(map(int, input().split()))
    start[m] = line[0]
    end[m] = line[1]
    
    if start[m] == 1:
        s_middle.append(end[m])
    if end[m] == N:
        middle_e.append(start[m])
        
if not s_middle or not middle_e:
    print('IMPOSSIBLE')
    sys.exit()

if set(s_middle) & set(middle_e):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 28156
n, k = gets.chomp.split.map(&:to_i)
m = gets.chomp.split.map(&:to_i).sort.reverse
if k >= n
  puts 0
else
  all_m = m
  all_m = m.slice(k, n-1) if k != 0
  puts all_m.inject(:+)
end

Measured memory_bytes: 21360
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> abox;
    vector<int> bbox;
    for(int i = 1; i <= a; i++){
        if(a%i == 0) abox.push_back(i);
    }
    for(int i = 1; i <= b; i++){
        if(b%i == 0) bbox.push_back(i);
    }
    vector<int> resbox;
    for(int i = 0; i < abox.size(); i++){
        if (count (bbox.begin(), bbox.end(), abox[i])){
            resbox.push_back(abox[i]);
        }
    }
    sort(resbox.begin(), resbox.end(), greater<int>());
    cout << resbox[k-1];
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

using namespace std;

#define int long long
#define str string
#define rtn return
#define pb push_back
#define db long double
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()

const int N = 1e5 + 7;

int dp[100005][4];
int n;
int a[100005], b[100005], c[100005];

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

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	dp[0][0] = a[0]; dp[0][1] = b[0]; dp[0][2] = c[0];
	for (int i = 1; i < n; i++) {
		dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = b[i] + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = c[i] + max(dp[i - 1][0], dp[i - 1][1]);
	}
	int ans = 0;
	for (int i = 0; i < 3; i++) ans = max(ans, dp[n - 1][i]);
	cout << ans << "\n";
	return 0;
}

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

ll dp[401][401];

int main(){
    int N; cin >> N;
    ll a[401];
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    for(int i=0; i<N; i++){
        dp[i][i+1]=0;
    }
    ll sum[401];
    sum[0]=0;
    for(int i=0; i<N; i++){
        sum[i+1]=sum[i]+a[i];
    }
    const ll INF=pow(10,16);
    for(int k=2; k<=N; k++){
        for(int j=0; j<=N-k; j++){
            ll res=INF;
            for(int l=1; l<k; l++){
                res = min(res, dp[j][j+l]+dp[j+l][j+k]);
            }
            dp[j][j+k] = res + sum[j+k] - sum[j];
        }
    }
    cout << dp[0][N] << endl;
}

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

using namespace std;

typedef pair<int, int> pii;

int main()
{
    int n, AC;
    char c;
    vector<pii> v;
    while (cin >> n >> c >> AC, (n | AC)) {
        v.push_back(pii(-AC, n));
    }
    
    sort(v.begin(), v.end());
    while (cin >> n) {
        int cnt = 1;
        for (int i = 0; i < (int)v.size(); i++) {
            if (i > 0 && v[i].first != v[i-1].first) {
                cnt++;
            }
            if (v[i].second == n) break;
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 3000
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define clr clear()
#define sqr(a) (a*a)
#define mk make_pair
#define pb push_back
string en="\n";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define peR(i,n) for(i=n;i>0;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define srch(a,x) binary_search(all(a),x)
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef unsigned long long ULL;
bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
bool f(int a,int b)
{
    if(a>b) return true;
    else return false;
}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;
    while(cin>>n)
    {
        vi a;
        rep(i,n)
        {
            vp(a,x);
        }
        sort(all(a),f);
        s=c=0;
        for(i=n-1;i>=0;i--)
        {
            if(i%2==0) s+=a[i];
            else c+=a[i];
        }
        s=s-c;
        cout<<s<<en;
    }
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    if (S.length() == 26) {
      String ans = "-1";
      boolean[] available = new boolean[26];
      for (int i = 25; i >= 0; i--) {
        char c = S.charAt(i);
        available[c-'a'] = true;
        char next = 'X';
        for (int j = c-'a'+1; j < 26; j++) {
          if (available[j]) {
            next = (char)('a'+j);
            break;
          }
        }
        if (next != 'X') {
          ans = S.substring(0, i)+next;
          break;
        }
      }
      System.out.println(ans);
    } else {
      boolean[] used = new boolean[26];
      for (int i = 0; i < S.length(); i++) {
        used[S.charAt(i)-'a'] = true;
      }
      char unused = 'X';
      for (int i = 0; i < 26; i++) {
        if (!used[i]) {
          unused = (char)('a'+i);
          break;
        }
      }
      System.out.println(S+unused);
    }
  }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int x, y;
	cin >> x >> y;

	if(x % y != 0) {
		cout << x << endl;
	}
	else {
		cout << -1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define mod 1000000007
#define MAX 300005
using namespace std;
//char nc()
//{
//	static char buf[100000],*p1=buf,*p2=buf;
//	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
char nc(){return getchar();}
int read()
{
	int x=0,y=1;
	char c=nc();
	while(!isdigit(c))
	{
		if(c=='-')y=-1;
		c=nc();
	}
	while(isdigit(c))
	{
		x=(x<<1)+(x<<3)+(c^48);
		c=nc();
	}
	return x*y;
}
int n;
char s[MAX];
long long f[MAX][3][3];
long long mo(long long x)
{
	return x<mod?x:x-mod;
}
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	f[0][0][0]=1;
	for(int i=1;i<=n;i++)
	{
		if(s[i]!='1')
		{
			f[i][0][1]=mo(f[i][0][1]+f[i-1][0][0]);
			f[i][0][2]=mo(f[i][0][2]+f[i-1][0][1]);
			f[i][0][1]=mo(f[i][0][1]+f[i-1][0][2]);
			f[i][1][1]=mo(f[i][1][1]+f[i-1][1][0]);
			f[i][1][2]=mo(f[i][1][2]+f[i-1][1][1]);
			f[i][1][1]=mo(f[i][1][1]+f[i-1][1][2]);
			f[i][2][1]=mo(f[i][2][1]+f[i-1][2][0]);
			f[i][2][2]=mo(f[i][2][2]+f[i-1][2][1]);
			f[i][2][1]=mo(f[i][2][1]+f[i-1][2][2]);
		}
		if(s[i]!='0')
		{
			f[i][1][0]=mo(f[i][1][0]+f[i-1][0][0]);
			f[i][2][0]=mo(f[i][2][0]+f[i-1][1][0]);
			f[i][2][0]=mo(f[i][2][0]+f[i-1][2][0]);
			f[i][0][0]=mo(f[i][0][0]+f[i-1][0][1]);
			f[i][1][0]=mo(f[i][1][0]+f[i-1][1][1]);
			f[i][2][0]=mo(f[i][2][0]+f[i-1][2][1]);
			f[i][0][1]=mo(f[i][0][1]+f[i-1][0][2]);
			f[i][1][1]=mo(f[i][1][1]+f[i-1][1][2]);
			f[i][2][1]=mo(f[i][2][1]+f[i-1][2][2]);
		}
	}
	printf("%lld",(f[n][1][0]+f[n][2][0]+f[n][2][1]+f[n][2][2])%mod);
	return 0;
}


Measured memory_bytes: 25168
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    scanf("%d",&N);
    for(int i=0;i<=25;i++){
        if(N-4*i<0){break;}
        if((N-4*i)%7==0){cout<<"Yes"<<endl;return 0;}
    }
    cout<<"No"<<endl;
    
    return 0;
}


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

using namespace std;

int main()
{
    string in;
    cin >> in;
    for (int i = 0; i < in.size(); i++)
    {
        if (in[i] == '9')
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int N;
vector<ll> T, A;

void input() {
  cin >>N;
  T.assign(N, 0); A.assign(N, 0);
  rep(i, N) cin >>T[i] >>A[i];
}

int main() {
  input();
  ll a = 0, b = 0;
  rep(i, N){
    ll c = T[i], d = A[i];
    // 比が現在の得票数以上になっている
    if (a <= c && b <= d){ a = c; b = d; continue; }
    // 比が丁度一緒になってる
    if (a % c == 0 && b % d == 0 && a / c == b / d) continue;
    // 得票数と比が異なっている
    ll aa = a % c == 0 ? a : (a/c + 1) * c;
    ll bb = aa / c * d;
    if (bb >= b){
      a = aa; b = bb;
    }else{
      b = b % d == 0 ? b : (b/d + 1) * d;
      a = b / d * c;
    }
  }
  ll res = a + b;
  cout <<res <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>

using namespace std;
#define lli long ling int;

int main()
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    // a, b swap
    int tmp = 0;
    tmp = a;
    a = b;
    b = tmp;

    // a, c swap
    tmp = a;
    a = c;
    c = tmp;

    cout << a << " " << b << " " << c <<endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int h, w, i, j, k, cnt;
    char s[50][51];
    int p[4] = {-1, 0, 0, 1};
    int q[4] = { 0,-1, 1, 0};

    scanf("%d %d", &h, &w);

    for(i=0; i<h; i++){
        scanf("%s", s[i]);
    }

    for(i=0; i<h; i++){
        for(j=0; j<w; j++){
            if(s[i][j] == '#'){
                cnt=0;
                for(k=0; k<4; k++){
                    if(s[i+p[k]][j+q[k]] == '#')
                        cnt++;
                }
                if(cnt == 0){
                    printf("No\n");
                    return 0;
                }
            }
        }
    }

    printf("Yes\n");

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>

int main(){
	int a, b, c, ans = 0, count = 0;
	scanf("%d %d %d", &a, &b, &c);
	if(a >= b){
	do{
		ans += a;
		count++;
		}while(ans < c);
	}
	else{
		do{
			ans += b;
			count++;
		}while(ans < c);
	}
	printf("%d", count);
	return 0;
}

Measured memory_bytes: 1688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1e9 + 7;

int main() {
    ll n, k;
    cin >> n >> k;
    ll cnt = 0;
    for (ll i = k; i <= n + 1; i++) {
        cnt += (i * (n - i + 1) + 1) % MOD;
    }
    cout << cnt % MOD << endl;
    return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include "string.h"
int a[27];
int dp[50007];
using namespace std;
int main() {
	int n,k;
	cin>>k>>n;
	memset(dp, 0, sizeof(dp));
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=50007;i++)dp[i]=1e9;
	dp[0]=0;
	for(int i=1;i<=n;i++)
		for(int j=0;j+a[i]<=k;j++)
			dp[j+a[i]]=min(dp[j+a[i]],dp[j]+1);
	cout<<dp[k]<<endl;
}


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

map<long long, long long> mp;

int main()
{
	long long n;
	vector<long long> vec(2 * 100005);
	long long ans = 0;

	cin >> n;
	for (long long i = 1; i <= n; i++) {
		cin >> vec[i];
	}

	mp[0] = 1;
	for (long long i = 1; i <= n; i++) {
		vec[i] += vec[i - 1];

		ans = ans + mp[vec[i]];
		mp[vec[i]]++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 14336
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    x,y=parseMap(split(readline()))
    ans=0
    while x<=y
        ans+=1
        x*=2
    end
    println(ans)
end
main()

Measured memory_bytes: 165128
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,mod,l[525],r[525];
ll f[525][252],ans;
pair<int,int> a[525]; 
inline ll calc(int k){
	memset(f,0,sizeof(f));
	int c1=0,c2=0; f[0][0]=1;
	for(int i=1;i<=m;c1+=(a[i].second==0),c2+=(a[i].second!=0),++i) for(int j=0;j<=i&&j<=k;++j){
		if(a[i].second==0) (f[i][j]+=f[i-1][j]*(a[i].first-c1-j))%=mod; 
		else{
			if(j) (f[i][j]+=f[i-1][j-1]*(a[i].first-j-c1+1))%=mod;
			(f[i][j]+=f[i-1][j]*(a[i].second-k-n-(c2-j)))%=mod;
		}
	}
	return f[m][k];
}
int main(){
	cin>>n>>mod; m=n<<1;
	for(int i=0;i<m;++i){
		l[i]=0; r[i]=m-1;
		while(l[i]<m&&l[i]*l[i]+i*i<n*n) ++l[i];
		while(r[i]>0&&r[i]*r[i]+i*i>m*m) --r[i];
		--l[i];
		if(i<n) a[i+1]=make_pair(l[i]+1,r[i]+1);
		else a[i+1]=make_pair(r[i]+1,0);
	}
	sort(a+1,a+m+1);
	for(int i=0;i<=n;++i) (ans+=((i&1)?-1:1)*calc(i))%=mod;
	cout<<(ans%mod+mod)%mod<<endl;
	return 0;
}

Measured memory_bytes: 4624
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#define MAX 100000
#define INFTY (1 << 30)

class Edge {
public:
  int t, w;
  Edge(){}
  Edge(int t, int w): t(t), w(w) {}
};

vector<Edge> G[MAX];
int n, d[MAX];

bool vis[MAX];
int cnt;

void bfs(int s) {
  for ( int i = 0; i < n; i++ ) d[i] = INFTY;
  queue<int> Q;
  Q.push(s);
  d[s] = 0;
  int u;
  while ( !Q.empty() ) {
    u = Q.front(); Q.pop();
    for ( int i = 0; i < G[u].size(); i++ ) {
      Edge e = G[u][i];
      if ( d[e.t] == INFTY ) {
        d[e.t] = d[u] + e.w;
        Q.push(e.t);
      }
    }
  }
}

void solve() {
  // 適当な視点 s から最も遠い節点 tgt を求める
  bfs(0);
  int maxv = 0;
  int tgt = 0;
  for ( int i = 0; i < n; i++ ) {
    if ( d[i] == INFTY ) continue;
    if ( maxv < d[i] ) {
      maxv = d[i];
      tgt = i;
    }
  }

  // tgt から最も遠い節点の距離 maxv を求める
  bfs(tgt);
  maxv = 0;
  for ( int i = 0; i < n; i++ ) {
    if ( d[i] == INFTY ) continue;
    maxv = max(maxv, d[i]);
  }

  cout << maxv << endl;
}

main() {
  int s, t, w;
  cin >> n;

  for ( int i = 0; i < n-1; i++ ) {
    cin >> s >> t >> w;

    G[s].push_back(Edge(t, w));
    G[t].push_back(Edge(s, w));
  }
  solve();
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

char shift(char c, int i) {
    int ci = int(c) + i;
    if (ci > int('Z')) { ci -= int('Z' - 'A') + 1; }
    return char(ci);
}

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

    int n;
    cin >> n;
    string s;
    cin >> s;

    rep(i, 0, s.size()) { cout << shift(s[i], n); }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] T = new int[N];
        long sum = 0;
        for(int i = 0; i < N; i++){
            T[i] = sc.nextInt();
            sum += T[i];
        }
        int M = sc.nextInt();
        int[][] P = new int[2][M];
        for(int i = 0; i < M; i++){
            P[0][i] = sc.nextInt();
            P[1][i] = sc.nextInt();
        }
        sc.close();

        for(int i = 0; i < M; i++){
            int a = P[0][i];
            System.out.println(sum - T[a-1] + P[1][i]);
        }

   }
}

Measured memory_bytes: 23764
while True :
	a,op,b = input().split()
	if op == '?' : break
	a,b = int(a),int(b)
	if op == '+' : print(a+b)
	if op == '-' : print(a-b)
	if op == '*' : print(a*b)
	if op == '/' : print(int(a/b))


Measured memory_bytes: 5596
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;
const double PI=3.14159265359;


 
int main(){
    
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
    string s;
    cin>>s;
    
    
    vector<int> es(n), ws(n);
    
    es[0]=s[0]=='E';
    ws[0]=s[0]=='W';
    for(int i=1; i<n; i++){
        es[i]=es[i-1]+(s[i]=='E');
        ws[i]=ws[i-1]+(s[i]=='W');
    }
    
    int ans=n;
    for(int i=0; i<n; i++){
        if(!i){
            ans=min(ans, es[n-1]-es[0]);
        }
        else if(i==n-1){
            ans=min(ans, ws[n-2]);
        }
        else{
            ans=min(ans, ws[i-1]+es[n-1]-es[i]);
        }
    }
    cout<<ans;
    
    
    return 0;
    
}

Measured memory_bytes: 2964
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}

	return d;
}

lli solve(lli a, double b) {

	cin >> a >> b;

	lli c = round(b * 100);

	a *= c;
	a /= 100;

	cout << a << endl;
	return a;
}

int main(void) {

	solve(0,0);
	return 0;
}

Measured memory_bytes: 3696
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

bool m[N]={0};


int main()
{
    
    int a[3];
    
    rep(i,0,3)
    scf(a[i]);
    
    sort(a,a+3);
    
    if(a[0]==5&&a[1]==5&&a[2]==7)
    printf("YES\n");
    
    else
    printf("NO\n");
         
     
        
    
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    string s;
    int k;
    cin >> s >> k;
    int cnt = 1, res = 0;
    rep(i, s.size() - 1)
    {
        if (s[i] == s[i + 1])
            cnt++;
        else
        {
            res += cnt / 2;
            cnt = 1;
        }
    }
    if (cnt == s.size())
    {
        cout << (s.size() * k) / 2 << endl;
        return 0;
    }
    res += cnt / 2;
    res *= k;
    if (s[0] == s[s.size() - 1])
    {
        int a = 1, b = 1;
        rep(i, s.size())
        {
            if (s[i] == s[i + 1])
                a++;
            else
                break;
        }
        reverse(all(s));
        rep(i, s.size())
        {
            if (s[i] == s[i + 1])
                b++;
            else
                break;
        }
        res -= (a / 2 + b / 2) * (k - 1);
        res += ((a + b) / 2) * (k - 1);
    }
    cout << res << endl;
}

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


int main(){
  unsigned long long int n, ch, co;
  cin >> n;
  //vector<int> A(n);
  //for(i=0; i<n; i++) cin >> A[i];
  unsigned long long int a, b, c;
  //string s;
  cin >> a >> b;
  if(a==0) cout << 0 << endl; 
  else {unsigned long long int s = a+b;
  c = n/s;

  co = n%s;
  if(co<=a)ch = a*c+co;
  else ch = a*c+a;
  
  cout << ch << endl;}
  
}

Measured memory_bytes: 256
//金桥 傅思程
#include <bits/stdc++.h>
using namespace std;

int main()
{
	int a,b,c,d,e,f=0,k;
	cin>>a>>b>>c>>d>>e>>k;
	if(abs(a-b)>k)f=1;
	if(abs(a-c)>k)f=1;
	if(abs(a-d)>k)f=1;
	if(abs(a-e)>k)f=1;
	if(abs(b-c)>k)f=1;
	if(abs(b-d)>k)f=1;
	if(abs(b-e)>k)f=1;
	if(abs(c-d)>k)f=1;
	if(abs(c-e)>k)f=1;
	if(abs(d-e)>k)f=1;
	if(f==1)cout<<":(";
	else cout<<"Yay!";
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = Integer.parseInt(scanner.nextLine());
			if (n == 0) {
				break;
			}
			int[][] num = new int[n][2];
			for (int i = 0; i < n; i++) {
				String[] s = scanner.nextLine().split(" ");
				int[] b = new int[s.length - 1];
				num[i][0] = Integer.parseInt(s[0]);
				int frame = 1;
				for (int j = 1; j < s.length; j++) {
					b[j - 1] = Integer.parseInt(s[j]);
				}
				int j = 0;
				while (j < b.length) {
					if (frame >= 10) {
						num[i][1] += b[j];
						j++;
					} else {
						num[i][1] += b[j] + b[j + 1];
						if (b[j] == 10) {
							num[i][1] += b[j + 2];
							j++;
						} else {
							if (b[j] + b[j + 1] == 10) {
								num[i][1] += b[j + 2];
							}
							j += 2;
						}
					}
					frame++;
				}

			}
			Arrays.sort(num, new Comparator<int[]>() {

				@Override
				public int compare(int[] a, int[] b) {
					if (a[1] == b[1]) {
						return a[0] - b[0];
					}
					return b[1] - a[1];
				}
			});
			for (int i = 0; i < n; i++) {
				System.out.println(num[i][0] + " " + num[i][1]);
			}

		}
	}
}

Measured memory_bytes: 21848
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int h,a;
    cin >> h >> a;
    int answer = 0;
    while(h>0){
        answer++;
        h-=a;
    }
    cout<< answer << endl;
    return 0;
}

Measured memory_bytes: 256
import Data.List
import Data.Maybe
import qualified Data.ByteString.Char8 as B
main=print.solve.map(fst.fromJust.B.readInt).B.words=<<B.getContents
solve(n:m:xs)=foldr(+)0.take(m-n).sort.(zipWith(-)=<<tail).sort$xs

Measured memory_bytes: 19924
#include<iostream>
#include<cmath>
#include<string>
#include <algorithm>
#include <numeric>
using namespace std;

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

    if(s[2] == s[3] && s[4]==s[5]){
        cout << "Yes"<<endl;
        return 0;
    }
    cout<< "No" <<endl;

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8

a, b, c = map(int, input().rstrip().split())
count = 0

while True:
    if a == b and b == c and c == a :
        count = -1 if a % 2 == 0 else 0
        break
    elif a % 2 == 0 and b % 2 == 0 and c % 2 == 0 :
        a, b, c = (b+c)/2, (c+a)/2, (a+b)/2
        count += 1
    else:
        break
print(count)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
 
int main(void) {
	char str[200], tmp[200] = {};
	int m, h, slen;
	int i, j;
	
	while (scanf("%s", str), str[0] != '-'){	
		slen = strlen(str);
		
		scanf("%d", &m);
		
		for (i = 0; i < m; i++){
			scanf("%d", &h);
			for (j = 0; j < h; j++)	tmp[j] = str[j];
			for (j = 0; j < slen - h; j++) str[j] = str[j+h];
			for (j = 0; j < h; j++) str[slen-1 - j] = tmp[h-1 - j];
		}
		printf("%s\n", str);
	}
		
	return 0;
}

Measured memory_bytes: 584
#
# abc070 c
#
import sys
from io import StringIO
import unittest
import math
from functools import reduce


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2
2
3"""
        output = """6"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """5
2
5
10
1000000000000000000
1000000000000000000"""
        output = """1000000000000000000"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    T = [int(input()) for _ in range(N)]

    print(lcmlist(T))


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


def lcmlist(l):
    return reduce(lcm, l)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16168
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int res;

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

    int K, N;
    cin >> K >> N;
    int house[200000];
    for (int i = 0; i < N; i++)
    {
        cin >> house[i];
    }
    int maxdistance = 0;
    sort(house, house + N);
    for (int i = 0; i < N - 1; i++)
    {
        int d = house[i + 1] - house[i];
        if (maxdistance < d)
        {
            maxdistance = d;
        }
    }
    if (maxdistance < K - house[N - 1] + house[0])
    {
        maxdistance = K - house[N - 1] + house[0];
    }
    cout << K - maxdistance << endl;
    return 0;
}

Measured memory_bytes: 1024
#累積和　なるほど！

n,q = map(int, input().split())
s = input()
lr = list(map(str, [input() for i in range(q)]))

ac = [0]*n
#012345678
# ACACTACG
# 01122233

for i in range(1,n):
	if s[i-1:i+1] =='AC':
		ac[i] = ac[i-1] + 1
	else:
		ac[i] = ac[i-1]

for i in range(q):
	l,r = map(int, lr[i].split())
	answer = ac[r-1]-ac[l-1] 

	print(answer)


Measured memory_bytes: 13432
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int arr[s.length()]={0};
	for(int i=0;i<s.length();i++)
	{	
		if(s[i]=='L')
			continue;
		int c=0;
		while(s[i]=='R')
		{
			i++;
			c++;
		}

		if(c%2==0)
		{
			arr[i]+=c/2;
			arr[i-1]+=c/2;
		}
		else
		{
			arr[i-1]+=(c+1)/2;
			arr[i]+=c/2;
		}
		i--;
	}
	for(int i=s.length()-1;i>=0;i--)
	{
		if(s[i]=='R')
			continue;
		int c=0;
		while(s[i]=='L')
		{
			i--;
			c++;
		}
		if(c%2==0)
		{
			arr[i]+=c/2;
			arr[i+1]+=c/2;
		}
		else
		{
			arr[i]+=(c)/2;
			arr[i+1]+=(c+1)/2;
		}
		i++;
	}
	for(int i=0;i<s.length();i++)
	{
		cout<<arr[i]<<" ";
	}
	return 0;
}

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

int main(void){
	int w;

	while(cin>>w && w != -1){
		int sum = 1150;

		for(int i=11;i<=w && i<=20;i++) sum += 125;
		for(int i=21;i<=w && i<=30;i++) sum += 140;
		for(int i=31;i<=w;i++) sum += 160;

		cout<<4280-sum<<endl;
	}

	return 0;
}

Measured memory_bytes: 0