akhauriyash/Code-Regression huggingface dataset:
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o A.exe A.cpp 
Execute: ./A
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

int main() { 	
	int x;
	cin >> x;
	
	if(400 <= x && x < 600) cout << 8 << endl; 
	if(600 <= x && x < 800) cout << 7 << endl; 
	if(800 <= x && x <1000) cout << 6 << endl; 
	if(1000<= x && x <1200) cout << 5 << endl; 
	if(1200<= x && x <1400) cout << 4 << endl; 
	if(1400<= x && x <1600) cout << 3 << endl; 
	if(1600<= x && x <1800) cout << 2 << endl; 
	if(1800<= x && x <2000) cout << 1 << endl; 
	
	return 0; 
} 


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

int main() {
  int s;
  cin >> s ;
  int s1 = s / 100;
//  cout << s1 << endl;
  int s2 = (s - s1 * 100) / 10;
//  cout << s2 << endl;
  int s3 = s - (s1 * 100) - (s2 * 10);
//  cout << s3 << endl;
  cout << s1 + s2 + s3 << endl;
}


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

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

    int count = 0;
    for (int i = 0; i < n; ++i) {
        int a; cin >> a;
        while (a % 2 == 0) {
            a /= 2;
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


d, n = map(int, input().split())


def func(x):
    cnt = 0
    while x % 100 == 0:
        cnt += 1
        x /= 100
    return cnt == d


cntcnt = 0

for i in range(1, 10000000):
    if func(i):
        cntcnt += 1
        if cntcnt == n:
            print(i)
            exit()


Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
const long INF=1000000000000;

//関数
class union_find{
    vector<long> parent, tree_size;
    public:
    union_find(long n) : parent(n), tree_size(n,1){
        for(int i=0;i<n;i++) parent.at(i)=i;
    }
    long find(long x){
        while(parent.at(x)!=x) x=parent.at(x)=parent.at(parent.at(x));
        return x;
    }
    bool marge(long a,long b){
        a=find(a);
        b=find(b);
        if(a==b) return false;
        if(tree_size.at(a)<tree_size.at(b)) swap(a,b);
        tree_size.at(a)+=tree_size.at(b);
        parent.at(b)=a;
        return true;
    }
};



int main() {
    
    
    //入力
    string S,T;
    cin>>S>>T;
    
    
    //計算
    long s=S.size(),t=T.size();
    for(int k=s-t;k>=0;k--){
        //cout<<k<<endl;
        
        bool flag=false;
        for(int i=0;i<t;i++){
            //cout<<S.at(k+i)<<" "<<T.at(i)<<endl;
            if(S.at(k+i)!='?' && S.at(k+i)!=T.at(i)) flag=true;
        }
        if(flag) continue;
        
        
        for(int i=0;i<s;i++){
            if(k<=i && i<k+t){
                cout<<T.at(i-k);
            }else{
                if(S.at(i)=='?') cout<<'a';
                else cout<<S.at(i);
            }
        }
        cout<<endl;
        return 0;
    }
    
    //出力
    cout<<"UNRESTORABLE"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll N,M=0,A=0,R=0,C=0,H=0;
  cin>>N;
  for(ll i=0;i<N;i++){
    string s;
    cin>>s;
    if(s.at(0)=='M'){M++;}
    if(s.at(0)=='A'){A++;}
    if(s.at(0)=='R'){R++;}
    if(s.at(0)=='C'){C++;}
    if(s.at(0)=='H'){H++;}
  }
  cout<<M*A*R+M*A*C+M*A*H+M*R*C+M*R*H+M*C*H+A*R*C+A*R*H+A*C*H+R*C*H<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const double PI = acos(-1.0);

class Point
{
public:
    double y, x;
    Point(){
        y = x = 0.0;
    }
    Point(double y0, double x0){
        y = y0;
        x = x0;
    }
    Point operator+(const Point& p) const{
        return Point(y + p.y, x + p.x);
    }
    Point operator-(const Point& p) const{
        return Point(y - p.y, x - p.x);
    }
    Point operator*(double a) const{
        return Point(y * a, x * a);
    }
    Point operator/(double a) const{
        return Point(y / a, x / a);
    }
    double length() const{
        return sqrt(y * y + x * x);
    }
    double dist(const Point& p) const{
        return sqrt(pow(y - p.y, 2) + pow(x - p.x, 2));
    }
    Point rotate(double theta) const{
        return Point(x * sin(theta) + y * cos(theta), x * cos(theta) - y * sin(theta));
    }
    bool operator< (const Point& p) const{
        return x < p.x;
    }
};

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<pair<Point, double> > v(n);
        for(int i=0; i<n; ++i)
            cin >> v[i].second >> v[i].first.x >> v[i].first.y;

        double ret = DBL_MAX;
        for(int i=0; i<100; ++i){
            sort(v.begin(), v.end());
            for(int j=1; j<n; ++j)
                ret = min(ret, v[j].first.dist(v[j-1].first) - v[j].second - v[j-1].second);
            for(int j=0; j<n; ++j)
                v[j].first = v[j].first.rotate(2*PI/100);
        }
        printf("%.10f\n", ret);
    }
}

Measured memory_bytes: 3600
#include <iostream>
#include <utility>
#include <map>
#include<vector>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
   int h,w;
   cin>>h>>w;
   int n;
   cin>>n;
   map <pair<int,int>,int> m;
  long long int row[h+5];
  long long int col[w+5];
   for(int i=0;i<=h;i++)
   {
       row[i]=0;
   }
   for(int i=0;i<=w;i++)
   {
       col[i]=0;
   }
   for(int i=0;i<n;i++)
   {
       int a,b;
       cin>>a>>b;
       row[a]++;
       col[b]++;
       m.insert(make_pair(make_pair(a,b),1));
   }
    long long int maxX=0,maxY=0;
    for(int i=1;i<=h;i++)
    {
       maxX= max(maxX,row[i]);
    }
   for(int i=1;i<=w;i++)
    {
        maxY= max(maxY,col[i]);
    }
    vector<int>candiX;
    vector<int> candiY;
    for(int i=1;i<=h;i++)
    {
       if(row[i]==maxX)
       {
           candiX.push_back(i);
       }
    }
   for(int i=1;i<=w;i++)
    {
      if(col[i]==maxY)
       {
           candiY.push_back(i);
       }  
    }
       
   long long int ans = maxX+maxY-1;
   bool b = false;
   //cout<<maxX<<"****"<<maxY<<endl;
   for(int i =0;i<candiX.size();i++)
    {
         if(b==true) break;
       for(int j=0;j<candiY.size();j++)
       {
              
         
              if(m.find(make_pair(candiX[i],candiY[j]))==m.end())  //not found
              {
                ans++;
              // cout<<"Ye chasla for "<<candiX[i]<<" "<<candiY[j]<<endl;
                b=true;
                 break;
              }
       }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 30768
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    ll n,m,i;
    cin>>n>>m;
    vector<ll> s(m), c(m);
    for(i=0;i<m;i++) cin>>s[i]>>c[i];
    vector<ll> t(4,-1ll);
    for(i=0;i<m;i++)
    {
        if(t[s[i]]==-1 || t[s[i]] == c[i]) t[s[i]] =c[i];
        else {cout<<-1;return 0;}
    }
    if(t[1]==-1 && n!=1) t[1]=1;
    else if(t[i]==-1 && n==1) t[1]=0;
    for(i=2;i<=n;i++)
    {
       if(t[i]==-1) t[i]=0; 
    }
    if(t[1]==0 && n!=1) {cout<<-1;return 0;}
    else 
    {
        ll ans = t[1];
        for(i=2;i<=n;i++) ans = ans*10 + t[i];
        cout<<ans;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 500010
#define INF 1e9
#define int unsigned long long
//#define int __int128
#define rep(i, l, r) for(register int i = l;i <= r;++ i)
using namespace std;
inline int read()
{
	char cc = getchar(); int cn(0), flus(1);
	while(cc > '9' || cc < '0') {if(cc == '-') flus = -flus; cc = getchar();};
	while(cc >= '0' && cc <= '9') {cn = cn * 10 + cc - '0'; cc = getchar();};
	return flus * cn;
}
signed main()
{
	int n, a, b;
	n = read();
	a = read();
	b = read();
	int c;
	c = b - a;
	if(!(c - c / 2 * 2)) printf("%lld",c / 2);
	else printf("%lld",min((a + b - 1)>>1, ((n << 1) - a - b + 1) >> 1));
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class AtCodeeeeeeeeeeeeeeeeeeeer
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            string ans = "No";
            for (int i = 0; i < s.Length; i++)
            {
                s = s.Substring(1, s.Length - 1) + s[0];
                if (s == t)
                {
                    ans = "Yes";
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
priority_queue<string> vs;
set<string> S;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin>>s;
  int K;cin>>K;
  int n=s.length();
  FOR(i,0,n){
    string str = "";
    str += s[i];
    if(vs.size()==K){
      if(str>vs.top())continue;
    }
    if(S.count(str)==0){
      vs.push(str);
    if(vs.size()==K+1)vs.pop();
    }
    S.insert(str);
    FOR(j,i+1,n){
      str += s[j];
      if(vs.size()==K){
      if(str>vs.top())continue;
    }
      if(S.count(str)==0){
      vs.push(str);
    if(vs.size()==K+1)vs.pop();
    }
      S.insert(str);
    }
  }
  vector<string> ans;
  while(!vs.empty()){
    ans.push_back(vs.top());
    vs.pop();
  }
  sort(ans.begin(),ans.end());
  cout<<ans[K-1]<<endl;
}

Measured memory_bytes: 256
from collections import defaultdict

def main():
    d = defaultdict(lambda: 0)
    n = int(input())
    for _ in range(n):
        x = int(input())
        d[x] += 1

    cnt = 0
    for key, value in sorted(d.items(), key=lambda x: x[1], reverse=True):
        if value%2 == 1:
            cnt += 1
    print(cnt)
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 20568
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            TaskC.Vertex[] vs = new TaskC.Vertex[n];
            for (int i = 0; i < n; ++i) vs[i] = new TaskC.Vertex();
            for (int i = 0; i < n - 1; ++i) {
                TaskC.Vertex a = vs[in.nextInt() - 1];
                TaskC.Vertex b = vs[in.nextInt() - 1];
                a.adj.add(b);
                b.adj.add(a);
            }
            TaskC.Vertex f = dfs(vs[0], vs);
            TaskC.Vertex q = dfs(f, vs);
            int diam = q.dist;
            if (diam % 3 == 1) {
                out.println("Second");
            } else {
                out.println("First");
            }
        }

        private TaskC.Vertex dfs(TaskC.Vertex start, TaskC.Vertex[] vs) {
            for (TaskC.Vertex v : vs) {
                v.dist = -1;
            }
            start.dist = 0;
            start.dfs(null);
            TaskC.Vertex res = start;
            for (TaskC.Vertex v : vs) {
                if (v.dist > res.dist) {
                    res = v;
                }
            }
            return res;
        }

        static class Vertex {
            int dist;
            List<TaskC.Vertex> adj = new ArrayList<>();

            public void dfs(TaskC.Vertex parent) {
                for (TaskC.Vertex u : adj)
                    if (u != parent) {
                        u.dist = dist + 1;
                        u.dfs(this);
                    }
            }

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 99344
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

const ll inf=998244353;

inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}

int main()
{
    string s;
    cin >> s;
    int m=0;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='R')
        {
            m=1;
        }
    }
    if(s[0]=='R'&&s[1]=='R')
    {
        m=2;
    }
    if(s[1]=='R'&&s[2]=='R')
    {
        m=2;
    }
    if(s[0]=='R'&&s[1]=='R'&&s[2]=='R')
    {
        m=3;
    }
    cout << m << endl;
    return 0;
}


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

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

#define forn(i, a, n) for (int i = a; i < n; ++i)
#define ford(i, a, n) for (int i = n - 1; i >= a; --i)
#define fore(i, a, n) for (int i = a; i <= n; ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
	for (auto i : a) cerr << i << ' ';\
	cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

const ld eps = 1e-9;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

const int N = 51;
ll cnt[N][N][N * N];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a;
	cin >> n >> a;
	vector<int> x(n);
	forn(i, 0, n) cin >> x[i];
	cnt[0][0][0] = 1;
	forn(i, 0, n) {
		fore(j, 0, n) {
			forn(s, 0, N * N) {
				cnt[i + 1][j][s] += cnt[i][j][s];
				if (j && s >= x[i])
					cnt[i + 1][j][s] += cnt[i][j - 1][s - x[i]];
			}
		}
	}
	ll ans  = 0;
	fore(i, 1, n) ans += cnt[n][i][i * a];
	cout << ans << '\n';
	return 0;
}


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

int main() {
	int K, N;
	cin >> K >> N;
	vector<int> A(N);
	rep(i, N) cin >> A.at(i);
	vector<int> dis(N);
	rep(i, N - 1) {
		dis.at(i) = A.at(i + 1) - A.at(i);
	}
	dis.at(N - 1) = K - A.at(N - 1) + A.at(0);
	cout << K - *max_element(dis.begin(), dis.end()) << endl;
	return 0;
}

Measured memory_bytes: 1920
import java.io.*;
import java.util.*;
 
public class Main{
   public static void main(String[] args) {
      MyScanner sc = new MyScanner();
      out = new PrintWriter(new BufferedOutputStream(System.out));
      
      //begin
      int n = sc.nextInt();
      int[] nums = new int[n];
      int[] sortnums = new int[n];
      for(int i = 0; i < n; i++)
      {
        nums[i] = sc.nextInt();
        sortnums[i] = nums[i];
      }
      Arrays.sort(sortnums);
      int i = n - 2;
      while(i > -1 && sortnums[i] == sortnums[n - 1])
        i--;
      if(i == -1)
        for(int j = 0; j < n; j++)
            out.println(nums[j]);
      else
      {
          int k = n - 1 - i;
          if(k == 1)
            for(int j = 0; j < n; j++)
                if(nums[j] != sortnums[n - 1])
                    out.println(sortnums[n - 1]);
                else
                    out.println(sortnums[i]);
          else
            for(int j = 0; j < n; j++)
                out.println(sortnums[n - 1]);
                
      }
      //end
      out.close();
   }
 
   public static PrintWriter out;
      
   public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;
 
      public MyScanner() {
         br = new BufferedReader(new InputStreamReader(System.in));
      }
 
      String next() {
          while (st == null || !st.hasMoreElements()) {
              try {
                  st = new StringTokenizer(br.readLine());
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
          return st.nextToken();
      }
 
      int nextInt() {
          return Integer.parseInt(next());
      }
      long nextLong() {
          return Long.parseLong(next());
      }
      double nextDouble() {
          return Double.parseDouble(next());
      }
      String nextLine(){
          String str = "";
	  try {
	     str = br.readLine();
	  } catch (IOException e) {
	     e.printStackTrace();
	  }
	  return str;
      }
   }
}

Measured memory_bytes: 48128
#include <iostream>
#include <vector>
#include <algorithm>

int main()
{
    int count = 0;
    std::cin >> count;

    std::vector<int> in;
    in.resize(count);
    for (auto& val : in)
    {
        std::cin >> val;
    }

    std::sort(in.begin(), in.end());
    int last = *in.begin() - 1;
    for (const auto& val : in)
    {
        if (last == val)
        {
            std::cout << "NO";
            return 0;
        }
        last = val;
    }

    std::cout << "YES";
    return 0;
}

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

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007LL;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

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

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

static void A_task();

int main()
{
	A_task();
	fflush(stdout);
	return 0;
}

static void A_task()
{
	char wt[20] = { 0 };

	getstring(wt);
	std::string wtr = wt;
	std::string ans;
	if (wtr == "Sunny") {
		ans = "Cloudy";
	}
	else if (wtr == "Cloudy") {
		ans = "Rainy";
	}
	else {
		ans = "Sunny";
	}
	printf("%s\n", ans.c_str());
}


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

using namespace std;

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

#define mod 100000

int T[101][101][4];

int main(){

	while(1){
		int h,w;
		cin >> w >> h;
		if(w==0 && h==0) break;

		rep(i,h) T[i][0][0]=1;
		rep(i,w) T[0][i][2]=1;

		REP(i,1,h-1){
			REP(j,1,w-1){

				T[i][j][0]=(T[i-1][j][0]+T[i-1][j][1])%mod;
				T[i][j][1]=T[i-1][j][2]%mod;
				T[i][j][2]=(T[i][j-1][2]+T[i][j-1][3])%mod;
				T[i][j][3]=T[i][j-1][0]%mod;
			}
		}

		cout << (T[h-1][w-1][0]+T[h-1][w-1][1]+T[h-1][w-1][2]+T[h-1][w-1][3])%mod << endl;

	}

	return 0;
}

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

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

int main(){
  int n,m,a,b;
  cin >> n >> m;
  int H[n] = {};
  int F[n] = {};
  for(int i = 0; i < n; i++)
    cin >> H[i];
    
  for(int i = 0; i < m; i++){
    cin >> a >> b;
    if(H[a-1] > H[b-1]){
      if(F[b-1] == 0)
        n--;
      F[b-1]++;
    } else if(H[a-1] < H[b-1]){
      if(F[a-1] == 0)
        n--;
      F[a-1]++;
    } else {
      if(F[a-1] == 0)
        n--;
      F[a-1]++;
      if(F[b-1] == 0)
        n--;
      F[b-1]++;
    }
  }
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 4408
import java.util.Scanner

import scala.collection.mutable.ListBuffer

object Main {
  def main(args : Array[String]) = {
    val scanner = new Scanner(System.in)
    val N = scanner.nextLine().toInt
    var inputs = ListBuffer.empty[Array[Int]]
    for(i <- 1 to N){
      inputs += scanner.nextLine().split(" ").map(_.toInt).sorted
    }

    inputs.foreach{
      case Array(a,b,c) =>
        if(Math.pow(c, 2) == Math.pow(a, 2) + Math.pow(b, 2)) {
          println("YES")
        }else{
          println("NO")
        }
    }
  }
}

Measured memory_bytes: 50644
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    int N;
    cin >> N;
    map<string, int> m;
    REP(i, N){
        string s;
        cin >> s;
        m[s]++;
    }
    int tmp = 1;
    set<string> s;
    for (auto iter : m){
        if (tmp < iter.second){
            s.clear();
            s.insert(iter.first);
            tmp = iter.second;
        }else if (tmp == iter.second) s.insert(iter.first);
    }
    for (auto iter : s) cout << iter << endl;


    return 0;
}



Measured memory_bytes: 34560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<vector<double>> vvd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x_, i_, j_) cerr << #x_ << "------------" << "\n";cerr << "from " << i_ << " to " << j_ << "\n";for(ll k_=i_; k_<=j_; k_++) cerr << x_[k_] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX_LOG = 21;
const int MAX_N = 1000*101;

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


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

	string s;
	cin >> s;
	deque<char> q;
	for(auto ch: s){
		q.push_back(ch);
	}
	int state = 0; //0 means normal
	int t;
	cin >> t;
	for(int i = 0; i < t; i++) {
		int ti;
		cin >> ti;
		if(ti == 1) {
			state ^= 1;
		}
		else {
			int fi;
			cin >> fi;
			if(fi == 1) {
				if(state == 1) {
					fi = 2;
				}
			}
			else {
				if(state == 1) {
					fi = 1;
				}
			}
			char ci;
			cin >> ci;
			if(fi == 1) {
				q.push_front(ci);
			}
			else {
				q.push_back(ci);
			}
		}
	}
	string ans;
	for(auto ch: q) {
		ans += ch;
	}
	if(state == 1) {
		reverse(all(ans));
	}
	cout << ans << endl;
	return 0;
}		


