akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define N 100

int main(){

  int a[N];
  int n,i,j;
  int min,temp,count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);

  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(a[j]<a[min]){
        min=j;
      }
      }
      if(i!=min){
        temp=a[i];
      a[i]=a[min];
      a[min]=temp;
      count++;
    }
  }

    for(i=0;i<n-1;i++)
    printf("%d ",a[i]);
    printf("%d\n",a[n-1]);
    printf("%d\n",count);

    return 0;

  }

Measured memory_bytes: 2696
import Data.Char

main :: IO ()
main = do
    xs <- map digitToInt <$> getLine
    putStrLn $ solve xs

solve :: [Int] -> String
solve [a, b, c, d]
    | a + b + c + d == 7 = show a ++ "+" ++ show b ++ "+" ++ show c ++ "+" ++ show d ++ "=7"
    | a + b + c - d == 7 = show a ++ "+" ++ show b ++ "+" ++ show c ++ "-" ++ show d ++ "=7"
    | a + b - c - d == 7 = show a ++ "+" ++ show b ++ "-" ++ show c ++ "-" ++ show d ++ "=7"
    | a + b - c + d == 7 = show a ++ "+" ++ show b ++ "-" ++ show c ++ "+" ++ show d ++ "=7"
    | a - b + c - d == 7 = show a ++ "-" ++ show b ++ "+" ++ show c ++ "-" ++ show d ++ "=7"
    | a - b - c + d == 7 = show a ++ "-" ++ show b ++ "-" ++ show c ++ "+" ++ show d ++ "=7"
    | a - b + c + d == 7 = show a ++ "-" ++ show b ++ "+" ++ show c ++ "+" ++ show d ++ "=7"
    | otherwise          = show a ++ "+" ++ show b ++ "+" ++ show c ++ "+" ++ show d ++ "=7"

Measured memory_bytes: 380
using System;

namespace AtCoder
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] data;
            int time = 0;
            data = new int[5];
            for (int i = 0; i < 5; i++)
            {
                data[i] = int.Parse(Console.ReadLine());
            }

            int index = 0;
            int value = 10;
            for(int i = 0; i < 5; i ++)
            {
                int temp = data[i] % 10;
                if (temp < value && temp != 0)
                {
                    value = temp;
                    index = i;
                }
            }

            for (int i = 0; i < index; i++)
            {
                time += data[i];
                if (time % 10 == 0)
                {

                }
                else
                {
                    time += 10;
                    time = (int)Math.Floor((double)time / 10) * 10;
                }
            }

            for (int i = index + 1; i < 5; i++)
            {
                time += data[i];
                if (time % 10 == 0)
                {

                }
                else
                {
                    time += 10;
                    time = (int)Math.Floor((double)time / 10) * 10;
                }
            }
            Console.WriteLine(time + data[index]);
        }
    }
}

Measured memory_bytes: 11092
import java.util.*;
class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int num=sc.nextInt();
		System.out.print("Christmas ");
		for(int i=0;i<25-num;i++)
		{
			System.out.print("Eve ");
		}
		System.out.println();
	}
}

Measured memory_bytes: 21588
r = []
A = input().split(" ")
N,Y = map(int,A)
a = -1
b = -1
d = -1
for i in range(N+1):
    for j in range(N+1):
        c = (N-i)-j
        if c >= 0 and Y == 10000*i+5000*j+1000*c:
            a = i
            b= j
            d = c
print("{0} {1} {2}".format(a,b,d))

Measured memory_bytes: 3064
// vim: set fdm=marker:
// {{{
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <utility>
 
using namespace std ;
 
typedef long long ll ;
 
// }}}
 
 
char query(int loc) {
    cout << loc << endl;
    string s;
    cin >> s;
    if(s[0] == 'V')
        exit(0);
    return s[0];
}
 
int main()
{
    int N;
    cin >> N;
    char l = query(0);
    char r = query(N-1);
    int lb = 0, ub = N-1;
    while(true) {
        int mid = (lb+ub)/2;
        char m = query(mid);
        if(0 == (mid-lb)%2) {
            if(l != m)
                ub = mid;
            else {
                lb = mid;
            }
        }
        else {
            if(l == m)
                ub = mid;
            else {
                lb = mid;
                l = m;
            }
        }
    }
    return 0;
}

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

int main() {
    int x,n,m;
    cin>>n>>m;
    priority_queue<int> pq;
    for(int i=0;i<n;++i) {
        cin>>x;
        pq.push(x);
    }
    for(int i=0;i<m;++i) {
        x = pq.top(); pq.pop();
        pq.push(x/2);
    }
    long long s=0;
    while(!pq.empty()) {
        s+=pq.top();
        pq.pop();
    }
    cout<<s<<endl;
    return 0;
}


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

using namespace std;
#define reg register
#define rep(i, a, b) for (reg int i = (int) a; i <= (int) b; i++)
#define rev(i, a, b) for (reg int i = (int) a; i >= (int) b; i--)
#define _r read()

int have[10];

inline int read();

int main() {
	rep(i, 1, 3) {
		have[_r]++, have[_r]++;
	}
	sort(have + 1, have + 4 + 1);
	if (have[1] == 1 && have[2] == 1 && have[3] == 2 && have[4] == 2) cout << "YES"<< endl;
	else cout << "NO" << endl;
	return 0;
}

inline int read() {
	reg int a = 0, c = getchar(), s = c == '-';
	while (!isdigit(c)) c = getchar();
	while (isdigit(c)) a = (a << 1) + (a << 3) + (c ^ 48), c = getchar();
	return s ? -a : a;
}


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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
typedef long long int lli;


