akhauriyash/Code-Regression huggingface dataset:
import sys

def main():
    N = int(input())
    X = list(map(int, input().split()))

    for x in X:
        if x % 2 == 1:
            continue

        if x % 3 != 0 and x % 5 != 0:
            print('DENIED')
            return

    print('APPROVED')
    return


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
ll n,m;
ll a[200010];
ll res=0;
int main()
{
	cin >>n>>m;
	for (int i=0;i<n;i++) cin >>a[i];
	sort(a,a+n);
	for (int i=0;i<n-m;i++) res+=a[i];
	cout <<res;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w,K;
    cin>>h>>w>>K;
    string str[h];
    int s[h][w];
    for(int i=0;i<h;i++){
        cin>>str[i];
        for(int j=0;j<w;j++){
            s[i][j]=str[i][j]-48;
        }
    }
    int b=1;//全探索の数:2^(H-1)個
    int m=10000;
    for(int i=1;i<h;i++)b*=2;
    for(int i=0;i<b;i++){
        int I=i;
        int x[h];//横に切った時、横列が何番目のグループに属すか
        x[0]=0;
        int cut=0;
        bool cont=false;
        int g=0;//グループ番号
        for(int j=1;j<h;j++){
            if(I%2){
                g++;
                cut++;
            }
            x[j]=g;
            I/=2;
        }
        g++;//現時点で「グループの数」が入っている
        int white[g][w]={};//「iグループj列」の白チョコの数
        for(int j=0;j<h;j++){
            for(int k=0;k<w;k++){
                white[x[j]][k]+=s[j][k];
            }
        }
        for(int j=0;j<g;j++){
            for(int k=0;k<w;k++){
                if(white[j][k]>K)cont=true;
            }
        }
        if(cont)continue;
        int wa[g][w];
        for(int j=0;j<g;j++)wa[j][0]=white[j][0];
        for(int j=1;j<w;j++){
            for(int k=0;k<g;k++){
                wa[k][j]=wa[k][j-1]+white[k][j];
                if(wa[k][j]>K){
                    for(int l=0;l<g;l++)wa[l][j]=white[l][j];
                    cut++;
                    break;
                }
            }
        }
        m=min(m,cut);
    }
    cout<<m<<endl;
    return 0;
}

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

int main() {
  int64_t x;
  cin >> x;
  int64_t p = 100;
  int64_t count = 0;
  while(1){
    p *= 1.01;
    count++;
    if(x <= p) break;
  }
  cout << count << endl;
}


Measured memory_bytes: 3644
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

public class Program
{

    public static void Main()
    {
        string c1 = Console.ReadLine();
        string c2 = Console.ReadLine();
        string ans = "NO";
        c2 = new string(c2.Reverse().ToArray());
        if (c1 == c2) ans = "YES";
        Console.WriteLine(ans);
    }


    static int[] s_to_i(string[] s)
    {
        int[] ret = Array.ConvertAll<string, int>(s, delegate (string value) { return int.Parse(value); });
        return ret;
    }
}

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

#define fto(i, x, y) for(auto i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(auto i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(auto i = (x); i <= (y); i += a)
#define ftoit(it, var) for (auto it = var.begin(); it != var.end(); ++it)

#define ii pair<int, int>
#define mp make_pair
#define ff first
#define ss second

#define vi vector<int>
#define vii vector<ii>
#define ll long long
#define vll vector<ll>

#define eb emplace_back
#define ef emplace_front
#define lb lower_bound
#define ub upper_bound

#define oo 1000000007
#define OO 1000000000000000007LL

using namespace std;

#define Pro "tmp"
#define maxN 1000007

vii adj[maxN];
int color[maxN], visited[maxN];

void DFS(int u) {
    visited[u] = 1;
    fto(i, 0, (int)adj[u].size()-1) {
        int v = adj[u][i].ff;
        int w = adj[u][i].ss;
        if (visited[v]) continue;
        color[v] = (color[u]+w)%2;
        DFS(v);
    }
    return;
}

int main() {
    int n;
    scanf("%d", &n);

    fto(i, 1, n-1) {
        int u, v, w;
        scanf("%d%d%d", &u, &v, &w);
        adj[u].eb(v, w%2);
        adj[v].eb(u, w%2);
    }

    DFS(1);
    fto(i, 1, n) printf("%d\n", color[i]);

    return 0;
}

Measured memory_bytes: 35200
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        Scanner s  = new Scanner(System.in);
        String str = s.nextLine();
        String up  = str.toUpperCase();
        String low = str.toLowerCase();
        int i;
        for(i=0;i<str.length();i++){
            if(str.charAt(i)==up.charAt(i))System.out.print(low.charAt(i));
            else System.out.print(up.charAt(i));
        }
        System.out.println();
    }
}