Measured memory_bytes: 1368
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N, M;
    cin >> N >> M;
    if (N == M) cout << "Yes\n";
    else cout << "No\n";
}

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	int A[100002] = {0};

	cin >> N ;
	vector<pair<int, int>> v;
	for(int i=1; i<=N; i++){
		cin >> A[i];
		v.push_back({A[i], i});
	}

	sort(v.begin(), v.end());

	for(auto itr = v.begin(); itr != v.end(); itr++){
		if(itr != v.begin()){
			printf(" ");
		}
		printf("%d", itr->second);
	}
	printf("\n");
	return 0;
}

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

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


Measured memory_bytes: 256
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T.sort()

ans = 1
c = 0
now = T[0]
for i in range(N):
    if c == C:
        c = 0
        ans += 1
        now = T[i]
    if T[i] <= now + K:
        c += 1
    else:
        ans += 1
        c = 1
        now = T[i]
print(ans)

Measured memory_bytes: 7384
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<int,string> P;

int main() {
  int n; cin>>n;
  string s[n];
  for(int i=0;i<n;i++) {
    cin>>s[i];
  }
  sort(s,s+n);
  vector<P> v;
  v.push_back(make_pair(-1,s[0])); int nw=0;
  for(int i=1;i<n;i++) {
    if (v[nw].second == s[i]) v[nw].first--;
    else {v.push_back(make_pair(-1,s[i])); nw++;}
  }
  sort(v.begin(), v.end());
  int mx = v[0].first;
  //cout<<endl;
  for(P x:v) {
    if (x.first != mx) break;
    cout<<x.second<<endl;
  }
}

