akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long int
#define FIO  ios::sync_with_stdio(false); cin.tie(0);   cout.tie(0);
#define all(in) in.begin(), in.end()
typedef pair<ll, ll> pll;

ll mod = 1e9 + 7;

ll fastPow(ll x, ll n){
    ll ans = 1;
    while(n){
        if(n&1){
            ans *= x;   ans %= mod;
        }
        x *= x;     x %= mod;
        n >>= 1;
    }
    return ans;
}

void solve(){
    ll n;   cin >> n;
    if(n < 2){
        cout << 0 << endl;
        return;
    }
    ll ans = fastPow((ll)10, n);
    ll t1 = fastPow((ll)9, n);
    t1 <<= 1;   t1 %= mod;
    ll t2 = fastPow((ll)8, n);
    ans = ans - t1 + t2 + mod;
    ans %= mod;
    cout << ans << endl;
}

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


Measured memory_bytes: 3640
from itertools import combinations

n, m, x = map(int, input().strip().split())

caa_list = []

for i in range(n):
  c, *aa = map(int, input().strip().split())
  caa_list.append((c, aa))

caa_list.sort(key=lambda x: x[0])

mc = 10 ** 9

for i in range(1, n+1):
  for caas in combinations(caa_list, i):
    sc = 0
    saa = [0] * m
    for c, aa in caas:
      sc += c
      for j in range(m):
        saa[j] += aa[j]
    if all(a >= x for a in saa):
      if mc > sc:
        mc = sc
        
if mc == 10 ** 9:
  print(-1)
else:
  print(mc)


Measured memory_bytes: 9228
def rec1 (n,w): # 重さにフォーカスしたdp
    v = 0
 
    if dp[n][w] > 0:
        return dp[n][w]
 
    if n == N: # 最後の商品以降で重さがw以下になるように選ぶ→選べない→0
        v = 0
    elif items[n][1] > w: #n番目のitemが制限より重い→スキップ
        v = rec1(n + 1 ,w)
    else: #item nを選べるとき→選ぶか，選ばないか選択する
        c1 = rec1(n + 1, w ) #選ばないルート
        c2 = rec1(n + 1, w - items[n][1]) + items[n][0]
        v = max( c1,c2)
    dp[n][w] = v
    return v
 
 
 
 
#v,w
 
N, W = map(int, input().split())
items = [ tuple(map(int, input().split()) )for _ in range(N)]
maxW = maxV = -1
for item in items:
    v,w = item
    maxW = max(maxW,w)
    maxV = max(maxV,v)
# MAX_W = max([item[1] for item in  items])
# vのsum → 高々2 * 10e5
 
 
if maxW <= 1000:
    dp = [[-1] * 200001 for _ in range(N + 1)]
    rec1(0, W)
    print(dp[0][W])
elif maxV <= 1000:
    INF = 10 ** 18
    dp = [INF] * 200001
    dp[0] = 0
    for item in items:
        v, w = item
        for j in range(200000,v-1,-1):
            dp[j] = min( dp[j - v] + w ,dp[j])
    for j in range(200000, - 1, -1):
        if dp[j] <= W:
            print(j)
            break


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

using namespace std;