int memo[1000010] = {0,0,1};
double PI = 3.14159265359;

lli MOD = 10e9+7;

int main(void){
    
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    
    tx -=sx;
    ty -=sy;
    sx = 0;
    sy = 0;
    
    for(int i = 0; i < tx; i++) cout << 'R';
    for(int i = 0; i < ty; i++) cout << 'U';
    for(int i = 0; i < tx; i++) cout << 'L';
    for(int i = 0; i < ty; i++) cout << 'D';
    
    cout << "DR";
    for(int i = 0; i < tx; i++) cout << 'R';
    for(int i = 0; i < ty; i++) cout << 'U';
    cout << "ULUL";
    for(int i = 0; i < tx; i++) cout << 'L';
    for(int i = 0; i < ty; i++) cout << 'D';
    cout << "DR" << endl;
    
}


Measured memory_bytes: 256
N, M = map(int, input().split())


l = [None] * N

for i in range(N):
    l[i] = tuple(map(int, input().split()))

l = sorted(l, key=lambda x: x[0], reverse=False)

p = 0
m = 0

for a, b in l:
    p += a * b
    m += b
    if m >= M:
        p -= (m - M) * a
        break
print(p)

Measured memory_bytes: 18844
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

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

ll mod = 1e9 + 7;


int main(){
	string s;
	cin >> s;
	if(s.compare("SUN")==0){
		cout << "7" << endl;
	}else if(s.compare("MON")==0){
		cout << "6" << endl;
	}else if(s.compare("TUE")==0){
		cout << "5" << endl;
	}else if(s.compare("WED")==0){
		cout << "4" << endl;
	}else if(s.compare("THU")==0){
		cout << "3" << endl;
	}else if(s.compare("FRI")==0){
		cout << "2" << endl;
	}else if(s.compare("SAT")==0){
		cout << "1" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include <stdlib.h>
int main(void){
    char N[4];
    scanf("%s",N);
    for (int i=0; N[i]!='\0'; i++) {
        if (N[i]=='7') {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;


int main() {
    ll n;
    cin >> n;
    vector<ll> f(n + 1, 0);

    for (ll i = 1; i*i <= n ; i++) {
        if (i * i > n) continue;
        for (ll j = 1; j*j <=  n; j++) {
            ll tmp = i * i + j * j + i * j;
            if (tmp > n) continue;
            for (ll k = 1; k*k <= n; k++) {
                ll t = i * i + j * j + k * k + i * j + j * k + k * i;
                // cout <<"t = "<< t << endl;
                // if (t > n) break;
                if (1 <= t && t <= n) {
                    f[t]++;
                }
            }
        }
    }

    for (ll i = 1; i <= n; i++) {
        cout << f[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3596
/*
AizuOnline A0053
Title sum of primes
13/2/12 AC
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int n;


int primes[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,
	      101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,
	      211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,
	      307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,
	      401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,
	      503,509,521,523,541,547,557,563,569,571,577,587,593,599,
	      601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,
	      701,709,719,727,733,739,743,751,757,761,769,773,787,797,
	      809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,
	      907,911,919,929,937,941,947,953,967,971,977,983,991,997,
	      1009,1013,1019,1021,1031,1033,1039,1049,1051,1061,1063,1069,1087,1091,1093,1097,1103,1109,1117,1123,1129,1151,1153,1163,1171,1181,1187,1193,1201,1213,1217,1223,1229,1231,1237,1249,1259,1277,1279,1283,1289,1291,1297,1301,1303,1307,1319,1321,1327,1361,1367,1373,1381,1399,1409,1423,1427,1429,1433,1439,1447,1451,1453,1459,1471,1481,1483,1487,1489,1493,1499,1511,1523,1531,1543,1549,1553,1559,1567,1571,1579,1583,1597,1601,1607,1609,1613,1619,1621,1627,1637,1657,1663,1667,1669,1693,1697,1699,1709,1721,1723,1733,1741,1747,1753,1759,1777,1783,1787,1789,1801,1811,1823,1831,1847,1861,1867,1871,1873,1877,1879,1889,1901,1907,1913,1931,1933,1949,1951,1973,1979,1987,1993,1997,1999,2003,2011,2017,2027,2029,2039,2053,2063,2069,2081,2083,2087,2089,2099,2111,2113,2129,2131,2137,2141,2143,2153,2161,2179,2203,2207,2213,2221,2237,2239,2243,2251,2267,2269,2273,2281,2287,2293,2297,2309,2311,2333,2339,2341,2347,2351,2357,2371,2377,2381,2383,2389,2393,2399,2411,2417,2423,2437,2441,2447,2459,2467,2473,2477,2503,2521,2531,2539,2543,2549,2551,2557,2579,2591,2593,2609,2617,2621,2633,2647,2657,2659,2663,2671,2677,2683,2687,2689,2693,2699,2707,2711,2713,2719,2729,2731,2741,2749,2753,2767,2777,2789,2791,2797,2801,2803,2819,2833,2837,2843,2851,2857,2861,2879,2887,2897,2903,2909,2917,2927,2939,2953,2957,2963,2969,2971,2999,3001,3011,3019,3023,3037,3041,3049,3061,3067,3079,3083,3089,3109,3119,3121,3137,3163,3167,3169,3181,3187,3191,3203,3209,3217,3221,3229,3251,3253,3257,3259,3271,3299,3301};
//
int isprime(int n)
{
  int i;
  for(i=0;i<sizeof(primes)/sizeof(int);i++)
    if(n == primes[i])
      return(-1);
  else if(n % primes[i] ==0)
      return(0);
  return(-1);
}
main()
{
  int i;
  int cnt,sum;

  while(EOF != scanf("%d",&n) && n)
    {

      if(n==1)
	sum=2; 
      else
	{
	  cnt=1;sum=2;i=3;
	  while(cnt < n)
	    {
	      if(isprime(i))
		{
		  sum += i;
		  cnt++;
		}
	      i+=2;
	    }
	}
	  printf("%d\n",sum);
    }

return(0);
}

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

int main(){
    string s;
    cin >> s;
    int m = 700;
    rep(i,3) if(s[i] == 'o') m += 100;
    cout << m << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int x=s.nextInt();
		int y=s.nextInt();
		while (x!=0||y!=0){
		if (x<y)System.out.println(x+" "+y);
		else System.out.println(y+" "+x);
		x=s.nextInt();
		y=s.nextInt();
	}}}

Measured memory_bytes: 27200
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#define fr first
#define sc second
using namespace std;

typedef pair<int, int> iiP;
struct edge{
  int to, cost; edge(){}
  edge(int to, int cost):to(to), cost(cost){}
};

int n, m;
vector<vector<edge> > graph;

void init(int n){
  
  graph.resize(0), graph.resize(n);

}

int Prim(){
  
  int ret = 0;
  vector <int> used(n, 0);
  priority_queue<iiP, vector<iiP>, greater<iiP> > que;
  que.push(iiP(0, 0));
  while(!que.empty()){
    iiP p = que.top(); que.pop();
    if(used[p.sc]++) continue;
    ret += p.fr;
    for(int i = 0; i < graph[p.sc].size(); i++){
      que.push(iiP(graph[p.sc][i].cost, graph[p.sc][i].to));
    }
  }
  return ret;

}

int main(){

  while(cin >> n >> m, n||m){
    init(n);
    for(int i = 0; i < m; i++){
      int a, b, c; cin >> a >> b >> c;
      graph[a].push_back(edge(b, c));
      graph[b].push_back(edge(a, c));
    }
    
    cout << Prim() << endl;
  }

}

Measured memory_bytes: 1212
import java.util.Scanner;

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

       String str = scan.next();
       int n =scan.nextInt();

       for(int i =0;i<n;i++){

          String mstr = scan.next();

             if(mstr.equals("replace")){

                int a = scan.nextInt();
                int b = scan.nextInt();
                String p = scan.next();

                str = str.substring(0,a)+p+str.substring(b+1,str.length());

              } else if(mstr.equals("reverse")){

                int a = scan.nextInt();
                int b = scan.nextInt();
                String s ="";

                   for(int k =b;k>=a;k--){

                      s+=str.charAt(k);

                   }

                str = str.substring(0,a)+s+str.substring(b+1,str.length());

              } else {

                int a = scan.nextInt();
                int b = scan.nextInt();
                System.out.println(str.substring(a,b+1));

              }

          }

       }
   }



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

using namespace std;

#define pb push_back
#define fo(i, n) for(int i =1 ; i <= n; ++i)

typedef long long ll;
const int N = 2000200;
const ll inf = 1e18;
const int mod = 1e9 + 7;
ll n, C;

ll x[N], v[N], s[N];
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> C;
    for(int i = 0; i < n; ++i) {
        cin >> x[i] >> v[i];
    }
    for(int i = n; i < n + n; ++i)
        x[i] = x[i - n], v[i] = v[i - n];
    for(int i = 0; i < n + n; ++i) {
        s[i] = (i ?  s[i - 1] : 0) + v[i];
    }
    for(int i = 0; i < n; ++i)
        x[i] = C - x[i];
    multiset<ll> sub;
    for(int l = 0; l <= n; ++l) {
        sub.insert(x[l] + s[l-1]);
    }
    ll ans = 0;
    for(int r = n; r < n + n; ++r) {
        sub.erase(sub.find(x[r - n] + (r - n ? s[r - n - 1] : 0)));
        if(sub.empty()) break;
        ll res = s[r] - 2 * x[r] - *sub.begin();
        ans = max(ans, res);
    }
    for(int r = n; r < n + n; ++r) {
        ans = max(ans, s[r] - s[n - 1] - x[r]);
    }
    for(int l = 0; l < n; ++l) {
        ans = max(ans, s[n - 1] - (l ? s[l - 1] : 0) - x[l]);
    }
    sub.clear();
    for(int r = n; r < n + n; ++r) {
        sub.insert(s[r] - x[r]);
    }
    for(int l = n - 1; l >= 0; --l) {
        sub.erase(sub.find(s[l + n] - x[l + n]));
        if(sub.empty()) break;
        ll res = -(l ? s[l - 1] : 0) - 2 * x[l] + *sub.rbegin();
        ans = max(ans, res);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 14720
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

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

int n,k,X,Y;
pi stone[100];

set<vector<pi> > S;
vector<pi> body;
set<vector<pi> > next;

bool adj(pi a,pi b)
{
	int DX=a.first-b.first,DY=a.second-b.second;
	
	return DX!=DY&&abs(DX)<2&&abs(DY)<2;
}

void makeNext(int cur)
{
	if(cur>=n)
	{
		rep(i,n)rep(j,i)if(body[i]==body[j]||//ÌªdÈÁ½
			i!=j+1&&adj(body[i],body[j]))//³Å×èÁÄ¢È¢Æ±ëª×èÁ½
		return;
		
		if(!S.count(body))next.insert(body),S.insert(body);
		return;
	}
	
	rep(d,6)
	{
		pi tmp=body[cur==0?cur+1:cur-1];//×ÌÌÌÊuðîÉ6Ó²×é
		tmp.first+=dx[d]; tmp.second+=dy[d];
		
		//×è¤æ¤É®­
		if(!adj(tmp,body[cur]))continue;
		if(0<cur&&cur<n-1&&!adj(tmp,body[cur+1]))continue;
		
		//ÎÉÍüêÈ¢
		rep(i,k)if(stone[i]==tmp)goto FAIL;
		
		swap(tmp,body[cur]); makeNext(cur+2);
		swap(tmp,body[cur]); FAIL:;
	}
	makeNext(cur+1);
}

void dmp(const vector<pi> &v)
{
	rp(i,v)cout<<"("<<v[i].first<<","<<v[i].second<<") ";
	cout<<endl;
}

int main()
{
	while(cin>>n,n)
	{
		body.clear();
		rep(i,n)
		{
			int x,y; cin>>x>>y;
			body.pb(mp(x,y));
		}
		cin>>k;
		rep(i,k)cin>>stone[i].first>>stone[i].second;
		cin>>X>>Y;
		
		if(body[0]==mp(X,Y))
		{
			cout<<0<<endl; continue;
		}
		
		S.clear(); S.insert(body);
		queue<pair<int,vector<pi> > >Q; Q.push(mp(0,body));
		
		while(!Q.empty())
		{
			int cc=Q.front().first+1;
			body=Q.front().second; Q.pop();
			next.clear(); makeNext(0); //cout<<"next.size()="<<next.size()<<endl;;
			fr(it,next)
			{
				//dmp(*it);
				if((*it)[0]==mp(X,Y))
				{
					cout<<cc<<endl; goto END;
				}
				S.insert(*it);
				Q.push(mp(cc,*it));
			}
		}
		END:;
	}
	
	return 0;
}

Measured memory_bytes: 20000
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
template <class T>
void chmin(T &a, T b) { a = min(a, b); }
template <class T>
void chmax(T &a, T b) { a = max(a, b); }
void ok() { cerr << "ok" << endl; }
using D = double;
using Point = complex<D>;
const D eps = 1e-40;
inline int sgn(const D &a) { return (a < -eps) ? -1 : (a > eps) ? 1 : 0; }
inline D cross(const Point &a, const Point &b) {
    return a.real() * b.imag() - a.imag() * b.real();
}
inline D dot(const Point &a, const Point &b) {
    return a.real() * b.real() + a.imag() * b.imag();
}
istream &operator>>(istream &is, Point &p) {
    D a, b;
    is >> a >> b;
    p = Point(a, b);
    return is;
}
inline int ccw(const Point &a, const Point &b, const Point &c) {
    D d = cross(b - a, c - a);
    if (sgn(d) > 0) {
        return +1; //counter-clockwise
    } else if (sgn(d) < 0) {
        return -1; //clockwise
    } else {
        if (sgn(dot(b - a, c - a)) < 0) {
            return -2; //c,a,b
        } else if (sgn(dot(a - b, c - b)) < 0) {
            return +2; //a,b,c
        }
    }
    return 0; //a,c,b
}
struct Line {
    Point a, b; //a,bを通る直線
    Line(const Point &p0, const Point &p1) : a(p0), b(p1) {}
};
struct Segment {
    Point a, b;
    Segment(const Point &p0, const Point &p1) : a(p0), b(p1) {}
};
inline Point projection(const Line &l, const Point &b) { //a to b
    return l.a + (dot(l.b - l.a, b - l.a) / norm(l.b - l.a)) * l.b;
}
inline Point reflection(const Line &l, const Point &b) {
    return b + (projection(l, b) - b) * static_cast<D>(2.0);
}
inline bool parallel(const Line &l1, const Line &l2) {
    return sgn(cross(l1.b - l1.a, l2.b - l2.a)) == 0;
}
inline bool vertical(const Line &l1, const Line &l2) {
    return sgn(dot(l1.b - l1.a, l2.b - l2.a)) == 0;
}
inline bool intersect(const Segment &s1, const Segment &s2) {
    return ccw(s1.a, s1.b, s2.a) * ccw(s1.a, s1.b, s2.b) <= 0 && ccw(s2.a, s2.b, s1.a) * ccw(s2.a, s2.b, s1.b) <= 0;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int q;
    cin >> q;
    while (q--) {
        Point p0, p1, p2, p3;
        cin >> p0 >> p1 >> p2 >> p3;
        Segment l1(p0, p1), l2(p2, p3);
        if (intersect(l1, l2)) {
            cout << 1 << '\n';
        } else {
            cout << 0 << '\n';
        }
    }
}


Measured memory_bytes: 3316
#include <iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
using namespace std;

int main() {
	long long i, N, M,a;
	long long sum = 0;
	long long count = 0;
	cin >> N >> M;
	priority_queue<long long>A;

	for (i = 0; i < N; i++) {
		cin >>  a;
		A.push(a);
	}

	for (i = 0; i < M; i++) {
		a = A.top();
		A.pop();
		a /= 2;
		A.push(a);
	}

	for (i = 0; i < N; i++) {
		sum += A.top();
		A.pop();
	}

	cout << sum << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_pair tree<pair<int,int>,null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_mutiset tree<int,null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> pi; 
#define PI 3.1415926535897932384
#define FOR(i,vv,n) for(int i=vv;i<n;i++)
#define FORR(i,n,vv) for(int i=n-1;i>=vv;i--)
#define ve vector 
#define maxind(v) (max_element(v.begin(),v.end())-v.begin())
#define minind(v) (min_element(v.begin(),v.end())-v.begin())
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007ll
#define INF 1000000000000000000ll
#define PRECISE cout.precision(18);
#define all(v) v.begin(),v.end()
#define BS(v,n) binary_search(all(v),n)
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(all(v),greater <ll>())
#define uni(v) v.resize(unique(all(v))-v.begin())
#define F first
#define S second
#define GET(i,p) get<p>(i)

int main(){

	// #ifndef ONLINE_JUDGE
 //    // for getting input from input.txt	
 //    freopen("input.txt", "r", stdin);
 //    // for writing output to output.txt
 //    freopen("output.txt", "w", stdout);
	// #endif	

    FAST
//	PRECISE

ll n;
cin>>n;
ve <ll> ans;
while(n>0){
	ll k=n%26;
	k--;
	k=(k+26)%26;
	ans.pb(k);
	n-=k+1;
	n/=26;
}
FORR(i,ans.size(),0)
cout<<(char)(ans[i]+'a');

return 0;
 }

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

    int main() {
        
        int k;
        cin >> k;
        int a = 7%k;
        
        for(int i=1; i<=k; i++){
            
            if(a%k==0){
                cout << i <<' ';
                return 0;
            }
            
            a*=10;
            a+=7;
            a%=k;
            
        }
        
        cout << -1 <<' ';
        
        return 0;
        }


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

typedef long long ll;
typedef long double ld;
const ll INF = (ll)1e18 + 9;

template<typename Head> void print(Head head) { std::cout << head << std::endl; }
template<typename Head, typename... Tail> void print(Head head, Tail... tail) {
  std::cout << head << " ";
  print(tail...);
}
template<typename Iterator> void printVec(Iterator begin, Iterator end)
{
  for (Iterator it = begin; it != end; it++) {
    std::cout << *it << " ";
    if (it == end - 1) { std::cout << std::endl; }
  }
}

int main()
{
  ll N;
  std::cin >> N;

  std::vector<ll> va(N, 0LL);
  std::vector<ll> vans(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
  }

  ll sign = +1;
  if (N % 2 == 0) {
    sign = +1;
  } else {
    sign = -1;
  }

  ll pos = N / 2;
  for (ll i = 0; i < N; i++) {
    pos += sign * i;
    vans[pos] = va[i];
    sign *= -1;
  }

  printVec(vans.begin(), vans.end());
  return 0;
}


Measured memory_bytes: 5248
#include <cstdio>

int main (){
    int N;
    scanf("%d",&N);
    int A[N],B[N],C[N-1];
    for (int i = 0; i < N; i++){
        scanf("%d",&A[i]);
    }
    for (int i = 0; i < N; i++){
        scanf("%d",&B[i]);
    }
    for (int i = 0; i < N-1; i++){
        scanf("%d",&C[i]);
    }
    int count=0;
    int num;
    for (int i = 0; i < N; i++){
        num = A[i]-1;
        count+=B[num];
        if(A[i+1]-A[i]==1) count+=C[num];
    }
    printf("%d",count);
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		String inputs = sc.next();
		String[] input = inputs.split("");
		String output = "";
		for(int i=0;i<n;i++) {
			if(i == k-1) {
				output = output + input[i].toLowerCase();
			}else {
				output = output + input[i];
			}
		}
		System.out.println(output);
	}
}


Measured memory_bytes: 21844
n,m,l = map(int,(input().split()))
A=[]
B=[]
C=[]
cc=[]
x=0
for i in range(n):
    k = [int(i) for i in input().split()]
    A.append(k)

for i in range(m):
    k = [int(i) for i in input().split()]
    B.append(k)




for i in range(n):
    for j in range(l):
        for k in range(m):
            x += A[i][k]*B[k][j]
        cc.append(x)
        x=0
    C.append(cc)
    cc=[]

for j in C:
    print(' '.join(map(str, j)))

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

int main(){
  int N, K;
  cin >> N >> K;
  int sum = 1;
  for (int i=0;i<N;i++){
    if (sum * 2 < sum + K){
      sum *= 2;
    }
    else{
      sum += K;
    }
  }
  cout << sum << endl;
}

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

#define N 200000

int compare(const void *a, const void *b) {
	int ia = *(int *) a;
	int ib = *(int *) b;

	return ia - ib;
}

int main() {
	static int hh[N];
	int n, k, i;
	long long ans;

	scanf("%d%d", &n, &k);
	for (i = 0; i < n; i++)
		scanf("%d", &hh[i]);
	qsort(hh, n, sizeof *hh, compare);
	ans = 0;
	for (i = 0; i < n - k; i++)
		ans += hh[i];
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
long long dp[2010][2010],fr[2010];
int n,k;
int main()
{
	//freopen("forget.in","r",stdin);
	//freopen("forget.out","w",stdout);
	scanf("%d%d",&n,&k);
	dp[0][n+1]=1;
	for(int i=1;i<=k;i++)
	{
		fr[n+1]=dp[i-1][n+1];
		for(int j=n;j;j--)	fr[j]=(fr[j+1]+dp[i-1][j])%mod;
		for(int j=1;j<=n-i+1;j++) dp[i][j]=fr[j]%mod;
	}
	dp[k][1]=(dp[k][1]-dp[k-1][1]+mod)%mod;
	for(int i=1;i<=(n-k-1);i++) (dp[k][1]*=2)%=mod;
	cout<<dp[k][1]%mod<<endl;
}

Measured memory_bytes: 31104
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

template<typename T> void  Asort(T * a, int n) { sort(a, a + n,    less<T>()); }
template<typename T> void RAsort(T * a, int n) { sort(a, a + n, greater<T>()); }

int n, m, x[100000], d[100000 - 1];

int main() {
	cin >> n >> m;
	inc(i, m) { cin >> x[i]; }
	Asort(x, m);
	
	inc(i, m - 1) { d[i] = x[i + 1] - x[i]; }
	Asort(d, m - 1);
	
	// inc(i, m) { cout << x[i] << " " ; } cout << endl;
	
	int ans = 0;
	inc(i, m - n) { ans += d[i]; }
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#pragma _attribute_((optimize("-O2")))

#include <iostream>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <cstdio>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <string>
#include <sstream>
#include <time.h>
#include <iomanip>

//#define Local

using namespace std;

set<int> dis;

bool chs(int in)
{
	bool flag = 1;
	while(flag&&in>0)
	{
		int tmp = in % 10;
		in /= 10;
		if (dis.count(tmp) != 0)
			flag = 0;
	}
	return flag;
}

int main()

{

	ios::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input1.txt", "r", stdin);
	//freopen("output1.txt", "w", stdout);

	int t, k;
	while(cin>>t>>k)
	{
		dis.clear();
		while(k--)
		{
			int tmp;
			cin >> tmp;
			dis.insert(tmp);
		}
		while(1)
		{
			if(chs(t))
			{
				cout << t << endl;
				break;
			}
			t++;
		}
	}

#ifdef Local
	cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
#endif
	return 0;
}

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

int main(void) {
    vector<char> s(3);
    int count = 0;
    for(int i:s){
        cin >> s.at(i);
        if(s.at(i) == '1')count ++;
    }
    cout << count << endl;

    
}


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

using namespace std;

int main() {
    int N=0;
    cin>>N;
    
    vector<int> day(3);
    vector<int> prevDayCost(3);
    while(N--) {
        cin>>day[0]>>day[1]>>day[2];
        vector<int> costDay(3);
        for(int I=0; I<3; I++) {
            for(int J=0; J<3; J++) {
                if(I!=J) {
                    costDay[I] = max(costDay[I], (prevDayCost[J]+day[I]));
                }
            }
        }
       prevDayCost = costDay;
    }

    cout<<max(prevDayCost[0], max(prevDayCost[1], prevDayCost[2]))<<endl;

    return 0;
}


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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()
#define fst first
#define sec	second
#define pb push_back

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

const int mod = 1e9 + 7;


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

	int n;
	cin >> n;
	vi h(n);
	rep(i, n){
		cin >> h[i];
	}

	int sum=0, ans=0;
	rep(i, n-1){
		if(h[i] >= h[i+1]){
			sum++;
		}else{
			sum=0;
		}
		ans = max(ans, sum);
	}

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



Measured memory_bytes: 640
def nibungi_search(arr, a)
  return false if arr.size <= 1 && arr.last != a
  mid = (arr.size/2).floor
  n = arr[mid]

  if a == n
    return true
  elsif a > n
    nibungi_search(arr[mid..-1], a)
  else
    nibungi_search(arr[0..mid-1], a)
  end
end

loop do
  n = gets.to_i
  break if n == 0

  arr = gets.split(' ').map(&:to_i).sort
  _q = gets.to_i
  q_arr = gets.split(' ').map(&:to_i)

  count = 0
  q_arr.each do |a|
    count += 1 if nibungi_search(arr, a)
  end
  puts count
end

Measured memory_bytes: 22416
N, W = map(int, input().split())

S = [list(map(int, input().split())) for i in range(N)]

def make(S):
    T = {0: 0}
    for v, w in S:
        T0 = dict(T)
        for k, val in T.items():
            if k+w > W:
                continue
            if k+w in T0:
                T0[k+w] = max(T0[k+w], val + v)
            else:
                T0[k+w] = val + v
        T = T0
    v = 0
    R = []
    for k in sorted(T):
        v = max(v, T[k])
        R.append((k, v))
    return R

def solve(T0, T1):
    T0.sort()
    T1.sort(reverse=1)

    it = iter(T1); k1, v1 = next(it)
    yield 0
    for k0, v0 in T0:
        while k0 + k1 > W:
            k1, v1 = next(it)
        yield v0 + v1


T0 = make(S[:N//2])
T1 = make(S[N//2:])

print(max(solve(T0, T1)))



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

int main() {
  int N, K, A;
  A = 1;
  cin >> N >> K;
  for (int i = 0; i < N; i++){
    if (A < K) {
      A *= 2;
    }
    else {
      A += K;
    }
  }
  cout << A << endl;
}


Measured memory_bytes: 256
#include<iostream> 
#include<string>
#include<algorithm>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second

int d[500];

string s;

string ps(string s) {
	string ret = "";
	for(int i = 0;i < s.size();i++) {
		if(s[i] >= 'A' && s[i] <= 'Z'){
			ret.pb(s[i]);
		}else if(s[i] == '?')ret.pb('A');
		else if(s[i] == '+' || s[i] == '-') {
			int j = 0;
			while(s[i] == '+' || s[i] == '-') {
				j += d[s[i]];
				i++;
			}
			if(s[i] == '?') {
				ret.pb('A');	
			}else {
				s[i] -= 'A';
				j = (j + 26 * 100) % 26;
				s[i] = (s[i] + j + 26) % 26;
				s[i] += 'A';
				ret.pb(s[i]);
			}
		}else {
			int cou = 1;
			int start = i + 1;
			while(cou > 0) {
				i++;
				if(s[i] == '[') {
					cou++;
				}else if(s[i] == ']') {
					cou--;
				}
			}
			if(i - start > 0) {
				string t = s.substr(start,i - start);
				/*for(auto &c : t) {
					if(c == '[') c = ']';
					else if(c == ']') c = '[';
				}*/
				//cerr << "aaa    " << t << endl;
				t = ps(t);
				reverse(t.begin(),t.end());
				ret += t;
			}
		}
	}
	return ret;
}

int main(){
	while(1) {
		cin >> s;
		if(s == ".")break;

		d['+'] = 1;
		d['-'] = -1;
		cout << ps(s) << endl;
	}
	return 0;
}



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

int main(){
  int loop,isBad=0;
  char a,b;
  a = getchar();
  for(loop=0;loop<3;loop++){
    b = getchar();
    if(a!=b){
      a=b;
    }else{
      isBad = 1;
      break;
    }
  }
  if(isBad){
    cout << "Bad" << endl;
  }else{
    cout << "Good" << endl;
  }
  return 0;
}


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

int main()
{
    int n, x, a = 3;
    cin >> n >> x;
    if (x == 1 || x == n*2-1){
        cout << "No";
        return 0;
    }
    cout << "Yes" << endl;
    for (int i=0; i<2*n-1;i++)
    {
        if (i == n-2){
            cout << n * 2 - 1 << endl;
        }
        else if (i == n-3 && x != 2){
            cout << 2 << endl;
        }
        else if (i == n-1){
            cout << x << endl;
        }
        else if (i == n){
            cout << 1 << endl;
        }
        else
        {
            if (a == x) a++;
            cout << a << endl;
            a++;
        }
    }
    return 0;
}

Measured memory_bytes: 1536
def main(n, h):
    for i in range(n - 1):
        j = n - i - 1
        if h[j - 1] - h[j] > 1:
            return "No"
        if h[j - 1] > h[j]:
            h[j - 1] -= 1
    return 'Yes'


if __name__ == '__main__':
    n = int(input())
    h = list(map(int, input().split()))
    print(main(n, h))

Measured memory_bytes: 14396
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 200005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N,K,f[MAXN];
int a[MAXN];
void Solve() {
    read(N);read(K);
    for(int i = 1 ; i <= N ; ++i) {
        read(a[i]);
    }
    sort(a + 1,a + N + 1);
    f[0] = 1;
    int ans = N;
    for(int i = N ; i >= 1 ; --i) {
        for(int j = K - 1 ; j >= 0 ; --j) {
            if(f[j] && a[i] + j >= K) ans = min(i - 1,ans);
            if(j >= a[i]) f[j] |= f[j - a[i]];
        }
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define     __        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define     pi        acos(-1)
#define     ll        long long int
#define     fopen     freopen("in.txt","r",stdin)
#define     fwrite    freopen("o.txt","w",stdout)
#define     f0(n)     for(int i=0;i<n;i++)
#define     mem(a)    memset(a,0,sizeof(a))
#define     mems(a)   memset(a,-1,sizeof(a))

int main()
{
    __
    //fopen;
    //fwrite;
    ll a,b,k,tm=0;
    cin>>a>>b>>k;
    for(int i=1;i<=k;i++)
    {
        if(i%2==1){
            if(a%2==1) a--;
            tm=(a/2);
            a-=(a/2);
            b+=tm;
           }
           else{
               if(b%2==1) b--;
            tm=(b/2);
            b-=(b/2);
            a+=tm;
           }
          // cout<<a<<" ab "<<b<<endl;
    }

    cout<<a<<" "<<b;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
bool comp(ll &a,ll &b){
  return a > b;
}
int main()
{
  int x,y,a,b,c;cin >> x >> y >> a >> b >> c;
  vector<ll> p(a),q(b),r(c);
  rep(i,a) cin >> p[i];
  rep(i,b) cin >> q[i];
  rep(i,c) cin >> r[i];

  sort(p.begin(), p.end(), comp);
  sort(q.begin(), q.end(), comp);  
  priority_queue<ll,vector<ll>,greater<ll>> pq;
  ll res = 0;
  rep(i,x){
    pq.push(p[i]);
    res += p[i];
  }
  rep(i,y){
    pq.push(q[i]);
    res += q[i];
  }
  sort(r.begin(), r.end(), comp);
  rep(i,c){
    int tmp = pq.top();
    if(tmp < r[i]){
      res += r[i] - tmp;
      pq.pop();
    }
    else break;
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 4724
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
#include <assert.h>
#include <array>

using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mn(x) *min_element((x).begin(),(x).end())
#define mx(x) *max_element((x).begin(),(x).end())
#define sum(x) accumulate((x).begin(),(x).end(),0ll)
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef  unsigned long long  ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;

const ld pi=acos(-1);
const ll inf=(ll)1e9+1;
const int mod=1000000007;
//const int mod=998244353;

ll n,m,k;
const int N=1e6;






int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    int q,t,u,v,h;
    ll x,a,b,c,d,y,z;
    string s;
    cin >> s;
    n=(int)s.length();
    u=0;
    for(int i=0; i<n; i++){
        u+=s[i]-'0';
    }
    if(u%9){
        cout << "No\n";
    }
    else{
        cout << "Yes\n";
    }
    
    return 0;
}



Measured memory_bytes: 3768
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    ll A, B, ans = 1;
    cin >> A >> B;
    FOR(i, 2, 1000001) {
        if (A == 1 || B == 1) break;
        if ((A % i == 0) && (B % i == 0)) ans++;
        while (A != 0 && A % i == 0) A /= i;
        while (B != 0 && B % i == 0) B /= i;
    }
    if (A != 1 && A == B) ans++;
    cout << ans << endl;
    return 0;
}

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

#define mp make_pair
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const ll maxn=1010 , inf=1e18+10;

vector < pair <int , ld> > g[maxn];

double x[maxn] , y[maxn] , r[maxn];
ld dis[maxn];

void dijekstra(int u)
{
    set < pair <int , ld> > s;
    dis[u]=0;
    s.insert(mp(u , 0));
    while(s.size())
    {
        pair <int , ld> a=*s.begin();
        s.erase(s.begin());
        for(int i=0 ; i<g[a.first].size() ; i++)
        {
            int v=g[a.first][i].first;
            ld w=g[a.first][i].second;
            if(dis[v] > a.second + w)
            {
                s.erase(mp(v , dis[v]));
                dis[v] = a.second + w;
                s.insert(mp(v , dis[v]));
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin>>x[0]>>y[0]>>x[1]>>y[1]>>n;
    r[0]=r[1]=0;
    for(int i=2 ; i<n+2 ; i++)
        cin>>x[i]>>y[i]>>r[i];
    for(int i=0 ; i<n+2 ; i++)
        for(int j=i+1 ; j<n+2 ; j++)
        {
            int s1=abs(x[i]-x[j]) , s2=abs(y[i]-y[j]);
            ld d=sqrt(1ll*s1*s1 + 1ll*s2*s2)-r[i]-r[j] , t=0;
            g[i].pb(mp(j , max(t , d)));
            g[j].pb(mp(i , max(t , d)));
        }
    for(int i=0 ; i<n+2 ; i++)
        dis[i]=inf;
    dijekstra(0);
    cout<<fixed<<setprecision(9)<<dis[1];
    return 0;
}


Measured memory_bytes: 32768
data class Edge(val v1: Int, val v2: Int)

fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val edges = mutableListOf<Edge>()
  for (v1 in 1..n) {
    for (v2 in (v1 + 1)..n) {
      if (n % 2 == 0) {
        if (v1 + v2 == n + 1) continue
      }
      if (n % 2 == 1) {
        if (v1 + v2 == n) continue
      }
      edges.add(Edge(v1, v2))
    }
  }
  println(edges.size)
  for (edge in edges) {
    println("${edge.v1} ${edge.v2}")
  }
}

Measured memory_bytes: 31988
#include <utility>
#include <cstdio>
#include <cmath>
#include <climits>
#include <iostream>
using namespace std;

//---- Spreadsheet
int main(void){
    int r,c;
    cin >> r >> c;
    int s[r+1][c+1];
    for(int i=0; i<r; i++){
        s[i][c]=0;
        for(int j=0; j<c; j++){
            cin >> s[i][j];
            s[i][c]+=s[i][j];
        }
    }
    for(int j=0; j<c+1; j++){
        s[r][j]=0;
        for(int i=0; i<r; i++){
            s[r][j]+=s[i][j];
        }
    }
    for(int i=0; i<r+1; i++){
        for(int j=0; j<c; j++){
            cout << s[i][j] << " ";
        }
        cout << s[i][c];
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace  std;
#define f(i,n) 		for(i=0;i<n;i++)
#define fr(i,n,a) 	for(i=n;i>=a;i--)
#define fa(i,a,n) 	for(i=a;i<n;i++)
#define deb(x)		cout<<#x<<" "<<x<<endl;
#define deb2(x,y)	cout<<#x<<","<<#y<<" "<<x<<","<<y<<endl;
#define buf(x)		cout<<"Check"<<x<<endl;
#define ll			long long int 
#define ft			first
#define s			second
#define pb			push_back
#define mp			make_pair
#define d			double
#define all(v)		v.begin(),v.end()	
#define et(v)		for(auto itr:v)
inline void p(int x[],int n)	{	int i;f(i,n)cout<<x[i]<<" ";cout<<endl; }
void solve()
{  	
	ll N,K,i,ans=0;
	cin>>N>>K;
	f(i,N)
	{
		ll u,v;
		cin>>u>>v;
		d dist=sqrt(pow(u,2)+pow(v,2));
		if(dist<=(d)K)
			++ans;
	}
	cout<<ans;
}
int main()
{	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll t=1;
	//cin>>t;
	while(t--)
	{
		solve();
		cout<<endl;
		
	}
	return 0;
}
		


Measured memory_bytes: 3696
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, s = 0;

  std::string A, B, C;

  std::cin >> N >> A >> B >> C;

  for (int i = 0; i < N; i ++) {
    char a = A[i], b = B[i], c = C[i];

    if (a == b && a == c) {
      ;
    }
    else if (a == b || a == c || b == c) {
      s ++;
    }
    else {
      s += 2;
    }
  }

  std::cout << s << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
int l1,l2,ans;
char s[1005],t[1005];
int main()
{
	scanf("%s\n",s+1);
	scanf("%s",t+1);
	l1=strlen(s+1),l2=strlen(t+1);
	ans=l2;
	for (int i=1;i<=l1-l2+1;i++)
	{
		int ans1=0;
		for (int j=i;j<i+l2;j++)
		if (s[j]!=t[j-i+1]) ans1++;
		ans=ans<ans1?ans:ans1; 
	}
	printf("%d",ans);
	return 0;
} 

Measured memory_bytes: 1712
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ull unsigned long long 

int main(){
  int n;cin>>n;
  if(n%2==0){
    cout<<n/2;
  }
  else
    cout<<(n/2)+1;
}

Measured memory_bytes: 256