Measured memory_bytes: 17908
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll k,a,b;
    cin>>k>>a>>b;
    ll bisket=1;
    if(b-a<=2) bisket+=k;
    else{
        bisket+=a-1;
        k-=a-1;
        if(k%2==1) bisket++,k--;
        bisket+=(b-a)*(k/2);
    }
    cout<<bisket;
}

Measured memory_bytes: 3600
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 100010
using namespace std;
struct edge{int x, y, next;}a[N];
int n, x, p[N], l, f[N], b[N];
inline void add(int x, int y){a[++l].x=x; a[l].y=y; a[l].next=p[x]; p[x]=l;}
inline void dp(int x){
	f[x]=0;
	for(int i=p[x]; i; i=a[i].next)dp(a[i].y);
	l=0; for(int i=p[x]; i; i=a[i].next)b[++l]=f[a[i].y];
	sort(b+1, b+1+l);
	for(int i=1; i<=l; i++)f[x]=max(f[x], b[i]+l-i+1);
}
int main(){
	scanf("%d", &n);
	for(int i=2; i<=n; i++){scanf("%d", &x); add(x, i);}
	dp(1); printf("%d", f[1]);
	return 0;
}

Measured memory_bytes: 4224
#include<iostream>
#include <algorithm>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
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; }
//forとか代入しない場合は++iでもi++でも同じ