Measured memory_bytes: 27040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PI acos(-1.0)
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	int n,k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i,n) cin >> p[i];

  sort(ALL(p));
  int sum = 0;
  rep(i,k){
    sum += p[i];
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll x[100001];
const int MOD = 1e9 + 7;
ll fact[100001];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x[i];
		x[i]--;
	}
	fact[0]=1;
	for(int i=1;i<=100000;i++)
	{
		fact[i]=(fact[i-1]*i)%MOD;
	}
	ll ans = 1;
	int ptr = 1;
	ll target = 1;
	ll cnt = 1;
	for(int i = 0; i < n; i++)
	{
		while(ptr<n)
		{
			if(x[ptr]>target)
			{
				ptr++;
				target+=2;
				cnt++;
				continue;
			}
			else if(x[ptr]==target)
			{
				ptr++;
				cnt++;
				target+=2;
				break;
			}
			else break;
		}
		//cerr<<cnt<<'\n';
		ans=(ans*cnt)%MOD;
		target-=2;
		cnt--;
	}
	cout<<ans<<'\n';
	
}


Measured memory_bytes: 1792
N = int(input())
A = list(map(int, input().split()))

ans = []
rain = 0

#山1を出す
for i in range(N):
  if i % 2 == 0:
    rain += A[i]
  else :
    rain -= A[i]

ans.append(rain)

