akhauriyash/Code-Regression huggingface dataset:
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
const long long MAX = (ll)1e5+1000;

class stat{
   public:
   ll c;
   ll s;
   ll f;
   stat(ll a,ll a1,ll a2) {c=a;s =a1;f=a2;};
};
int main(void) {
   ll N;
   cin>>N;
   vector<stat*> vS(N-1);
   rep(i,0,N-1) {
      ll c,s,f;
      cin>>c>>s>>f;
      vS[i] = new stat(c,s,f);
   }
   rep(i,0,N) {
      ll now = 0;
      rep(j,i,N-1) {
         if (now < vS[j]->s) now = vS[j]->s;
         else now = (1 + (int)(now-1)/vS[j]->f) * vS[j]->f;
         now += vS[j]->c;
         // cout<<i<<" "<<j<<" "<<now<<endl;
      }
      cout<<now<<endl;
   }



   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>

using namespace std;

int main(){
    int n, w; cin >> n >> w;
    vector<pair<int, int>> wvs(n);
    for(int i=0; i<n; ++i){
        cin >> wvs[i].first >> wvs[i].second;
    }
    vector<long long> dp(w+1);
    for(int i=0; i<n; ++i){
        vector<long long> next(w+1);
        for(int j=1; j<=w; ++j){
            next[j]=max(next[j-1], dp[j]);
            int k=wvs[i].first;
            if(j>=k) next[j]=max(next[j], dp[j-k]+wvs[i].second);
        }
        dp.swap(next);
    }
    cout << dp[w] << endl;
    return 0;
}


Measured memory_bytes: 1816
import math
from decimal import *
n = int(input())

total = Decimal('0')

for i in range(n):
  x, u = map(str, input().split())
  if u == 'BTC':
    x = Decimal(Decimal(x)) * Decimal(380000.0)
  total += Decimal(x)

print(round(total, 4))


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

int main(){
    int h,w,d;
    cin>>h>>w>>d;
    pair<int,int> pos[h*w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int a;
            cin>>a;
            pos[a-1]={i,j};
        }
    }
    int l=h*w/d+1;
    int sum[d][l]={};
    for(int i=0;i<d;i++){
        for(int j=i+d;j<h*w;j+=d){
            auto a=pos[j];
            auto b=pos[j-d];
            sum[i][j/d]=sum[i][j/d-1]+abs(a.first-b.first)+abs(a.second-b.second);
        }
    }
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        int l,r;
        cin>>l>>r;
        --l,--r;
        cout<<sum[l%d][r/d]-sum[l%d][l/d]<<endl;
    }
}