// 入力
string s, t;

// DPテーブル
int dp[3100][3100] = {0}; // 初期値も初期条件も 0

//Wが大きいときはWじゃなくてVで回してあげる、で重さが最小になるようにすればいい、ここでも全探索の時みたいなループ軸の変更,答えの時はsum_vを使う
int main() {
    cin >> s >> t;
    
    //dp
    for (int i = 0; i < s.size(); i++)
    {
        for (int j = 0; j < t.size(); j++)
        {
            if(s[i] == t[j]) chmax(dp[i+1][j+1],dp[i][j]+1);
            //ここでdp[i][j+1]、dp[i+1][j]ふたつが必要なのはどちらか大きい方が必要だから,dp[i][j+1]とdp[i+1][j]で大きさが違う時があるので
            chmax(dp[i+1][j+1],dp[i][j+1]);
            chmax(dp[i+1][j+1],dp[i+1][j]);
        }
        
    }

    //具体的なLCSを求める
    string res =  "";
    int i = (int)s.size();
    int j = (int)t.size();

    while(i > 0 && j > 0){
        //(i-1,j)→(i,j)
           if(dp[i][j] == dp[i-1][j]){
               i--;
           }
        //(i,j-1)→(i,j)
           else if(dp[i][j] == dp[i][j-1]){
               j--;
           }
        //(i-1,j-1)→(i,j)
        else {
               //この場合s[i-1]もt[j-1]も同じなのでどっちでもいい
               res = s[i-1] + res;
               i--;
               j--;
               
           }
    } 

    cout << res << endl;
    
    
    
}




