akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<string>
using namespace std;

int main(){
    string s;
    cin >> s;
    int counter = 0;

    if(s[0] == '1'){
        ++counter;
    }
    if(s[1] == '1'){
        ++counter;
    }
    if(s[2] == '1'){
        ++counter;
    }

    cout << counter << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int test[123456];
int main() {
	long long n, k, a, b, sum = 0, ans = 0; cin >> n >> k;
	for (int h = 1; h < n; h++) {
		cin >> a; test[h] = a + test[h-1];
	}
	for (int h = 0; h < k; h++) {
		cin >> b;
		ans += abs(test[sum + b] - test[sum]);
        ans % 10000;
        sum+=b;
	}
	cout << ans % 100000 << endl;
}


Measured memory_bytes: 3464
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,c,t,temp,x,y;
string str;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
	    cout<<'x';
	}
	
	
	
	
	
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;

class Main{
	public static void main(String args[]){
		Scanner scanner = new Scanner(System.in);
		int a=scanner.nextInt();
		int b=scanner.nextInt();
		
		int d=a/b;
		int r=a%b;
		
		BigDecimal aBig = new BigDecimal(a);
		BigDecimal bBig = new BigDecimal(b);
		BigDecimal fBig = aBig.divide(bBig,5,aBig.ROUND_HALF_EVEN);
		System.out.println(d+" "+r+" "+fBig.toPlainString());
	}
}

Measured memory_bytes: 26576
is_not_first = 0
while True:
  a, b = map(int, input().split())
  if not a:
    break
  
  if is_not_first:
    print()
  is_not_first += 1

  print_flag = 0
  for year in range(a, b + 1):
    if (not year % 4) and ((not (not year % 100)) or (not year % 400)):
      print(year)
      print_flag = 1

  if not print_flag:
    print("NA")


Measured memory_bytes: 5720
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {
  static Scanner sc = new Scanner(System.in);
  public static void main(String[] args) {
    // aoj version
    while(true) {
      int n = sc.nextInt();
      int k = sc.nextInt();
      if(n==0)break;
      Set<String> strs = new HashSet<String>();
      String[] cards = new String[n];
      for(int i = 0; i < n; i++) cards[i] = sc.next();
      dfs(strs, cards, k, "");
      System.out.println(strs.size());
    }
  }
  static void dfs(Set<String> strs, String[] cards, int k, String s) {
    if(k==0) { strs.add(s); return; }
    for(int i = 0; i < cards.length; i++) {
      String sc = cards[i];
      if(sc==null) continue;
      cards[i] = null;
      dfs(strs, cards, k-1, s+sc);
      cards[i] = sc;
    }
  }
}

Measured memory_bytes: 12000
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;