Measured memory_bytes: 2176
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main()
	{
		int K = GetInt();
		int T = GetInt();
		int[] a = new int[T];
		for(int i = 0; i < T; i++)
			a[i] = GetInt();

		int aMax = a.Max();
		Console.WriteLine(Math.Max(aMax - 1 - (K - aMax), 0));
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 13268
n = int(input())
a = list(map(int,input().split()))
mod = 10**9 + 7
ans = 0

for i in range(60):
    cou  = 0
    bit = 1 << i
    for j in a:
        if j & bit:
            cou += 1
    num1 = cou
    num0 = n - num1
    ans += ((num1*num0) * bit )%mod
print(ans%mod)

Measured memory_bytes: 50988
N = int(input())
wordlist = [input() for i in range(N)]

siri = wordlist[0][0]
wordpool = []
import sys

for word in wordlist:
    if word[0] == siri and word not in wordpool:
        siri = word[-1]
        wordpool.append(word)
    else:
        print("No")
        sys.exit()
        
print("Yes")

Measured memory_bytes: 3060
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  int i = s.size();
  while(i >= 0) {
    s = s[s.size()-1] + s.substr(0,s.size()-1);
    if(s == t) { cout << "Yes" << endl; return 0; }
    i--;
  }
  cout << "No" << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//cout << fixed << setprecision(17) << res << endl;
 
int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> A(n);
    ll sum = 0;
    for (auto & a : A) {
        cin >> a;
        sum += a;
    }
    ll count = 0;
    //ll th = sum);
    // cerr << th << endl;
    for (auto & a : A) {
        if (a * m * 4 >= sum) {
            ++count;
        }
    }
    if (count >= m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector< pair<int, int> > a;
  for(int i=0;i<n;i++){
    int tmp=0;
    cin >> tmp;
    a.push_back( make_pair(tmp, i+1) );
  }
  sort(a.begin(), a.end());
  for(int i=0;i<n;i++){
    cout << a.at(i).second << " ";
  }
  cout << endl;

  return 0;
}

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

int main()
{
	int a, b;
	cin >> a >> b;
	
	if (a - b*2 > 0)
	{
		cout << a - b*2 << endl;
	}
	else
	{
		cout << 0 << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{min,max};
use std::collections::BTreeMap;

fn main() {
    let _n = read_i64();
    let xs = read_vec_i64();
    let ys = {
        let mut ys2 = vec![];
        ys2.push(0);
        for (i,x) in xs.iter().enumerate() {
            let y = ys2[i];
            ys2.push(x + y);
        }
        ys2
    };
    let mut map = BTreeMap::new();
    for &y in &ys {
        *map.entry(y).or_insert(0 as i64) += 1;
    }
    let mut res = 0;
    for (_,&a) in map.iter() {
        if a >= 2 {
            res += a * (a-1) / 2;
        }
    }
    println!("{}", res);
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}


Measured memory_bytes: 12524
N = int(input())
A = list(map(int, input().strip().split()))
num = 0
while True:
    cnt = 0
    for i in range(N):
        if int(A[i]) % 2 == 0:
            cnt += 1
    if cnt == N:
        for i in range(N):
            A[i] = int(A[i]) / 2
        num += 1
    else:
        break
print(num)

Measured memory_bytes: 3060
/*
ID: jerrywcy
TASK: AtCoder ABC 100 Problem B
LINK: https://abc102.contest.atcoder.jp/tasks/abc102_b
LANG: C++
*/
#include <bits/stdc++.h>

using namespace std;

int d,n;

int p(int x,int y){
	int ret=1;
	while (y--)ret*=x;
	return ret;
}
 
int main(){
	cin>>d>>n;
	int delta=p(100,d);
	
	if (n==100)n++;
	cout<<n*delta<<endl;
	
	return 0;
}

Measured memory_bytes: 256
main = do
  s <- getLine
  let [m,f,r] = map (read::String->Int) . words $ s
  if m /= -1 || f /= -1 || r /= -1 then
    let score = m+f
        grade = do
            if m == -1 || f == -1
                then "F"
                else if score >= 80 then "A"
                else if score < 80 && score >= 65 then "B"
                else if score < 65 && score >= 50 then "C"
                else if score < 50 && score >= 30 then
                  if r>=50 then "C"
                  else "D"
                else "F"
    in do
    putStrLn grade
    main
  else
      return ()

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

using namespace std;


int main() {
    int n, m;
    cin >> n >> m;
    map<int, vector<int>> mp;
    map<int, int> mp1;
    vector<pair<int, int>> v;

    for (int i = 0; i < m; ++i) {
        int p, c;
        cin >> p >> c;
        v.push_back(make_pair(p, c));
        mp[p].push_back(c);
    }
    map<int, vector<int>>::iterator it;
    for (it = mp.begin(); it != mp.end(); ++it) {
        vector<int> tmp = it->second;
        sort(tmp.begin(), tmp.end());
        it->second = tmp;
    }

    for (auto x : v) {
        int pp = x.first, cc = lower_bound(mp[x.first].begin(), mp[x.first].end(), x.second) - mp[x.first].begin();
        printf("%06d%06d\n", pp, cc + 1);
    }
}

Measured memory_bytes: 13172
#include<stdio.h>
 
int main(){
    int n, i, max;
    int data[101];

    for (i = 0; i < 101; i++) data[i] = 0;
    while(scanf("%d", &n) != EOF) data[n] += 1;
    max = 0;
    for (i = 1; i < 101; i++){
        if(max < data[i]) max = data[i];
    }
    for (i = 1; i < 101; i++){
        if(max == data[i]){
            printf("%d\n", i);
        }
    }
    return 0;
}

Measured memory_bytes: 596
n=int(input())
a=list(map(int,input().split()))
b=[]
e=False
while e==False:
    b=[]
    a_m=[]
    for i in a:
        if i!=0:
            a_m.append(i)
    #print(a_m)#a=m a of positive
    temp=min(a_m)
    #5
    for i in a:
        g=i%temp
        if i==temp:
            b.append(i)#myself
        elif g!=0:
            b.append(i%temp)
        
    #b is only positive
    #print("temp:",temp)
    #print("b",b)
    if not b:#if empty 
        ans=temp
        e=True
         
    else:
        if temp==min(b):
            ans=temp
            e=True
        else:
            a=b
     #       print(a)
                
print(ans)






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


int main() {
  int K;
  string S;
  cin >> K;
  cin >> S;
  
  if(S.size() <= K){
    cout << S <<endl;
  }
  else{
    int j = 0;
    while (j < K) {
    cout << S.at(j);
    j++;
    }
    cout << "..." <<endl;
  }
}


Measured memory_bytes: 3624
N = int(input())
T = list(map(int, input().split()))
M = int(input())

PX = []

for _ in range(M):
    p, x = map(int, input().split())
    PX.append((p, x))

for p, x in PX:
    t = T.copy()
    t[p - 1] = x
    print(sum(t))


Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
	int n, a, b, c, i;
	while (1){
		scanf("%d", &n);
		if (n == 0) break;
		for (i =0; i < n; i++){
			scanf("%d%d%d", &a, &b, &c);
			if ((a == 100 || b == 100 || c == 100) || (a + b)/2.0 >= 90 || (a + b + c)/3.0 >= 80){
				printf("A\n");
			}else if ((a + b + c)/3.0 >= 70 || (a + b + c)/3.0 >= 50 && a >= 80 || b >= 80){
				printf("B\n");
			}else printf("C\n");
		}
	}
	return 0;
}

Measured memory_bytes: 584
import java.util.*;
public class Main{
  public static void main(String[] args){
  	Scanner sc=new Scanner(System.in);
    int N=sc.nextInt();
    int K=sc.nextInt();
    int X=sc.nextInt();
    int Y=sc.nextInt();
    int sum=0;
    for(int time=1;time<=N;time++){
      if(time<=K) sum+=X;
      else sum+=Y;
    }
    System.out.println(sum);
  }
}

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;



void solve() {
	//~ freopen("distance.in", "r", stdin);
	//~ freopen("distance.out", "w", stdout);
	ios_base::sync_with_stdio(false); 
	cin.tie(nullptr);
	
	char c;
	cin >> c;
	switch (c) {
	case 'A': 
		cout << "T";
		break;
	case 'C':
		cout << "G";
		break;
	case 'G':
		cout << "C";
		break;
	case 'T':
		cout << "A";
		break;
	}
}

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




Measured memory_bytes: 256
#include<stdio.h>
#define N 101
void dfs(void);
void visit(int);

int n,d[N],f[N],color[N],G[N][N]={},time;

int main(){
  int i,j,u,k,v;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      G[u-1][v-1]=1;
    }
  }

  dfs();

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

  return 0;
}
void dfs(){
  int v;
  for(v=0;v<n;v++){
    color[v]=0;
  }
  time=0;
  for(v=0;v<n;v++){
    if(color[v]==0){
      visit(v);
    }
  }
}
void visit(int u){
  int v;

  color[u]=1;
  d[u]=++time;
  for(v=0;v<n;v++){
    if(G[u][v]!=0){
      if(color[v]==0){
	visit(v);
      }
    }
  }
  color[u]=2;
  f[u]=++time;
}

