akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n;
int p[maxn], a[maxn];
bool cmp(int x, int y) {
    return p[x]<p[y];
}
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&p[i]);
    for(int i=1;i<=n;i++) a[i] = i;
    sort(&a[1],&a[n+1],cmp);
    int ans = 0;
    for(int i=1;i<=n;i++) {
//        printf("%d ",a[i]);
        if((a[i]&1) != (i&1)) ans++;
    }
//    printf("\n");
    printf("%d",ans/2);
}


Measured memory_bytes: 1152
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s = "N:S:E:W:R:L".split(":");
        int[][] l = { { 0, 1 }, { 1, 0 }, { 2, 0 }, { 0, 2 }, { 1, 2 }, { 2, 1 } };
        Map<String, int[]> m = new HashMap<>();
        for (int i = 0; i < 6; i++) {
            m.put(s[i], l[i]);
        }
        for (;;) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
            int sum = 1;
            int[] d = { 1, 2, 3 };
            while (n-- > 0) {
                int[] t = m.get(sc.next().charAt(0) + "");
                int p=d[t[0]];
                d[t[0]]=d[t[1]];
                d[t[1]]=7-p;
                sum += d[0];
            }
            System.out.println(sum);
        }
    }
}



Measured memory_bytes: 34420
n = map(int,input().split())
a = list(map(int,input().split()))

ok,ng = 1,10000
while ng-ok > 1:
    mid = (ok+ng)//2

    valid = True
    now = 0
    for i in a:
        now += i
        now -= mid
        if now < 0:
            valid = False

    if valid:
        ok = mid
    else:
        ng = mid

print(ok)



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

typedef long long ll;
ll n, m;

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> n >> m;
    if (m & 1)
        m--;

    ll t =  max(0LL,  (m/2 - n + 1) / 2);
    n += t;
    m -= 2 * t;
    cout << min(n, m / 2) << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){

    int n;
    cin >> n;

    int data[10][10];
    for(int i=0; i<10; i++) {
        for(int j=0; j<10; j++) {
            data[i][j] = 0;
        }
    } 
    
    for(int i=1; i<=n; i++) {
        string s = to_string(i);
        data[stoi(s.substr(0,1))][stoi(s.substr(s.size()-1, 1))]++;
    }
    
    unsigned long long count = 0;
    
    for(int i=0; i<10; i++) {
        for(int j=0; j<10; j++) {
            count += data[i][j] * data[j][i];
        }
    }


    cout << count << endl;

    return 0;
}


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

int main() {
    
    vector<int> S(10000);
    for(int i=0;i<10000;i++){
        cin>>S.at(i);
        if(S.at(i)==0) break;
        else cout<<"Case "<<i+1<<": "<<S.at(i)<<endl;
    }
}



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

int main()
{
	string str;
	cin >> str;
	int price = 700;
	for (char& c : str) {
		if (c == 'o')
		{
			price += 100;
		}
	}
	cout << price;
    return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;

  vector<vector<char>> data(H, vector<char>(W));
  vector<bool> h(H, false);
  vector<bool> w(W, false);
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> data.at(i).at(j);
      
      if (data.at(i).at(j) == '#') {
        h.at(i) = true;
        w.at(j) = true;
      }
    }
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (h.at(i) && w.at(j)) {
        cout << data.at(i).at(j);
      }
    }
    if (h.at(i))  cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int r;
    cin >> r;
    if (r < 1200) cout << "ABC" << endl;
    else if (r < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << endl
#define RETURN(x)    \
  cout << x << endl; \
  return 0
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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;
}

signed main() {
  init();
  ll X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;

  priority_queue<ll> P;
  priority_queue<ll> Q;
  vll R(C);
  rep(i, A) {
    ll a;
    cin >> a;
    P.push(a);
  }
  rep(i, B) {
    ll a;
    cin >> a;
    Q.push(a);
  }
  ll r_max = 0;
  rep(i, C) {
    cin >> R[i];
    if (r_max < R[i]) r_max = R[i];
  }

  ll ans = 0;

  ll count = 0;
  while (count < X) {
    ll p_top = P.top();
    if (r_max <= p_top) {
      ans += p_top;
      P.pop();
      count++;
    } else {
      break;
    }
  }

  X -= count;

  count = 0;
  while (count < X) {
    ll q_top = Q.top();
    if (r_max <= q_top) {
      ans += q_top;
      Q.pop();
      count++;
    } else {
      break;
    }
  }

  Y -= count;

  rep(i, X) {
    ll a = P.top();
    P.pop();
    R.pb(a);
  }
  rep(i, Y) {
    ll a = Q.top();
    Q.pop();
    R.pb(a);
  }
  SORT(R);
  REVERSE(R);

  rep(i, X + Y) {
    ans += R[i];
  }

  ANS;
  return 0;
}

Measured memory_bytes: 7916
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pq priority_queue
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int N = 1e5 + 5;

int n, k;
int a[N], dp[N];

int f(int idx) {
    if(idx == n) return 0;
    int &sol = dp[idx];
    if(sol != -1) return sol;
    sol = INF;
    for(int i = 1; i <= k; i++) {
        if(idx + i <= n)
            sol = min(sol, f(idx + i) + abs(a[idx] - a[idx + i]));
    }
    return sol;
}

void solve() {
    cin >> n >> k;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    memset(dp, -1, sizeof(dp));
    cout << f(1) << "\n";
}

int main() {
 
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    solve();
    
}