int main( ) {
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,a,b,c;
	t = 1;
	while(t--) {
	 cin >> a >> b >> c;
	 if(b - a == c - b)
	  cout << "YES" << endl;
	 else
	  cout << "NO" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int i, n, sum=0, ans=0;
    scanf("%d", &n);
    int d[n];
    for(i = 0; i < n; ++i){
        scanf("%d", &d[i]);
        sum += d[i];
    }
    for(i = 0; i < n; ++i){
        ans += (sum-d[i])*d[i];
    }
    ans /= 2;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5, INF = 0x3f3f3f3f, M = N << 1;

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for (int i = 0; i < n;) {
    int j = i;
    while (s[j] == s[i] && j < n) j++;
    i = j;
    ans++;
  }
  cout << ans << '\n';
}

Measured memory_bytes: 512
import sys

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


def main():
    N = int(readline())
    X = readline().strip()
    p = X.count('1')

    power_down = [0] * N
    power_up = [0] * N
    power_down[0] = 1
    power_up[0] = 1
    for i in range(N - 1):
        if p > 1:
            power_down[i + 1] = power_down[i] * 2 % (p - 1)
        power_up[i + 1] = power_up[i] * 2 % (p + 1)

    base_down = base_up = 0
    for i in range(N):
        if X[i] == '1':
            if p > 1:
                base_down = (base_down + power_down[N - i - 1]) % (p - 1)
            base_up = (base_up + power_up[N - i - 1]) % (p + 1)

    ans = [1] * N
    for i in range(N):
        if p == 1 and X[i] == '1':
            ans[i] = 0
            continue

        if X[i] == '1':
            m = (base_down - power_down[N - i - 1]) % (p - 1)
            q = p - 1
        else:
            m = (base_up + power_up[N - i - 1]) % (p + 1)
            q = p + 1

        while m:
            ans[i] += 1
            q = bin(m).count('1')
            m %= q

    print(*ans, sep='\n')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 87436
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
pair<long,long> D[200000];
long sum[200001];
void Calc(){
	int N = rei();
	long T = rei()+1;
	for(int i=0;i<N;i++){
		long a = rei();
		long b = rei();
		D[i] = {a+1,b+1};
	}
	sort(D,D+N,[](pair<long,long> l,pair<long,long> r){
		return l.first*r.second + l.second == r.first*l.second + r.second ? l.second < r.second : l.first*r.second + l.second > r.first*l.second + r.second;
	});
	vector<long> DP1(50); 
	vector<long> DP2(50);
	for(int i=1;i<50;i++){
		DP1[i] = T+1; 
	}
	DP1[0] = 1;
	int p = 0;
	for(;p<N && D[p].first != 1;p++){
		DP2[0] = 1;
		for(int i=1;i<50;i++){
			DP2[i] = min(DP1[i],DP1[i-1]*D[p].first + D[p].second);
		}
		swap(DP1,DP2);
	}
	int st = p;
	for(;p<N;p++){
		sum[p+1] = sum[p] + D[p].second;
	}
	int ans = 0;
	for(int i=0;i<50;i++){
		int bf = st-1;
		int bl = N;
		while(bf != bl){
			int bc = (bf+bl+1)/2;
			if(bc == st-1 || sum[bc]+DP1[i] <= T){
				bf = bc;
			}
			else{
				bl = bc-1;
			}
		}
		if(bf != st-1){
			ans = max(ans,i+bf-st);
		}
	}
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, m;
	int a[100];
	cin >> n >> m;
	int sum = 0;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		sum+=a[i];
	}
	sort(a, a + n, greater<int>());
	if((4 * m * a[m - 1]) >= sum){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
typedef long long ll;
ll n,m,ans=0,a[100001][26];
char s[100010],t[100010];
int main(){
    scanf("%s",s);
    scanf("%s",t);
    n=strlen(s);
    m=strlen(t);
    for(int i=0;i<n;i++){
        for(int j=0;j<26;j++){
            a[i][j]=-1;
        }
    }
    for(int i=0;i<n;i++){
        a[i][s[i]-'a']=(i)%n;
        for(int j=i-1;s[(j+n*n)%n]!=s[i];j--){
            a[(j+n*n)%n][s[i]-'a']=(i)%n;
        }
    }
    ll p=-1;
    for(int i=0;i<m;i++){
        p++;
        p%=n;
        ans++;
        if(a[p][t[i]-'a']==-1){
            printf("-1\n");
            return 0;
        }
        ans+=(n+a[p][t[i]-'a']-p)%n;
        p=a[p][t[i]-'a'];
    }
    printf("%lld\n",ans);
}

Measured memory_bytes: 20864
A, B = gets.chomp.split.map(&:to_i)

lowestPriceForA = (A/0.08).ceil

if ((A+1)/0.08) == ((A+1)/0.08).floor then
    highestPriceForA = ((A+1)/0.08) - 1
else
    highestPriceForA = ((A+1)/0.08).floor
end

priceRangeA = []
for i in lowestPriceForA..highestPriceForA do
    priceRangeA.push(i)
end
# p priceRangeA

lowestPriceForB = (B/0.1).ceil

if ((B+1)/0.1) == ((B+1)/0.1).floor then
    highestPriceForB = ((B+1)/0.1) - 1
else
    highestPriceForB = ((B+1)/0.1).floor
end

priceRangeB = []
for i in lowestPriceForB..highestPriceForB do
    priceRangeB.push(i)
end
# p priceRangeB

mary = priceRangeA & priceRangeB
# p mary
if mary.empty? then
    puts (-1).to_s
else
    puts mary[0]
end


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


int main(void) {
  int n;
  cin >> n;
  vector<ll> a(n + 2);
  rep(i, n) {
    cin >> a[i + 1];
  }
  a[0] = a[n + 1] = 0;

  ll sum = 0;
  rep(i, n + 1) {
    sum += abs(a[i + 1] - a[i]); 
  }

  for (int i = 1; i <= n; ++i) {
    ll num = sum;
    num = num - abs(a[i - 1] - a[i]) - abs(a[i] - a[i + 1]);
    num = num + abs(a[i - 1] - a[i + 1]);
    cout << num << endl;
  }

  
  return 0;
}

Measured memory_bytes: 3888
import java.util.Scanner;

//20180508
//04

public class Main {
    public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		while (scanner.hasNextLine()) {
			int a = scanner.nextInt();
			String op = scanner.next();
			int b = scanner.nextInt();
			int ans = 0;

			if("+".equals(op)) {
				ans = a + b;
			}
			if("-".equals(op)) {
				ans = a - b;
			}
			if("*".equals(op)) {
				ans = a * b;
			}
			if("/".equals(op)) {
				ans = a / b;
			}
			if("?".equals(op)) {
				break;
			}
			System.out.println(ans);
		}

    	scanner.close();
    }
}


Measured memory_bytes: 26308
# 入力
N, A, B = map(int, input().split())
X = list(map(int, input().split()))

# 町1, 町2, ..., 町Nの順に訪問する
ans = sum(
    min(A * (r - l), B)
    for l, r in zip(X, X[1:])
)

# 出力
print(ans)


Measured memory_bytes: 14224
#include <iostream>
 #include <algorithm>

 using namespace std;

 int main(){
     int a, b, c, times = 0;
     cin >> a >> b >> c;
     switch ((a % 2) + (b % 2) * 2 + (c % 2) * 4) {
         case 0: times -= 1; break;
         case 1: a -= 1;     break;
         case 2: b -= 1;     break;
         case 3: c -= 1;     break;
         case 4: c -= 1;     break;
         case 5: b -= 1;     break;
         case 6: a -= 1;     break;
         case 7: times -= 1; break;
         default: ;
     }
     int m = max({a, b, c});
     times += (m * 3 - a - b - c) / 2 + 1;
     cout << times << endl;
     return 0;
 }


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

long downScore(const vector<int> &c, const vector<int> &last, const int d)
{
    int dScore = 0;
    for (int i = 0; i < 26; ++i)
    {
        dScore += c.at(i) * (d - last.at(i));
    }
    return dScore;
}

int main()
{
    const int typeNum = 26;
    int D;
    cin >> D;

    vector<int> c(typeNum);
    vector<vector<long>> s(D + 1);
    vector<int> last(typeNum);

    for (int i = 0; i < typeNum; ++i)
    {
        cin >> c.at(i);
    }

    for (int j = 1; j <= D; ++j)
    {
        vector<long> dayS(typeNum);
        for (int i = 0; i < typeNum; ++i)
        {
            cin >> dayS.at(i);
        }
        s.at(j) = dayS;
    }

    vector<int> t(D + 1);

    for (int i = 1; i <= D; ++i)
    {
        cin >> t.at(i);
    }

    vector<int> v(D + 1);

    for (int i = 1; i <= D; ++i)
    {
        int type = t.at(i) - 1;
        last.at(type) = i;

        long dayScore =
            s.at(i).at(type) - downScore(c, last, i);

        v.at(i) = v.at(i - 1) + dayScore;
    }

    for (int i = 1; i <= D; ++i )
    {
        cout << v.at(i) << endl;
    }

    return 0;
}

Measured memory_bytes: 3656
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main() {
	ios_base::sync_with_stdio(false);

	int a, b;
	cin >> a >> b;
	int aa = min(a, b);
	int bb = max(a, b);
	REP(i, bb) cout << aa;
	cout << endl;
	
}

Measured memory_bytes: 3644
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<complex>

#define INF (long long)1000000000
#define MOD 1000000007
#define EPS 1e-8

#define REP(i, m) for(long long i = 0; i < m; ++i)
#define FOR(i, n, m) for(long long i = n; i < m; ++i)
#define ALL(v) v.begin(), v.end()
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	string s;
	cin>>s;
	int k;
	cin>>k;
	REP(i,s.size()) {
		if(i!=s.size()-1) {
			if(s[i]!='a'&&(int)('z'-s[i])+1<=k) {
				k-=(int)('z'-s[i])+1;
				s[i]='a';
			} else {
				continue;
			}
		} else {
			int c = k%26;
			if(c<=(int)('z'-s[i])) {
				s[i]=s[i]+c;
			} else {
				c-=(int)('z'-s[i]);
				--c;
				s[i]='a'+c;
			}
		}
	}
	cout<<s<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

typedef long long ll;

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

  string a;
  cin >> a;

  int n = a.length();

  ll count[26];
  fill(count, count + 26, 0);
  for(int i = 0; i < n; i++){
    count[a[i] - 'a']++;
  }

  ll sub = 0;
  for(char ch = 'a'; ch <= 'z'; ch++){
    sub += count[ch - 'a'] * (count[ch - 'a'] - 1) / 2; 
  }

  ll sum = (ll)n * (n - 1) / 2 - sub + 1;

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 720
N,W=map(int,input().split())
w=[0]*N
v=[0]*N
for i in range(N):
    w[i],v[i]=map(int,input().split())
dp=[0]*(W+1)
for i in range(N):
    j=W
    while j>=w[i]:
        dp[j]=max(dp[j],dp[j-w[i]]+v[i])
        j-=1
print(dp[W])

Measured memory_bytes: 42092
NUM = 10**9 + 7
def solve():
    N = int(input())
    dict = {}
    for n in range(2, N + 1):
        for i in range(2, n + 1):
            while n % i == 0:
                n //= i
                if not i in dict.keys():
                    dict[i] = 1
                else:
                    dict[i] += 1
    res = 1
    for i in dict.values():
        res *= (i + 1)
        res %= NUM
    return res

if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
#define pb push_back
#define fi first
#define se second
#define mk make_pair

typedef long long ll;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
int Nerr;
template<typename A> string to_string(A *p) {return to_string(vector<A>(p, p + Nerr));}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;

/***********************************************************************/


void solve_case(){
	int n;cin >> n;
	vector<int> vec(n);
	map<ll, ll> ma;
	for(int x = 0; x<n; x++){
		cin >> vec[x];
		ma[vec[x]]++;
	}
	ll ans = 0;
	for(auto a: ma){
		ans += a.second * (a.second - 1)/2;
	}
	for(int x =0; x<n; x++){
		cout << ans - ma[vec[x]] + 1 << "\n";
	}


 }


int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
 	for(int x =1; x<= t; x++){
 		// cout << "Case #" << x << ": ";
 		solve_case();

 	}
}