Measured memory_bytes: 37120
#include <stdio.h>

int main(void)
{
	int a; int b; int c;
	scanf("%d %d %d", &a, &b, &c);

	int media;
	if (a > b) {
		media = a; a = b; b = media;
	}
	if (b > c) {
		media = b; b = c; c = media;
	}
	if (a > b) {
		media = a; a = b; b = media;
	}
	printf("%d %d %d\n", a, b, c);

	return 0;
}

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

int main()
{
    long long int X;
    scanf("%lld",&X);
    long long int sum=100;
    int year=0;
    while(sum<X)
    {
        year++;
        sum=sum+sum*0.01;

    }
    printf("%d",year);

    return 0;
}


Measured memory_bytes: 1732
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n;
	cin >> n;
	if (n < 1200) cout << "ABC\n";
	else if (n < 2800) cout << "ARC\n";
	else cout << "AGC\n";

	return 0;
}


Measured memory_bytes: 256
N,Q=map(int,input().split())
S=input()
ans=[0]*(N+1)
for i in range(N):
	if i!=N-1 and S[i]+S[i+1]=="AC":
		ans[i+1]=ans[i]+1
	else:
		ans[i+1]=ans[i]
for i in range(Q):
	l,r=map(int,input().split())
	print(ans[r-1]-ans[l-1])

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

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

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

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

    int a, b;
    cin >> a >> b;

    int ans = (a + b + 1) / 2;
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
long long a,b;
cin >> a >> b;
if(a*b<=0)cout << "Zero" << "\n";
else if(a>0)cout << "Positive" << "\n";
else if((b-a)%2==0)cout << "Negative" << "\n";
else cout << "Positive" << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define MPlus(x,y) {x=(x+y)%M;}
#define MSub(x,y) {x=(x-y+M)%M;}
#define MMul(x,y) {x=(x*y)%M;}