Measured memory_bytes: 10644
#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()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main()
{
	string s;
	cin >> s;
	int ans = 0;
	rep(i,s.size()-1)
	{
		if(s[i]!=s[i+1])ans ++ ;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	while(1){
		int n;
		vector<int> p;
		cin>>n;
		if(n==0) break;
		for(int i=0;i<n;i++){
			int score;
			cin>>score;
			p.push_back(score);
		}
		sort(p.begin(),p.end());
		int sum=0;
		for(int j=1;j<n-1;j++){
			sum += p[j];
		}
		double ave=sum/(n-2);
		cout<<(int)ave<<endl;
	}
	return 0;
}

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

int main() {
	string s;
	cin >> s;
	int n = s.length();
	bool ok = true;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) { //奇数文字(0-origin)
			if (s[i] == 'L') ok = false;
		}
		else {
			if (s[i] == 'R')ok = false;
		}
	}

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

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

const long long MOD = 1'000'000'007;

int main() {
    long long n, m;
    cin >> n >> m;
    vector<long long> x(n), y(m);
    for (int i = 0; i < n; i++) {
        cin >> x.at(i);
    }
    for (int i = 0; i < m; i++) {
        cin >> y.at(i);
    }

    long long ansx = 0;
    for (int i = 1; i <= n; i++) {
        ansx += x.at(i - 1) * (n - 2 * i + 1) % MOD;
        ansx %= MOD;
    }
    long long ansy = 0;
    for (int i = 1; i <= m; i++) {
        ansy += y.at(i - 1) * (m - 2 * i + 1) % MOD;
        ansy %= MOD;
    }
    long long ans = (ansx * ansy) % MOD;
    cout << ans << endl;
}   

Measured memory_bytes: 1792
s = input()
if 0 < int(s[:2]) <= 12:
  if int(s[2:]) > 12 or int(s[2:]) == 0:
    print('MMYY')   
  else:
    print('AMBIGUOUS')
else:
  if 0 < int(s[2:]) <= 12:
    print('YYMM')   
  else:
    print('NA')

  

Measured memory_bytes: 2940
#include <stdio.h>

int main(void) {
	int a, b, c,i,n;
	scanf("%d", &n);
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a,&b,&c);
	if(a*a == (b*b + c*c))
		printf("YES\n");
	else if(b*b == (c*c + a*a))
		printf("YES\n");
	else if(c*c == (b*b + a*a))
		printf("YES\n");
	else
		printf("NO\n");
	}
	return 0;
}

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