Measured memory_bytes: 636
a = [[], [], []]
line = input().split(" ")
a[0] = list(map(int, line))
line2 = input().split(" ")
a[1] = list(map(int, line2))
line3 = input().split(" ")
a[2] = list(map(int, line3))
ans = []
anss = "No"
for i in range(min(a[0])+1):
    ans = list(map(lambda x: x - i, a[0]))
    if min(ans) < 0:
        continue
    for j in range(min(a[1])+1):
        if ans != list(map(lambda x: x - j, a[1])):
            continue
        for k in range(min(a[2])+1):
            if ans == list(map(lambda x: x - k, a[2])):
                anss = "Yes"
                break
        else:
            continue
        break
    else:
        continue
    break
print(anss)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define CON 1000000000000
#define SIX 1000000
using namespace std;

int main() {
  int a,b,c;
  int num;
  cin >> a >> b >> c;
  if(b/a >= c) {
    num = c;
  } else {
    num = b/a;
  }
  cout << num << endl;
  return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
    
    int n, m;
    cin >> n >> m;
    V<int> a(n), b(n), c(m), d(m);
    rep(i,n) cin >> a[i] >> b[i];
    rep(i,m) cin >> c[i] >> d[i];

    rep(i,n) {
        int ans = -1;
        int dist = inf;
        rep(j,m) {
            int tmp = abs(c[j] - a[i]) + abs(d[j] - b[i]);
            if(dist > tmp) {
                dist = tmp;
                ans = j+1;
            }
        }
        cout << ans << endl;
    }
}

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

using namespace std;

template<typename T> string to_string(const T& v) {
  string str;
  for (const auto& i : const_cast<T&>(v)) str += to_string(i) + " ";
  return str.substr(0, max(0, (int)str.size() - 1));
}

#ifdef __MINGW32__

template<> string to_string<int>(const int& v) {
  stringstream ss;
  ss << v;
  return ss.str();
}

template<> string to_string<long>(const long& v) {
  stringstream ss;
  ss << v;
  return ss.str();
}

template<> string to_string<long long>(const long long& v) {
  stringstream ss;
  ss << v;
  return ss.str();
}

template<> string to_string<unsigned int>(const unsigned int& v) {
  stringstream ss;
  ss << v;
  return ss.str();
}

template<> string to_string<unsigned long>(const unsigned long& v) {
  stringstream ss;
  ss << v;
  return ss.str();
}

template<> string to_string<unsigned long long>(const unsigned long long& v) {
  stringstream ss;
  ss << v;
  return ss.str();
}

template<> string to_string<float>(const float& v) {
  stringstream ss;
  ss << v;
  return ss.str();
}

template<> string to_string<double>(const double& v) {
  stringstream ss;
  ss << v;
  return ss.str();
}

template<> string to_string<long double>(const long double& v) {
  stringstream ss;
  ss << v;
  return ss.str();
}

#endif