int main() {
    int k; cin >> k;
    int now = 0, ans = 0;
    rip(i,10000000,0) {
        ans++;
        now *= 10;
        now += 7;
        now %= k;
        if(now == 0) break;
    }
    if(ans == 10000000) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

ll solve(){
  string s; cin>>s;
  ll M = s.size();
  ll N = M+1;
  ll up[N]; up[0] = 0;
  ll down[N]; down[N-1] = 0;
  REP(i,M){
    if(s[i]=='<'){
      up[i+1] = up[i] + 1;
    }else{
      up[i+1] = 0;
    }
  }
  for(int i=M-1;i>=0;--i){
    if(s[i]=='>'){
      down[i] = down[i+1] + 1;
    }else{
      down[i] = 0;
    }
  }
  ll ans = 0;
  REP(i,N){
    ans += max(up[i],down[i]);
  }
  return ans;
}

int main(){
  cout << solve()<<"\n";
}

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

using namespace std;

vector<int>vc;

int j,b,k;
int main () {
int n;
cin>>n;
for(int i = 0 ; i < n ; i ++){
    cin>>j;
    k+=j;
    vc.push_back( j );
}
sort (vc.begin(),vc.end());
b=k-vc[vc.size() - 1];
if (b>vc[vc.size()-1]){
    cout<<"Yes";
}
else {
    cout<<"No";
}
}



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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

void compute() {

}
// A
int main() {

  int x;
  cin >> x;
  if( x ==5 || x ==7 || x ==3 ) puts("YES")  ;
  else puts("NO");
  compute();
  return 0;
}


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

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var seq = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var avg = seq.Max();

            var ans = int.MaxValue;

            for (var i = 1; i <= avg; ++i) {
                var sumVal = seq.Select(s => (s-i) * (s-i)).Sum();
                // Console.WriteLine($"{i}: {sumVal}");
                ans = Math.Min(ans, sumVal);
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 28240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    string s; cin >> s;
    rep(i,s.size()) {
        if(i % 2 == 0) {
            if(s[i] == 'L') { cout << "No" << endl; return 0; }
        }
        else {
            if(s[i] == 'R') {cout << "No" << endl; return 0;}
        }
    }
    cout << "Yes" << endl;
    
}



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

int main(){
    int N;
    cin >> N;
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            if(N == i*j){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        long ans = 1;
        long[] s = new long[n];
        for(int i =0;i<n;i++){
            s[i]=Long.parseLong(sc.next());
        }
        Arrays.sort(s);
        for(int i = 0;i<n;i++){
            if(s[i]==0){
                ans = 0;
                break;
            }
            if(Math.log10(s[i])+Math.log10(ans)>18||ans*s[i]>1000000000000000000L){
                ans = -1;
                break;
            }
            ans*=s[i];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 60176
package main

import "fmt"

func main() {
	var N, x int
	fmt.Scan(&N, &x)

	a := make([]int, N)
	for i := range a {
		fmt.Scan(&a[i])
	}

	b := make([]int, N-1)
	for i := range b {
		b[i] = a[i] + a[i+1]
	}

	c := 0
	for i := range b {

		n := b[i] - x

		if n <= 0 {
			continue
		}

		c += n
		if i == len(b)-1 {
			break
		}

		var r int
		n -= a[i+1]
		if n > 0 {
			n -= a[i]
		} else if n < 0 {
			r = -n
		} else {
			r = 0
		}
		b[i+1] -= a[i+1] - r
		a[i+1] = r
	}
	fmt.Println(c)
}


Measured memory_bytes: 5504
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<int32_t, int32_t>;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int32_t a, b;
  cin >> a >> b;
  if (a == b) {
    std::cout << "a == b" << std::endl;
  } else if (a > b) {
    std::cout << "a > b" << std::endl;
  } else {
    std::cout << "a < b" << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3156
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;
#define NL cout<<endl;
#define NNL cout<<endl<<endl;

int MAX = 1e+6+5;
int BIG = 1e+18+3;
int MOD = 1e+9+7;

signed main()
{
    IOS;
    int a,b; cin>>a>>b;
    
    int maxv = max(a,b);
    int minv=a+b-maxv;

    repa(i,1,maxv) cout<<minv;
}

Measured memory_bytes: 256
N = int(input())
P = list(map(float,input().split()))

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

for i,p in enumerate(P):
    for j in range(i+1):
        dp[i+1][j+1] += dp[i][j] * p
        dp[i+1][j] += dp[i][j] * (1-p)

m = (len(dp[-1])+1) // 2
print(sum(dp[-1][m:]))

Measured memory_bytes: 149768
#include<iostream>
using namespace std;
int main()
{
    long int A, B, K;
    cin >> A >> B;
    if(A > B)
    {
        K = B;
        while(K < A)
        {
            K++;
            if(A - K == K - B)
            {
                cout << K;
                return 0;
            }
        }
    }
    else
    {
        K = A;
        while(K < B)
        {
            K++;
            if(B - K == K - A)
            {
                cout << K;
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE";
}

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

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

using namespace std;

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

int main() {
  int k, x;
  cin >> k >> x;

  bool first = true;
  for (int i = -1000000; i <= 1000000; i++) {
    if (i >= (x - (k - 1)) && i <= (x + (k - 1))) {
      if (!first) {
        cout << " ";
      }
      cout << i;
      first = false;
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
n,m,c = map(int,input().split())
b = list( map(int,input().split()) )
a = [ list( map(int,input().split()) ) for _ in range(n) ]

ans = 0
for i in a:
  d = 0
  for j in range(m):
    d += i[j] * b[j]
  d += c
  if d > 0:
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;
using Graph = vector<vector<int>>;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  ll n; cin >> n;
  vll ne(n); rep(i, n) ne[i] = i + 1;
  vll x(n), y(n); rep(i, n) cin >> x[i]; rep(i, n) cin >> y[i];
  ll a = 0, b = 0, kai = 0;
  do
  {
    ll X = 0, Y = 0;
    rep(i, n)
    {
      if(x[i] == ne[i]) X++;
      if(y[i] == ne[i]) Y++;
    }
    if(X == n)
    {
      a = kai;
    }
    if(Y == n)
    {
      b = kai;
    }
    kai++;
  } while (next_permutation(all(ne)));
  fin(abs(a - b));
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int n,i,a,j,b,ans;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        for(j=i,a=0;j>=1;j=j/2)
            if(j%2==0)
                a=a+1;
        if(i==1)
            {
                ans=i;
                b=a;
            }
        else
            if(a>b)
                {
                    b=a;
                    ans=i;
                }
    }
    printf("%d",ans);
    return 0;
}

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

template<typename T>
T get_value(std::istream& is);

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

  const auto N {get_value<int>(cin)};
  auto tmp {N};
  auto sum {0u};
  do {
    sum += tmp % 10;
  } while (tmp /= 10);

  cout << (!(N % sum) ? "Yes\n" : "No\n");

  return 0;
}

template<typename T>
inline T get_value(std::istream& is)
{
  T v;
  is >> v;
  return v;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    vector<ll> X(N);
    rep(i,N){
        cin >> X[i];
        X[i]--;
    }

    ll ans = INF;

    rep(i,100){
        ll sum= 0;
        rep(j,N){
            sum+= (X[j]-i)*(X[j]-i);
        }
        chmin(ans,sum);
    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3492
#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 <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
//#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
//#define EXIST(s, e) ((s).find(e)!=(s).end())
//#define SORT(c) sort(begin(c),end(c))
//#define pb emplace_back
//#define MP make_pair
//#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int N;
    cin >> N;
    vector<int> p(N);
    rep(i, 0, N) cin >> p[i];

    int M;
    cin >> M;
    vector<pair<int,int> > px(M);
    rep(i,0,M) cin >> px[i].first >> px[i].second;

    int sum = 0;
    rep(i,0,N) sum += p[i];

    rep(i,0,M){
        int tmp = sum;
        tmp += px[i].second;
        tmp -= p[px[i].first - 1];
        cout << tmp << endl;
    }


    return 0;
}


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

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = INT_MAX;
const ll LLINF = INT64_MAX;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

//AGC,GAC,ACG,A*GC,AG*Cを含まない、A,G,C,Tのみを含むn文字の文字列の総数(mod 1e9+7)
// dp[i][j][k][l] := i文字目まで見た時に、3,2,1文字前がj,k,lのときの総数
// 0:A,1:G,2:C,3:T
ll dp[110][4][4][4];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            for (int k = 0; k < 4; k++)
            {
                if (i == 0 && j == 1 && k == 2)
                {
                    continue;
                }
                if (i == 1 && j == 0 && k == 2)
                {
                    continue;
                }
                if (i == 0 && j == 2 && k == 1)
                {
                    continue;
                }
                dp[3][i][j][k] = 1;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            for (int k = 0; k < 4; k++)
            {
                for (int l = 0; l < 4; l++)
                {
                    for (int next = 0; next < 4; next++)
                    {
                        // AGC
                        if (k == 0 && l == 1 && next == 2)
                        {
                            continue;
                        }
                        // GAC
                        if (k == 1 && l == 0 && next == 2)
                        {
                            continue;
                        }
                        // ACG
                        if (k == 0 && l == 2 && next == 1)
                        {
                            continue;
                        }
                        // A*GC
                        if (j == 0 && l == 1 && next == 2)
                        {
                            continue;
                        }
                        // AG*C
                        if (j == 0 && k == 1 && next == 2)
                        {
                            continue;
                        }
                        (dp[i + 1][k][l][next] += dp[i][j][k][l]) %= MOD;
                    }
                }
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            for (int k = 0; k < 4; k++)
            {
                (ans += dp[n][i][j][k]) %= MOD;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
const long long MOD = 1000000007;

long long pow(long long a, long long b) //a^b
{
    if(b==0) return 1;

    if(b%2==0)
    {
        long long d = pow(a,b/2);
        return (d*d)%MOD;
    }
    else
    {
        return a*pow(a,b-1)%MOD;
    }
}

long long comb(long long n,long long m) //nCm
{
    long long t =1;
    for(long long i=0;i<m;++i)
    {
        t=t*(n-i)%MOD;
    }
    t=t%MOD;
    for(long long i=1;i<=m;++i)
    {
        t = t*pow(i,MOD-2)%MOD;
    }

    return t;
}


int main()
{
    long long X,Y;cin>>X>>Y;
    if((X+Y)%3!=0)
    {
        cout << 0<< endl;
        return 0;
    }
    long long N = (2*Y-X)/3;
    long long M = (2*X-Y)/3;
    if(N<0 || M <0) 
    {cout << 0 << endl;return 0;}

    cout<<comb(N+M,M)%MOD<<endl;


}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll h,w,d,x;cin>>h>>w>>d;
	vector<P> a(h * w + 1);
	for(ll i = 1; i <= h; i++) {
		for(ll j = 1; j <= w; j++) {
			cin>>x;
			a[x] = mp(i,j);
		}
	}
	vector<ll> b(h * w + 1,0LL);
	b[1] = a[1].fs + a[1].sc;
	for(int i = 0; i <= h * w - d; i++) {
		b[i + d] = b[i] + abs(a[i + d].fs - a[i].fs) + abs(a[i + d].sc - a[i].sc);
	}
	
	ll q;cin>>q;
	for(int i = 0; i < q; i++) {
		ll l,r;cin>>l>>r;
		cout << b[r] - b[l] << endl;
	}


	return 0;
}

Measured memory_bytes: 3200
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
#include<queue>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



int main()
{
	ll  i, j, k, l, m, sum, flag, N, x, y, M, K, H, W, A, B;
	cin >> N;
	vector<ll>a(3*N);
	REP(i, 0, 3*N) {
		cin >> a[i];
	}
	priority_queue<int, vector<int>, greater<int> > Q1;
	vector<ll>sum1(N+1);
	vector<ll>sum2(N + 1);
	vector<ll>ans1(N + 1);
	REP(i, 0, N + 1) {
		sum1[i] = 0;
		sum2[i] = 0;
		ans1[i] = 0;
	}
	REP(i, 0, N) {
		Q1.push(a[i]);
		sum1[0] += a[i];

	}
	REP(i, N, 2 * N) {
		Q1.push(a[i]);
		sum1[i - N + 1] = sum1[i - N] + a[i] - Q1.top();
		Q1.pop();
	}
	priority_queue<int> Q2;
	REP1(i, 3 * N, 2 * N) {
		Q2.push(a[i]);
		sum2[0] += a[i];
	}
	REP1(i, 2*N,  N) {
		Q2.push(a[i]);
		sum2[2*N-i] = sum2[2*N-i-1] + a[i] - Q2.top();
		Q2.pop();
	}
	REP(i, 0, N + 1) {
		ans1[i] = sum1[i] - sum2[N - i];
	}
	sort(ans1.begin(), ans1.end());
	output(ans1[N]);
	
}













Measured memory_bytes: 6136
#include <iostream>
#include <functional>
#include <algorithm>
using namespace std;
int main() {
	int N,house[1005],i,ans;
	ans = 0;
	cin >> N;
	for (i = 0;i < N;i++) {
		cin >> house[i];
	}
	sort(house,house+N,greater<int>());
	cout << house[0]-house[N-1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <queue>
#include <map>

using namespace std;

int ans;
const int MAX_COUNT = 1000;
char color[3] = {'r', 'g', 'b'};
set<string> mSet;

typedef pair<string, int> PSI;

bool solve(string str)
{
	queue<PSI> que;
	que.push(PSI(str, 0));
	
	while(!que.empty())
	{
		PSI current = que.front();
		que.pop();

		bool is_solved = true;
		for(int i=0; i<current.first.size()-1; i++)
		{
			if(current.first[i] != current.first[i+1])
			{
				is_solved = false;
				break;
			}
		}

		if(is_solved)
		{
			ans = current.second;
			return true;
		}

		if(mSet.find(current.first) == mSet.end())
		{
			mSet.insert(current.first);
		}
		else
		{
			continue;
		}

 		for(int i=0; i<current.first.size()-1; i++)
		{
			if(current.first[i] != current.first[i+1])
			{
				for(int k=0; k<3; k++)
		   		{
	   				if(current.first[i] != color[k] && current.first[i+1] != color[k])
   					{
				   		string new_str = string(current.first.begin(), current.first.end());
			   			new_str[i] = color[k];
		  				new_str[i+1] = color[k];
						que.push(PSI(new_str, current.second+1));
					}
				}
			}
		}
	}

	return false;
}

int main()
{
	string str;
	while( 1 )
	{
		cin >> str;
		if(str == "0") break;

		ans = MAX_COUNT;
		mSet.clear();

		if(!solve(str))
		{
			printf("NA\n");
		}
		else
		{
			printf("%d\n", ans);
		}
	}
}

Measured memory_bytes: 2120
#include <bits/stdc++.h>
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)
#define rep(i, n) repi(i, 0, n)
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
// using P = pair<int, int>;
struct Vec{
        double x, y;
};
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;
}
using namespace std;


int dp[2009];
int mod = 1e9 + 7;

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

        rep(i, s) dp[i] = 0;
        dp[0] = 1;
        repi(i, 1, s+1) {
            rep(k, i - 2){
                dp[i] += dp[k];
                dp[i] %= mod;
            }
        }
        cout << dp[s] << endl;

        return 0;
}

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

int main(){
  int n,m;cin >>n>>m;
  vector<int> p(m),y(m);
  for(int i=0;i<m;i++)cin >>p[i] >>y[i];
  map<int,vector<int>> mp;
  for(int i=0;i<m;i++)mp[p[i]].push_back(y[i]);
  for(auto&& w:mp)sort(begin(w.second),end(w.second));
  for(int i=0;i<m;i++){
   int k=lower_bound(begin(mp[p[i]]),end(mp[p[i]]),y[i])-begin(mp[p[i]]);
    printf("%06d%06d\n",p[i],k+1);
  }
}


Measured memory_bytes: 13184
def ge_div(a, b):
    while a!=0:
        yield a/b,a%b
        a = (a%b)*10

while True:
    try:
        p, q = map(int, raw_input().split())
    except:
        break
    rem_list = [p]
    ans = ""
    index = -1
    for a,b in ge_div(10*p,q):
        ans += str(a)
        rem_list.append(b)
        if b in rem_list[:-1]:
            index = rem_list.index(b)
            break
    print ans
    if not index == -1:
        print " "*index + "^"*(len(ans)-index)

Measured memory_bytes: 4236
function AA(str){
   for(var i=1;i<arr.length-1;i++){
      if(arr[i]==0){arr[i]=str;return;}
   }
}
function BB(){
   for(var i=arr.length-2;i>=1;i--){
      if(arr[i-1]!="A" && arr[i]==0 && arr[i+1]!="A"){arr[i]="B";return;}
   }
   AA("B");
}
function CC(){
   for(var i=1;i<arr.length-1;i++){
      if(arr[i]!=0 && arr[i+1]==0){arr[i+1]="C";return;}
      if(arr[i]!=0 && arr[i-1]==0){arr[i-1]="C";return;}
   }
   if(n%2==1)arr[(n-1)/2+1]="C";
   else arr[n/2+1]="C";
}
function DD(){
   var max=[0,0];
   for(var i=1;i<arr.length-1;i++){
      if(arr[i]!=0)continue;
      var jA=i;
      var jB=i;
      var cnt=0;
      while(true){
         if(arr[jA]!="X")jA--;
         if(arr[jB]!="X")jB++;
         if(arr[jA]=="X" && arr[jB]=="X")break;
         if(/[ABCD]/.test(arr[jA]) || /[ABCD]/.test(arr[jB]))break;
         cnt++;
         if(max[1]<cnt)max=[i,cnt];
      }
   }
   if(max[1]!=0){arr[max[0]]="D";return;}
   AA("D");
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=input.trim().split("\n");
while(true){
   var nm=Arr.shift().split(" ").map(Number);
   var n=nm[0];
   var m=nm[1];
   if(n==0 && m==0)break;
   var arr=[];
   for(var i=0;i<n;i++)arr.push(0);
   arr.unshift("X");
   arr.push("X");
   for(var i=0;i<m;i++){
      var v=Arr.shift();
      if(v=="A")AA("A");
      if(v=="B")BB();
      if(v=="C")CC();
      if(v=="D")DD();
   }
   arr.shift();
   arr.pop();
   console.log(arr.join("").replace(/0/g,"#"));
}

Measured memory_bytes: 10428
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s.size()!=6)
	{
		cout<<"No";
		return 0;
	}
	else if(s[2]==s[3]&&s[4]==s[5])
	{
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	return 0;
 } 

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
const int N=5003;
const int mod=1000000007;
int n;
vector<int> e[N];
int dp[N][N],g[N],siz[N],tmp[N];
void dfs(int x,int fa)
{
	siz[x]=1;
	dp[x][1]=1;
	for(int i=0;i<e[x].size();i++)
	{
		int to=e[x][i];
		if(to==fa) continue;
		dfs(to,x);
		for(int j=1;j<=siz[x]+siz[to];j++)
			tmp[j]=0;
		for(int j=1;j<=siz[x];j++)
			for(int k=0;k<=siz[to];k++)
				tmp[j+k]=(tmp[j+k]+1ll*dp[x][j]*dp[to][k]%mod)%mod;
		siz[x]+=siz[to];
		for(int j=1;j<=siz[x];j++)
			dp[x][j]=tmp[j];
	}
	for(int j=2;j<=siz[x];j++)
		dp[x][0]=(dp[x][0]-1ll*dp[x][j]*g[j]%mod+mod)%mod;
}
int main()
{
	scanf("%d",&n);
	g[0]=1;
	for(int i=2;i<=n;i+=2)
		g[i]=1ll*g[i-2]*(i-1)%mod;
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		e[u].push_back(v),e[v].push_back(u);
	}
	dfs(1,0);
	printf("%d",mod-dp[1][0]);
	return 0;
}

Measured memory_bytes: 97408
#include<bits/stdc++.h>
#define N 500005
using namespace std;

int A[N];

int main(){

  int n,x;
  cin>>n;

  int max1=0,min0=0;
  
  for(int i=0;i<n;i++){
    
    scanf("%d",&x);
    
    if(A[0]==1) printf("No\n");
    else if(x>=n+3) printf("Yes\n");
    else{

      if(min0>=x&&x<max1){
	printf("No\n");
	continue;
      }
      
      printf("Yes\n");

      int f=0;
      if(max1==x) f=1;
      
      A[x]++;
      
      while(A[x]==2){
	A[x]=0;
	A[--x]++;
      }
      
      if(f||max1<x) max1=x;
      	
      x=max(1,min0);
      
      while(A[x]==1){
	min0=x;
	x++;
      }
      
    }
    
  }
  
  return 0;
}

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

int main() {
  int a,b,c,k;
  int ans=0;

  cin >> a>>b>>c>>k;

  if(k>a+b) {
    ans=a-(k-a-b);
  }
  else if(k<a){
    ans=k;
  }
  else ans=a;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;
string y = "Yes";
string n = "No";

int  main()
{
	vector<int> x(5);
	int ans = 0;
	rep(i, 5)
	{
		cin >> x[i];
		if (x[i] == 0)
			ans = i + 1;
	}
	cout << ans << endl;
	return (0);
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        
        int d = 0;
        
        for(d = 0; d < 100; d++) {
            if(Math.pow(k,d) > n) {
                break;
            }
        }
        
        System.out.println(d);
    }
}

Measured memory_bytes: 24916
#include "bits/stdc++.h"

using namespace std;

bool open[111][22];
int p[111][22];

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin.exceptions(cin.failbit);
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		for (int d = 0; d < 10; ++d) {
			cin >> open[i][d];
		}
	}
	for (int i = 0; i < n; ++i)
		for (int j = 0; j <= 10; ++j)
			cin >> p[i][j];
	int mx = -1e9 - 9;
	for (int mask = 1; mask < (1 << 10); ++mask) {
		int sum = 0;
		for (int j = 0; j < n; ++j) {
			int c = 0;
			for (int d = 0; d < 10; ++d)
				if (((mask >> d) & 1) and open[j][d])
					++c;
			sum += p[j][c];
		}
		mx = max(mx, sum);
	}
	cout << mx << endl;
}


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


int main() {
  double l; cin >> l;
  double x = l/3;
  cout << fixed << setprecision(15) << x*x*x << endl;

}

  

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
//using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	long long n,k ;
	cin >> n >> k ;
	cout << 1+(n-2)/(k-1) << endl ;
}


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

int main()
{
    char s[4];
    for(int i=0;i<4;i++)
    {
        cin>>s[i];
    }
    if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3])
    {
        cout<<"Bad"<<endl;
    }
    else
    {
        cout<<"Good"<<endl;
    }
}

Measured memory_bytes: 888
# ABC127D - Integer Cards
from operator import itemgetter as gt


def main():
    N, M, *X = map(int, open(0).read().split())
    A, B = X[:N], [i for i in zip(*[iter(X[N:])] * 2)]
    A.sort(), B.sort(key=gt(1), reverse=1)
    ans, flg, idx = 0, 0, 0
    for i, j in B:
        for _ in range(i):
            if idx < N and A[idx] < j:
                ans += j
                idx += 1
            else:
                flg = 1
                break
        if flg:
            break
    if idx < N:
        ans += sum(A[idx:])
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 39516
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <stack>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main(int argc, char *argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);//incompatible with `while (cin >> ...)'
    int n;
    cin >> n;
    if (n > 194) {
        cout << 5 << endl;
    }
    else if (n > 188) {
        cout << 4 << endl;
    }
    else if (n > 164) {
        cout << 3 << endl;
    }
    else if (n > 134) {
        cout << 2 << endl;
    }
    else if (n > 104) {
        cout << 1 << endl;
    }
    else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cctype>
#include <cmath>
#include <functional>
#include <map>
#include <cstdio>
#include <stack>
using namespace std;
typedef long long ll;

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

vector<int> prime_num,answer;
bool arr[55556];
int N;

void eratos(){
    rep(i,55556){
        arr[i] = true;
    }
    arr[0] = arr[1] = false;
    reps(i,2,sqrt(55556)){
        if(arr[i]){
            for(int j = 0; i * (j+2)< 55556; j++){
                arr[i*(j+2)] = false;
            }
        }
    }

    reps(i,2,55556){
        if(arr[i]) prime_num.push_back(i);
    }
}    

int main(){
    cin >> N;
    eratos();
    
    rep(i,prime_num.size()){
        if(prime_num[i] % 5 == 1) answer.push_back(prime_num[i]);
    }

    rep(i,N){
        cout << answer[i] << " ";
    }

    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		for(int i=0;i<200;i++) {
			if (s.equals(t)) {
				System.out.println("Yes");
				return;
			}
			s = rotate(s);
		}
		System.out.println("No");
	}

	public static String rotate(String s) {
		return s.substring(s.length() - 1) + s.substring(0, s.length() - 1);
	}
}


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

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()

using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long, long>;
using pdd = pair<ld, ld>;

template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<ll>;
V(size_t) -> V<ll>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){os << "(" << v.first << ", " << v.second << ")"; return os;}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<vector<T>> &v){ for(auto &e : v){os << e << "\n";} return os;}
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
void fail() { cout << -1 << '\n'; exit(0); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

const ll INF = (1ll<<62);
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
const ll mod = (int)1e9 + 7;
//const ll mod = 998244353;

int main(){

    string N;
    cin >> N;

    ll res = 0;
    REP(i, N.size()){
        res += N[i] - '0';
    }
    cout << (res%9 ? "No" : "Yes") << endl;

    return 0;
}

Measured memory_bytes: 3748
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int T = int.Parse(input[1]);
        int c, t;

        int ans = int.MaxValue;

        for (int i = 0; i < N; i++)
        {
            input = Console.ReadLine().Split(' ');
            c = int.Parse(input[0]);
            t = int.Parse(input[1]);

            if(t <= T)
            {
                if(c < ans)
                {
                    ans = c;
                }
            }
        }

        if(ans == int.MaxValue)
        {
            Console.WriteLine("TLE");
        }
        else
        {
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
long long dp[100100];
int n;
int W;
int w;
long long v;
void add(){
	for(int i=100000;i>=v;i--)
		dp[i]=min(dp[i],dp[i-v]+w);
}
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>W;
	memset(dp,63,sizeof(dp));
	dp[0]=0;
	for(int i=1;i<=n;i++){
		cin>>w>>v;
		add();
	}
	for(int i=100000;i>=0;i--){
		if(dp[i]<=W){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define int long long

bool isprime(int n){
    double rootn = sqrt(n);
    if (n < 2){
        return false;
    }
    else if (n == 2){
        return true;
    }
    else if (n % 2 == 0){
        return false;
    }
    else{
        for(int i = 3; i <= rootn; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }
}

// 空のベクトルを二つ渡す。N (>=2) 以下の素数を primes に順番に入れる。
void prime_vectors(int N, vector<int>& primes, vector<bool>& is_prime){
    primes = {};
    is_prime = {};
    for(int i=0; i<=N; i++){
        is_prime.push_back(true);
    }

    primes.push_back(2);
    for(int j=4; j<=N; j+=2){
        is_prime[j] = false;
    }

    int i;
    for(i=3; i*i<=N; i+=2){
        if(!is_prime[i]) continue;
        primes.push_back(i);
        for(int j=2*i; j<=N; j+=i){
            is_prime[j] = false;
        }
    }

    for(; i<=N; i+=2){
        if(is_prime[i]){
            primes.push_back(i);
        }
    }
}

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n, q;
    cin >> n >> q;

    vector<vector<int>> e(n);
    for(int i=0; i<n-1; i++){
        int a, b;
        cin >> a >> b;
        e[a-1].push_back(b-1);
        e[b-1].push_back(a-1);
    }

    // 数が小さいほうが根とは限らないぞ！！！
    // いや知らんわそんなん
    #if 1
    for(int i=0; i<n; i++){
        sort(e[i].begin(), e[i].end());
    }
    stack<int> narabikae;
    bool moudeta[n] = {false};

    // 根は 1（1 引いてるのでここでは 0）と決まっている
    narabikae.push(0);
    moudeta[0] = true;
    vector<vector<int>> new_e(n);
    while(!narabikae.empty()){
        int v = narabikae.top();
        moudeta[v] = true;
        narabikae.pop();
        for(int i=0; i<e[v].size(); i++){
            if(moudeta[e[v][i]]){
                // v じゃなくて e[v][i] の方が根だった
                // new_e[e[v][i]].push_back(v); // もうこれは入ってるはず
            }
            else{
                new_e[v].push_back(e[v][i]);
                narabikae.push(e[v][i]);
            }
        }
    }
    e = new_e;
    #endif

    vector<int> graph(n, 0);
    for(int i=0; i<q; i++){
        int p, x;
        cin >> p >> x;
        graph[p-1] += x;
    }

    stack<int> stk;
    stk.push(0);
    while(!stk.empty()){
        int v = stk.top();
        stk.pop();
        for(int j=0; j<e[v].size(); j++){
            graph[e[v][j]] += graph[v];
            stk.push(e[v][j]);
        }
    }  


    for(int i=0; i<n-1; i++){
        cout << graph[i] << " ";
    }
    cout << graph[n-1] << endl;
    
    return 0;
}

Measured memory_bytes: 26984
// #include<iostream>
// #include<vector>
// #include<algorithm>
// #include<map>
// #include<cstring>
// #include<math.h>
// #include<bitset>
// #include<queue>
// #include<set>
// #include<iomanip>
// #include<math.h>
// #include<assert.h>
// #include<string>
// #include<cstdlib>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i<N; i++){
    cin >> a[i];
  }
  map<int,int> mp;
  for(int i=0; i<N; i++){
    mp[a[i]]++;
  }
  int cnt=0;
  for(auto m: mp){
    if(m.second%2){
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 5376