akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define lp(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define pii pair<int,int>
#define ff first
#define ss second
#define pb push_back

const int maxn=51;
const ll maxk=1e18 ;
const int modulo=1e9+7;

using namespace std ;

struct matrix
{
    ll m[maxn][maxn] ;

    matrix()
    {
        lp(i,0,maxn)
        lp(j,0,maxn) m[i][j]=0;
    }

    matrix operator*(matrix other) const
    {
        matrix ans ;
        lp(i,0,maxn)
        lp(j,0,maxn)
        lp(k,0,maxn)
        ans.m[i][j] = ( ans.m[i][j] + m[i][k] * other.m[k][j] ) % modulo ;
        return ans ;
    }

};

matrix expo(matrix x, ll n)
{
    if(n==1) return x ;
    if(n%2==0)
    {
        matrix aux=expo(x,n/2) ;
        return aux*aux ;
    }
    matrix aux = expo(x,(n-1)/2 ) ;
    return (aux*aux*x) ;
}

int main()
{
    int n;
    ll k ;
    scanf("%d%lld",&n,&k) ;
    matrix  marc ;
    lp(i,0,n)
    lp(j,0,n) scanf("%lld", &marc.m[i][j]) ;

    matrix base ;

    lp(i,0,n) base.m[0][i] = 1 ;

    matrix cool ;
    lp(i,0,n) lp(j,0,n) cool.m[i][j]=1;

    printf("%lld\n" , (base*expo(marc,k)*cool).m[0][0] ) ;

}


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

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0);

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	long long int x = 1000000000000000000;
	int n,i;
	cin>>n;

	unsigned long long int a[n];
	for(i=0;i<n;i++)
	cin>>a[i];
	
	unsigned long long int ans = 1;

	sort(a,a+n);
	if(a[0] == 0){
		cout<<"0";
		return 0;
	}

	for(i=0;i<n;i++){
		long long int temp = ans * a[i];
		if(temp / ans != a[i] || temp > x){
			cout<<"-1";
			return 0;
		}
		ans = temp;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 4428
abcd = input()
n = len(abcd)-1

for i in range(2**n):
    ope = ['-']*n
    for j in range(n):
        if (i >> j & 1):
            ope[j] = '+'
    formula = ''
    for i, o in zip(abcd, ope+['']):
        formula += i+o
    if eval(formula) == 7:
        print(formula+'=7')
        break


Measured memory_bytes: 3060
import java.io.*;
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		FastReader scan = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		Task solver = new Task();
		solver.solve(1, scan, out);
		out.close();
	}
	
	static class Task {
		public void solve(int testNumber, FastReader scan, PrintWriter out) {
			int n = scan.nextInt();
			PriorityQueue<Double> pq = new PriorityQueue<>();
			for(int i = 0; i < n; i++) pq.add(scan.nextDouble());
			for(int i = 0; i < n-1; i++) {
				double a = pq.poll();
				double b = pq.poll();
				pq.add((a+b)/2);
			}
			out.println(pq.poll());
		}
	}
	
	static void shuffle(int[] a) {
		Random get = new Random();
		for(int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			int temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}
	
	static void shuffle(long[] a) {
		Random get = new Random();
		for(int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			long temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}
	

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public FastReader(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}

		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: 21460
#include <cstdlib>
#include <iostream>
#include <vector>
#define mod 1000000007

int main() {
    int H, W;
    std::cin >> H >> W;
    std::vector<std::vector<long long>> dp(H, std::vector<long long>(W, -1));
    for(int i = 0; i < H; ++i) {
        for(int j = 0; j < W; ++j) {
            char c;
            std::cin >> c;
            if(c == '#') {
                dp[i][j] = 0;
            }
        }
    }
    bool skip = false;
    for(int j = 0; j < W; ++j) {
        if(dp[0][j] != 0 && !skip) {
            dp[0][j] = 1;
        } else {
            dp[0][j] = 0;
            skip = true;
        }
    }
    skip = false;
    for(int i = 0; i < H; ++i) {
        if(dp[i][0] != 0 && !skip) {
            dp[i][0] = 1;
        } else {
            dp[i][0] = 0;
            skip = true;
        }
    }
    for(int i = 1; i < H; ++i) {
        for(int j = 1; j < W; ++j) {
            if(dp[i][j] != 0) {
                dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod;
            }
        }
    }
    std::cout << dp[H-1][W-1] << "\n";
    return 0;
}

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

int main() {
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);
    for (int i = 0; i < M; i++)
        cin >> B[i];
    int A[N][M];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }

    int res = 0;
    for (int i = 0; i < N; i++) {
        int sum = 0;
        for (int j = 0; j < M; j++)
            sum += A[i][j] * B[j];
        sum += C;
        if (sum > 0) res++;
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;

int main( void )
{
	int n, k, input[100000];
	while(cin >> n >> k, n | k) {
		int sum = 0;
		for(int i=0; i < n; ++i) {
			cin >> input[i];
			if(i < k) sum += input[i];
		}
		int i, j, ans = sum;
		i = 0; j = k-1;
		while(j < n-1) {
			sum -= input[i++];
			sum += input[++j];
			ans = max(ans, sum);
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main()
{
	int n;
	
	scanf("%d", &n);
	for (int i = 1; i <= 3500; i++) {
		for (int j = 1; j <= 3500; j++) {
			long long x = 1ll * n * i * j;
			long long y = 1ll * 4 * i * j - 1ll * n * j - 1ll * n * i;
			if (y > 0 && x % y == 0) {
				printf("%d %d %lld\n", i, j, x / y);
				return 0;
			}
		}
	}
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n + 10];
  for (int i = 2; i <= n; i++)
  {
    cin >> a[i];
  }

  int b[n + 10];
  for (int i = 0; i < n; i++){
    b[i] = 0;
  }
  for (int i = 2; i <= n; i++){
    b[a[i]]++;
  }
  for (int i = 1; i < n; i++){
    cout << b[i] << endl;
  }
  cout << 0 << endl;
}

Measured memory_bytes: 5204
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;  cin >> n;
  map<string,int> ma;
  for(int i=0 ; i<n ; i++){
    string s;  cin >> s;
    ma[s]++;
  }
  vector<pair<int, string> >p;
  for(auto ite=begin(ma);ite!=end(ma);ite++){
    p.push_back(make_pair(ite->second,ite->first));
  }
  sort(p.begin(), p.end(),greater<pair<int,string> >());
  vector<string> k;
  for(int i=0 ; i<n ; i++){
    k.push_back(p[i].second);
    if(p[i].first > p[i+1].first)break;
  }
  sort(k.begin(),k.end());
  k.erase(unique(k.begin(),k.end()), k.end());
  for(int i=0 ; i<k.size() ; i++){
    cout << k[i] << endl;
  }
  return 0;
}


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

int main()
{
  long long n,k;
  cin>>n>>k;
  vector<long long> arr(n);
  for(int i=0;i<n;i++)
    cin>>arr[i];
  vector<bool> dp(k+1,false);
  for(int i=1;i<=k;i++)
  {
      for(int j=0;j<n;j++)
      {
          if(i<arr[j])
            break;
         if(dp[i-arr[j]]==false)
            {
                dp[i]=true;
                break;
            }
      }
  }
    if(dp[k]) cout<<"First"<<endl;
    else
    cout<<"Second"<<endl;
    return 0;
}


Measured memory_bytes: 3604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;

class Main {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final DecimalFormat df = new DecimalFormat("0.########");
    public static void main(String[] Args) throws IOException {
        double r = Double.parseDouble(br.readLine());
        System.out.println(df.format(Math.PI*r*r)+" "+df.format(2.0*Math.PI*r));
    }
}

Measured memory_bytes: 25748
/*
	@author: cheerioskun
*/
#pragma GCC target("popcnt")
#include "bits/stdc++.h"
#define f first
#define sc second
#define pb push_back
#define MOD 1000000007L
#define inf 0x3f3f3f3f
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long int ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
using namespace std;

ll a[3003], dp[3003][3003][2];

int main(){
	fast_io
	int N;
	cin>>N;
	for(int i = 0;i < N; ++i){
		cin>>a[i];
	}
	for(int i = 0;i < N; ++i){
		dp[i][i][0] = a[i];
		dp[i][i][1] = -a[i];
	}
	for(int l = 2; l <= N; ++l){
		for(int i = 0;i + l <= N; ++i){
			// Set the 0 dp
			dp[i][i + l - 1][0] = max(a[i] + dp[i + 1][i + l - 1][1], dp[i][i + l - 2][1] + a[i + l - 1]);
			// Set the 1 dp
			dp[i][i + l - 1][1] = min(-a[i] + dp[i + 1][i + l - 1][0], dp[i][i + l - 2][0] - a[i + l - 1]);
		}
	}
	cout<<dp[0][N-1][0]<<endl;
	#ifndef ONLINE_JUDGE
    	cout<<"Time Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
	#endif
}



Measured memory_bytes: 85444
import java.io.*;
import java.util.*;

public class Main {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static StringTokenizer st;

    private static int readInt() throws IOException {
        while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return Integer.parseInt(st.nextToken());
    }

    public static void main(String[] args) throws IOException {
        int N = readInt();
        long D = readInt();

        long D_squared = D * D;
        int count = 0;
        for (int i = 0; i < N; i++) {
            long dx = readInt();
            long dy = readInt();
            if (dx * dx + dy * dy <= D_squared) count++;
        }
        System.out.println(count);
    }
}


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


int main() {
	
	int N,M,X,Y;
	cin >> N >> M >> X >> Y;
	vector<int> x(N+1), y(M+1);
	for(int i=0; i<N; i++) cin >> x.at(i);
	for(int i=0; i<M; i++) cin >> y.at(i);
	x.at(N)=X, y.at(M)=Y;
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	

	if( x.back() < y.front() ){
		cout << "No War" << endl;
	}
	else cout << "War" << endl;
		
		
	return 0;
}

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

typedef long long ll;

int main(){
	int n;
	std::cin >> n;
	std::vector<ll> count(100001);
	ll total = 0;

	for(int i=0; i<n; i++){
		int a;
		std::cin >> a;
		count[a]++;
		total += a;
	}

	int query;
	std::cin >> query;
	std::vector<ll> res;
	for(int q=0; q<query; q++){
		int b, c;
		std::cin >> b >> c;
		total += count[b] * (c-b);
		count[c] += count[b];
		count[b] = 0;
		res.emplace_back(total);
	}
	for(int i=0; i<query; i++){
		std::cout << res[i] << std::endl;
	}
	return 0;
}

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

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

    vector<int> manip(m), used(n+1, false);
    for(int i=0; i<m; i++){
        cin >> manip[i];
    }

    for(int i=m-1; i>=0; i--){
        if(!used[manip[i]]){
            cout << manip[i] << endl;
            used[manip[i]] = true;
        }
    }
    for(int i=1; i<=n; i++){
        if(!used[i]){
            cout << i << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = 1000000007;

const int INF = 2000000000;


int main()
{
    int n,m;
    cin >> n >> m;
    ve<int> a(m);
    in(m,a);
    ve<int> c = {0,2,5,5,4,5,6,3,7,6};
    
    ve<pair<int,int>> b;
    rep(i,m) b.push_back({a[i],c[a[i]]});
    sort(all(b));reverse(all(b));
    
    
    vi dp(n+1,-INF);
    dp[0] = 0;
    rep(i,n+1){
        if(dp[i] == -INF) continue;
        rep(j,m){
            if(i+b[j].se <= n){
                dp[i+b[j].se] = max(dp[i+b[j].se], dp[i]+1);
            }
        }
    }
    //outve(dp);
    
    while (n > 0) {
        rep(i,m){
            if(n < b[i].se) continue;
            if(dp[n-b[i].se] == dp[n]-1){
                cout << b[i].fi;
                n-=b[i].se;
                break;
            }
        }
    }
    cout <<endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define in(a, n) for(int i=0;i<n;i++)
#define w while(t--)
#define tc int t; cin>>t;
int intlog(double base, double x) {
    return (int)(log(x) / log(base));
}
bool sortbysec(const pair<string,long long> &a,
              const pair<string,long long> &b)
{
    return (a.second < b.second);
}
long long b[1000009];
long long z[1000009];
int lcm(int a, int b)
 {
    return (a*b)/__gcd(a, b);
 }
int main()
{
    int n,m;
    cin>>n>>m;
    n-=1,m-=1;
    cout<<n*m;

}


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

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

    vector<pair<long long int, pair<long long int, long long int>>> dish(n);
    for(int i=0; i<n; i++){
        long long int a, b;
        cin >> a >> b;
        dish[i] = {a+b, {a,b}};
    }
    sort(dish.begin(),dish.end());
    reverse(dish.begin(),dish.end());

    long long int ans = 0;
    for(int i=0; i<n; i++){
        if(i % 2 == 0) ans += dish[i].second.first;
        if(i % 2 == 1) ans -= dish[i].second.second;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  
  int n;
  cin >> n;
  
  int count = 0;
  vector<int> p(n);
  
  for ( int i = 0; i < n; i++){
    cin >> p.at(i);
  }
  
  for ( int i = 0; i < n; i++){
    if ( p.at(i) != i + 1 ){
      count++;
    }
  }
  
  if ( count == 0 || count ==2 ){
    cout << "YES";
  }else{
    cout << "NO";
  }
  
  cout << endl;
      
}

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

int main(){
  vector<int> a(3);
  for (int i=0 ; i<3 ; i++)
    cin >> a.at(i);
  
  int n;
  vector<int> ans;
  for (int i=0 ; i<3 ; i++){
    for (int j=0 ; j<3 ; j++){
      if (i==j)
        continue;
      n = abs(a.at(j)-a.at(i)) + abs(a.at(3-i-j)-a.at(j));
      ans.push_back(n);
    }
  }
  
  sort(ans.begin(), ans.end());
  cout << ans.at(0) << endl;
}

Measured memory_bytes: 3632
M=2**64-1
eval"N,*A="+`dd`.split*?,
C=[0,N].map{|z|y,*a=A[z,N]*3;a.map{|x|y^y=x}}
e,f=C.map{|z|z[b=0,N].map{|x|b=b*9+x&M};b}
q=1-9**N&M
N.times{|i|e==f&&p(i,A[i]^A[N])
e=e*9+C[0][i]*q&M}

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


vector<int> topologicalSort(int v,const vector<int> edge[]){
	vector<int> zeros;
	vector<int> in(v),res;
	for(int i=0;i<v;i++){
		for(int j=0;j<(int)edge[i].size();j++)in[edge[i][j]]++;
	}
	for(int i=0;i<v;i++)if(in[i]==0)zeros.push_back(i);
	while(!zeros.empty()){
		int u=zeros.back();
		zeros.pop_back();
		res.push_back(u);
		for(int i=0;i<(int)edge[u].size();i++){
			if(--in[edge[u][i]]==0)zeros.push_back(edge[u][i]);
		}
	}
	return res;
}


int main(){
	int h,w;
	int xmin[26],ymin[26],xmax[26],ymax[26];
	char image[50][50];
	int t;
	cin>>t;
	while(t--){
		fill_n(xmin,26,51);
		fill_n(ymin,26,51);
		fill_n(xmax,26,-1);
		fill_n(ymax,26,-1);
		cin>>h>>w;
		bool ok=true;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				char c;
				cin>>c;
				image[i][j]=c;
				if(c=='.')continue;
				int idx=c-'A';
				ymin[idx]=min(ymin[idx],i);
				ymax[idx]=max(ymax[idx],i);
				xmin[idx]=min(xmin[idx],j);
				xmax[idx]=max(xmax[idx],j);
			}
		}
		vector<int> edge[26];
		for(int i=0;i<26;i++){
			if(ymax[i]==-1)continue;
			for(int y=ymin[i];y<=ymax[i];y++){
				for(int x=xmin[i];x<=xmax[i];x++){
					if(image[y][x]=='.'){
						ok=false;
						break;
					}
					if(i+'A'!=image[y][x])edge[i].push_back(image[y][x]-'A');
				}
			}
		}
		vector<int> order(topologicalSort(26,edge));
		if(ok&&order.size()==26)cout<<"SAFE"<<endl;
		else cout<<"SUSPICIOUS"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1220
A, B, H, M = gets.chomp.split.map(&:to_i)

theta = Math::PI * 2 * (H / 12.0 + ((M / 60.0) / 12.0) - (M / 60.0))

puts Math.sqrt(( A**2 + B**2 - (2 * A * B * Math.cos(theta)) ).abs)

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

int main(){
    vector<int>x(5);
    int ans;
    for(int i=0;i<5;i++){
        cin>>x.at(i);
        if(x.at(i)==0)ans=i+1;
    }

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


Measured memory_bytes: 3596
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  getc solve >>= mapM_ print

solve :: [String] -> [Int]
solve [] = []
solve (x:xs:ys) = f : solve ys
  where
    n = toInt x
    ps = sort $ wrds toInt xs
    f = snd $ foldl (\(a,b) p -> (a+p,b+a+p)) (0,0) ps

toInt :: String -> Int
toInt = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getc :: ([String] -> a) -> IO a
getc f = f . lines <$> getContents

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

int dp[31];

int main() {
	while(1){
		int n;
		cin >> n;
		if(n == 0)break;
	
		dp[1] = 1;
		dp[2] = 2;
		dp[3] = 4;
		for(int i = 4; i <= n; i++)
			dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
		
		int ans = (dp[n] % 3650 == 0) ? dp[n] /3650 : dp[n] / 3650 + 1;
	
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const int MOD = 1000000007;
#define inf 1e9

int main() {
    int n;
    cin>>n; 
    vector<int> t(n+1,0),x(n+1,0),y(n+1,0);
    rep(i,n) cin>>t[i+1]>>x[i+1]>>y[i+1];
    for (int i=1; i<n+1; i++) {
        int dis=abs(x[i]-x[i-1]+y[i]-y[i-1]);
        int dif=t[i]-t[i-1];
        if (dis%2!=dif%2||dif<dis) {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
} 


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long int ll;
using ipair = pair<int,int>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
const int MOD=1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){ 
    int n,x,t;cin>>n>>x>>t;
    int ans;
    if(n%x==0)ans = n*t/x;
    else ans = (n/x+1)*t;
    cout<<ans<<endl;
    return 0;
}

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

#define MAXN 100005
#define ll long long int


int main(){
    string a,b;
    cin>>a>>b;
    int ans=0;
    for(int i=0;i<a.length();i++)if(a[i]!=b[i])ans++;
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3916
/*
      author : nishi5451
      created: 11.08.2020 21:03:15
*/

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


int main(){
    string s;
    cin >> s;
    for(auto a : s){
        if(a=='1') cout << 9;
        else cout << 1;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>

 

using namespace std;

 

int main()
{
    long long int x;
    int n;
    long long int min, max, sum;
    
    max = -1000000;
    min = 1000000;
    sum = 0;
    
    cin >> n;
   
    
    for(int i=0; i<n; i++)
    {
        cin >> x;
        if (x > max)
            max = x;
        if (x < min)  
            min = x;
        sum = sum + x;
    }
    cout << min << ' ';
    cout << max << ' ';
    cout << sum << endl;
}


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, k, u, v;
string s, t;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>s>>t;
	ll cou = 0;
	for(ll i=0;i<3;i++) cou += (s[i]==t[i]);
	cout<<cou; 
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

ll my_pow(ll a, int n) {
	if (!a) {
		return 0;
	}
	if (!n) {
		return 1;
	}
	if (n & 1) {
		return (a * my_pow(a, n - 1)) % 998244353LL;
	}
	return my_pow((a * a) % 998244353LL, n / 2);
}


int main() {
	int n;
	int mx = 0;
	int d;
	cin >> n;
	vector <int> g(n, 0);
	cin >> d;
	if (d != 0) {
		cout << 0;
		return 0;
	}
	g[0] = 1;
	for (int i = 1; i != n; ++i) {
		cin >> d;
		if (d == 0) {
			cout << 0;
			return 0;
		}
		mx = max(mx, d);
		++g[d];
	}
	ll res = 1;
	for (int i = 1; i != mx + 1; ++i) {
		res *= my_pow(g[i - 1], g[i]);
		res %= 998244353LL;
	}
	cout << res;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;
    ll dis = abs(B - A);
    ll p = (V - W) * T;
    if (p >= dis) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


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

int main(){
    vector<int> a(3);
    int sum=0;

    for(int i=0; i<3; i++){
        cin >> a.at(i);
    }

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

    cout << a.at(0) + a.at(1) + 10*a.at(2) << endl;

    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> N >> M;
	while (N) {
		cin >> K;
		vector<vector<bool>>flag(M, vector<bool>(721));
		vector<queue<int>>Q(N);
		for (int i = 0; i < K; i++) {
			int a, b, c, d;
			cin >> a >> b >> c >> d;
			a -= 540;
			b--;
			c--;
			if (d) {
				Q[b].push(a);
			}
			else {
				for (int j = Q[b].front(); j < a; j++) {
					flag[c][j] = true;
				}
				Q[b].pop();
			}
		}
		cin >> K;
		for (int i = 0; i < K; i++) {
			int a, b, c;
			cin >> a >> b >> c;
			a -= 540;
			b -= 540;
			c--;
			int ans = 0;
			for (int j = a; j < b; j++) {
				ans += flag[c][j];
			}
			cout << ans << endl;
		}
		cin >> N >> M;
	}
	return 0;
}

Measured memory_bytes: 4752
L, R = map(int, input().split())

ans = 2018
R = min(R, L+2020)
for i in range(L, R+1):
    f = False
    for j in range(i+1, R+1):
        m = (i*j)%2019
        if  m  == 0:
            ans = m
            f = True
            break     
        ans = min(ans, m)
    if f:
        break
print(ans)


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

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

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

    int ma = 0;
    int count = 0;
    rep(i, n){
        if(h[i] >= ma){
            count++;
            ma = h[i];
        }
    }

    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
typedef long long LL;
template<class T> inline void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

int main(void) {
	string S;
	cin >> S;

	map<char, int> dict;
	for (int i = 0; i < S.size(); i++)
	{
		dict[S[i]]++;
	}

	if (dict.size() != 2) {
		cout << "No" << endl;
		return 0;
	}

	for (auto &kv:dict) {
		if (kv.second != 2) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}


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

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

#define LOG(variable) cerr << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cerr << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
template<typename T = int>
T in() {T a; cin >> a; return a;}
/***** MAIN *****/
signed main() {
  int n; cin >> n;
  string s = "";
  if(n <= 26) {
    putchar('a'+n-1);
    cout << endl;
    return 0;
  }
  
  while(n > 0) {
    if(n%26 == 0) {
      s = 'z' + s;
      n--;
    } else {
      s = char('a' + (n % 26)-1) + s;
    }
    n /= 26;
  }
  // if(n == 0) {
  //   s = 'z' + s;
  // } else {
  //   s = char('a' + n-1) + s;
  // }
  cout << s;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <numeric>
#include <string>
#include <map>
#include <set>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
    for (T &x : vec)
        is >> x;
    return is;
}

int main(){
    ll n,m;
    cin >> n >> m;

    ll ans=0;

    if(n*2>=m){
        ans=m/2;
    }else{
        ans=n;
        m-=n*2;
        ans+=m/4;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
  
typedef struct{
    double x,y;
} Point;
  
 
int koch(int n, Point p1, Point p2){
 
    Point s,t,u;
    double degree = M_PI / 3;
 
    if(n == 0)
    {
      printf("%.8f %.8f\n", p2.x, p2.y);
      return;
    }
 
    s.x = (2 * p1.x + 1 * p2.x) / 3.0;
    s.y = (2 * p1.y + 1 * p2.y) / 3.0;
    t.x = (1 * p1.x + 2 * p2.x) / 3.0;
    t.y = (1 * p1.y + 2 * p2.y) / 3.0;
    u.x = (t.x - s.x) * cos(degree) - (t.y - s.y) * sin(degree) + s.x;
    u.y = (t.x - s.x) * sin(degree) + (t.y - s.y) * cos(degree) + s.y;
 
    koch(n-1,p1,s);  
    koch(n-1,s,u);
    koch(n-1,u,t);    
    koch(n-1,t,p2);
}
  
  
int main(){
    int n;
    Point p1,p2;
      
    p1.x = 0;
    p1.y = 0;
    p2.x = 100;
    p2.y = 0;
      
    scanf("%d",&n);
 
    printf("%.8f %.8f\n",p1.x,p1.y);
    koch(n,p1,p2);
      
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>

typedef struct{
  double x;
  double y;
}PP;

double ssyy(PP,PP,PP);
double ttyy(PP,PP,PP);
double ssxx(PP,PP,PP);
double ttxx(PP,PP,PP);
void kock(int,PP,PP);

int main(){
  int n;
  PP p1 = {0.00000000,0.00000000},p2 = {100.00000000,0.00000000};
  scanf("%d",&n);
  printf("%f %f\n",p1.x,p1.y);
  kock(n,p1,p2);
  printf("%f %f\n",p2.x,p1.y);
  return 0;
}

void kock(int n,PP p1,PP p2){
  PP s,t,u;
  double th = M_PI * 60.0 / 180.0;
  if(n == 0) return;
  
  s.x = ssxx(s,p1,p2);
  t.x = ttxx(t,p1,p2);
  s.y = ssyy(s,p1,p2);
  t.y = ttyy(t,p1,p2);
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;
  
  kock(n - 1,p1,s);
  printf("%f %f\n",s.x,s.y);
  kock(n - 1,s,u);
  printf("%f %f\n",u.x,u.y);
  kock(n - 1,u,t);
  printf("%f %f\n",t.x,t.y);
  kock(n - 1,t,p2);
}

double ssxx(PP ss,PP p1,PP p2){
  return ss.x = (2.0 * p1.x + 1.0 * p2.x) / 3.0;
}

double ttxx(PP tt,PP p1,PP p2){
  return tt.x = (1.0 * p1.x + 2.0 * p2.x) / 3.0;
}

double ssyy(PP ss,PP p1,PP p2){
  return ss.y = (2.0 * p1.y + 1.0 * p2.y) / 3.0;
}

double ttyy(PP tt,PP p1,PP p2){
  return tt.y = (1.0 * p1.y + 2.0 * p2.y) / 3.0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <cstring>
#include <stdio.h>
#include <stack>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 50;
int n, x, y;
int a[N], b[N], c[500][500];
ll ans1 = 0, ans2 = 0;

int main( ){
    int num = 1;
    x = 0;
    y = 1;
    while (x + y <= 1e5) {
        x += y;
        a[x] = 1;
        b[x] = y;
        y++;
    }
    scanf("%d", &n);
    if (a[n]) {
        printf("Yes\n%d\n", b[n]+1);
        x = 2, y = 1;
        num = 1;
        while (x <= b[n]+1) {
            for (int i = 1; i < x; i++) {
                c[i][y] = num;
                c[x][i] = num++;
            }
            x++;
            y++;
        }
        for (int i = 1; i <= b[n]+1; i++) {
            printf("%d ", b[n]);
            for (int j = 1; j <= b[n]; j++) {
                printf("%d%c", c[i][j], j == b[n] ? '\n' : ' ');
            }
        }
    }
    else {
        printf("No\n");
    }
    return 0;
}


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

using namespace std;


int main() {
#ifdef LOCAL
    freopen("atcoder/3/input.txt", "r", stdin);
#endif

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

    if ((a == 5 && b == 5 && c == 7) ||
        (a == 5 && c == 5 && b == 7) ||
        (b == 5 && c == 5 && a == 7)) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }


    return 0;
}











Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

const int p = 2019;
struct mint
{
    ll x;
    mint(ll x = 0) : x(x % p) {}
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= p)
            x -= p;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += p - a.x) >= p)
            x -= p;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= p;
        return *this;
    }

    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const
    {
        if (t == 0)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    mint inv() const
    {
        return pow(p - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
};

int main()
{
    int l, r;
    cin >> l >> r;

    int sml, lrg;
    sml = min(l % 2019, r % 2019);
    lrg = max(l % 2019, r % 2019);

    int ans = 2020;
    for (ll i = l; i < r; i++)
    {
        for (ll j = i + 1; j <= r; j++)
        {
            int now = (i * j) % 2019ll;
            ans = min(ans, now);
            if (ans == 0)
            {
                break;
            }
        }

        if (ans == 0)
        {
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll N,K,S;
  cin >> N >> K >> S;
  ll cnt = 0;
  for (int i = 0; i < K; i++) {
    cout << S << " ";
    cnt++;
  }
  for (int i = cnt; i < N; i++) {
    if (S != 1000000000) {
      cout << S+1 << " ";
    } else {
      cout << 1 << " ";
    }
  }
  return 0;
}

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

struct UnionFind {
    vector<int> data;

    UnionFind(int sz) { data.assign(sz, -1); }

    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return (false);
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int k) {
        if (data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }

    int size(int k) { return (-data[find(k)]); }
};

int main() {
    int N, M;
    cin >> N >> M;
    unordered_map<int, int> m;
    for (int i = 0; i < N; i++) {
        int p;
        cin >> p;
        p--;
        m[p] = i;
    }
    UnionFind uf(N);
    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        uf.unite(x, y);
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (i == m[i] || uf.find(m[i]) == uf.find(i)) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int p[11];
int c[11];

int main() {
	int d, g;
	cin >> d >> g;
	for (int i = 0; i < d; i++)
		cin >> p[i] >> c[i];
	int ans = 1e9;
	for (int i = 0; i < (1 << d); i++) {
		int tmp = 0;
		long sum = 0;
		for (int j = 0; j < d; j++) {
			if (i & (1 << j)) {
				tmp += p[j];
				sum += 100 * (j + 1) * p[j] + c[j];
			}
		}
		for (int j = d - 1; j >= 0 && sum < g; j--) {
			if (!(i & (1 << j))) {
				int point = 100 * (j + 1);
				long rest = g - sum;
				int cnt = min(p[j], int((rest + point - 1) / point));
				sum += point * cnt;
				tmp += cnt;
			}
		}
		ans = min(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3624
import numpy as np
A, B = map(int, input().split())

x_A_max = (A+1)/0.08
x_A_min = np.ceil(A/0.08)

x_B_max = (B+1)/0.1
x_B_min = np.ceil(B/0.1)

if (x_A_max<=x_B_min)or(x_A_min>=x_B_max):
    print(-1)
elif x_A_min<x_B_min:
    print(int(x_B_min))
else:
    print(int(x_A_min))

Measured memory_bytes: 20628
#include <iostream>
#include <string>
#include <vector>


using namespace std;

int main(){
  int N;
  cin >> N;
  int H[N];
  for(int i = 0; i < N; i++){
    cin >> H[i];
  }
  int current_max = -1;
  bool boolean = true;
  for(int i = 0; i < N; i++){
    if(current_max > H[i]+1){
      boolean = false;
      break;
    }
    if(H[i] > current_max) current_max = H[i];
  }
  if(boolean){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main()
{
  double R;
  cin >> R;
  cout << fixed<<setprecision(10)<<R * 2 * 3.1415926535 << endl;
}

Measured memory_bytes: 3788
n = int(input())
nums = []
for i in range(n + 1):
    if i != 0:
        # .find()は見つからなかったら-1を返す。for文で回してるので見つかった場合は0が出る
        if i % 3 == 0 or str(i).find("3") != -1:
            nums.append(i)
print("", " ".join(map(str, sorted(nums))))



Measured memory_bytes: 6104
# 1行、1変数を受け取るとき
K, N = map(int, input().split())
ls = list(map(int, input().split()))

max_dist = 0

for i in range(len(ls) - 1):
    max_dist = max(ls[i + 1] - ls[i], max_dist)

print(K - max(max_dist, K - ls[-1] + ls[0]))

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

#define REP(i,n) for (int i=0;i<(n);++i)
#define rall(a) (a).rbegin(),(a).rend()

using namespace std;

using pii = pair<int, int>;

bool solve() {

    cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vector<pii> v(N);
    int sum_depth = 0;
    REP(i, N) {
        string S;
        cin >> S;
        int depth = 0;
        int min_depth = 0;
        for (char c: S) {
            if (c == '(') {
                ++depth;
            } else if (c == ')') {
                --depth;
                min_depth = min(min_depth, depth);
            }
        }
        if (depth < 0) {
            min_depth -= depth;
        }
        v[i] = pii(min_depth, depth);
        sum_depth += depth;
    }
    
    if (sum_depth != 0) return false;

    sort(rall(v));

    int depth_left = 0;
    int depth_right = 0;
    int min_min_depth = 0;

    REP(i, N) {
        auto [min_depth, diff_depth] = v[i];

        if (diff_depth > 0) {
            if (depth_left + min_depth < 0) return false;
            depth_left += diff_depth;
        } else if (diff_depth < 0) {
            if (depth_right + min_depth < 0) return false;
            depth_right -= diff_depth;
        } else {
            min_min_depth = min(min_min_depth, min_depth);
        }
    }

    assert(depth_left == depth_right);

    return depth_left + min_min_depth >= 0;
}

int main() {

    cout << (solve() ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 11000
import os
import heapq
import sys
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase


"""def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)"""

"""def pw(a,b):
    result=1
    while(b>0):
        if(b%2==1): result*=a
        a*=a
        b//=2
    return result"""



def inpt():
    return [int(k) for k in input().split()]


def main():
    n=int(input())
    kyu=8
    for i in range(400,1900,200):
        c=i+199
        if(i<=n<=c):
            print(kyu)
            exit()
        kyu-=1




BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()


Measured memory_bytes: 67324
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
string s[7]={"SUN", "MON", "TUE","WED","THU","FRI","SAT"};
int cal(){
	string a;cin>>a;
	rep(i,7){
		if(a==s[i]) return 7-i;
	}
}
int main()
{
	cout<<cal()<<endl;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意


a = int(input())
b = int(input())

if a > b: a,b = b,a

ans = 1
if ans == a: ans = 2
if ans == b: ans = 3

print(ans)



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

using ll = long long;

ll a[5100] = {};

bool dp_right[5010][5010] = {};
bool dp_left[5010][5010] = {};

int main(void){
    // Here your code !
    ll n,k;
    cin >> n >> k;
    
    
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    
    sort(a,a+n);
    
    for(int i = 0; i < n; i++){
        dp_right[i][0] = true;
        
        for(int j = 4999; j >= 0; j-- ){
            if(!dp_right[i][j]) continue;
			int nj = min(j + a[i], k);
			dp_right[i + 1][j] = true;
			dp_right[i + 1][nj] = true;
        }
    }
    
    
    dp_left[n][0] = true;
    
    for(int i = n-1; i >= 0; i--){
        dp_left[i][0] = true;
        
        for(int j = 4999; j >= 0; j-- ){
			if(!dp_left[i + 1][j]) continue;
			int nj = min(j + a[i], k);
			dp_left[i][j] = true;
			dp_left[i][nj] = true;
        }
    }
    
    //必要なカードの数
    ll res = 0;
    
    for(int i = 0; i < n ; i++){
        if( a[i] >= k ){
            res++;
            continue;
        }
        vector<int> x;
        
        for(int j = 0; j < k; j++) {
			if(dp_left[i + 1][j]) x.push_back(j);
		}
		
        for(int j = 0; j < k; j++){
            if(!dp_right[i][j]) continue;
            //cout << i << " " << j << endl;
			auto it = lower_bound(x.begin(), x.end(), max(0LL, k - j - a[i]));
			if(it == x.end()) continue;
			if(*it + j < k){
        		res++;
        		//cout << a[i] << endl;
        		break;
			}
        }
    }
    
    cout << n - res << endl;
    
}


Measured memory_bytes: 49408
<>=~$";@p=glob<>;
@p=map{abs($_-$')}@p;
sub f{
    my ($a, $b) = @_;
    ($a, $b) = ($b, $a) if ($a > $b);
    until ($a == 0){
        ($a, $b) = ($b%$a, $a)
    }
    return $b;
}
$a=$p[$0];
$a=&f($a,$_)for@p;
print $a

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

int main() {
  int N, K;
  long long sum = 0;
  cin >> N >> K;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }

  //体力でかい順にする
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());

  for (int i = K; i < N; i++) {
    sum += vec.at(i);
  }

  cout << sum << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<numeric>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main(){
    string s;
    cin >> s;
    rep(i, s.length()) {
        for ( int j = i; j <= s.length(); ++j ) {
            string tmp_s = s.substr(0, i);
            tmp_s += s.substr(j, s.length()-j);
//            cout << tmp_s << endl;
            if ( tmp_s == "keyence" ) {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int func(int a,char s,int b){
    if(s=='+')
        return(a+b);
    else
        return(a-b);
}
int main() {
    int a,b;
    char s[1];
    scanf("%d %c %d",&a,s,&b);
    printf("%d\n",func(a,s[0],b));
    return 0;
}

Measured memory_bytes: 128