int main() {
  int n;
  while (cin >> n) {
    int t = 1;
    vector<int> res;
    for (; n; n /= 2, t *= 2) if (n % 2) res.emplace_back(t);
    cout << to_string(res) << endl;
  }
}

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int dp[41][60001][3] = {};
int main(){
    int N;
    int inf = 1e5;
    while(cin >> N && N){
        vector<int> P(N+1,0),T(N+1,0);
        for(int i=0;i<=N;i++) for(int j=0;j<=60000;j++) for(int k=0;k<=2;k++) dp[i][j][k] = inf;
        for(int i=1;i<=N;i++) cin >> P[i] >> T[i];
        dp[0][0][0] = 0;
        for(int i=1;i<=N;i++){
            for(int j=0;j<=T[i];j++){
                if(j+P[i]<=T[i]){
                    dp[i][T[i]+2*P[i]][0] = min(dp[i][T[i]+2*P[i]][0],dp[i-1][j][0]+2*P[i]);
                    dp[i][T[i]][1] = min(dp[i][T[i]][1],dp[i-1][j][0]+P[i]);
                }
                for(int k=1;k<=2;k++){
                    if(j+(k+1)*abs(P[i]-P[i-1])<=T[i]){
                        dp[i][T[i]+(k+2)*P[i]][0] = min(dp[i][T[i]+(k+2)*P[i]][0],dp[i-1][j][k]+abs(P[i]-P[i-1])+P[i]);
                        if(k==1) dp[i][T[i]][k+1] = min(dp[i][T[i]][k+1],dp[i-1][j][k]+abs(P[i]-P[i-1]));
                    }
                }
            }
        }
        int ans = inf;
        for(int j=0;j<=60000;j++) ans = min(ans,dp[N][j][0]);
        if(ans!=inf){
            cout << "OK " << ans << endl;
            continue;
        }
        cout << "NG ";
        for(int i=1;i<=N;i++){
            bool ok = true;
            for(int j=0;j<=60000;j++) if(dp[i][j][0]!=inf) ok = false;
            if(ok){
                cout << i << endl;
                break;
            }
        }
    }
}


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

using namespace std;

class UnionFind {
 public:
  vector<int> parent;

  UnionFind(int n) : parent(n, -1) {}

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

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

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

  bool unite(int x, int y) {
    int rx = root(x), ry = root(y);
    if (rx == ry) return false;
    if (parent[rx] > parent[ry]) swap(rx, ry);
    parent[rx] += parent[ry];
    parent[ry] = rx;
    return true;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M, K;
  cin >> N >> M >> K;
  UnionFind uf(N);
  vector<vector<int>> AB(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    AB[a].emplace_back(b);
    AB[b].emplace_back(a);
    uf.unite(a, b);
  }
  vector<int> res(N, 0);
  for (int i = 0; i < N; i++) {
    res[i] = uf.size(i) - (int)AB[i].size();
  }
  for (int i = 0; i < K; i++) {
    int c, d;
    cin >> c >> d;
    c--, d--;
    if (uf.issame(c, d)) res[c]--, res[d]--;
  }
  for (int i = 0; i < N; i++) {
    cout << res[i] - 1 << (i == N - 1 ? '\n' : ' ');
  }
  return 0;
}


Measured memory_bytes: 7544
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))


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

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};

int main(){

    int a, b, c;
    cin >> a >> b >> c;
    bool flg = false;

    for(int k=1; k<=b; k++){
        int rec = (k*a)%b;
        if(rec == c) flg = true;
    }

    if(flg) cout << "YES" << endl;
    else cout << "NO" << endl;


}

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

int main(){
  int h,w;
  cin >> h >> w;
  int k;
  cin >> k;
  vector<vector<char>> maze(h,vector<char>(w));
  int black = 0;
  rep(i,h){
    rep(j,w){
      cin >> maze[i][j];
      if(maze[i][j] == '#') black ++;
    }
  }
  int ans = 0;
  rep(i,pow(2,h)){//縦を全探索
    rep(j,pow(2,w)){//横を全探索
      int tmp = 0;//各ケースのtemp
      rep(p,h){//縦を操作
        bool hbit = (i>>p)&1;
        if (hbit) continue;
        rep(q,w){//横を操作
          bool wbit = (j>>q)&1;
          if (wbit) continue;
          if (maze[p][q] == '#') tmp++;
        }//w
      }//p
      if (tmp == k) ans++;
    }//j
  }//i
  cout << ans << endl;
}

Measured memory_bytes: 4056
fun main(args: Array<String>) {
    a60(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

fun a60(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    val strList = args[0].split(" ")
    val isShiritori = (1..(strList.size - 1)).all { strList[it].first() == strList[it - 1].last() }
    println(if (isShiritori) "YES" else "NO")
}

Measured memory_bytes: 38220
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long int
using namespace std;
int mod = 1e9 + 7;

int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio;

	int n;
	cin >> n;
	unordered_map<string, int> mp;
	string s;
	for (int i = 0; i < n; i++) {
		cin >> s;
		mp[s]++;
	}
	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;
	return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
	double v, y;
	
	while (cin >> v){
		y = (v * v) / 19.6;
		double n = (y + 5) / 5;
		cout << (int)ceil(n) << endl;
	}
	return (0);
}

Measured memory_bytes: 1228
#!/usr/bin/env pypy3
import sys
sys.setrecursionlimit(15000)
x = int(input())
ret = 0
while x > 0:
    a,x = divmod(x,500)
    ret += a*1000
    b,x = divmod(x,5)
    ret += b*5
    x = 0
print(ret)

Measured memory_bytes: 38256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
signed main(){
    ll H, W; 
    cin>>H>>W;
    vector<vector<ll>> G(H, vector<ll>(W));
    ll cnt = 0;
    REP(i, H){
        REP(j, W){
            cin>>G[i][j];
        } 
    }
    stringstream ss;
    vector<P> A(H*W);
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(i==H-1 and j==W-1) break;
            if(i%2 == 0){
                if(G[i][j] % 2 == 1){
                    if(j==W-1){
                        G[i+1][j]++;
                        cnt++;
                        ss << i+1 << " " << j+1 << " " << i+2 << " " << j+1 << "\n";
                    }                    
                    else{
                        cnt++;
                        G[i][j+1]++;
                        ss << i+1 << " " << j+1 << " " << i+1 << " " << j+2 << "\n";
                    }
                }
            }
            else {
                int nj = W-1-j;
                if(G[i][nj]%2 == 1){
                    if(j==W-1){
                        G[i+1][nj]++;
                        cnt++;
                        ss << i+1 << " " << nj+1 << " " << i+2 << " " << nj+1 << "\n";
                    }                    
                    else{
                        G[i][nj-1]++;
                        cnt++;
                        ss << i+1 << " " << nj+1 << " " << i+1 << " " << nj << "\n";
                    }
                }
            }
        }
    }
    cout << cnt << endl;
    cout << ss.str();
    return 0;
}

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