Measured memory_bytes: 10368
n = gets.chomp!.to_i

takahashi = []
aoki = []
tokuten = []

n.times do |i|
  a, b = gets.chomp!.split(" ").map(&:to_i)
  takahashi << a
  aoki << b
  tokuten << { idx: i, point: a + b }
end
tokuten.sort! { |a, b| b[:point] <=> a[:point] }

ans = 0
n.times do |i|
  if i.even?
    ans += takahashi[tokuten[i][:idx]]
  else
    ans -= aoki[tokuten[i][:idx]]
  end
end

puts ans


Measured memory_bytes: 33912
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var AB = ReadInts();

            for (int i = 1; i < 1000000; i++)
            {
                if (i * AB[0] >= AB[1])
                {
                    WriteLine(i);
                    return;
                }
            }

        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 17932
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val n, m = sc.nextInt()
    val uf = new UnionFindTree(n)
    for (i <- 0 until m) {
      val l, r, d = sc.nextInt()

      uf.diff(l - 1, r - 1) match {
        case Some(x) =>
          if (x != d) {
            println("No")
            debug(l, r, d, x)
            sys.exit(0)
          }
        case None => uf.unite(l - 1, r - 1, d)
      }
    }
    println("Yes")
  }

  def debug(args: Any*): Unit = {
    Console.err.println(args.mkString(" "))
  }
}