template< typename Monoid >
struct segTree {
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  segTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid get(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }
};


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n,m;
  cin>>n>>m;
  set<int> es[n];
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    es[a].insert(b);
    es[b].insert(a);
  }
  
  segTree<P> seg(n,[](P a,P b){return min(a,b);},P(inf,inf));
  rep(i,n){
    seg.update(i,P(es[i].size(),i));
  }

  
  vector<vi> node(n);
  map<P,bool> mp;
  while(true){
    P p=seg.get(0,n);
    if(p.F==inf) break;
    //cout<<p.F<<' '<<p.S<<endl;
    for(int x:es[p.S]){
      if(node[p.S].size()%2){
        node[p.S].PB(x);
      }else{
        node[x].PB(p.S);
      }
      es[x].erase(p.S);
      seg.update(x,P(es[x].size(),x));
    }
    seg.update(p.S,P(inf,p.S));
  }

  rep(i,n){
    //cout<<node[i].size()<<endl;
    if(node[i].size()%2){
      cout<<-1<<endl;
      return 0;
    }
  }

  rep(i,n){
    for(int j:node[i]){
      cout<<i+1<<' '<<j+1<<endl;
    }
  }

}

Measured memory_bytes: 22016
/*
ID: zhaowei10
TASK:
LANG: C++14
*/
#include "bits/stdc++.h"

using namespace std;