int main() {

    //
    ll N;
    cin >> N;
    string S;
    cin >> S;

    //
    ll r=0, g=0, b=0;
    for (ll i=0; i<N; i++) {
        if      (S[i] == 'R') {
            r++;
        }
        else if (S[i] == 'G') {
            g++;
        }
        else if (S[i] == 'B') {
            b++;
        }
    }
    ll count = r * g * b;

    //
    for (ll i=0; i<N-2; i++) {
        for (ll j=i+1; j<N-1; j++) {
            if (2*j-i > N-1) {
                continue;
            }
            else if (S[i]!=S[j] and S[j]!=S[2*j-i] and S[2*j-i]!=S[i]) {
                count--;
            }
        }
    }

    //
    cout << count << endl;
}

Measured memory_bytes: 3620
N = int(input())
A = [(a, i) for i, a in enumerate(map(int, input().split()), start=1)]
A.sort(reverse=True)

dp = [[0] * (N + 1) for _ in range(N + 1)]

for s, (a, i) in enumerate(A):
    for l in range(s + 1):
        r = s - l
        dp[l + 1][r] = max(dp[l + 1][r], dp[l][r] + a * (i - (l + 1)))
        dp[l][r + 1] = max(dp[l][r + 1], dp[l][r] + a * (N - r - i))

ans = 0
for i in range(N + 1):
    ans = max(ans, dp[i][N - i])
print(ans)


Measured memory_bytes: 96320
N=int(input())
a=[]
for i in range(N):
    a.append(list(map(int,input().split())))

num=0
for i in range(N):
    t=a[i][0]
    x=a[i][1]
    y=a[i][2]
    if  x+y<=t and (x+y)%2==t%2:
        num+=0
    else:
        num+=1


if num==0:
    print('Yes')
else:
    print('No')
    