int main()
{
    char c;
    cin >> c;
    if (c >= 'A' && c <= 'Z')
        cout << 'A' << endl;
    else
        cout << 'a' << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n, m; cin >> n >> m;
    vector<int> X(n); cin >> X;
    map<int, int> cnt, cnt2;
    REP(i, n) {
        cnt[X[i]%m]++;
        cnt2[X[i]]++;
    }
    map<int, int> self;
    EACH(p, cnt2) {
        // cout << p.first << " " << p.second << endl;
        self[p.first%m] += p.second/2;
    }
    set<int> used;
    ll ans = 0;
    EACH(p, cnt) {
        int x, c; tie(x, c) = p;
        if ( used.count(x) > 0 ) continue;
        int y = m-x;
        used.insert(x);
        used.insert(y);
        if (x == y) {
            ans += c/2;
            // cout << c << endl;
        }
        else if (x == m || y == m) {
            ans += (cnt[x]+cnt[y])/2;
        }
        else {
            int c1 = c, c2 = cnt[y];
            int l1 = self[x], l2 = self[y];
            int M = 0;
            REP(i, min(c1, c2)+1) {
                int a = i;
                a += min<int>((c1-i)/2, l1);
                a += min<int>((c2-i)/2, l2);
                M = max(M, a);
            }
            ans += M;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 19456
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
 
int w, h;
 
int dfs(int y, int x, vector<string> &v){
  int my[] = {-1,0,1,0};
  int mx[] = {0,-1,0,1};
  int ret = 1;
  REP(i, 4){
    int ny = y + my[i], nx = x + mx[i];
    if(0<=ny&&ny<h&&0<=nx&&nx<w && v[ny][nx] == '.'){
      v[ny][nx] = '#';
      ret += dfs(ny, nx, v);
    }
  }
  return ret;
}
 
int main(){
  while(cin >>w >>h && w){
    vector<string> v(h);
    REP(i, h) cin >>v[i];
    REP(i, h) REP(j, w) if(v[i][j] == '@') cout <<dfs(i, j, v) <<endl;
  }
  return 0;
}

Measured memory_bytes: 1264
#include <iostream>
#include <cstdio>

using namespace std;
int a[20][20];
int main()
{
    int n,k;
    cin>>n>>k;
    long long cnt=0;
    if(!k){
        cout<<(long long)n*n<<endl;
        return 0;
    }
    for(int i=k;i<=n-1;i++){
        //cout<<(i-k+1)* (n/(i+1))<<endl;
        cnt += (i-k+1)* (n/(i+1));
        if(n%(i+1)-k>=0){
            cnt+= n%(i+1)-k +1;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int a, b, c, d, x, y;
	cin >> a >> b >> c >> d;
	x = a / d;
	if (a % d != 0) {
		x++;
	}
	y = c / b;
	if (c % b != 0) {
		y++;
	}
	if (x >= y) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <string>
#include <utility>
#include <cassert>

using namespace std;
typedef long long ll;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int h;
    cin >> h;
    if (k <= h) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <bits/stdc++.h>
#include <set>
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define vii vector<pair<int, int> >
#define si stack<int>
#define pb push_back
#define mp make_pair
#define ALL(T) (T).begin(), (T).end()
#define MODU 1000000007
typedef long long ll;
using namespace std;

ll intmax = (1LL<<32)-1;
ll llmax = (1LL<<60)-1;

const int INF = 1e9 + 5;

class fastio{
public:
	fastio(){
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
	}
} __fastio;

template <typename T>
T abs(T x){
	if(x<0)	return -x;
	else return x;
}

void DFSVisit(int u, vector<int> g[], vector<bool> &visited){ 
    visited[u] = true;
    for(int i=0; i<g[u].size(); i++){
        if(!visited[g[u][i]]){
            DFSVisit(g[u][i], g, visited); 
        }
    }
} 
  
void DFS(vector<int> adj[], int V){
    vector<bool> visited(V, false); 
    for(int u=0; u<V; u++) 
        if(!visited[u]) 
            DFSVisit(u, adj, visited);
}


void solve(){
	
}

int main(){
	int n;
	cin >> n;
	int dp[3];
	cin >> dp[0] >> dp[1] >> dp[2];
	int a,b,c;
	int cp[3];
	for(int i=1; i<n; i++){
		cin >> a >> b >> c;
		for(int j=0; j<3; j++) cp[j] = dp[j];
		dp[0] = a + max(cp[1], cp[2]);
		dp[1] = b + max(cp[0], cp[2]);
		dp[2] = c + max(cp[1], cp[0]);
	}
	cout << *max_element(dp, dp+3);
}

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

using namespace std;

int main (){
	int n,m;
  	cin >> n >> m;
  	cout << (((n*(n-1)/2) > 0 ? (n*(n-1)/2) : 0)+((m*(m-1)/2) > 0 ? (m*(m-1)/2) : 0));
  	return 0;
}

Measured memory_bytes: 256
import sys

def merge(A, left, mid, right):
  n1 = mid - left
  n2 = right - mid
  L = []
  R = []
  
  global count
  
  for i in range(n1):
    L.append(A[left + i])
  for i in range(n2):
    R.append(A[mid + i])
  L.append('INFTY')
  R.append('INFTY')
  
  a = 0
  b = 0
  
  for k in range(left, right):
    if L[a] <= R[b]:
      A[k] = L[a]
      a += 1
    else:
      A[k] = R[b]
      b += 1
    count += 1

def mergeSort(A, left, right):
  if left + 1 < right:
    mid = (left + right) / 2
    mergeSort(A, left, mid)
    mergeSort(A, mid, right)
    count = merge(A, left, mid, right)


n = sys.stdin.readline()
n = int(n)


count = 0

data = sys.stdin.readline()
data_list = data.split(" ")

for i in range(n):
  data_list[i] = int(data_list[i])

mergeSort(data_list, 0, n)

for i in range(n):
  data_list[i] = str(data_list[i])

print " ".join(data_list)
print count

Measured memory_bytes: 71312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100005,mod=1e9+7;
int n,m,a[N];
struct matrix{
	int a[4][4];
	matrix(){memset(a,0,sizeof(a));}
	int*operator[](int x){return a[x];}
	matrix operator*(matrix b){
		matrix ret;
		for(int i=0;i<4;i++)
			for(int k=0;k<4;k++)
				for(int j=0;j<4;j++)
					ret[i][j]=(ret[i][j]+(ll)a[i][k]*b[k][j])%mod;
		return ret;
	}
	matrix operator^(int k){
		matrix ret,x=*this;
		for(int i=0;i<4;i++)ret[i][i]=1;
		if(k<=0)return ret;
		while(k){
			if(k&1)ret=ret*x;
			k>>=1;x=x*x;
		}
		return ret;
	}
};
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)scanf("%d",&a[i]);
	matrix mul,ans;
	mul[0][0]=1;mul[0][1]=1;mul[0][2]=1;mul[0][3]=1;
	mul[1][1]=1;mul[1][3]=1;
	mul[2][2]=1;mul[2][3]=1;
	mul[3][0]=1;mul[3][1]=1;mul[3][2]=1;mul[3][3]=2;
	ans[0][0]=1;
	a[0]=-1;
	for(int i=1;i<=m;i++){
		ans=ans*(mul^(a[i]-a[i-1]-1));
		mul[3][0]=0;mul[3][1]=0;mul[3][2]=0;mul[3][3]=1;
		ans=ans*mul;
		mul[3][0]=1;mul[3][1]=1;mul[3][2]=1;mul[3][3]=2;
	}
	if(a[m]<n-1)ans=ans*(mul^(n-1-a[m]));
	cout<<ans[0][3]<<"\n";
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 100005;
int a[MAXN],n;
int main()
{
	scanf("%d",&n);
	long long ans=0,sum=0;
	for(int i=1;i<=n;++i){
		scanf("%d",a+i);
		if(a[i]==0)ans+=sum/2,sum=0;
		else sum+=a[i];
	}
	ans+=sum/2;
	cout<<ans<<endl;
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    int vec[N][2];
    for(int i=0;i<N;i++){
        for(int j=0;j<2;j++){
            cin >> vec[i][j];
        }
    }
        for(int i=0;i<N;i++){
            if(vec[i][0]==vec[i][1] && vec[i+1][0]==vec[i+1][1]){
                if(vec[i+2][0]==vec[i+2][1]){
                    cout << "Yes" << endl;
                    return 0;
                }
                else continue;
            }
        }
        cout << "No" << endl;
    }
    

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

int main() {
int a,b,c;
cin >> a >> b >> c;
  bool ans = false;
rep2(i,1,b+1){
  if(a*i%b == c) ans=true;
}
if(ans) cout << "YES" << endl;
else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int const nax = 2e5 + 10 ;
class DSU {
private :
    int sz[nax], par[nax];
    int n;
public :
    DSU (int _n) {
        n = _n;
        for (int i = 1 ; i <= n ; i ++) {
            sz[i] = 1;
            par[i] = i;
        }
    }
    int find (int x) {
        return par[x] == x ? x : par[x] = find(par[x]);
    }
    bool unite (int u, int v) {
        u = find(u);
        v = find(v);
        if (u == v) return false;
        if (sz[u] < sz[v]) swap(u, v);
        sz[u] += sz[v];
        par[v] = u;
        return true;
    }
};
int n, m;
pair<int, int> a[nax];
pair<int, int> b[nax];
int d[nax];
vector<pair< int, int> > g[nax];
pair<int, int> edge[nax];
int top ;
int ans[nax];

bool vis[nax];

int main () {
    scanf("%d %d", &n, &m);
    for (int i = 1 ; i <= n ; ++ i)
        scanf("%d %d", &a[i].first, &a[i].second);
    for (int i = 1 ; i <= m ; ++ i) {
        scanf("%d %d", &b[i].first, &b[i].second);
    }
    sort(a + 1 , a + 1 + n);

    for (int i = 1 ; i <= n + 1; ++ i) {
        d[i] = a[i - 1].second  ^ a[i].second ;
    }
  //  fprintf(stderr, "-------------\n");
    for (int i = 1 ; i <= m ; ++ i) {
        int l = lower_bound(a + 1 , a + 1 + n, make_pair(b[i].first, 0)) - a ;
        int L = 1, R = n, mid, r = -1;
        while (L <= R) {
            int mid = L + R >> 1;
            if (a[mid].first <= b[i].second) {
                r = mid;
                L = mid + 1;
            }
            else R = mid - 1;
        }
        if (r < l) edge[i] = make_pair(1, 1);
        else
            edge[i] = make_pair(l, ++ r);
    }
    DSU ds(n + 5);

    for (int i = 1 ; i <= m ; ++ i) {
        int u = edge[i].first, v = edge[i].second;

        if (ds.unite(u, v)) {
            g[u].emplace_back(v, i);
            g[v].emplace_back(u, i);
        }
    }
    function<int (int, int)> dfs = [&] (int nod, int from) ->int {
        vis[nod] = true;
        for (auto it : g[nod]) {
            if (it.first == from) continue;
            int ret = dfs(it.first, nod);
            if (ret) {
                d[nod] ^= 1;
                ans[++ top] = it.second ;
            }
        }
        return d[nod];
    };
    for (int i = 1 ; i <= n + 1 ; ++ i) {
        if (vis[i]) continue;
        if (dfs(i, 0)) return !printf("-1");
    }
    sort(ans + 1 , ans + top + 1);
    printf("%d\n", top);
    for (int i = 1 ; i <= top ; ++ i)
        printf("%d ", ans[i]);
}

/**
3 4

5 1
10 1
8 0
initial state 101
1 10 -> 111
4 5 -> 100
6 7 ->
8 9


*/
/*
    Good Luck
        -Lucina
*/


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

int Power10(int n){
	int ret=1;
	for(int i=0;i<n;++i)
		ret*=10;
	return ret;
}

int Digits(int n){
	int count=0;
	if(n!=0){
		while(n>0){
			count++;
			n/=10;
		}
	}
	else count=1;
	return count;
}

int main(){
	map<int,int>mp;
	int n,m;
	int ans=0;
	cin>>n>>m;
	rep(i,m){
		int s,c;
		cin>>s>>c;
		if(mp.count(s)==0)mp[s]=c;
		else{
			if(mp[s]==c);
			else{
				cout<<-1<<endl;
				return 0;
			} 
		}
	}
	for(auto p:mp){
		ans+=Power10(n-p.first)*p.second;
		if(n!=1&&p.first==1&&p.second==0){
			cout<<-1<<endl;
			return 0;
		}
	}

	if(Digits(ans)!=n){
		ans+=Power10(n-1)*1;//上位の数の追加
	}

	cout<<ans<<endl;

	//cout<<Digits(ans)<<endl;

	return 0;
}

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

int main() {
  string n;
  cin >> n;
  for (int i = 0; i < n.size(); i++) {
    if (n[i] == '1') {
      cout << 9;
    } else if (n[i] == '9') {
      cout << 1;
    } else {
      cout << n[i] - '0';
    }
  }
  cout << endl;
}

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

int main() {
  int A, B, C, D;
  scanf("%d %d %d %d",&A,&B,&C,&D);
  int L=A+B;
  int R=C+D;
  string str;
  if (L>R) {
    str="Left";
  } else if (L<R) {
    str="Right";
  } else {
    str="Balanced";
  }
  printf("%s\n",str.c_str());
  return 0;
}


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

using namespace std;

#define LL long long
#define ULL unsigned LL
#define LD long double
#define debug(x) cerr << #x << " " << x << endl;

const int INF = 1e9 + 2137;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, k;
	cin>>n>>k;
	int h[n];
	for(int i=0; i<n; i++) {
		cin>>h[i];
	}
	int dp[n];
	dp[0] = 0;
	for(int i=1; i<n; i++) {
		dp[i] = INF;
		for(int j=i-1; j>=max(0, i-k); j--)
			dp[i] = min(dp[i], dp[j]+abs(h[i]-h[j]));
	}
	cout<<dp[n-1];
}


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

using namespace std;

struct work {
    int a, b;
    bool operator<(const work& right) const { return b < right.b; }
};

int main() {
    int n;
    cin >> n;
    vector<work> work(n);
    rep(i, n) cin >> work[i].a >> work[i].b;
    sort(work.begin(), work.end());
    bool flag = true;
    long long asum = 0, lim;
    rep(i, n) {
        asum += work[i].a;
        lim = work[i].b;
        if (asum > lim) {
            flag = false;
            break;
        }
    }
    if (flag) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
}


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

double dp[3003][3003],H[3003],T[3003];
int main()
{
    int n,i,j,l;
    double sum=0.0;
    scanf("%d",&n);

    for(i=1; i<=n; i++){
        scanf("%lf",&H[i]);
        T[i]=1.0-H[i];
    }

    dp[1][0]=T[1];
    dp[1][1]=H[1];

    for(i=2; i<=n; i++){
        for(j=0; j<=n; j++){          
            if(j==0) dp[i][j]=dp[i-1][j]*T[i];
            else if(j==n) dp[i][j]=dp[i-1][j-1]*H[i];
            else {
                dp[i][j]=dp[i-1][j-1]*H[i] + dp[i-1][j]*T[i];
            }
        }
    }

    l=n/2; l++;
    for(i=l; i<=n; i++){
        sum+=dp[n][i];
    }
    printf("%0.10lf\n",sum);
    return 0;
}

Measured memory_bytes: 74172
#include<bits/stdc++.h>
using namespace std;
int n, m;
int a, b, c;
int d[3];
int x ,y, w, h, r;
int p = 1;
int cnt = 0;
int main(){
    scanf("%d %d", &n, &m);
    double c = (double) n / (double)m;
    printf("%d %d %.5f", n/m, n%m, c);
    /*while(scanf("%d %d %d", &a, &b, &c), n||m){

    }*/
    return 0;
}


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

const int MOD = (int)1e9+7;

int main(){
	int N;
	string S,T;
	cin >> N >> S >> T;

	for(int i=0;i<N;i++){
		cout << S.at(i) << T.at(i);
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 8
#define rep(i,n) for(int i=0;i<n;i++)
bool a[N][N];//本来の組み合わせ
vector<int> route;//探索済みの要素を格納
int n,m;
int ct = 0;
int ans = 0;

void search(int t1){
    route.push_back(t1);
    //cout << t1+1 << " " << ct << endl;
    ct++;
    rep(i,n){
        if(a[t1][i] == 1||a[i][t1] == 1){
            if(count(route.begin(),route.end(),i) == 0){//次に行こうとしている場所がまだ訪れていない
                search(i);
            }
        }
    }
    if(ct == n)ans++;
    ct--;
    route.pop_back();
    return;
}

int main(void){
    cin >> n >> m;
    rep(i,n) rep(j,n) a[i][j] = 0;
    rep(i,m){
        int x,y;
        cin >> x >> y;
        a[x-1][y-1] = 1;
        a[y-1][x-1] = 1;
    }//入力ここまで
    search(0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
uses math;
var
 i1,i2,s,n,k,z:longint;
begin
 readln(k,n);
 for i1:=0 to k do
  for i2:=max(n-i1-k,0) to min(n-i1,k) do
   inc(s);
 writeln(s);
end.

Measured memory_bytes: 128
from collections import deque
from itertools import product
import sys
import math

sys.setrecursionlimit(200000)
input = sys.stdin.readline


def read():
    N, M = map(int, input().strip().split())
    return N, M


def solve(N, M):
    H = (N-1) // 2
    LL = 0
    LR = (H // 2) * 2 + 1
    RL = N - (H - H//2) * 2
    RR = N
    pairs = []
    while LR - LL > 1:
        pairs.append((LL+1, LR))
        LL += 1
        LR -= 1
    while RR - RL > 1:
        pairs.append((RL+1, RR))
        RL += 1
        RR -= 1
    for i in range(M):
        print(*pairs[i])


if __name__ == '__main__':
    inputs = read()
    solve(*inputs)


Measured memory_bytes: 21532
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use nalgebra::max;

#[fastout]
fn main() {
    input! {
    n: usize,
    mut xyh: [(i64, i64, i64); n]
    }
    xyh.sort_by_key(|x| -x.2);
    for i in 0..=100 {
        for j in 0..=100 {
            let th = (xyh[0].0 - i).abs() + (xyh[0].1 - j).abs() + xyh[0].2;
            let mut is_correct = true;
            for k in 1..n {
                let (x, y, h) = xyh[k];
                if h != max(th - (x - i).abs() - (y - j).abs(), 0) {
                    is_correct = false;
                    break;
                }
            }
            if is_correct {
                println!("{} {} {}", i, j, th);
            }
        }
    }
}



Measured memory_bytes: 2148
def main():
    from heapq import heappushpop, heapify
    N = int(input())
    a = [int(val) for val in input().split()]
    first_half_sums = [0]*(N+1)
    second_half_sums = [0]*(N+1)

    first_half = a[:N]
    heapify(first_half)
    first_sum = sum(first_half)
    first_half_sums[0] = first_sum

    second_half = [-val for val in a[2*N:]]
    heapify(second_half)
    second_sum = sum(second_half)
    second_half_sums[0] = -second_sum

    for i in range(N):
        first_sum += a[i + N]
        first_sum -= heappushpop(first_half, a[i + N])
        first_half_sums[i + 1] = first_sum

        second_sum += -1 * a[2*N - (i+1)]
        second_sum -= heappushpop(second_half, -1 * a[2*N - (i+1)])
        second_half_sums[i+1] = -second_sum

    ans = - (1 << 60)
    for i in range(N+1):
        ans = max(ans, first_half_sums[i] - second_half_sums[N-i])
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 120848
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vector<int>>
#define fin(ar,k,n) for(int i=k;i<n;i++) cin>>ar[i]
#define fout(ar,k,n) for(int i=k;i<n;i++) cout<<ar[i]<<' '
#define all(z) z.begin(),z.end()
#define mcc ((int)1e9+7)
#define mcf 998244353
#define mi map<int,int>
#define mem(a,n) memset(a,n,sizeof(a))
#define pii pair<int,int>
#define mp(a,b) make_pair(a,b)

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> fst;

const int N=1e5+7;
vi gp[N],vis(N),dp(N);
int n,m,ans=0;
queue<int> q;

void dfs(int v,int l)
{
	vis[v]=1;
	for(auto const a: gp[v])
	{
		if(!vis[a])
		{
			dfs(a,l+1);
		}
		dp[v]=max(dp[v],dp[a]+1);
	}
	return;
}

void solve()
{
	cin>>n>>m;
	for (int i=0;i<m;i++)
	{
		int u,v;
		cin>>u>>v;
		gp[u].emplace_back(v);
	}
	for(int i=1;i<=n;i++) q.push(i);
	while(!q.empty())
	{
		int cur=q.front();
		q.pop();
		if(!vis[cur]) dfs(cur,0);
	}
	for (int i=1;i<=n;i++)
	{
		ans=max(dp[i],ans);
	}
	cout<<ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;

int main(void)
{
	int q, com, x;
	set<int> S;
    cin >> q;
    rep(i, q)
    {
        cin >> com >> x;
        if (com == 0)
        {
            S.insert(x);
            cout << S.size() << endl;
        }
        else if (com == 1)
        {
            cout << S.count(x) << endl;
        }
        else
        {
            S.erase(x);
        }
    }
}


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

int my_strcmp(char *s, char *t);
void my_strcpy (char *s, char *t);
void fill_a (char *s);

int main(void) {
    char s[51], s_[51], t[51], s2[51];
    int i;
    int unrestorable = 1;

    scanf("%s", s_);
    scanf("%s", t);

    for (i = 0; s_[i] != '\0'; i++) {
        if (my_strcmp(&s_[i], t)) {
            strcpy(s2, s_);
            my_strcpy(&s2[i], t);
            fill_a(s2);
            if (unrestorable == 1) {
                strcpy(s, s2);
            } else {
                if (strcmp(s, s2) > 0) {
                    strcpy(s, s2);
                }
            }

            unrestorable = 0;
        }
    }

    if (unrestorable == 1) {
        puts("UNRESTORABLE");
    } else {
        puts(s);
    }
    return 0;
}

int my_strcmp (char *s, char *t) {
    char *cs, *ct;
    cs = s; ct = t;
    for (; *ct != '\0'; cs++, ct++) {
        if (*cs == '\0') return 0;
        if (*cs != *ct && *cs != '?') {
            return 0;
        }
    }
    return 1;
}

void my_strcpy (char *s, char *t) {
    int i;
    for(i = 0; t[i] != '\0'; i++) {
        s[i] = t[i];
    }
}

void fill_a (char *s) {
    int i;
    for (i = 0; s[i] != '\0'; i++) {
        if (s[i] == '?') {
            s[i] = 'a';
        }
    }
}


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

// #define DEBUG 1

#define int long long
#define for0(i,n) for (int i=0; i<n; i++)
#define iter(c) for(auto it=c.begin(); it!=c.end(); it++)
#define iter2(c) for(auto it2=c.begin(); it2!=c.end(); it2++)
#define pb push_back
#define ms(a,z) memset(a,z,sizeof(a));
#define mp make_pair
#define X first
#define Y second
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define all(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define pmod(x,m) (((x)%(m)+m)%m)
#ifdef int
#define read(x) scanf("%lld",&x);
#else
#define read(x) scanf("%d",&x);
#endif

#ifdef DEBUG
#define nl cout<<"\n";
#define pr(x) cout<<(x)<<" ";
#define prl(x) cout<<#x " = "<<x<<endl;
#define prp(x) cout<<"("<<(x).first<<" "<<(x).second<<") ";
#define printv(v) {for(int _=0; _<sz(v); _++) cout<<v[_]<<" "; cout<<"\n";}
#define printa(a,s) {for (int _=0; _<s; _++) cout<<a[_]<<" "; cout<<"\n";}
#define print2D(a,m,n) {for (int _=0; _<m; _++) {for (int __=0; __<n; __++) cout<<a[_][__]<<" "; cout<<"\n";} cout<<"\n";}
#define priter(v) iter(v) {pr(*it)} nl
#define debug cout<<"ok at line "<<__LINE__<<endl;
#else
#define nl
#define pr(x)
#define prl(x)
#define prp(x)
#define printv(v)
#define printa(a,s)
#define print2D(a,m,n)
#define priter(v)
#define debug
#endif
#define MAXN 100000

using namespace std;

typedef long long ll;

const int INF = 2147483647;
const long long INFL = 9223372036854775807LL;
const double EPSILON = 0.00000001;
const long long MOD = 1000000007;

int32_t main()
{
    #ifdef DEBUG
    //freopen("B.txt","r",stdin);
    //freopen("","w",stdout);
    #endif

    int L; 
    cin >> L;
    int maxb = 0;
    for (maxb=0; (1<<maxb)<=L; maxb++) ;
    maxb--;
    prl(maxb);
    int n = maxb+1;
    
    vector<vector<int>> edges;
    for (int i=0; i<maxb; i++) {
        int a = i+1, b=i+2;
        edges.pb(vector<int>{a,b,1<<i});        
        if (L&(1<<i))
            edges.pb(vector<int>{a,b,1<<(i+1)}); 
        else 
            edges.pb(vector<int>{a,b,0});
    }
    
    for (int i=0; i<maxb; i++) {
        if (L&(1<<i))
            edges.pb(vector<int>{i+1,n,0});
    }
    
    cout<<n<<" "<<sz(edges)<<endl;
    for0(i,sz(edges)) {
        cout<<edges[i][0]<<" "<<edges[i][1]<<" "<<edges[i][2]<<endl;
    }
    return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  
  int count = 0;
  
  for (int i = 0; i < N; i++) {
    int X;
    cin >> X;
    if (X >= K) {
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<string,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[100000],dp[100][100];
int g[10][10];

int check(int f){
  l = 0;
  ll ans = 0;
  rep(i,0,n)if(d[i])l++;
  if(l == n)return 1;
  rep(i,0,n){
    if(!g[f][i] || d[i])continue;
    d[i] = 1;
    ans += check(i);
    d[i] = 0;
  }
  return ans;
}

int main(){
  cin >> n >> m;
  rep(i,0,m){
    int a,b;
    cin >> a >> b;
    a--;b--;
    g[a][b] = g[b][a] = 1;
  }
  clr(d,0);
  d[0] = 1;
  print(check(0));
  return 0;
}

Measured memory_bytes: 1024
import sys
import math
import itertools
import collections
from collections import deque
from collections import defaultdict

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD2 = 998244353
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    N, K = NMI()
    A = NLI()
    
    ng = 0       #ng:とり得る最小の値-1
    ok = 10**9+10  #ok:とり得る最大の値+1

    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2

        cut = 0
        for a in A:
            if a % mid == 0:
                cut += math.floor(a/mid)-1
            else:
                cut += math.floor(a/mid)


        if cut <= K:
            ok = mid
        else:
            ng = mid

    print(ok)
    

if __name__ == '__main__':
    main()

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

using namespace std;

long long pov(long long x,int p){
    if(p==0)
        return 1;
    long long y=pov(x,p/2);
    if(p%2)
        return y*y*x;
    else
        return y*y;
}

long double x;
int p;

int main()
{
    cin>>x;
    p=floor(log2(x))+1;
    cout<<pov(2,p)-1<<'\n';
    return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var todayW = ReadLine();

        var w = new string[] { "Sunny", "Cloudy", "Rainy" };

        var ans = w[(Array.IndexOf(w, todayW) + 1) % 3];

        WriteLine(ans);
    }
}


Measured memory_bytes: 25892
//Author: Rahul Purohit

#include<bits/stdc++.h>
#define vi vector<int>
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define ll  long long int
#define pi pair<ll,ll>
#define f first
#define mp make_pair
#define mod 1000000007
#define s second
#define pb push_back
#define mp make_pair
using namespace std;
int gcd(int a, int b)
{
	if(b==0)
		return a;
	else
		return (b,a%b);
}
/*ll isp[N]={1};
void sieve(int n)
{
	isp[0]=isp[1]=0;
	for(int i=2;i<=n;i++)
	{
		if(isp[i]==1)
		{
			for(int j=i*i;j<=n;j+=i)
			{
				isp[j]==0;
			}
		}
	}
}*/
ll pow(int x,int  y,int m)
{
	ll ans=1;
	while(y!=0)
	{
		if(y%2==1)
		{
			ans=(ans*x)%m;
		}
		x=(x*x)%m;
		y/=2;
	}
	return ans;
}
template <class x>
void swap(x &a,x &b)
{
	x tp;
	tp=a;
	a=b;
	b=tp;
}
int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	ll n,x,res=1,temp=0;
	cin>>n>>x;
	ll ar;
	for(auto i=0;i<n;++i)
	{
	    cin>>ar;
	    temp+=ar;
	    if(temp<=x)
	    {
	        ++res;
	    }
	}
	cout<<res;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long h,w,i,j,k,b[55][55];
char a[55][55];
int main(){
	cin>>h>>w;
	for(int i=1;i<=h;++i){
		for(int j=1;j<=w;++j){
			cin>>a[i][j];
			if(a[i][j]=='#'){
				b[i-1][j]++;
				b[i-1][j-1]++;
				b[i-1][j+1]++;
				b[i][j-1]++;
				b[i][j+1]++;
				b[i+1][j]++;
				b[i+1][j+1]++;
				b[i+1][j-1]++;
			}
		}
	}
	for(int i=1;i<=h;++i){
		for(int j=1;j<=w;++j){
			if(a[i][j]!='#'){
				cout<<b[i][j];
			}
			else cout<<a[i][j];
		}
		cout<<endl;
	}
	return 0;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a,sum=0;
	cin>>a;
	for(int i=1;i<=a;i++)
		for(int j=1;j<=a;j++)
			for(int k=1;k<=a;k++)
				sum+=__gcd(__gcd(i,j),k);
	cout<<sum<<"\n";
	return 0;
}


Measured memory_bytes: 3644
n,m = map(int,input().split())

A = [list(input()) for i in range(n)]
B = [list(input()) for i in range(m)]
ans = 0
for i in range(n-m+1):
    for j in range(n-m+1):
        temp=0
        for k in range(m):
            for l in range(m):
                if B[k][l]==A[i+k][j+l]:
                    temp+=1
                    ans = max(ans,temp)
                                    
print('Yes' if ans==m*m else 'No')

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
int a,b,c;
int main()
{
	scanf("%d%d%d",&a,&b,&c);
	if(b-a==c-b)
	printf("YES\n");
	else
	printf("NO\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	

	string S;
	map<char,int> K;
  cin>>S;
	fx(S.size()){
		K[S.at(x)]++;
	}
	string ans=S;
  if(ans=="zyxwvutsrqponmlkjihgfedcba"){ce("-1")}
	for(int a=S.size();a>=0;a--){
      char f;
      if(a==S.size()){f='a';}else{f=S.at(a)+1;}
		fx(26){
			char s=f+x;
          if(s>'a'+25){x=29;continue;}
			if(K[s]==0){
              if(a!=S.size())
              ans=ans.substr(0,ans.size()-1);
				ans+=s;
				a=-1;
				x=29;
			}
		}
      if(a!=S.size()&&a!=-1){
		K[ans.at(ans.size()-1)]--;
		ans=ans.substr(0,ans.size()-1);
      }
	}
	
	ce(ans)
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
#define gap ' '
#define L(i) ((i) - (&i))

const int inf = 1e9 + 7;
const int MAXN = 1e5 + 5;

	
int main(){		
	ll n, t; cin >> n >> t;
	ll ans = 0;
	vector<ll> a(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
	}
	ll sum = 0;
	ll s = 0, f = 0;
	for(int i = 0; i < n; ++i){
		if(a[i] <= f){	
			f = a[i] + t;
		}
		else{
			ans+=f-s;
			s = a[i];
			f = a[i] + t;
		}

	}
	ans+=f-s;
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 4824
#include <bits/stdc++.h>
#define MAX 205
using namespace std;

char a[MAX][MAX];
int n, m;
int dis[MAX][MAX];
const int mx[] = {0, 1}, my[] = {1, 0};

struct node{
    int x, y, dis;
    friend bool operator <(node a, node b){
        return a.dis > b.dis;
    }
};
priority_queue<node> q;

int main()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        scanf("%s", a[i]+1);
    }
    memset(dis, 0x3f, sizeof(dis));
    dis[1][1] = a[1][1]!='.';
    q.push((node){1, 1, a[1][1]!='.'});
    while(!q.empty()){
        node t = q.top();
        q.pop();
        if(t.dis > dis[t.x][t.y]) continue;
        for(int i = 0; i < 2; i++){
            int u = t.x+mx[i], v = t.y+my[i];
            if(u <= 0 || u > n || v<=0 || v>m) continue;
            if(dis[u][v] > t.dis+(a[t.x][t.y]=='.' && a[u][v]!='.')){
                dis[u][v] = t.dis+(a[t.x][t.y]=='.' && a[u][v]!='.');
                q.push((node){u, v, dis[u][v]});
            }
        }
    }
    cout << dis[n][m] << endl;

    return 0;
}

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

const long long mod =1e9+7 ;
const int N = 1e3+5;


#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define fr(i,l,m) for(int i=l;i<m;i++)
# define vii vector<int>
#define vpr vector<pair<ll,ll> >
ll pwr(ll x,ll y);
int h,w,dp[N][N];
////
////
////
char mat[N][N];

void process()
{
    for(int i=h;i>0;i--)
    {
        for(int j=w;j>0;j--)
        {
            if(mat[i][j]=='.')
            {
                if(i<h)
                {
                    dp[i][j]=(dp[i+1][j]%mod+dp[i][j]%mod)%mod;
                }
                if(j<w)
                {
                    dp[i][j]=(dp[i][j]%mod+dp[i][j+1]%mod)%mod;
                }
            }
        }
    }
}









////
////
///
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);


cin>>h>>w;
fr(i,1,h+1)
{
    fr(j,1,w+1)
    {
        cin>>mat[i][j];

    }
}
dp[h][w]=1;
process();
cout<<dp[1][1]<<endl;
return 0;
}
ll pwr(ll x,ll y)
{
    ll ans=1;
    x=x%mod;
    while(y>0){
    if(y&1)ans=(x*(ans%mod))%mod;
    x=(x*x)%mod;
    y=y/2;

    }
    return ans%mod;
}



Measured memory_bytes: 5120
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<queue>
#include<vector>
#include<utility>
#include<functional>
typedef long long ll;
using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  if(2*K-1 <= N){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


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

typedef signed long long ll;
typedef long double ld;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) x.begin(), x.end()

#define DEBUG

void call(int);

int main()
{
	int n;
	cin >> n;
	call(n);
	return 0;
}

void call(int n)
{
	int i = 1;
CHECK_NUM:
	int x = i;
	if (x % 3 == 0)
	{
		cout << " " << i;
		goto END_CHECK_NUM;
	}
INCLUDE3:
	if (x % 10 == 3)
	{
		cout << " " << i;
		goto END_CHECK_NUM;
	}
	x /= 10;
	if (x)
		goto INCLUDE3;
END_CHECK_NUM:
	if (++i <= n)
		goto CHECK_NUM;

	cout << endl;
}



Measured memory_bytes: 3096
# -*- coding: utf-8 -*-
lst = [int(input()) for i in range(5)]
k = int(input())

flg = True
for i, v1 in enumerate(lst):
  for j, v2 in enumerate(lst):
    if abs(v1 - v2) > k:
      flg = False
      break
  if not flg:
    break

print('Yay!' if flg else ':(')

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<tuple>
using namespace std;


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

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

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

	string left, right;

	rep(i, n / 2){
		left += s[i];
	}

	for(int i = n / 2; i < n; ++i) {
		right += s[i];
	}

	if(left == right){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
using System;

class ITP1_7_D
{
  static void Main()
  {
    string[] s = Console.ReadLine().Split(' ');
    long n = long.Parse(s[0]);
    long m = long.Parse(s[1]);
    long l = long.Parse(s[2]);
    long[,] A = new long[n, m];
    long[,] B = new long[m, l];
    long[,] C = new long[n, l];
    for (int i = 0; i < n; i ++)
    {
      string[] input = Console.ReadLine().Split(' ');
      for (long j = 0; j < m; j ++) A[i, j] = long.Parse(input[j]);
    }
    for (long i = 0; i < m; i ++)
    {
      string[] input = Console.ReadLine().Split(' ');
      for (long j = 0; j < l; j ++) B[i, j] = long.Parse(input[j]);
    }
    for (long i = 0; i < n; i ++)
    {
      for (long j = 0; j < l; j ++)
      {
        for (long k = 0; k < m; k ++) C[i, j] += A[i, k] * B[k, j];
        if (j != l - 1) Console.Write(C[i, j] + " ");
        else Console.Write(C[i, j]);
      }
      Console.WriteLine();
    }
  }
}



Measured memory_bytes: 17936