#ifdef LOCAL
#include "../../_library/cpp/debug.h"
#define FILE "test"
#else
#define debug(...) 0
#define FILE ""
#endif

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  if (fopen(FILE ".in", "r")) {
    freopen(FILE ".in", "r", stdin);
    freopen(FILE ".out", "w", stdout);
  }

  string s, t;
  cin >> s >> t;
  int cnt = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] != t[i])
      ++cnt;
  }
  cout << cnt;
}


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

int comp(const void *a,const void *b){
	return *(int *)b-*(int *)a;
}

int main(){
	int N;
	int i;
	long long int AOKI=0;
	long long int TAKAHASHI=0;
	long long int result;
	
	scanf("%d",&N);
	
	int A[N],B[N];
	int AplusB[N];
	
	for(i=0;i<N;i++){
		scanf("%d %d",&A[i],&B[i]);
		AOKI+=B[i];
		AplusB[i]=A[i]+B[i];
	}
	
	qsort(AplusB,N,sizeof(int),comp);
	
	for(i=0;i<N;i+=2){
		TAKAHASHI+=AplusB[i];
	}
	
	result=TAKAHASHI-AOKI;
	
	printf("%lld",result);
	
	return 0;
}

Measured memory_bytes: 1788
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
using namespace std;

int kaijo(int a){
  int i,ans=1;
  for(i=1;i<=a;i++){
  ans*=i;
  }
  return ans;
}

int mathC(int a,int b){

  int i,ans=1;
  if(b>a/2) b=a-b;
  for(i=1;i<=b;i++){
    ans*=(a-i+1);
    ans/=i;
  }
  
  return ans;
}

int max(int x[],int N){
  int i,max=x[0];
	for(i=1;i<N;i++){
      if(max<x[i]) max=x[i];
    }
  return max;
}

int min(int x[],int N){
  int i,min=x[0];
	for(i=1;i<N;i++){
      if(min>x[i]) min=x[i];
    }
  return min;
}

int main(void){
  
  long int ans=0;
  long int N,a,b;
  
  cin >> N >> a >>b;
  
  ans+=N/(a+b)*a;
  if(N%(a+b)<a) ans+=N%(a+b);
  else if(N%(a+b)>=a) ans+=a;
    
  cout << ans <<endl;
	return 0; 
}