//閉路検出はrootにたいしてhasLoopを呼び出す
//root以外のSizeArrayは正確ではないから外部からアクセスできないようにする
//基本可変配列で初期化
class UnionFindTree(n: Int) {
  private val par = new Array[Int](n)
  private val hasLoops = new Array[Boolean](n)
  private val sizeArray = new Array[Long](n)
  private val weightArray = new Array[Long](n)
  init(n)

  def init(n: Int): Unit = {
    for (i <- 0 until n) {
      par(i) = i
      sizeArray(i) = 1
      hasLoops(i) = false
    }
  }

  def root(x: Int): Int = {
    if (par(x) == x) {
      x
    } else {
      //経路圧縮
      val tmp = root(par(x))
      weightArray(x) += weightArray(par(x))
      par(x) = tmp
      tmp
    }
  }

  def size(x: Int): Long = {
    sizeArray(root(x))
  }

  def hasLoop(i: Int): Boolean = {
    hasLoops(i)
  }

  def isSame(x: Int, y: Int): Boolean = {
    root(x) == root(y)
  }

  def unite(x: Int, y: Int, w: Int): Unit = {
    val (xx, yy) = (root(x), root(y))
    if (!isSame(x, y)) {
      //xxにyyをつけるとき
      if (sizeArray(xx) >= sizeArray(yy)) {
        par(yy) = xx
        sizeArray(xx) += sizeArray(yy)
        weightArray(yy) = -w - weightArray(y) + weightArray(x)
      }
      //yyにxxをつけるとき
      else {
        par(xx) = yy
        sizeArray(yy) += sizeArray(xx)
        weightArray(xx) = w + weightArray(y) - weightArray(x)
      }
    } else {
      hasLoops(xx) = true
    }

  }

  def diff(x: Int, y: Int): Option[Long] = {
    if (!isSame(x, y)) None else Option(weightArray(x) - weightArray(y))
  }

  def isParent(x: Int): Boolean = {
    par(x) == x
  }

}


Measured memory_bytes: 117424
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
 
int main(void)
{
    int n,x=0,y=0;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++)
        cin >> a[i];

    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());

    for(int i = 0;i<n;i++){
        if(i%2==0)
            x += a[i];
        else
            y += a[i];
    }

    cout << x-y << endl;

}

Measured memory_bytes: 256
# ABC082 B

def main():
    s = input()
    t = input()

    list_s = []
    list_t = []

    for char in s:
        list_s.append(char)
    
    for char in t:
        list_t.append(char)
    
    if ''.join(sorted(list_s)) < ''.join(sorted(list_t)[::-1]):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>
#include <functional>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;

using namespace std;

#ifndef LOCAL
#define cerr _cer
struct _cert
{
    template <typename T> _cert& operator << (T) { return *this; }
};
_cert _cer;
#endif

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
		cerr << (*i) << " ";
    }
    cerr << "\n";
}
const ll MOD = 1e9 + 7;

ll get(ll *x, int n) {
    ll ans = 0;
    for (int i = 0; i < n - 1; ++i) {
        ll l = x[i + 1] - x[i];
        ll cc = (ll)(i + 1) * (ll)(n - (i + 1));
        ans = (ans + l * cc) % MOD;
    }
    return ans;
}