Measured memory_bytes: 27300
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
    string s; cin >> s;
    string away, bway, BtoD;
    string ans = "Yes";
    if(c<d){
        bway = s.substr(b, d-b-1);
        away = s.substr(a, c-a-1);
        if(bway.find("##") != string::npos) ans = "No";
        if(away.find("##") != string::npos) ans = "No";
    }else{
        BtoD = s.substr(b-2, d-b+3);
        if(BtoD.find("...") == string::npos) {// ...がない
            ans = "No";
        }else{// ...がある
            bway = s.substr(b, d-b-1);
            away = s.substr(a, c-a-1);
            if(bway.find("##") != string::npos) ans = "No";
            if(away.find("##") != string::npos) ans = "No";
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 772
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
const long long INF = 1LL << 60;
const int MOD = 1000000007;
signed main(void){
    string s,t; cin>>s>>t;
    int n = s.size(), m = t.size();
    vector <int> ds(26), dt(26);
    rep(i,n) ds[s[i]-'a']++;
    rep(i,m) dt[t[i]-'a']++;
    rep(i,26) {if(dt[i]&&ds[i]==0) {cout<<-1<<endl; return 0;} }
    vector <vector<int>> data(26,vector <int>());
    //場所を保存
    rep(i,n){
        data[s[i]-'a'].push_back(i);
    }
    rep(i,26) data[i].push_back(INF);
    int now = 0;
    int ans = 0;
    rep(i,m){
        int ne = *lower_bound(data[t[i]-'a'].begin(),data[t[i]-'a'].end(),now);
        if(ne==INF) {ans++; now = 0;
         ne = *lower_bound(data[t[i]-'a'].begin(),data[t[i]-'a'].end(),now);
        }
        now = ne+1;
    }
    
    //if(ans >= 1000000000) {cout<<-1<<endl; return 0;}
    ans = ans*n + now;
    //if(ans >= 1000000000) {cout<<-1<<endl; return 0;}
    cout<<ans<<endl;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<typename T=int>inline T get(){
   char c=getchar(); bool neg=(c=='-');
   T res=neg?0:c-'0'; while(isdigit(c=getchar()))res=res*10+(c-'0');
   return neg?-res:res;
}
template<typename T=int>inline void put(T x,char c='\n'){
   if(x<0)putchar('-'),x*=-1; int d[20],i=0;
   do{d[i++]=x%10;}while(x/=10); while(i--)putchar('0'+d[i]);
   putchar(c);
}
//end

typedef pair<int,int> P;
typedef pair<ll,P> T;
struct edge{int to,cost,dist;};
vector<edge> g[51];
int c[51],d[51];

int main(){
   int n=get(),m=get(),s=min(get(),2500);
   rep(_,0,m){
      int x=get()-1,y=get()-1,a=get(),b=get();
      g[x].push_back({y,a,b});
      g[y].push_back({x,a,b});
   }
   rep(i,0,n)c[i]=get(),d[i]=get();
   ll dist[51][2510]; rep(i,0,n)rep(j,0,2510)dist[i][j]=INF; dist[0][s]=0;
   priority_queue<T,vector<T>,greater<T>> pq;
   pq.push({0,{0,s}});
   while(!pq.empty()){
      auto t=pq.top(); pq.pop();
      ll di=t.first; int v=t.second.first,silv=t.second.second;
      if(dist[v][silv]<di)continue;
      if(silv+c[v]<=2500 and chmin(dist[v][silv+c[v]],di+d[v])){
         pq.push({di+d[v],{v,silv+c[v]}});
      }
      for(auto e:g[v]){
         ll nd=di+e.dist; int nc=silv-e.cost,nv=e.to;
         if(nc>=0 and chmin(dist[nv][nc],nd)){
            pq.push({nd,{nv,nc}});
         }
      }
   }
   rep(i,1,n){
      ll res=INF;
      rep(j,0,2510)chmin(res,dist[i][j]);
      put<ll>(res);
   }
   return 0;
}

Measured memory_bytes: 6200
from collections import defaultdict

N, M = map(int, input().split())
A = list(map(int, input().split()))

Amod = defaultdict(int)
sum_mod = 0
for v in A:
    sum_mod = (sum_mod + v) % M
    Amod[sum_mod] += 1

sum_mod = 0
ans = 0
for v in A:
    # print(Amod, v, Amod[(2 * M - sum_mod) % M], sum_mod)
    ans += Amod[sum_mod]
    sum_mod = (sum_mod + v) % M
    Amod[sum_mod] -= 1

print(ans)


Measured memory_bytes: 14920
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define PI 3.141592653589793238
int main()
{
    // #ifndef ONLINE_JUDGE
    // freopen("/home/pushkar/cpp/input.txt", "r", stdin);
    // freopen("/home/pushkar/cpp/output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    ll a[n], i, ans = 0;
    for (i=0;i<n;i++)
    cin >> a[i];
    sort(a, a+n);
    ans = a[n-1];
    i = n-2;
    n -= 2;
    while (n)
    {
        ans += a[i];
        n--;
        if (n == 0)
        break;
        ans += a[i];
        n--;
        i--;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 5228
#include<cstdio>

int n,m,k,a,cnt;
int vis[50];

int main() {
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++) {
		scanf("%d",&k);
		for(int j=1;j<=k;j++) {
			scanf("%d",&a);
			vis[a]++;
		}
	}
	for(int i=1;i<=30;i++)
		if(vis[i]>=n)
			cnt++;
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 128
N=int(input())
ABC=[]
for i in range(N):
	ABC+=[[int(i) for i in input().split()]]
DP=[[0,0,0] for i in range(N)]
for i in range(N):
	DP[i]=[ABC[i][0]+max(DP[i-1][1],DP[i-1][2]),ABC[i][1]+max(DP[i-1][0],DP[i-1][2]),ABC[i][2]+max(DP[i-1][1],DP[i-1][0])]
print(max(DP[N-1]))

Measured memory_bytes: 76888
#include <iostream>

namespace cplib {
    template <int64_t mod>
    class ModInt {
        public:
        int64_t val;

        ModInt(): val(0) {}
        ModInt(int64_t init_val): val(
            init_val >= 0? init_val % mod: mod - (-init_val) % mod
        ) {}

        bool operator !() {return val != 0;}
        ModInt operator -() {return ModInt(-val);}
        bool operator ==(ModInt rhs) {return val == rhs.val;}
        bool operator !=(ModInt rhs) {return val != rhs.val;}

        ModInt& operator ++() {
            val++;
            if (val == mod) val = 0;
            return *this;
        }
        ModInt operator ++(int) {
            ModInt res = *this;
            val++;
            if (val == mod) val = 0;
            return res;
        }
        ModInt& operator --() {
            if (val == 0) val = mod;
            val--;
            return *this;
        }
        ModInt operator --(int) {
            ModInt res = *this;
            if (val == 0) val = mod;
            val--;
            return res;
        }

        ModInt& operator +=(ModInt rhs) {
            val += rhs.val;
            if (val >= mod) val -= mod;
            return *this;
        }
        ModInt& operator -=(ModInt rhs) {
            val -= rhs.val;
            if (val < 0) val += mod;
            return *this;
        }
        ModInt& operator *=(ModInt rhs) {
            val = (val * rhs.val) % mod;
            return *this;
        }
        ModInt& operator /=(ModInt rhs) {
            int64_t base = rhs.val, res = 1, pow = mod - 2;
            while (pow > 0) {
                if (pow % 2 == 1) res = (res * base) % mod;
                base = (base * base) % mod;
                pow /= 2;
            }
            val = (val * res) % mod;
            return *this;
        }

        ModInt operator +(ModInt rhs) {return ModInt(*this) += rhs;}
        ModInt operator -(ModInt rhs) {return ModInt(*this) -= rhs;}
        ModInt operator *(ModInt rhs) {return ModInt(*this) *= rhs;}
        ModInt operator /(ModInt rhs) {return ModInt(*this) /= rhs;}

        friend std::istream& operator >>(std::istream& is, ModInt& target) {
            int64_t init_val;
            is >> init_val;
            target = ModInt(init_val);
            return is;
        }
        friend std::ostream& operator <<(std::ostream& os, ModInt source) {
            os << source.val;
            return os;
        }
    };
}

int main() {
    using mint = cplib::ModInt<1000000007>;

    int n, k;
    std::cin >> n >> k;

    int max = std::min(n - 1, k);
    mint c0 = 1, c1 = 1, ans = 1;
    for (int i = 1; i <= max; i++) {
        c0 = c0 * (n + 1 - i) / i;
        c1 = c1 * (n - i) / i;
        ans += c0 * c1;
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 1000000

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll n,x[200010],y[200010];
    cin>>n;
    for(int i=0;i<n;i++){
	cin>>x[i];
	y[i]=x[i];
    }
    sort(y,y+n);
    for(int i=0;i<n;i++){
	if(x[i]<=y[n/2-1])cout<<y[n/2]<<endl;
	else cout<<y[n/2-1]<<endl;
    }
}




Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <unordered_map>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

UINT gcd(UINT a, UINT b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

UINT lcm(UINT a, UINT b)
{
	return a * b / gcd(a, b);
}

const UINT mod = 1000000007;
const double pi = 3.141592653589793238462;
const INT intmax = 9223372036854775807;

UINT _PowMod(UINT x, UINT y, UINT _mod)
{
	if (y == 0)
	{
		return 1;
	}
	else if (y == 1)
	{
		return x % _mod;
	}
	else if (y % 2 == 0)
	{
		auto tmp = _PowMod(x, y / 2, _mod);
		return tmp * tmp % _mod;
	}
	else
	{
		auto tmp = _PowMod(x, y / 2, _mod);
		return (tmp * tmp % _mod) * x % _mod;
	}
}


UINT PowMod(UINT x, UINT y)
{
	return _PowMod(x, y, mod);
}

UINT getModInv(UINT N)
{
	return PowMod(N, mod - 2);
}

INT nCrMod(INT start, INT n, INT r)
{
	if (n < r)
	{
		return 0;
	}
	INT a = start;
	for (size_t i = n; i >= n - r + 1; i--)
	{
		a *= i;
		a %= mod;
	}
	for (size_t i = 1; i <= r; i++)
	{
		a *= getModInv(i);
		a %= mod;
	}
	return a;
}

INT nHrMod(INT start, INT n, INT r)
{
	return nCrMod(start, n + r - 1, r);
}

INT _nCrMod(INT start, INT n, INT r)
{
	if (n <= 0)
	{
		return 0;
	}
	return nCrMod(start, n, r);
}

struct uf
{
	vector<INT> p;

	uf(INT n) : p(n)
	{
		for (size_t i = 0; i < n; i++)
		{
			p[i] = i;
		}
	}

	INT rt(INT n)
	{
		return p[n] == n ? n : p[n] = rt(p[n]);
	}

	void un(INT n, INT m)
	{
		p[rt(n)] = p[rt(m)];
	}

	bool eq(INT n, INT m)
	{
		return rt(n) == rt(m);
	}
};

bool lineCol(INT a1x, INT a1y, INT a2x, INT a2y, INT b1x, INT b1y, INT b2x, INT b2y)
{
	auto ta = (b1x - b2x) * (a1y - b1y) + (b1y - b2y) * (b1x - a1x);
	auto tb = (b1x - b2x) * (a2y - b1y) + (b1y - b2y) * (b1x - a2x);
	auto tc = (a1x - a2x) * (b1y - a1y) + (a1y - a2y) * (a1x - b1x);
	auto td = (a1x - a2x) * (b2y - a1y) + (a1y - a2y) * (a1x - b2x);

	return tc * td < 0 && ta * tb < 0;
}

INT powInt(INT a, INT b)
{
	if (b == 0)
	{
		return 1;
	}
	if (b == 1)
	{
		return a;
	}
	INT tmp = powInt(a, b / 2);
	return (b % 2 == 1 ? a * tmp * tmp : tmp * tmp);
}

INT _sMod(string n, INT mod)
{
	INT k = (n[0] - '0') % mod;
	for (size_t i = 1; i < n.length(); i++)
	{
		k *= 10;
		k += (n[i] - '0');
		k %= mod;
	}
	return k;
}

#define forin(v, n)				\
for (size_t i = 0; i < n; i++)	\
{								\
	cin >> v[i];				\
}

#define vec(t, name, n)			vector<t> name(n)
#define vec_(t, name, n, init)	vector<t> name(n, init)

#define vec2(t, name, n, m)			vector<vector<t>> name(n, vector<t>(m))
#define vec2_(t, name, n, m, init)	vector<vector<t>> name(n, vector<t>(m, init))

struct xy
{
	INT x, y;
	xy() :x(0), y(0) {}
	xy(INT _x, INT _y) : x(_x), y(_y) {}
};

int main()
{
	INT a[3];
	forin(a, 3);
	sort(a, a + 3);
	if (a[0] == 5 && a[1] == 5 && a[2] == 7)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).end()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 

#define int ll

using namespace std;

const int N = 3e5 +5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
// const int M = 2e3 + 5 ;

const int M = 2e3 + 5; 
ll BIT1[M] , B2[M];

void upd(ll BIT[] , int pos , ll val){
    assert(pos>0);
    for(;pos<M;pos+=pos&-pos)
        BIT[pos] += val ;
}

ll psum(ll BIT[], int pos){
    ll res = 0;
    for(;pos>0;pos^=pos&-pos)
        res+=BIT[pos];
    return res;
}

ll rsum(ll BIT[] , int l , int r){
    if(l > r) return 0;
    return psum(BIT , r) - psum(BIT , l-1);
}

void solve()
{
    // int cnt[M] = {};
    int n , K;
    cin >> n >> K ;
    int a[n] , ans = 0;
    rep(i , n) cin >> a[i] , upd(B2, a[i] , 1) ;
    // rep(i , n)<< ' ';
    // cout << '\n';
    rep(i , n){
        int res = K * (K - 1)/2 ;
        res %= mod ;
        upd(BIT1 , a[i] , 1);
        // cout << a[i] << ' ' << psum(B2 , a[i]) << '\n';
        res = (res * ( n - psum(B2 , a[i]) )) % mod ;
        // cout << res << 'x' ;
        res = (res + (K * ((i+1) - psum(BIT1 , a[i]))) %mod ) % mod ;
        // cout << res << '\n';
        ans = (ans + res) % mod ;
    }
    cout << ans ;

}   

     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}

Measured memory_bytes: 256
#負閉路あり最短経路(逆符号最長)
#aoj,grl1b
import sys
n,m,p = map(int, input().split( ))
E = [[] for _ in range(n)]
inf = 10**12
for _ in range(m):
    a,b,c = map(int, input().split( ))
    E[a-1].append([b-1,p-c])###


D = [inf for _ in range(n)]
D[0] = 0
for _ in range(n):
    for ve in range(n):
        for ed in E[ve]:
            D[ed[0]] = min(D[ed[0]], D[ve] + ed[1])
#上終わってから更新あったら負閉路
#print(*D)
for _ in range(n+10):
    for ve in range(n):
        for ed in E[ve]:
            if D[ed[0]] > D[ve] + ed[1] and D[ed[0]]<inf//10:##後半の条件は始点から到達できる、の意味
                #print(D[ed[0]], D[ve], ed[1])
                D[ed[0]] = -inf

"""
for i in range(n):
    if E[i]:
        for ed in E[i]:
            if D[i] + ed[1] < D[ed[0]] and D[ed[0]]<inf//10:
                print(-1)
                sys.exit()
"""
#print(*D)
if D[n-1]>-inf//10:
    print(max(0,-D[n-1]))
else:
    print(-1)

Measured memory_bytes: 54744
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#ifndef U_L_LONG
typedef unsigned long long ULLONG;
#endif
#ifndef L_LONG
typedef long long LLONG;
#endif
template <class _T> static _T tp_abs(const _T& a) {
	//	usage:  tp_abs<type name>(a);
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}

static void ABC091C_2DPlane2NPoints();

#if 1
int main()
{
	ABC091C_2DPlane2NPoints();
	fflush(stdout);
	return 0;
}
#endif

class ABC091C_ball {
public:
	int px = 0;
	int py = 0;
	bool picked = false;

	bool isSmall(const ABC091C_ball& a) {
		return ((px < a.px) && (py < a.py));
	}

	static bool asc_x(const ABC091C_ball& a, const ABC091C_ball& b) {
		return (a.px < b.px);
	}

	static bool dsc_y(const ABC091C_ball& a, const ABC091C_ball& b) {
		return (a.py > b.py);
	}
};

static void ABC091C_2DPlane2NPoints()
{
	//	-----------------------------------------
	//		これまだ解けてないよ！！
	//	-----------------------------------------
	int N;
	get1int(N);

	auto reds = new ABC091C_ball[N + 1];
	for (int i = 0; i < N; i++) {
		get2int(reds[i].px, reds[i].py);
	}

	auto blues = new ABC091C_ball[N + 1];
	for (int i = 0; i < N; i++) {
		get2int(blues[i].px, blues[i].py);
	}

	std::sort(blues, blues + N, ABC091C_ball::asc_x);
	std::sort(reds, reds + N, ABC091C_ball::dsc_y);

	std::vector<ABC091C_ball> paired;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if ((!reds[j].picked) && (reds[j].isSmall(blues[i]))) {
				paired.push_back(reds[j]);
				reds[j].picked = true;
				break;
			}
		}
	}

	printf("%d\n",paired.size());

	delete[] blues;
	delete[] reds;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(void) {
	int n;
	cin >> n;
	int ans=1,odd=1;
	for(int i=0; i<n; i++){
		int temp;
		cin >> temp;
		ans*=3;
		if(temp%2==0)odd*=2;
	}
	cout << ans-odd << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
//i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;


int main(int argc, char **argv) {
    i64 x,k,d;
    cin >> x>>k>>d;

    x = abs(x);
    i64 num = x/d;
    i64 ans;
    if (num > k) {
        ans = x-k*d;
    } else if(num==k) {
        ans = x%d;
    } else {
        if ((k-num)%2 == 0) {
            ans = x%d;
        } else {
            ans = abs((x%d) - d);
        }
    }

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


Measured memory_bytes: 3628