Measured memory_bytes: 256
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
long long h,ans;
int main(){
	cin>>h;
	ans=1;
	while(h>0)
	{
		ans*=2;
		h/=2;
	}
	cout<<ans-1;
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main()
{
   long i,j,k;
   long n;
   long cnt = 0;
   long left,right,mid;
   long ans = 0;
   static long x[10000];
   static long y[10000];

   for(i = 0;;i++) {
      scanf("%ld %ld",&x[i],&y[i]);
      if(x[i] == 0 && y [i] == 0)
         break;
      else if(x[i] > y[i]) {
         long tmp = y[i];
         y[i] = x[i];
         x[i] = tmp;
      }

   }
   for(j = 0; j < i; j++) {
      printf("%ld %ld\n",x[j],y[j]);
   }

   return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  	if (N < 15) {
      cout << N * 800 << endl;
    }
  	else {
      cout << N * 800 - (N / 15 * 200) << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n,k,s=0,j,a,temp,i;
    int arr[1000];
    scanf("%d %d",&n,&k);
    for(i=0;i<n;i++){
    scanf("%d",&a);
    arr[i]=a;
        }
        for(i=0;i<n;i++){
            for(j=i+1;j<n;j++){
            if(arr[i]>arr[j]){
                temp=arr[i];
                arr[i]=arr[j];
                arr[j]=temp;
            }
        }
    }
        for(i=0;i<k;i++){
        s+=arr[i];
        }
    printf("%d",s);
}

Measured memory_bytes: 1740
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int A, B; cin >> A >> B;
	cout << (A%3==0 || B%3==0 || (A+B)%3==0?"Possible":"Impossible") << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
L = []

for x in range(3,n+1):
    if x % 3 == 0:
        L.append(x)
    else:
        i = x
        while i != 0:
            if i % 10 == 3:
                L.append(x)
                break
            else : i /= 10

print "",

while L != []:
    print L.pop(0),

Measured memory_bytes: 6512
#include<stdio.h>
#include<math.h>
int main()
{
          int T,A[1000],i,j,k;
          double m,Tot=0,a=0,ans1,ans;
         while(1){
                    scanf("%d",&T);
         if(T==0)
         {
                   return 0;
         }
          for(j=0;j<T;j++)
          {
                    scanf("%d",&A[j]);
          }
          for(i=0;i<T;i++)
          {
                    Tot=Tot+A[i];
          }
          m=Tot/T;
          for(i=0;i<T;i++)
          {
                    a=a+((A[i]-m)*(A[i]-m));
          }
          ans1=a/T;
          ans=sqrt(ans1);
          printf("%.8lf\n",ans);
          ans=0;
          ans1=0;
          Tot=0;
          m=0;
          a=0;
         }

          return 0;

}



Measured memory_bytes: 2056
n = int(input())
b = list(map(int,input().split()))
a = set(b)
flag = 0
if n % 2 == 1:
    if all(i % 2 == 0 for i in a) and len(a) == (n-1)//2 +1 and b.count(0) == 1:
        flag = 1
else:
    if all(i % 2 == 1 for i in a) and len(a) == (n-1)//2 + 1:
        flag = 1
print(2**(n//2)%(10**9+7) if flag==1 else 0)

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

string s;

int main() {
  cin >> s;

  int a = -1, z = 0;
  rep(i, s.size()) {
    if (s[i] == 'A' && a == -1) a = i;
    if (s[i] == 'Z') z = i;
  }

  cout << z - a + 1 << endl;

  return 0;
}


Measured memory_bytes: 640
import java.util.*;
import java.util.Map;
import java.util.TreeMap;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
        int K = sc.nextInt();
        double ans = 0;

        for(int i=1; i<=N; i++){
            double p = 1.0 / N;
            int a = i;
            for(int j=0; j<=18; j++){
                if(a>=K){
                    p *= Math.pow((double)1 / 2, j);
                    break;
                }
                a *= 2;
            }
            ans += p;
        }
        System.out.println(ans);
    }
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  if (b <= c || a >= d) {
    cout << 0 << endl;
    return 0;
  } else {
    if(d >= b) {
      if (c >= a) {
        cout << b - c << endl;
        return 0;
      } else {
        cout << b - a << endl;
        return 0;
      }
      return 0;
    } else {
      if (a >= c) {
        cout << d - a << endl;
        return 0;
      } else {
        cout << d - c << endl;
        return 0;
      }
      return 0;
    }
  }
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; 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 UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

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; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, k;
vector<pair<LL, LL>> vec;

int main() {
	cin >> n >> k;
	inc(i, n) {
		LL a, b;
		cin >> a >> b;
		vec.EB(a, b);
	}
	
	sort(ALL(vec));
	
	LL r = 0, ans;
	inc(i, n) {
		r += vec[i].SE;
		if(r >= k) { ans = vec[i].FI; break; }
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const ll N=3005;
ll mod=1e9+7;
char mat[N][N];
ll dp[N][N];
ll h,w;
ll helper(ll h,ll w)
{
	if(h==0||w==0)
	return 0;
	if(h==1&&w==1)
	return 1;
	if(mat[h-1][w-1]=='#')
	return 0;
	if(dp[h][w]!=-1)
	return dp[h][w];
	
	return dp[h][w]=(helper(h-1,w)+helper(h,w-1))%mod;
}
int main()
{
     cin>>h>>w;
     for(int i=0;i<h;i++)
     {
     	for(int j=0;j<w;j++)
     	cin>>mat[i][j];
     }
     memset(dp,-1,sizeof(dp));
     cout<<helper(h,w)<<endl;
	
	return 0;
}


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

int solve(int n){
	for(int i=1;i<=9;i++){
		if(n%i == 0 && n/i <= 9) return 1;
	}
	return 0; 
}

int main(){
int a;
cin >> a;
if(solve(a)) printf("Yes");	
else printf("No");
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    int N,M;
    cin>>N>>M;
    vi A(N);
    vector<pii> CB(M);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    sort(ALL(A));
    for(int i=0;i<M;i++){
        int B,C;
        cin>>B>>C;
        CB[i]=make_pair(C,B);
    }
    sort(ALL(CB));
    reverse(ALL(CB));
    int idx=0;
    for(int i=0;i<M;i++){
        for(int j=0;j<CB[i].second;j++){
            if(A[idx]<CB[i].first && idx<N){
                A[idx]=CB[i].first;
                idx++;
            }else{
                idx=N;break;
            }
        }
        if(idx>=N)break;
    }
    ll ans=0;
    for(int i=0;i<N;i++){
        ans+=A[i];
    }
    cout<<ans<<endl;
}


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

int main(){
	int H, W, i, j;

	while(1){
		cin >> H >> W;
		if(H == 0 && W == 0){
			break;
		}
		for(i = 0; i < H; i++){
			for(j = 0; j < W; j++){
				if(j == 0 || j == W - 1 || i == 0 || i == H - 1){
					cout << '#';
				}else{
					cout << '.';
				}
			}
			cout << endl;
		}
		cout << endl;
	}
			
	return 0;
}

Measured memory_bytes: 3048