int n, m;
ll x[120000];
ll y[120000];

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++i)
        scanf("%lld", x + i);
    for (int i = 0; i < m; ++i)
        scanf("%lld", y + i);
    cout << get(x, n) * get(y, m) % MOD;
	return 0;
}




Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int x, n;
    cin >> x >> n;
    if (n == 0)
    {
        cout << x << endl;
        return 0;
    }
    vint p(n);
    rep(i, n) cin >> p[i];
    int cur = -1000;
    int ans = 0;
    rep(i, 102)
    {
        int d = abs(i - x);
        int dnow = abs(x - cur);
        if (d < dnow && find(p.begin(), p.end(), i) == p.end())
        {
            ans = i;
            cur = i;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#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> h(N);
    rep(i, N) cin >> h[i];

    vector<int> dp(N+1, 1000000009);
    dp[0] = 0;
    rep(i, N) {
        if(i+1 < N) dp[i+1] = min(dp[i+1], dp[i]+abs(h[i]-h[i+1]));
        if(i+2 < N) dp[i+2] = min(dp[i+2], dp[i]+abs(h[i]-h[i+2]));
    }

    cout << dp[N-1] << endl;
    return 0;
}

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

#define INF int(1e9)
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=1000005;
const int mod=1e9+7;
int n,ans;
int fac[maxn],ifac[maxn];
int C(int a,int b){
	if(a<b||a<0||b<0)return 0;
	return 1LL*fac[a]*ifac[b]%mod*ifac[a-b]%mod;
}

int main(){
	scanf("%d",&n);
	fac[0]=fac[1]=ifac[0]=ifac[1]=1;
	for(int i=2;i<=n;i++){
		fac[i]=1LL*fac[i-1]*i%mod;
		ifac[i]=1LL*ifac[mod%i]*(mod-mod/i)%mod;
	}
	REP(i,n)ifac[i]=1LL*ifac[i-1]*ifac[i]%mod;
	if(n==2){
		puts("1");
		return 0;
	}
	ans=fac[n];
	rep(i,n-2){
		ans-=1LL*C(i+1,n-3-i)*fac[i+2]%mod*fac[n-3-i]%mod;
		if(ans<0)ans+=mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 8064
#include<stdio.h>
#include<string.h>
int main(void){

 int a, i;
 char s[4];

scanf("%s", s);

if(strlen(s)==2){
 printf("%s", s);
}
else if(strlen(s)==3){
 for(i=2; i>=0; i--)
  printf("%c", s[i]);
}
printf("\n");

return 0;
}

Measured memory_bytes: 128
/*
Author: CNYALI_LK
LANG: C++
PROG: Cf2017C_C.cpp
*/
#include<bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define all(x) x.begin(),x.end()
using namespace std;
const double eps=1e-8;
const double PI=acos(-1.0);
typedef long long ll;
template<class T>int chkmin(T &a,T b){return a>b?a=b,1:0;}
template<class T>int chkmax(T &a,T b){return a<b?a=b,1:0;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
#define min mmin
#define max mmax
#define abs aabs
char s[102000];
int ss[102000],lnx,n;
int pal(){
	int mid=lnx>>1;
	for(int i=1;i<=mid;++i){
		if(ss[i]!=ss[lnx-i+1])return 0;
	}
	return 1;
}
int dw(int x){
	int i;
	for(i=1;x;++i)if(s[i]!='x')--x;
	return i-1;
}
int chk(){
	int lm,rm;
	if(lnx&1){
		lm=dw((lnx+1)>>1),rm=lm;
	}
	else{
		lm=dw(lnx>>1),rm=dw((lnx>>1)+1);
	}
	int tot=0;
	while(lm>1||rm<n){
		if(s[lm-1]==s[rm+1]){
			--lm;++rm;
		}
		else if(s[lm-1]=='x'){
			--lm;
			++tot;
		}
		else{
			++rm;
			++tot;
		}
	}
	return tot;
}
int main(){
#ifdef cnyali_lk
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;++i)if(s[i]!='x'){
		ss[++lnx]=s[i];
	}
	if(!pal()){
		printf("-1\n");
	}
	else{
		printf("%d\n",chk());
	}
	return 0;
}



Measured memory_bytes: 768
/**
 * Я слил Atcoder Beginner Contest 172, решив всего две задачи!
 * Я не могу апнуть синего!
 * Я постоянно сливаю раунды, либо не решив тупую задачу, либо набрав штрафа!
 * Я постоянно уступаю всем своим друзьям и знакомым в контестах и нахожу этому оправдания!
 * Я постоянно придумываю сложные неверные решения к простым задачам!
 * -------------------------------------------------------------
 * -Решать сложные задачи
 * -Участвовать в контестах
 * -Делать виртуальные соревнования
 * -------------------------------------------------------------
 * Не уберу это, пока не начну нормально решать задачи, а не заниматься ерундой!!!
**/
  
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
 
typedef long long  ll;

#define press_F_to_pay_respect ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define fore(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define pob pop_back()
#define mp make_pair 
#define sc second 
#define f first 
#define ld long double
#define kek cout<<endl; 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) ((v).begin()), ((v).end()) 
#define halt {cout<<"NO"; return 0;}

const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int N = 200010;
const int INF = 1e8;
const ll LL_INF=1e10;
const long double pi=3.1415926535;
using namespace std;
using namespace __gnu_pbds;
typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main()
{
    #if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
    #endif
 press_F_to_pay_respect;
 // cout << fixed << setprecision(12) << ans;
 // string al = "abcdefghijklmnopqrstuvwxyz";
 int questions=1;
 // cin>>questions;
 
 while(questions--)
 {
   
   int x;
   cin>>x;
   if(x>=400 && x<=599) cout<<8;
   else if(x>=600 && x<=799) cout<<7;
   else if(x>=800 && x<=999) cout<<6;
   else if(x>=1000 && x<=1199) cout<<5;
   else if(x>=1200 && x<=1399) cout<<4;
   else if(x>=1400 && x<=1599) cout<<3;
   else if(x>=1600 && x<=1799) cout<<2;
   else cout<<1;
   
   
          
          
          
         
 }
 
 
 
 
  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
   
 
}

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

int N,x[200000],y[200000];

int main(){
	cin>>N;
	for(int i=0;i<N;i++){
		int p,q;
		cin>>p>>q;
		x[i]=p+q;
		y[i]=p-q;
	}
	sort(x,x+N);
	sort(y,y+N);
	cout<<max(x[N-1]-x[0],y[N-1]-y[0])<<endl;
}



Measured memory_bytes: 5164
#include <stdio.h>

int max(int a, int b) {
    if (a > b)
        return a;
    return b;
}

int bs(long long *arr, int n, long long val) {
    int l = 0, r = n-1, mid = (l+r)/2;

    while (r - l > 1) {
        mid = (r + l) >> 1;

        if (arr[mid] > val)
            r = mid;
        else
            l = mid;
    }
    if (arr[r] <= val)
        return r;
    if (arr[mid] <= val)
        return mid;
    if (arr[l] <= val)
        return l;
    return -1;
}

int main() {
    int n, m;
    long long k;
    long long aprefix[200000+7];
    long long bprefix[200000+7];

    scanf("%d %d %lld", &n, &m, &k);

    long long prev = 0, temp;
    for (int i=0; i < n; i++) {
        scanf("%lld", &temp);
        aprefix[i] = prev + temp;
        prev = aprefix[i];
    }
    prev = 0;
    for (int i=0; i < m; i++) {
        scanf("%lld", &temp);
        bprefix[i] = prev + temp;
        prev = bprefix[i];
    }
    int ans = 0;
    temp = bs(bprefix, m, k);
    if (temp != -1) {
        ans = temp + 1;
    }
    temp = bs(aprefix, n, k);
    if (temp != -1) {
        ans = max(ans, temp + 1);
    }

    for (int a=0; a < n; a++) {
        long long rem = k - aprefix[a];
        if (rem <= 0)
            break;
        int b = bs(bprefix, m, rem);
        if (b != -1)
            ans = max(ans, a + 1 + b + 1);
    }

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 4856
#include<bits/stdc++.h>
#define rg register
#define oo 0x7fffffff
#define ll long long
using namespace std;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		{
			fh=-1;
			jp=getchar();
		}
	while (jp>='0'&&jp<='9')
		{
			out=out*10+jp-'0';
			jp=getchar();
		}
	return out*fh;
}
const int MAXN=1e2+10;
int n;
int a[MAXN];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read();
	int x=read();
	for(rg int i=1;i<=n;++i)
		a[i]=read();
	sort(a+1,a+1+n);
	int ans=0;
	for(int i=1;i<=n;++i)
		{
			if(x>=a[i])
				ans++,x-=a[i];
			else
				{
					cout<<ans;
					return 0;
				}
		}
	if(x)
		cout<<n-1;
	else
		cout<<n;
	//fclose(stdin);
	//fclose(stdout);
	return 0;
}


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

int main(){
  char s, ans;
  cin >> s;
  if(s == 'A') ans = 'T';
  else if(s == 'T') ans = 'A';
  else if(s == 'G') ans = 'C';
  else ans = 'G';
  cout << ans << endl;
}

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

int main(void) {
    int m;
    int n; cin >> n;
    int a[3];
    for(int i = 0; i < n; i++) {
        cin >> a[0] >> a[1] >> a[2];
        m = max(max(a[0], a[1]), a[2]);
        if(m * m == (a[0] < m)*a[0]*a[0] + (a[1] < m)*a[1]*a[1] + (a[2] < m)*a[2]*a[2]) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}

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

int n, m, x;
int map[101];

int main(){
    cin >> n >> m >> x;
    for(int i = 0; i < n + 1; i ++) map[i] = 0;
    int buf;
    for(int i = 0; i < m; i++){
        cin >> buf;
        map[buf] = 1;
    }
    int lp = 0, rp = 0;
    for(int l = x; l != 0; l--) lp = lp + map[l];
    for(int r = x; r <= n; r++) rp = rp + map[r];
    if(rp < lp){
        cout << rp << endl;
    }else{
        cout << lp << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n, -1) {}
    void init(int n) { par.assign(n, -1); }

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

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

    bool merge(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (par[x] > par[y])
            swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    map<int, vector<int>> mp;
    for(int i=0;i<n;i++){
        int k, l; cin >> k;
        for(int j=0;j<k;j++){
            cin >> l; l--;
            mp[l].push_back(i);
        }
    }
    UnionFind uf(n);
    for(auto p: mp){
        auto v = p.second;
        for(int i=1;i<v.size();i++){
            uf.merge(v[i],v[i-1]);
        }
    }
    set<int> se;
    for(int i=0;i<n;i++){
        se.insert(uf.root(i));
    }
    if(se.size() == 1) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

int main(){
    int64_t n, k;
    cin >> n >> k;

    vector<int> a(n);
    for (auto i = 0; i < n; i++) {
        cin >> a[i]; a[i]--;
    }

    vector<bool> b(n, false);
    vector<int> c;
    int loop_index, next = a[0];
    while(true) {
        if(b[next]) {
            // c.push_back(next);
            loop_index = next;
            break;
        }
        b[next] = true;
        c.push_back(next);
        next = a[next];
    }

    int loop_size = 0;
    for (auto i = 0; i < (int)c.size(); i++) {
        if(c[i] == loop_index) {
            loop_size = (int)c.size() - i;
            loop_index = i;
            break;
        }
    }

//    cout << loop_index << " " << loop_size << endl;
//    for (auto elm : c) cout << elm << " ";
//    cout << endl;

    if(k > loop_index) {
        auto index = (k - 1 - loop_index) % (int64_t)loop_size + loop_index;
        // cout << index << endl;
        //if(index == 0) index = c.size() - 1;
        //else index--;
        cout << c[index] + 1 << endl;
        return 0;
    } else {
        cout << c[k - 1] + 1 << endl;
        return 0;
    }
}

Measured memory_bytes: 5020
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		char a = sc.next().charAt(0);
		
		char ans;
		if (a < 'a')
			ans = 'A';
		else
			ans = 'a';
			
		System.out.println(ans);
	}
}




Measured memory_bytes: 27028
// Package main provides
//
// File:  b.go
// Author: ymiyamoto
//
// Created on Mon Dec 31 13:18:10 2018
//
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	arr := make([]int, N)

	for i := range arr {
		fmt.Scan(&arr[i])
	}

	sort.Ints(arr)

	isAlice := true
	alice := 0
	bob := 0
	for i := len(arr) - 1; i >= 0; i-- {
		if isAlice {
			alice += arr[i]
		} else {
			bob += arr[i]
		}
		isAlice = !isAlice
	}

	fmt.Println(alice - bob)
}


Measured memory_bytes: 512
import java.io.*;
import java.util.*;
public class Main
{
    static PrintWriter out=new PrintWriter((System.out));
    public static void main(String args[])throws IOException
    {
        Reader sc=new Reader();
        int k=sc.nextInt();
        int n=sc.nextInt();
        int m=sc.nextInt();
        boolean found=false;
        for(int x=n;x<=m;x++)
        {
            if(x%k==0)
            {
                found=true;
                break;
            }
        }
        out.println(found?"OK":"NG");
        out.close();
    }

    public static void solve()
    {
    }

    static class Reader 
    { 
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");
        public String next()
        {
            while(!st.hasMoreTokens())
            {
                try
                {
                    st=new StringTokenizer(br.readLine());
                }
                catch(Exception e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

        public long nextLong()
        {
            return Long.parseLong(next());
        }

        public double nextDouble()
        {
            return Double.parseDouble(next());
        }

        public String nextLine()
        {
            try
            {
                return br.readLine();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
            return null;
        }

        public boolean hasNext()
        {
            String next=null;
            try
            {
                next=br.readLine();
            }
            catch(Exception e)
            {
            }
            if(next==null)
            {
                return false;
            }
            st=new StringTokenizer(next);
            return true;
        }
    } 
}

Measured memory_bytes: 32800
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define ln '\n'
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    bool ok = false;
    while (N > 0) {
        if (N%10==7) ok = true;
        N /= 10;
    }
    cout << (ok ? "Yes" : "No") << ln;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
 
using namespace std;
 
int h,w,sx,sy,gx,gy,tx,ty;
char house[505][505];   
bool isvisited[505][505]={false};
 
void search(int x,int y){
    if(isvisited[x][y]){
        return;
    }
    isvisited[x][y]=true;
 
    if(x<=0 || x>h || y<=0 || y>w){
        return;
    }
 
    if(house[x][y]=='#'){
        return;
    }
 
    search(x-1,y-1);
    search(x-1,y);
    search(x-1,y+1);
    search(x,y-1);
    search(x,y);
    search(x,y+1);
    search(x+1,y-1);
    search(x+1,y);
    search(x+1,y+1);
}
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>h>>w;
    if(h%w==0){
      cout<<h/w<<'\n';
    }
    else{
      cout<<h/w+1<<'\n';
    }
 
    return 0;
}


Measured memory_bytes: 256
ans = 0
fhun = int(input())
hun = int(input())
fif = int(input())
money = int(input())
for i in range(fhun + 1):
  for j in range(hun + 1):
    for l in range(fif + 1):
      if (500 * i + 100 * j + 50 * l) == money:
        ans += 1
print(ans)

Measured memory_bytes: 3060
use std::io;
use std::collections::HashSet;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let mut set = HashSet::new();
	let v:Vec<i32> = procon_read();
	let a = v[0];
	let b = v[1];
	let c = v[2];
	let d = a%b;
	let mut e = 0;
	loop{
		e = (e+d)%b;
		if !set.insert(e) {
			println!("NO");
			break;
		}
		if e == c {
			println!("YES");
			break;
		}
	}
}

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

struct UnionFind {
    vector<int> data;
    int sz;
    UnionFind(int sz) : data(sz, -1), sz(sz) { }
    bool unionSet(int x, int y) {
        if ((x = root(x)) == (y = root(y))) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y]; data[y] = x; sz--;
        return true;
    }
    bool findSet(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 size() { return sz; }
};

int main() {
    int n, m; cin >> n >> m;
    UnionFind uf(n);
    for (int i = 0; i < m; i++) {
        int x, y, z; cin >> x >> y >> z; x--, y--;
        uf.unionSet(x, y);
    }
    cout << uf.size() << endl;
    return 0;
}

Measured memory_bytes: 640
#include <vector>

#include <iostream>
#define rep(i,n) for(int i=0; i<(n); i++)

using namespace std;

typedef vector<int> vi;

// ?????£?????????????§£ (Strongly Connected Component)
// ????????°???????????°????????????????????£??¬??????????????? ???????????§
struct SCC {
	int N;     // ????????°
	vector<vi> G;    // ??°??????
	vector<bool> used;    // ?????§???????????????
	vector<int> order;    // ????????????????????????(?????£?????????????£?????????????)
	vector<int> vs;   // ??°????????????

	// ?????????????????????1
	SCC(int _N): G(_N), order(_N) {
		N = _N;
	}

	// ?????????????????????2
	SCC(vector<vi> &v): G(v), order(v.size()) {
		N = v.size();
		scc();
	}

	// a -> b ?????????????????????
	void add_edge(int a, int b){
		G[a].push_back(b);
	}

	// ??¢??°???????????§?????????scc(v)??¨????????????????????????
	vector<int> operator()(vector<vi> v){
		G.assign( v.begin(), v.end() );
		N = v.size();
		scc();
		return order;
	}

	// scc()??§??????
	void dfs(int n, int k, vector<vi> &v, vector<vi> &rv){
		//cout << "dfs: " << n << " " << k << endl;
		used[n] = true;
		order[n] = k;
		for(auto t: v[n]){
			if( !rv.empty() ) rv[t].push_back(n);		// ???????????°???????????????
			if( !used[t] ) dfs(t, k, v, rv);
		}
		vs.push_back(n);
	}

	// ?????£?????????????§£?????????
	int scc(){
		used.assign(N, false);
		vs.clear();
		vector<vi> rG(N);   // ????????????????????°????????¨
		for(int n=0; n < N; n++){
			if( !used[n] ) dfs(n, n, G, rG);
		}
		//cout << rG.size() << endl;
		//for(auto t: rG){
		//	cout << "rG: ";
		//	for(auto tt: t) cout << tt << ", ";
		//	cout << endl;
		//}
		//cout << vs.size() << endl;
		//for(auto t: vs) cout << "scc: " << t << endl;
		used.assign(N, false);
		int k = 0;
		//vector<vi> tmp(N, vi(N));
		vector<vi> tmp;
		for(int i = vs.size()-1; i >= 0; i--){
			if( !used[ vs[i] ] ) dfs(vs[i], k++, rG, tmp);
		}
		return k++;
	}
//	int scc(vector<vi> &v){
//		G = &v;
//		N = v.size();
//		scc();
//	}

	// ?±????????????£????????????????????????????????????
	bool find(int x, int y){
		return order[x] == order[y];
	}
};

// 2-SAT ??????
class TwoSAT{
};


// test
// AOJ GRL_3_C (http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_3_C&lang=jp)
int main(){
	int V, E;
	cin >> V >> E;
	SCC graph(V);
	rep(i,E){
		int s, t;
		cin >> s >> t;
		graph.add_edge( s, t );
	}

	graph.scc();
	//rep(i,V) cout << "graph: " << i << " " << graph.order[i] << endl;

	int Q;
	cin >> Q;
	rep(i,Q){
		int u, v;
		cin >> u >> v;
		cout << (int)graph.find(u, v) << endl;
	}

	return 0;
}

Measured memory_bytes: 4376
<?php

// test
// echo 'please enter: ';
// $a = 0;
// fscanf(STDIN,"%s %s", $a, $b);
// var_dump($a, $b);

// 読み込み
// echo 'please enter: ';
// K, Nを読み取る
fscanf(STDIN, "%d %d", $K, $N);
// Aiを読み取る
$string = fgets(STDIN);
// 文字列を数値に変換する関数
function stringToInt($string) {
  $int = (int)$string;
  return $int;
}
// Ai配列を作成する
$result[] = array_map(stringToInt, explode(" ", $string));
$A = $result[0];
array_push($A, $K+$A[0]);

// いざ求める
$distanceBetweenTwoHouses = 0;
for($i=0;$i<$N;$i++){
  $tempDistance = $A[$i+1] - $A[$i];
  if ($tempDistance > $distanceBetweenTwoHouses) {
    $distanceBetweenTwoHouses = $tempDistance;
  }
}

// echo $distanceBetweenTwoHouses;

echo $K - $distanceBetweenTwoHouses;
?>

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

int main(void)
{
    char s[101];
    int i,j,k;

    scanf("%s",s);
    k=strlen(s);
    for(i=0;i<k;i++)
        s[i]='x';
    printf("%s",s);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    string S;
    cin >> S;
    vector<int> cnt(26, 0);
    for (auto &c : S) {
        cnt.at(c - 'a')++;
    }
    for (auto &x : cnt) {
        if (x % 2) {
            cout << "No" << endl;
            exit(0);
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256