#山2~Nを出す
for i in range(1,N):
  ans.append((A[i-1]-(ans[i-1]//2))*2)

L=[str(a) for a in ans]
L=" ".join(L)
print(L)

Measured memory_bytes: 19096
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  vector <int> vec(1000);
  bool flag = true;
  for (int i = 0; i < s.size(); i++) {
    vec[s[i]]++;
  }
  for (int i = 0; i < 1000; i++) {
    if (vec[i] > 1) flag = false;
  }
  if (flag) cout << "yes" << endl;
  else cout << "no" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
const int MOD = 1000000007;
int main() {
    int r, D, x0;
    cin >> r >> D >> x0;
    long long X = x0;
    rep(i, 1, 11) {
        X = r * X - D;
        cout << X << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout);
using namespace std;
const int MAXN = 305;
const int MOD = 1e9 + 7;
const int INF = 1e9;
int n, m;
int _min[MAXN][4], _max[MAXN][4];
int f[MAXN][MAXN][MAXN], ans;

bool chk_valid(int x, int y, int z) {
    if (_min[x][2] != INF && !y)
        return 0;
    if (_min[x][3] != INF && !z)
        return 0;
    int p, q;
    p = _min[x][1], q = _max[x][1];
    if (p != INF && (p < y + 1 || q > x))
        return 0;
    p = _min[x][2], q = _max[x][2];
    if (p != INF && (p < z + 1 || q > y))
        return 0;
    p = _min[x][3], q = _max[x][3];
    return p != INF && q > z ? 0 : 1;
}

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++)
        _min[i][1] = _min[i][2] = _min[i][3] = INF;
    for (int i = 1, l, r, x; i <= m; i++) {
        scanf("%d %d %d", &l, &r, &x);
        _min[r][x] = min(_min[r][x], l);
        _max[r][x] = max(_max[r][x], l);
    }
    f[0][0][0] = 1;
    for (int i = 0; i < n; i++)
        for (int j = 0; j <= (!i ? 0 : i - 1); j++)
            for (int k = 0; k <= (!j ? 0 : j - 1); k++)
                if (f[i][j][k]) {
                    if (chk_valid(i + 1, j, k))
                        f[i + 1][j][k] = (f[i + 1][j][k] + f[i][j][k]) % MOD;
                    if (chk_valid(i + 1, i, k))
                        f[i + 1][i][k] = (f[i + 1][i][k] + f[i][j][k]) % MOD;
                    if (chk_valid(i + 1, i, j))
                        f[i + 1][i][j] = (f[i + 1][i][j] + f[i][j][k]) % MOD;
                }
    for (int i = 0; i < n; i++)
        for (int j = 0; j <= (!i ? 0 : i - 1); j++)
            ans = (ans + f[n][i][j]) % MOD;
    printf("%d", ans);
	return 0;
}


Measured memory_bytes: 108800
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N; cin>>N;
  int ans=0;
  for(int i=2;i<100000000;i++){
    if(N%i==0){
      N/=i;
      int count=1;
      for(;;){
        if(N%i!=0)break;
        count++;
        N/=i;
      }
      for(int j=0;;j++){
        if(j*(j+1)/2>count){
          ans+=j-1;
          break;
        }
      }
    }
    if(N==1)break;
  }
  if(N!=1)ans++;
  cout<<ans<<endl;
}

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

int check(int x){
  if (x == 2) {
    return 2;
  } else if (x == 4 || x == 6 || x == 9 || x == 11) {
    return 1;
  }
  return 0;
}

int main(){
  int x, y;
  int flgx = 0, flgy = 0;
  cin >> x >> y;
  if(check(x)==check(y)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3608
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP
*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define PB push_back
#define IN insert
#define MP make_pair
#define LW(v) sort(v.begin(),v.end());
#define HI(v) sort(v.begin(),v.end(),greater<long long>());
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>n>>m;
    a=n%m;
    b=m-a;
    cout<<min(a,b)<<endl;
}


Measured memory_bytes: 256
from collections import deque

n, m = list(map(int, input().split()))
edges = [list(map(int, input().split())) for _ in range(m)]

neighbor = [[] for _ in range(n)]
for edge in edges:
    neighbor[edge[0] - 1].append(edge[1] - 1)  # 1- → 0-index
    neighbor[edge[1] - 1].append(edge[0] - 1)

#print(neighbor)
visited = [-1] * n
ans = 1
for idx in range(n):
    if visited[idx] == -1:
        queue = deque()
        queue.append(idx)
        group_population = 1
        visited[idx] = 0
        while len(queue) > 0:
            vertex = queue.popleft()
            for nei in neighbor[vertex]:
                if visited[nei] == -1:
                    visited[nei] = 0
                    queue.append(nei)
                    group_population += 1

    ans = max(ans, group_population)

print(ans)

Measured memory_bytes: 80800
"""
全探索
先頭から3文字ずつで切っていき、"ABC"か判定し、区切りを1個後ろへずらす
"""
n = int(input())
s = input()
ans = 0
for i in range(len(s)-2) :
    if s[i:i+3] == "ABC" :
        ans += 1
print(ans)

Measured memory_bytes: 8992
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique((c).begin(), (c).end()), (c).end());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


void solve(LL H, LL W, vector<string> C){
	REP(i, H) {
        REP(j, 2) {
            cout << C[i] << endl;
        }
    }
}


int main(){	
	LL H;
	LL W;
	scanf("%lld",&H);
	vector<string> C(H-1+1);
	scanf("%lld",&W);
	for(int i = 0 ; i <= H-1 ; i++){
		cin >> C[i];
	}
	solve(H, W, C);
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, W;
    cin >> n >> W;
    vector<ll> w(n), v(n);
    REP(i,n) cin >> w[i] >> v[i];

    vector<vector<ll>> dp(n+1,vector<ll>(W+1));
    ll ans = 0;
    set<int> stw{0};
    REP(i,n) {
        set<int> tmp;
        swap(tmp,stw);
        for(auto x:tmp) {
            stw.insert(x);
            dp[i+1][x] = dp[i][x];
            //cerr << x << " " << dp[i+1][x] << endl;
        }
        for(auto x:tmp) {
            if (x + w[i] <= W) {
                dp[i+1][x + w[i]] = max(dp[i][x] + v[i], dp[i+1][x+w[i]]);
                ans = max(ans,dp[i+1][x+w[i]]);
                //cerr << x + w[i] << " " << dp[i+1][x + w[i]] << endl;
                stw.insert(x+w[i]);
            }
        }
        //cerr << endl;
    }

    cout << ans << '\n';


    return 0;
}

Measured memory_bytes: 89332
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

int main(){
    long long int a,ans,b=1;
    cin>>a;
    for(int i=1;i<a+1;i++){
    	if(10000<=i&&100000>i){
    		ans++;
    	}
    	else if(100<=i&&1000>i){
    		ans++;
    	}
    	else if(0<i&&10>i){
    		ans++;
    	}
    }
    cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  string a,b,c; cin>>a>>b>>c;
  cout<<a[0]<<b[1]<<c[2]<<endl;

  return 0;

}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * 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();
            double min = in.nextDouble();
            double x = in.nextDouble();

            int l = 2 * n;
            double max = min + x * (l - 1);

            double ans = 0;
            for (int i = 0; i < n; i++) {
                ans += (min + max) / 2;

                double nextMin = (min * (l - 2) + 3 * (min + x) + (min + 2 * x)) / l;
                double nextMax = (max * (l - 2) + 3 * (max - x) + (max - 2 * x)) / l;
                double nextX = (max - min) / (l - 3);

                min = nextMin;
                max = nextMax;
                x = nextX;
                l -= 2;
            }

            out.println(ans);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

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

        public double nextDouble() {
            return Double.parseDouble(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 23252
#include<iostream>
#include<algorithm>
#include<set>
#include<vector>
#include<set>
#include<complex>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

typedef complex<double> P;
const double EPS = 1e-10;
class DisjointSet{
public:
  vector<int> rank,p;
  DisjointSet(){}
  DisjointSet(int size){
    rank.resize(size,0);
    p.resize(size,0);
  }
  void makeset(int x){
    p[x]=x;
    rank[x]=0;
  }
  void merge(int x,int y){
    link(findset(x),findset(y));
  }
  void link(int x,int y){
    if ( rank[x] > rank[y]){
      p[y]=x;      
    }else {
      p[x]=y;
      if ( rank[x] == rank[y])rank[y]++;
    }
  }
  int findset(int x){
    if ( x != p[x])p[x] = findset(p[x]);
    return p[x];
  }
};

double cross(P a,P b){
  return ( a.real()*b.imag() - a.imag()*b.real());
}

bool is_point_online(P a,P b,P c){
  return ( abs(a-c)+abs(b-c) < abs(a-b)+EPS);
}

bool isl(P a1,P a2,P b1,P b2){
  if ( is_point_online(a1,a2,b1))return true;
  if ( is_point_online(a1,a2,b2))return true;
  if ( is_point_online(b1,b2,a1))return true;
  if ( is_point_online(b1,b2,a2))return true;
  if (  ( cross(a2-a1,b1-a1) * cross(a2-a1,b2-a1)<-EPS ) && 
	( cross(b2-b1,a1-b1)*cross(b2-b1,a2-b1)<-EPS))return true;
  else return false;
}

bool is_in(P *in,P a){
  int cnt = 0;
  rep(i,4){
    P cur = in[i]-a,next=in[(i+1)%4]-a;
    if ( cur.imag()>next.imag())swap(cur,next);
    if (cur.imag()<0 && 0 <=next.imag() &&
	cross(next,cur)>=0)cnt++;
    if ( is_point_online(in[i],in[(i+1)%4],a))return true;
  }
  if ( cnt % 2 == 1)return true;
  else return false;
}

class block{
public:
  P in[4];
  bool sect(block  a){
    
    rep(i,4){
      rep(j,4){
	if ( isl(in[i],in[(i+1)%4],a.in[j],a.in[(j+1)%4])){
	  return true;
	} 
      }
    }

    rep(i,4){
      if ( is_in(in,a.in[i])||is_in(a.in,in[i]))return true;
    }
    
    return false;
  }
};


class sq{
public:
  vector<block> in;
};


DisjointSet dj(100);

bool visited[100];

void dfs(int n,sq & me,int now){
  visited[now]=true;
  rep(i,n){
    if ( i != now && visited[i]==false && me.in[now].sect(me.in[i])==true)
      dfs(n,me,i);
  }
}

int solve(int n,sq me){
  rep(i,100)visited[i]=false;
  int cnt = 0;
  rep(i,n){
    if ( visited[i] == false){
      cnt++;
      dfs(n,me,i);
    }
  }  
  return cnt;
}


/*
int solve(int n,sq me){
  //rep(i,100)dj.makeset(i);
  rep(i,n){
    //    REP(j,i+1,n){
    rep(j,n){
      if ( i!=j  && me.in[i].sect(me.in[j]) == true)dj.merge(i,j);
    }
  }
  
  set<int> S;
  rep(i,n)S.insert(dj.findset(i));
  return S.size();
}
*/

main(){
  int n;
  while(cin>>n && n){
    rep(i,n){
      int m;
      cin>>m;
      sq now;
      rep(j,m){
	block ins;
	rep(k,4){
	  cin>>ins.in[k].real()>>ins.in[k].imag();
	}
	now.in.push_back(ins);
      }
      cout << solve(m,now) << endl;
    }
  }
  return false;
}

Measured memory_bytes: 996
/*input
1900


*/
 
 
 
#include <bits/stdc++.h>
using namespace std;
 
 
 
// #define int long long int
#define rep(i,n) \
    for(int i = 0; i < n; i++)
#define rep2(i, a, b) \
    for(int i = a; i < b; i++)
#define all(c) \
    c.begin(), c.end()
#define init(arr, num) \
    memset(arr, num, sizeof(arr))
#define fast\
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inputFile \
    freopen("input.txt", "r", stdin); 
#define outputFile \
    freopen("output.txt", "w", stdout);
#define modM 1000000007
#define PI 3.1415926535897932
#define F first
#define S second  
#define pb push_back  
#define INF 3e18
#ifdef gaviria
#define TRACE
#endif
#ifdef TRACE
#define trace(...) _f(#VA_ARGS, __VA_ARGS_)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
 
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< ll, ll > ii;
typedef unordered_set<int> usi;
 
 
 
ll n,i,j,k,m;
int r[4]={0,0,1,-1};
int c[4]={1,-1,0,0};



void solve()
{
cin>>n;

cout<<(1000-n%1000)%1000;


}
 
 
 
 
 
 
signed main()
{

    // inputFile;
    // outputFile;
    fast;
    int T = 1;
 // cin >> T;
ll h=T;
    while(T--){
 
        solve();
        cout<<endl;
 
     
        
        
 
    }
    
    
    return 0;
 
}

Measured memory_bytes: 3596
// C - City Savers
#include <stdio.h>
typedef long long ll;

int main(void){
    int n, i; 
    ll ans = 0;
    ll a[100002], b[100001];
    scanf("%d", &n);
    for(i=0; i<n+1; i++)scanf("%lld", &a[i]);
    for(i=0; i<n; i++)scanf("%lld", &b[i]);
    for(i=0; i<n; i++){
        ans += a[i]<b[i] ? a[i] : b[i];
        b[i] -= a[i]<b[i] ? a[i] : b[i];
        a[i] -= a[i]<b[i] ? a[i] : b[i];
        ans += a[i+1]<b[i] ? a[i+1] : b[i];
        a[i+1] -= a[i+1]<b[i] ? a[i+1] : b[i];
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const unsigned int M = 1000000007;
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    char a[1001],b[101],c[101];
    while(cin>>a>>b>>c){
        char s[4];
        s[0]=toupper(a[0]);
        s[1]=toupper(b[0]);
        s[2]=toupper(c[0]);
        s[3]='\0';
        cout<<s<<endl;
    }
}


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

int main() {
		
	string sa, sb, sc; cin >> sa >> sb >> sc;

	int na = sa.size();
	int nb = sb.size();
	int nc = sc.size();
	int tmp_a = 0;
	int tmp_b = 0;
	int tmp_c = 0;
	char who = 'a';
	char ans;
	while (true) {
		if (who == 'a') {
			if (tmp_a == na) {
				ans = 'A';
				break;
			}
			who = sa[tmp_a++];
		}
		else if (who == 'b') {
			if (tmp_b == nb) {
				ans = 'B';
				break;
			}
			who = sb[tmp_b++];
		}
		else { // who == 'c'
			if (tmp_c == nc) {
				ans = 'C';
				break;
			}
			who = sc[tmp_c++];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int A,B,C,D;
    scanf("%d",&A);
    scanf("%d",&B);
    scanf("%d",&C);
    scanf("%d",&D);
    if(A <= C)
    {
        if(B <= C)
        {
            printf("0");
        }
        else
        {
            if(D <= B)
            {
                printf("%d",D - C);
            }
            else
            {
                printf("%d",B - C);
            }
        }
    }
    else
    {
        if(D <= A)
        {
            printf("0");
        }
        else
        {
            if(D >= B)
            {
                printf("%d",B - A);
            }
            else
            {
                printf("%d",D - A);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

int main(){
   string s,t;
   cin >> s >> t;
   int cnt=0;
   rep(i,s.length()){
      if(s[i]==t[i]) cnt++;
   }
   cout << cnt <<endl;

   return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int a, b, c;

  cin >> a >> b >> c;

  if(a == b && b == c){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int n,k;
  cin >> n >> k;
  int dem=1,tong=0;
  for(int i=0;i<n;i++)
  {
    int m;
    cin >> m;
    tong+=m;
    if(tong<=k) dem++;
  }
  cout << dem;
  return(0);
}

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

using namespace std;
typedef long long ll;

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> xs(m, 0);
    for(int i = 0; i < m; ++i){
        cin >> xs.at(i);
    }
    sort(xs.begin(), xs.end());
    vector<ll> ds;
    for(int i = 0; i < m - 1; ++i){
        ds.push_back(xs.at(i + 1) - xs.at(i));
    }
    sort(ds.begin(), ds.end());
    ll ans = 0;
    for(int i = 0; i < (ll)ds.size() - (n - 1); ++i){
        ans += ds.at(i);
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int ans = 8;
    int N;
    cin >> N;
    N -= 400;
    ans -= N / 200;

    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

int main()
{
  int n;
  cin >> n;
  vll a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a.rbegin(), a.rend());
  vector<ll> b;
  b.push_back(a[0]);
  for (int i = 1; i < n; ++i) {
    b.push_back(a[i]);
    b.push_back(a[i]);
  }
  cout << accumulate(b.begin(), b.begin() + n - 1, 0LL) << endl;
  return 0;
}


Measured memory_bytes: 9028
//Palindromic Numbers

#include <bits/stdc++.h>
using namespace std;

int main()
{
  int A, B;
  cin >> A >> B;
  int count;
  for (int i = A; i <= B; i++)
  {
    int s=i%10,t=i/10000%10;//1の位、一万の位
    int u=i/10%10, v=i/1000%10;
    if(s==t && u==v) count++;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 100010;
const int INF = INT_MAX/2;


int n;
int32_t main(){
	cin >> n;
	int bills = ceil((double)n / (double)1000);
	//cout << bills*1000 << "\n";
	cout << bills*1000 - n;
}









Measured memory_bytes: 3708
from fractions import gcd

n = int(input())
A = list(map(int,input().split()))

left = [0]*n
right= [0]*n

for i in range(n-1):
  left[i+1] = gcd(left[i],A[i])
  right[n-i-2] = gcd(right[n-i-1],A[n-i-1])

ans = 0
for i in range(n):
  ans = max(ans, gcd(left[i],right[i]))
print(ans)


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

int main() {
    int min = 9999;
    int max = 0;
    int n, a;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a < min) min = a;
        if (a > max) max = a;
    }
    cout << (max - min) << endl;

    return 0;
}


Measured memory_bytes: 256
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, a, b) for (int i = a; i < (b); i++)
#define FOR(i, n) for (int i = n; i >= 0; i--)
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ll long long
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;
typedef pair<int,int> P;
vector<P> island(200002);
 
int main()
{
    int n,m;
    cin >> n >> m;
    
    REP(i,m) cin >> island[i].first >> island[i].second;
    if(m == 1){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    } 
    set<int> memo_list;
    REP(i,m){
        if(island[i].first == 1){
            memo_list.insert(island[i].second);
        }
    }
 
    int flag = 0;
    sort(island.begin(),island.end(),greater<P>());//降順ソート
    REP(i, m){
        if(island[i].second  == n){
            if(memo_list.count(island[i].first)){
                    flag = 1;
                    break;
            }
        }
        //else break;
    }
 
    if(flag == 0) cout << "IMPOSSIBLE" << endl;
    else if(flag == 1) cout << "POSSIBLE" << endl;
    //cout << "POSSIBLE" << endl;
 
 
    return 0;
}

Measured memory_bytes: 6528
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<int(n);i++)
#define forr(i,n) for(int i=int(n-1);i>=0;i--)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
#define forb(i,a,b) for(int i=int(a);i>=int(b);i--)
#define mod 998244353 
using namespace std;
using ll=long long int;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vii;
typedef pair<ll ,ll> pii;
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
    }
    return res;
}
vi v[100005];
bool vis[100005];
void dfs(int s)
{
    vis[s]=true;
    for(auto i:v[s])if(!vis[i])dfs(i);
}
void solve()
{
    int n,m;
    cin>>n>>m;
    forn(i,m)
    {
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    int ans=0;
    fora(i,1,n)
    {
        if(!vis[i])
        {
            ans++;
            dfs(i);
        }
    }
    cout<<ans-1;
}

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


Measured memory_bytes: 9720
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let H: i32 = read();
    let W: i32 = read();
    let mut vec: Vec<Vec<char>> = vec![];
    for _ in 0..H {
        vec.push(read::<String>().chars().collect())
    }
    use std::collections::VecDeque;
    let mut queue = VecDeque::new();
    let firstCost = if vec[0][0] == '#' { 1 } else { 0 };

    let mut costs = vec![vec![100 * 100 + 1; W as usize]; H as usize];
    queue.push_front((0, 0));
    costs[0][0] = firstCost;

    while let Some((row, column)) = queue.pop_back() {
        let cost = costs[row as usize][column as usize];
        if row == H - 1 && column == W - 1 {
            println!("{}", cost);
            return;
        }
        let directions = vec![(1, 0), (0, 1), (-1, 0), (0, -1)];
        for (dx, dy) in directions {
            if row + dy < 0 || H <= row + dy || column + dx < 0 || W <= column + dx {
                continue;
            }
            let newRow: usize = (row + dy) as usize;
            let newColumn: usize = (column + dx) as usize;
            let newCost =
                if vec[row as usize][column as usize] == '.' && vec[newRow][newColumn] == '#' {
                    cost + 1
                } else {
                    cost
                };
            if costs[newRow][newColumn] <= newCost {
                continue;
            }
            costs[newRow][newColumn] = newCost;
            queue.push_front((newRow as i32, newColumn as i32));
        }
    }
}


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

using namespace std;

typedef long long ll;
#define mems(p) memset(p,-1,sizeof(p))
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define nl "\n"

const int mxN = 5e5 + 1;
const ll MOD = 1e9 + 7;

void fast()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

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

int main() {
	fast();
	int x, y;
	cin >> x >> y;
	if (y % 2 == 0 && y >= x * 2 && y <= x * 4) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
}

Measured memory_bytes: 3608
#include<stdio.h>

int main()
{
    int N,M;
    int t1,t2;
    scanf("%d %d",&N,&M);
    int sum=0;
    for(t1=0;t1<=N-1;t1++)
    {
        sum=sum+t1;
    }
    for(t2=0;t2<=M-1;t2++)
    {
        sum=sum+t2;
    }
    printf("%d",sum);
    return 0;
}

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

using I = long long;
using U = unsigned long long;

using F = long double;

template <typename T> using Vec = vector<T>;
template <typename K, typename V> using HashMap = unordered_map<K, V>;
template <typename T> using HashSet = unordered_set<T>;
template <typename T> using PQueue = priority_queue<T>;
template <typename T> using Uq = unique_ptr<T>;

using StrView = string_view;

auto solve(I const N, Vec<string> const S) -> void {
  HashSet<StrView> set;
  for (auto& s : S) {
    set.emplace(s);
  }
  cout << set.size() << "\n";
}

auto main() -> int {
  I N;
  scanf("%lld", &N);
  Vec<string> S(N);
  for (I i = 0; i < N; ++i) {
    cin >> S[i];
  }
  solve(N, move(S));
  return 0;
}


Measured memory_bytes: 20920
#include<iostream>
using namespace std;
int main() {
  int a,b,s=0;
  cin >> a >> b;
  for(int i=0; i<(b-a+1); i++){
    int w,x,y,z;
    w = (a+i)%10;
    x = (a+i)/10%10;
    y = (a+i)/1000%10;
    z = (a+i)/10000%10;
    if(w == z && x == y){
      s++;
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include <functional>
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

enum class Type { N, S, P };

struct D {
    vector<D> children;
    Type type = Type::N;
    int value = -1;
    int level = -1;
};

int main()
{
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            return 0;
        }

        vector<string> vs;
        for (int i = 0; i < n; ++i) {
            string s;
            cin >> s;
            vs.push_back(s);
        }

        auto parse = [](const string& s) {
            int i = 0;
            while (s[i] == '.') {
                ++i;
            }
            if (s[i] == '+') {
                return D{{}, Type::S, -1, i};
            }
            else if (s[i] == '*') {
                return D{{}, Type::P, -1, i};
            }
            else {
                return D{{}, Type::N, stoi(s.substr(i)), i};
            }
        };

        unordered_map<int, vector<D>> mm;
        for (int i = vs.size() - 1; i >= 0; --i) {
            auto x = parse(vs[i]);
            if (x.type == Type::N) {
                mm[x.level].push_back(x);
            }
            else {
                x.children = mm[x.level + 1];
                mm.erase(x.level + 1);
                mm[x.level].push_back(x);
            }
        }

        function<int(const D&)> eval = [&eval](const D& d) {
            if (d.type == Type::N) {
                return d.value;
            }
            else if (d.type == Type::S) {
                return accumulate(
                    begin(d.children), end(d.children), 0,
                    [&eval](int a, const D& b) { return a + eval(b); });
            }
            else {
                return accumulate(
                    begin(d.children), end(d.children), 1,
                    [&eval](int a, const D& b) { return a * eval(b); });
            }
        };

        cout << eval(mm[0][0]) << endl;
    }
}

Measured memory_bytes: 3160
#include<stdio.h>

int main(void){
  int n,k,count = 0,a[100000];
  scanf("%d %d",&n,&k);
  for(int i = 0;i < n;i++){
    scanf("%d",&a[i]);
  }
  n = n - 1;
  while(n > 0){
    n = n - (k-1);
    count++;
  }
  printf("%d",count);
  return 0;
}


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

int main() {
  int N,K;
  cin>>N>>K;
  vector<long> a(N);
  for(int i=0;i<N;i++) cin>>a[i];
  if(N==1){
    if(a[0]==K) cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
    return 0;
  }
  sort(a.begin(),a.end());
  if(a[N-1]<K){
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
  }
  long g=gcd(a[0],a[1]);
  for(int i=0;i<N;i++) g=gcd(g,a[i]);

  for(int i=0;i<N;i++){
    if(a[i]<K) continue;
    else if(a[i]==K){
      cout<<"POSSIBLE"<<endl;
      return 0;
    }
    else{
      if(a[i]%g==K%g){
        cout<<"POSSIBLE"<<endl;
        return 0;
      }
    }
  }

  cout<<"IMPOSSIBLE"<<endl;

  }


Measured memory_bytes: 4032
#include <stdio.h>
#include <stdlib.h>
#define MAX 201

void initialize();
int isEmpty();
int isFull();
void push(int x);
int pop();

int top;
int S[MAX] = {0};

int main(void) {
	int x, y;
	char s[10];

	while ( scanf("%s", s) != EOF) {
//		printf("%s", s);
		switch (s[0]) {
		case '+':
			x = pop() + pop();
			push(x);
			break;
		case '-':
			x = pop();
			y = pop();
			x = y - x;
			push(x);
			break;
		case '*':
			x = pop() * pop();
			push(x);
			break;
		default:
			x = atoi(s);
			push(x);
			break;
		}
		
	}
	
	printf("%d\n", S[1]);
	return 0;
}

void initialize() {
	top = 0;
	return;
}

int isEmpty() {
//	printf("isEmpty %d\n", top);
	return top == 0;
}

int isFull() {
	return top >= MAX - 1;
}

void push(int x) {
	if (isFull()) {
		printf("Over Flow\n");
		exit(-1);
	}

	top++;
//	printf("push x = %d %d\n", x, top);
	S[top] = x;
}

int pop() {
	if (isEmpty()) {
//		printf("Under Flow\n");
		exit(-1);
	}
	top--;
	return S[top+1];	
}

Measured memory_bytes: 548
#include <bits/stdc++.h>    
using namespace std;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define int long long
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define fone for(i=0;i<n;i++)
#define endl "\n"
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N          = 5000*100+1;
const ll N2      = 1000*1000+5;
const ld PI  = 3.14159265;
const ll R   = 250;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
    }

signed main ()
{
    fastio();
    int n;
    int flag=0;
    cin>>n;
    while(n!=0)
    {
       if(n%10==7)
       {
        flag++;
       }
       n/=10;
    }
    if(flag)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }




    return 0;
    
}


Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
  int n;
  char c;

  while (1){
    int sum = 0, ace = 0;
    bool fin = false;
    do {
      scanf("%d", &n);
      if (n == 0){
        fin = true;
        break;
      }
      if (n == 1){
        ace++;
      }
      else {
        sum += min(n, 10);
      }
    } while (scanf("%c", &c), c != '\n');

    if (fin){
      break;
    }
    int rs = 0;
    for (int i = 0; i <= ace; i++){
      int tmp = sum + i + (ace - i) * 11;
      if (tmp > 21){
        tmp = 0;
      }
      rs = max(tmp, rs);
    }
    printf("%d\n", rs);
  }

  return (0);
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const int N=2200;
const int MAXN=4e6;
const int M=1e9+7;
ll fac[N*N],inv[N*N],f[N][N];
int n,k;
inline ll qpow(ll a,ll b){
	ll ans=1;
	while(b){
		if(b&1) ans=ans*a%M;
		b>>=1;a=a*a%M;
	} 
	return ans;
}
void init(){
	fac[0]=1;
	for(int i=1;i<=MAXN;i++) fac[i]=fac[i-1]*i%M;
	inv[MAXN]=qpow(fac[MAXN],M-2); 
	for(int i=MAXN;i>=1;i--) inv[i-1]=inv[i]*i%M;
}
inline ll C(int n,int m){
	if(n<m) return 0;
	return fac[n]*inv[m]%M*inv[n-m]%M;
}
int main(){
//	freopen("at2000.in","r",stdin);
	init();
	scanf("%d%d",&n,&k);f[0][0]=1;
	if(k==1) {printf("1\n");return 0; } 
	for(int i=1;i<=n;i++)
		for(int j=0;j<=i;j++) f[i][j]=(f[i-1][j]+(n-j+1)*C(n*k-i-(j-1)*(k-1)-1,k-2)%M*f[i][j-1])%M;
	printf("%lld\n",f[n][n]);
	return 0;
}

Measured memory_bytes: 101120
# coding: utf-8
line = gets
line.chomp!
/(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/ =~ line
x = $1.to_i
y = $2.to_i
z = $3.to_i
k = $4.to_i

line = gets
line.chomp!
array_x = line.split(" ").map(&:to_i)
array_x.sort!.reverse!

line = gets
line.chomp!
array_y = line.split(" ").map(&:to_i)
array_y.sort!.reverse!

line = gets
line.chomp!
array_z = line.split(" ").map(&:to_i)
array_z.sort!.reverse!

def nextdif(array,max,position)
  if(position+1 < max)
    return array[position]-array[position+1]
  else
    return -1
  end
end

sum=array_x[0]+array_y[0]+array_z[0]
i_x=0
i_y=0
i_z=0

dif_x=nextdif(array_x,x,i_x)
dif_y=nextdif(array_y,y,i_y)
dif_z=nextdif(array_z,z,i_z)
dif_all=0

stack=[]
stack.push([dif_all, i_x, dif_x, i_y, dif_y, i_z, dif_z])
# print(stack,"\n")

def insert_stack(st, array)
  for i in 0..st.size-1
    if(st[i][0] < array[0])
      next
    elsif(st[i][0] == array[0])
      j = 0
      while(st[i+j][0] == array[0])
        if(st[i+j][1] == array[1] and st[i+j][3] == array[3] and st[i+j][5] == array[5])
          return st
        else
          j += 1
          if (i+j >= st.size)
            break
          end
        end
      end
      return st.insert(i+j,array)

      # if(st[i][1] != array[1] or st[i][3] != array[3] or st[i][5] != array[5])
      #   return st.insert(i,array)
      # else
      #   return st
      # end
    else
      return st.insert(i,array)
    end
  end
  return st.insert(st.size,array)
end

for cnt in 1..k do
  target=stack.shift
  puts(sum-target[0])
  if (target[1]+1 < x)
    tar_x = Marshal.load(Marshal.dump(target))
    tar_x[0] = target[0]+target[2]
    tar_x[1] += 1
    tar_x[2] = nextdif(array_x,x,tar_x[1])
    if(tar_x[1] < x) 
      stack = insert_stack(stack, tar_x)
    end
  end
  if (target[3]+1 < y)
    tar_y = Marshal.load(Marshal.dump(target))
    tar_y[0] = target[0]+target[4]
    tar_y[3] += 1
    tar_y[4] = nextdif(array_y,y,tar_y[3])
    if (tar_y[3] < y)
      stack = insert_stack(stack, tar_y)
    end
  end
  if (target[5]+1 < z)
    tar_z = Marshal.load(Marshal.dump(target))
    tar_z[0] = target[0]+target[6]
    tar_z[5] += 1
    tar_z[6] = nextdif(array_z,z,tar_z[5])
    if (tar_z[5] < z)
      stack = insert_stack(stack, tar_z)
    end
  end
  # print(cnt,", ",stack,"\n")
    
end


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

int main()
{
    char s[101];
    char p[101];
    char ss[201];

    scanf("%s %s", s, p);

    strcpy(ss, s);
    strcat(ss, s);

    if (strstr(ss, p) != NULL) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}



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

int main() {
  int x;
  cin >> x;
  string out;
  
  if (x==3 || x==5 || x==7) {
    out = "YES";
  }
  
  else {
    out = "NO";
  }
  
  cout << out;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> vi;
    vector<bool> vb(N, false);
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        if (a == 0) {
            vi.push_back(b);
        }
        if (b == N - 1) {
            vb[a] = true;
        }
    }
    for (auto x : vi) {
        if (vb[x]) {
            cout << "POSSIBLE"
                 << "\n";
            return 0;
        }
    }
    cout << "IMPOSSIBLE"
         << "\n";
    return 0;
}


Measured memory_bytes: 892