akhauriyash/Code-Regression huggingface dataset:
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.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);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int A[] = new int[2 * N - 1];
            for (int i = 0; i < 2 * N - 1; i++) {
                A[i] = in.nextInt();
            }

            int lo = 0, hi = 2 * N;

            while (lo + 1 < hi) {
                int mid = lo + (hi - lo) / 2;

                if (onTopAtLeast(mid, A)) {
                    lo = mid;
                } else {
                    hi = mid;
                }
            }

            out.println(lo);
        }

        private boolean onTopAtLeast(int x, int[] a) {
            int LEN = a.length; // LEN = 2*N-1
            int N = (LEN + 1) / 2;
            int[] b = new int[2 * N - 1];
            for (int i = 0; i < LEN; i++) {
                b[i] = a[i] < x ? 0 : 1;
            }
            int[] c = new int[2 * N - 1];
            for (int i = 1; i < LEN - 1; i++) {
                c[i] = b[i - 1] + b[i] + b[i + 1] < 2 ? 0 : 1;
            }

            int left = N - 1;
            int right = N - 1; //srodeczek

            while (left > 1 && c[left - 1] != c[left]) left--;
            while (right < 2 * N - 3 && c[right] != c[right + 1]) right++;//C[1, 2*N-3]

            int ANS = ((N - 1) - left < right - (N - 1)) ? c[left] : c[right];

            return ANS == 1;
        }

    }

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

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

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

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

    }
}


Measured memory_bytes: 39864
#include<bits/stdc++.h>
using namespace std;
vector<int>v;
long long ss;
int main()
{
    int n,x,ans,k=-1;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
    	scanf("%d",&x);
    	v.push_back(x);
	}
	sort(v.begin(),v.end());
	bool p=false;
	for(int i=0;i<n-1;i++)
    {
    	ss+=v[i];
    	if(p)
    	{
    		if(ss*2<v[i+1])
    		{
    			k=-1;
    			p=false;
			}
		}
		else
		{
			if(ss*2>=v[i+1])
			{
				k=i;
				p=true;
			}
		}
	}
	if(k==-1)printf("1");
	else printf("%d",n-k);
}


Measured memory_bytes: 892
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

    private static PrintWriter out;

    private static <T> void mprintln(T ... ar){
        for(T i: ar) out.print(i + " ");
        out.println();
    }

    public static void main(String[] args) throws FileNotFoundException{

        // Input from file
        // File inputFile = new File("JavaFile.txt");
        // File outputFile = new File("JavaOutputFile.txt");
        // FileReader fileReader = new FileReader(inputFile);
        // Here it ends

        MyScanner sc = new MyScanner();
        // MyScanner sc = new MyScanner(fileReader);

        out = new PrintWriter(new BufferedOutputStream(System.out)); // Output to console
        // out = new PrintWriter(new PrintStream(outputFile)); // Output to file

        getAns(sc);

        out.close();
    }

    /*
     *Don't use builtin function (Math.ceil)
     */

    static final long MOD = (long) (1e9 + 7);

    private static void getAns(MyScanner sc){
        int n = sc.ni();
        out.println(n * (n + 1) >> 1);
    }

    static class MyScanner{
        BufferedReader br;
        StringTokenizer st;

        MyScanner(FileReader fileReader){
            br = new BufferedReader(fileReader);
        }

        MyScanner(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nn(){
            while(st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch(IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }

        char nc(){
            return nn().charAt(0);
        }

        int ni(){
            return Integer.parseInt(nn());
        }

        long nl(){
            return Long.parseLong(nn());
        }

        double nd(){
            return Double.parseDouble(nn());
        }

        int[] niArr0(int n){
            int[] ar = new int[n];
            for(int i = 0; i < n; i++) ar[i] = ni();
            return ar;
        }

        int[] niArr1(int n){
            int[] ar = new int[n + 1];
            for(int i = 1; i <= n; i++) ar[i] = ni();
            return ar;
        }

        long[] nlArr0(int n){
            long[] ar = new long[n];
            for(int i = 0; i < n; i++) ar[i] = nl();
            return ar;
        }

        long[] nlArr1(int n){
            long[] ar = new long[n + 1];
            for(int i = 1; i <= n; i++) ar[i] = nl();
            return ar;
        }
    }
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int,int> vii;
typedef vector<ll,ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef set <int> :: iterator sitr;
typedef set <ll> :: iterator sltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef mset <int> :: iterator msitr;
typedef mset <ll> :: iterator msltr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
vpll adj[200000];
int n;
bool black [200000];
bool vis[200000];
void color (){
    queue <ll> q;
    black[1] = true;
    q.push(1);

    while(!q.empty()){
        ll node = q.front();
        q.pop();
        if(!vis[node]){
            vis[node]=true;
            for(int i=0;i<adj[node].size();i++){
                ll nex,l;
                nex = adj[node][i].fi;
                l = adj[node][i].se;
                if(!vis[nex]){
                    if(l%2==0){
                        black[nex] = black[node];
                    }
                    else{
                        black[nex] = not black[node];
                    }
                    q.push(nex);
                }
            }
        }
    }

}
int main(){
    cin>>n;
    for(int i=1;i<n;i++){
        ll v1,v2,w;
        cin>>v1>>v2>>w;
        adj[v1].pb(mp(v2,w));
        adj[v2].pb(mp(v1,w));
    }
    color();
    for(int i=1;i<=n;i++){
        cout<<black[i]<<endl;
    }
}


Measured memory_bytes: 10368
class Task:
    def __init__(self, name, time):
        self.name = name
        self.time = time

queue = []

[n, q] = list(map(int, input().split()))

for i in range(n):
    [name, str_time] = input().split()
    time = int(str_time)
    queue.insert(0, Task(name, time))


elps = 0

while queue != []:
    one = queue.pop()
    a = min(one.time, q)
    one.time -= a
    elps += a
    if one.time > 0:
        queue.insert(0, one)
    else:
        print(one.name, elps)

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

int main(){
	int n,m;
	int s,t;
	int flag=0;
	cin>>n>>m;
	vector<vector<int>> graph(3*n);
	int tu,tv;
	for (int i = 0; i < m; i++) {
		cin>>tu>>tv;
		for (int j = 0; j < 3; j++) {
			graph[(tu-1+j*n)%(3*n)].push_back((tv-1+(j+1)*n)%(3*n));
		}
	}
	cin>>s>>t;
	int len=0;
	int dest;
	int temp;
	vector<int> reach(3*n,0);
	queue<int> q;
	q.push(s-1);
	while (len<3*n&&q.size()>0&&flag==0) {
		temp=q.size();
		len++;
		for (int i = 0; i < temp; i++) {
			for (int j  = 0; j  < graph[q.front()].size(); j++) {
				dest=graph[q.front()][j];
				if (reach[dest]==0) {
					q.push(dest);
					reach[dest]=1;
					if (reach[t-1]==1) {
						flag=1;
					}
				}
			}
			q.pop();
		}
	}
	if(flag==0){
		cout<<-1<<endl;
	}else {
		cout<<len/3<<endl;
	}
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int x, y;
    cin >> x >> y;
    int ans = 0;
    cout << max(0, (4-x)*100000) + max(0, (4-y)*100000) + (x == 1 && y == 1) * 400000 << endl;
    return 0;
}


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

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


Measured memory_bytes: 256
//Stack Over Flow Recursive

using System;
using System.Collections;
using System.Collections.Generic;
namespace Ccs
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());

            Program pr = new Program();

            Queue<long> queue = new Queue<long>();
            //queue.Enqueue(0);
            long x = 0;
            int count = 0;

            while (x <= n)
            {

                
                if (pr.Is_sgs(x))
                {
                    count++;
                  //  Console.WriteLine(x);
                }

                for (int i = 3; i <= 7; i += 2)
                    queue.Enqueue(x * 10 + i);

                x = queue.Dequeue();
//                if (queue.Count>0)
            }
            Console.WriteLine(count);

//          var pr = new Program();
//          Console.WriteLine(pr.Rec(0,n));
        }

        private const String sgs = "357";
        private bool Is_sgs(String s)
        {
           
            bool is_sgs_ = true;
            for(int i =0;i<sgs.Length;++i )
                is_sgs_ &= s.Contains(sgs[i].ToString());
           
            return is_sgs_;
        }   
        
        private bool Is_sgs(long n)
        {
            return this.Is_sgs(n.ToString());
        }

        /*
        private long Rec(int x, int n)
        {
            //            var x = int.Parse(s);
            if (n < x)
                return 0;
            //            if (Is_sgs(x))
            //                Console.WriteLine(x);

            long ret = Is_sgs(x) ? 1 : 0;

            foreach ( char c in sgs)
                ret += Rec(x * 10 + int.Parse( c.ToString() ), n);

            return ret;
        }
        */
    }
}


Measured memory_bytes: 14048
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using P = pair<ll, ll>;
const int MOD = (int)1e9 + 7;
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> const&P){
    os << P.first;
    os << " ";
    os << P.second;
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
//fixed<<setprecision(10)<<ans<<endl;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(3*N);
    REP(i,3*N) cin >> A[i];
    
    ll left=0, right=0;
    priority_queue<int,vector<int>,greater<int>> L; //昇順
    priority_queue<int> R; //降順
    vector<ll> left_max(3*N), right_min(3*N);
    REP(i,N){
        L.push(A[i]);
        left += A[i];
        
        R.push(A[i+2*N]);
        right += A[i+2*N];
    }
    left_max[N-1] = left;
    right_min[2*N] = right;

    REP(k,N){
        left -= L.top(); L.pop();
        right -= R.top(); R.pop();
        
        int index1 = N + k;
        int index2 = 2*N - k -1;
        
        left += A[index1]; L.push(A[index1]);
        right += A[index2]; R.push(A[index2]);
        
        left_max[index1] = max(left, left_max[index1-1]);
        right_min[index2] = min(right, right_min[index2+1]);
    }
    ll ans = -INF;
    debug(left_max)
    debug(right_min)
    REP(i,N+1){
        int index = N + i -1;
        chmax(ans,left_max[index] - right_min[index+1]);
    }
    cout << ans << endl;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	const int diff='a'-'A';
	string s; getline(cin,s);
	for(auto&&i:s){
		if('A'<=i&&i<='Z')i+=diff;
		else if('a'<=i&&i<='z')i-=diff;
	}
	cout<<s<<"\n"s;
}


Measured memory_bytes: 3180
n = int(input())
alp = 'abcdefghijklmnopqrstuvwxyz'
bef = [0 for _ in range(11)]
ans = ''
check = 2
count = 2

while count < 14 :
    s = (pow(26, count) - 1) // 25
    if n < s :
        check -= 1
        n -= (pow(26, check) - 1) // 25
        while n > 0 :
            if n >= pow(26, check - 1) :
                n -= pow(26, check - 1)
                bef[11 - check] += 1
            else :
                check -= 1
        break
    else :
        count += 1
        check += 1

for i in range(12-count,11) :
    ans += alp[bef[i]]
print(ans)


Measured memory_bytes: 9132
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    ll a, b, n; cin >> a >> b >> n;

    // rep(x, n + 1){
    //     cout << (a * x) / b << " " << a * (x / b) << endl;
    //     cout << (a * x) / b - a * (x / b) << endl;
    // }

    ll t = min(b - 1, n);

    cout << (a * t / b) - a * (t / b) << endl;

    return 0;
}

Measured memory_bytes: 3612
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        long a = in.nextLong();
        long b = in.nextLong();
        long k = in.nextLong();
        if(k<=a) a-=k;
        else{
            k-=a;
            b-=k;
            a=0;
            if(b<0) b=0;
        }
        out.println(a+" "+b);
    }
    
    /************* SOLUTION ENDS HERE **********/
}

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

int main() {
    int64_t n; cin >> n;
    cout << (
        (n * (n + 1) / 2) -
        ((n / 3) * (n / 3 + 1) * 3 / 2) -
        ((n / 5) * (n / 5 + 1) * 5 / 2) +
        ((n / 15) * (n / 15 + 1) * 15 / 2)
    ) << endl;
}



Measured memory_bytes: 3536
fun main(args:Array<String>){
  val S = readLine()!!
  val step = arrayOf('L','R')
  var answer = true
  
  for(i in 0 until S.length){
    if(S[i] == step[i%2]){
      answer = false
      break
    }
  }
  println(if(answer)"Yes" else "No")
}


Measured memory_bytes: 33668
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int MAX_V = 101;
const int INF=100000000;
// d[u][v]Íu©çvÖÌRXgBßÉ×Ú·éGbWÌRXgðüêÄ¨¢½è·êÎæ¢Í¸B
int d[MAX_V][MAX_V];
// ¸_
int V;
// S_ÎÅZoHâèðÆ­O(V^3)AÓª ÁÄà®ì
void warshall_floyd(){
    for(int i = 0; i < V; i++)
        for(int j = 0; j < V; j++)
            for(int k = 0; k < V; k++)
                d[j][k] = min(d[j][k],d[j][i]+d[i][k]);
}
int main(){
    int n,m,s,g1,g2;
    while(cin>>n>>m>>s>>g1>>g2&&!(n==0&&m==0&&s==0&&g1==0&&g2==0)){
        for(int i = 0; i < MAX_V; i++){
            for(int j = 0; j < MAX_V; j++){
                if(i==j)
                    d[i][j]=0;
                else
                    d[i][j]=INF;
            }
        }
        s--;
        g1--;g2--;
        for(int i = 0; i < m; i++){
            int b1,b2,c;
            cin>>b1>>b2>>c;
            b1--;
            b2--;
            d[b1][b2]=c;
        }
        V=n;
        warshall_floyd();
        int minCost=INF;
        // X^[g©çÇ±ÜÅ¯¶¹ðg¤©ÅÎ ¢Ê¯
        for(int i = 0; i < n; i++)
            minCost=min(minCost,d[s][i]+d[i][g1]+d[i][g2]);
        cout<<minCost<<endl;
    }
    return 0;
}

Measured memory_bytes: 0
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
int N;
long long L[90];
int main() {
	cin>>N;
	L[0]=2;
	L[1]=1;
	for(int i=2;i<N+1;i++){
		L[i]=L[i-1]+L[i-2];
	}


	if(N==1)cout<<1<<endl;
	else cout<<L[N]<<endl;

	return 0;
}


Measured memory_bytes: 256
import collections
import math
import operator as op
from functools import reduce
from collections import Counter
import numpy as np
import math
import bisect
import heapq

MOD = 1000000007

def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def main():
    N, K = get_inputs(int)

    ans = 0
    for L in range(K, N+2):
        n = L * (N - L + 1) + 1
        ans += n % MOD
        ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 27156
#include<stdio.h>

int main(void){

	int n;
	int i;
	int a[100];

	scanf("%d",&n);

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

	for(i=i-1;i>0;i--)
		printf("%d ",a[i]);

	printf("%d\n",a[0]);

	return 0;

}

Measured memory_bytes: 596
import math

def check( a,b ):
  g=math.ceil(a*100/8)
  
  for i in range(100):
      if b==int((g+i)*10/100):
          break
  
  if a!=int((g+i)*8/100):
      ans = "-1"
  else:
      ans = g+i
  return ans


a,b = map(int,input().split())
ans = check(a,b)
print(ans)

Measured memory_bytes: 9172
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a, b, k;
    cin >> a >> b >> k;
    for (int i = 100; i; i--) if (a % i == 0 && b % i == 0) {
        k--;
        if (!k) {
            cout << i;
            return 0;
        }
    }
}


Measured memory_bytes: 256
import sys
from collections import deque

n = int(input())

# 隣接行列と隣接リストを用意
dp = [[2*n for i in range(n)] for j in range(n)]
E = [[] for i in range(n)]

# 二部グラフ判定用
V = [0 for i in range(n)]

# 入力を受け取る
for i in range(n):
    s = input()
    for j in range(n):
        if s[j] == '1':
            E[i].append(j)
            dp[i][j] = 1
        if j == i:
            dp[i][j] = 0

def dfs(cur, pre, col):
    stack = deque([[cur, pre, col]])
    while stack:
        cur, pre, col = stack.pop()
        if V[cur] and V[cur] != col:
            return False
        else:
            V[cur] = col
        for e in E[cur]:
            if e != pre:
                stack.append([e, cur, -1 * col])
        # 一度通った辺は通らない
        E[cur] = []
    return True

# 二部グラフ判定
if not dfs(0, -1, 1):
    print(-1)
    sys.exit()

def warshall_floyd():
    for k in range(n):
        for i in range(n):
            for j in range(n):
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])

# 全頂点間の距離を求める
warshall_floyd()

# 直径を求める
diam = 0
for i in range(n):
    for j in range(n):
        diam = max(dp[i][j], diam)

print(diam+1)


Measured memory_bytes: 43120
import sys
def I(): return int(sys.stdin.readline().rstrip())
def S(): return sys.stdin.readline().rstrip()
N = I()
s,t = S(),S()
ans = 2*N
minus = 0
for i in range(1,N+1):
    if s[-i:]==t[:i]:
        minus = max(minus,i)
print(ans-minus)


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

struct edge {
  int to;
  ll cost;
};

ll dist[100010];
bool went[100010];
vector<edge> g[100010];

void dfs(int now, ll d) {
  went[now] = true;
  dist[now] = d;
  for (auto x : g[now]) {
    if (!went[x.to]) dfs(x.to, d + x.cost);
  }
}

// ====================================================================

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int s, t, c;
    cin >> s >> t >> c;
    s--, t--;
    g[s].push_back((edge){t, c});
    g[t].push_back((edge){s, c});
  }

  int q, k;
  cin >> q >> k;
  k--;

  dfs(k, 0);

  for (int que = 0; que < q; que++) {
    int s, t;
    cin >> s >> t;
    s--, t--;
    cout << dist[s] + dist[t] << endl;
  }
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	string s;
	cin >> s;
	bool flag[26];
	fill(flag, flag + 26, false);
	for (int i = 0; i < s.size(); i++) {
		for (int j = 97; j <= 122; j++) {
			if (s[i] == j) {
				flag[j - 97] = true;
			}
		}
	}
	for (int i = 0; i < 26; i++) {
		if (!flag[i]) {
			char ans = i + 97;
			cout << ans << endl;
			return 0;
		}
	}
	cout << "None" << endl;
	return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  srand((unsigned)time(NULL));
  ll N;
  cin >> N;
  cout << N + N*N + N*N*N << endl;
}

Measured memory_bytes: 3608
import sys

N, P = map(int, input().split())
S = list(map(int, input()))[::-1]

if P in [2, 5]:
    ans = 0
    if P == 2:
        ok = [0, 2, 4, 6, 8]
    else:
        ok = [0, 5]
        
    for i in range(N):
        if S[i] in ok:
            ans += N - i
    print(ans)
    sys.exit()

cnt = [0] * P
cnt[0] = 1

s = 0
for i in range(N):
    d = S[i] * pow(10, i, P)
    s += d
    s %= P
    cnt[s] += 1

ans = 0
for i in cnt:
    ans += (i * (i-1)) // 2

print(ans)

Measured memory_bytes: 6432
#include<bits/stdc++.h>
using namespace std;
# define ll long long
# define int long long
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
# define mo 1000000007
int n,q;
string s;
struct goku
{
    int a[26]={0};
};
goku seg[2000005];
void build(int st,int en,int id)
{
  //  cout<<id<<" ";
    if(st==en)
    {
       seg[id].a[s[st]-'a'] = 1;
       return ;
    }
    int mid = (st+en)/2;
  //  cout<<mid<<" ";
    build(st,mid,2*id+1);
    build(mid+1,en,2*id+2);
    for(int i=0;i<26;i++)
    {
        seg[id].a[i] = (seg[2*id+1].a[i]|seg[2*id+2].a[i]);
    }
}

void update(int st,int en,int id,int ta,char ch)
{
    if(st==en)
    {
       seg[id].a[s[st]-'a'] = 0;
       s[st]=ch;
       seg[id].a[s[st]-'a'] = 1;
       return;
    }
    int mid = (st+en)/2;
    if(mid>=ta)
    update(st,mid,2*id+1,ta,ch);
    else
    update(mid+1,en,2*id+2,ta,ch);
    for(int i=0;i<26;i++)
    {
        seg[id].a[i] = (seg[2*id+1].a[i]|seg[2*id+2].a[i]);
    }
}
vector<int> querry(int st,int en,int id,int l,int r)
{
    if(l<=st && en<=r)
    {
        vector<int> tt;
        int c=0;
         for(int i=0;i<26;i++)
    {
        tt.push_back(seg[id].a[i]);

    }
    return tt;
    }
    int mid = (st+en)/2;
    if(mid<l)
        return querry(mid+1,en,2*id+2,l,r);
    else if(mid>=r)
        return querry(st,mid,2*id+1,l,r);
    else
    {
        vector<int> op1= querry(mid+1,en,2*id+2,l,r) ,op2= querry(st,mid,2*id+1,l,r);
        for(int i=0;i<26;i++)
        {
            op1[i] = (op1[i]|op2[i]);
        }
        return op1;
    }
}

signed main(){
    gok
    cin>>n>>s>>q;
    build(0,n-1,0);
    while(q--)
    {
        int x=1;
       cin>>x;
        if(x==1)
        {
           int y;
           char c;
           cin>>y>>c;
           update(0,n-1,0,y-1,c);
        }
        else
        {
            int l,r;
            cin>>l>>r;
            vector<int> tt=querry(0,n-1,0,l-1,r-1);
            int an=0;
            for(int i=0;i<26;i++)
            {
                if(tt[i]>0)
                    an++;
            }
            cout<<an<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 215964
n = int(input())
a = list(map(int, input().split()))
minnum = float('inf')
for m in range(2):
    ans = 0
    s = [0]*(n+1)
    tmp = a[0] 
    if m == 0:
        if a[0] >= 0:
            ans += a[0]+1
            a[0] = -1 
    else:
        if a[0] <= 0:
            ans += abs(a[0])+1
            a[0] = 1

    for i in range(n):
        s[i+1] = s[i] + a[i]
        if s[i] < 0:
            if s[i+1] != 0 and s[i+1] > 0:
                continue
            else:
                ans += abs(s[i+1])+1
                s[i+1] = 1
        elif s[i] > 0:
            if s[i+1] != 0 and s[i+1] < 0:
                continue
            else:
                ans += abs(s[i+1])+1   
                s[i+1] = -1

    minnum = min(minnum,ans)
    a[0] = tmp

print(minnum) 

Measured memory_bytes: 14464
import math
a, b, h, m = map(int, input().split())

md = m / 60 * 360

bx = math.sin(math.radians(md)) * b
by = math.cos(math.radians(md)) * b

hd = h / 12 * 360 + m / 60 * 30

ax = math.sin(math.radians(hd)) * a
ay = math.cos(math.radians(hd)) * a

ans = math.sqrt((ax - bx)**2 + (by - ay)**2)
print(ans)

Measured memory_bytes: 9236
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    char c;
    cin>>c;
    cout<<(char)(c+1);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

#define MAX 200
#define MAX_T 60
typedef pair<int,int> P;

int T[MAX],D,dp[MAX][MAX];
vector<P> vec[MAX_T+1];

int solve(int d,P prev){
  if(d == D) return 0;
  if(dp[d][prev.second] >= 0) return dp[d][prev.second];
  int res = 0;
  for(int i = 0 ; i < (int)vec[T[d]].size() ; i++){
    int diff = abs(vec[T[d]][i].first-prev.first);
    res = max(res,solve(d+1,vec[T[d]][i])+diff);
  }
  return dp[d][prev.second] = res; 
}

int main(){
  int N,A,B,C;
  memset(dp,-1,sizeof(dp));

  scanf("%d%d",&D,&N);
  for(int i = 0 ; i < D ; i++){
    scanf("%d",&T[i]);
  }
  for(int i = 0 ; i < N ; i++){
    scanf("%d%d%d",&A,&B,&C);
    for(int j = A ; j <= B ; j++){
      vec[j].push_back(P(C,i));
    }
  }
  int ans = 0;
  for(int i = 0 ; i < (int)vec[T[0]].size() ; i++){
    ans = max(ans,solve(1,vec[T[0]][i]));
  }
  printf("%d\n",ans);

  return 0;
}

Measured memory_bytes: 1256
#include<bits/stdc++.h>
using namespace std;
int mod=1e9+7;
int main()
{
    int n;
    cin>>n;
    vector<vector<int>> can(n,vector<int> (n));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            cin>>can[i][j];
        }
    }
    vector<int> dp(1<<n);
    dp[0]=1;
    for(int mask=0;mask<(1<<n)-1;mask++)
    {
        int a=__builtin_popcount(mask);
        for(int b=0;b<n;b++)
        {
            if(can[a][b] && !(mask&(1<<b)))
            {
                int mask1=mask|(1<<b);
                dp[mask1]=(dp[mask1]%mod+dp[mask]%mod)%mod;
            }
        }
    }
    cout<<dp[(1<<n)-1]<<endl;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    ll N, T; cin >> N >> T;
    vector<ll> t(N);
    for(int i = 0; i < N; i++) cin >> t[i];

    ll sum = T;
    for(int i = 1; i < N; i++){
        ll tmp = abs(t[i] - t[i - 1]);
        if(tmp < T){
            sum += tmp;
        }else{
            sum += T;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 1792
import collections
elems = map(int, raw_input().split(' '))

def f(elems):
	elems.sort()
	
	return (elems[0] == elems[1] and elems[1] != elems[2]) or (elems[1] == elems[2] and elems[0] != elems[1])


print 'Yes' if f(elems) else 'No'

Measured memory_bytes: 85216
/*
Keep clam  Believe youself
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#include<set>
#include<cmath>
#define Xiaobo main
using namespace std;
const int maxn=2e5+7;
const int mod=1e9+7;
const double eps=1e-15;
const double pi=acos(-1);
const int INF=0x3f3f3f3f;
typedef long long ll;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}
//别急 dp找状态 问题看看本身的规律 贪心找方法
ll a[maxn];
ll b[maxn];
int Xiaobo()
{
	ll n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++) {
		scanf("%lld",&a[i]);
		a[i]/=2;
	}
	ll g=a[1],bei=a[1];
	int flag=1;
	for(int i=2;i<=n;i++) {
		g=gcd(a[i],bei);
		bei=bei/g*a[i];
		if(bei>m) {
			flag=0;
			break;
		}
	}
	for(int i=1;i<=n;i++) {
		ll k=bei/a[i];
		if(k%2==0) {
			flag=0;
			break;
		}
	}
	if(!flag) cout<<"0\n";
	else {
		ll ans=m/bei;
		cout<<(ans+1)/2<<'\n';
	}
	return 0;
} 


Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
#include <iostream>

using namespace std;

int main(){
	int n;

	scanf("%d",&n);
	int a[n];
	for(int i = 0; i < n; i++){
		scanf("%d",&a[i]);
	}
	cout<<a[n-1];
	for(int j = 1;j < n; j++){
	    cout<<" "<<a[n-j-1];
	}
	cout<<endl;

return 0;
	}


Measured memory_bytes: 3240
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<utility>
#define INF 0x3f3f3f3f
#define PI acos(-1)
#define ll long long
using namespace std;
ll c(ll n) {
	if (n<2) {
		return 0;
	}
	ll res = n*(n-1)/2;
	return res;
}
int main() {
	std::ios::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	cout << c(n) + c(m) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	int n; cin >> n;
	VI l(n); REP(i,n) cin >> l[i];
	sort(ALL(l));
	int ans=0;
	REP(i,n)for(int j=i+1;j<n;j++)for(int k=j+1;k<n;k++){
		if(l[i]!=l[j]&&l[i]!=l[k]&&l[j]!=l[k]){
			if(l[i]+l[j]>l[k])
				ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    std::string s; std::cin >> s;
    std::set<char> o = { 'R', 'U', 'D' }, e = { 'L', 'U', 'D' };
    int n = s.size();
    bool ok = true;
    for (int i = 0; i < n; i++) {
        ok &= ((i + 1) & 1 ? o : e).count(s[i]);
    }
    std::cout << (ok ? "Yes" : "No") << std::endl;
    return 0;
}



Measured memory_bytes: 256
import math


def isPalindrome(s):
    if s == s[::-1]:
        return True
    return False


def isStrongPalindrome(text):
    if isPalindrome(text):
        if isPalindrome(text[0:(len(text)-1)//2]):
            if isPalindrome(text[len(text)+3//2:]):
                return True
    return False


data = input()
    
if isStrongPalindrome(data):
    print("Yes")
else:
    print("No")
    




Measured memory_bytes: 38256
#include <iostream>
using namespace std;
int main()
{
        char s[4];
        cin >> s;

        int a[3]={0};
        for(int i=0;i<3;i++){
                if(s[i]=='a') a[0]++;
                else if(s[i]=='b') a[1]++;
                else if(s[i]=='c') a[2]++;
        }

        int i;
        for(i=0;i<3;i++){
                if(a[i]==0) break;
        }

        if(i==3) cout << "Yes" << endl;
        else cout << "No" << endl;

        return 0;
}


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

const int INF = 1001;

int main() {
  int N, T;
  cin >> N >> T;

  int ans = INF;
  rep(i, N) {
    int c, t;
    cin >> c >> t;
    if (t <= T && c < ans)
      ans = c;
  }

  if (ans == INF)
    cout << "TLE" << endl;
  else
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>

using namespace std;

using ll = long long;

int main() {
    string s;
    cin >> s;
    
    int n = s.size();
    
    int l = (n - 1) / 2;
    int r = n / 2;
    
    int m = 0;
    
    if (s[l] == s[r]) {
        char c = s[l];
        
        while(l >= 0 && r < n && s[l] == c && s[r] == c) {
            m = r - l + 1;
            
            l--;
            r++;
        }
    }
    
    cout << (n + m) / 2 << endl;
}


Measured memory_bytes: 512
s1 = range(11)+[10]*3
def f(x):
  if x==[]: return [0]
  e = s1[x[0]]
  A1 = [e+e1 for e1 in f(x[1:])]
  A2 = []
  if e==1: A2 = [e+10 for e in A1]
  return filter(lambda x: x<22, A1 + A2)

while 1:
  x = map(int,raw_input().split())
  if x[0]==0: break
  a = f(x)
  print max(a) if a else 0

Measured memory_bytes: 4300
#include <bits/stdc++.h>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H = 0;
vector<int> A(MAX+1);

int parent(int i) { return i / 2; }
int left(int i) { return 2 * i; }
int right(int i) { return 2 * i + 1; }

void maxHeapify(vector<int> &A, int i) {
    int l = left(i);
    int r = right(i);
    int largest;
    if (l <= H and A.at(l) > A.at(i)) largest = l;
    else largest = i;
    if (r <= H and A.at(r) > A.at(largest)) largest = r;

    if (largest != i) {
        swap(A.at(i), A.at(largest));
        maxHeapify(A, largest);
    }
}

int extract() {
    int maxv;
    if (H < 1) return -INFTY;
    maxv = A.at(1);
    A.at(1) = A.at(H--);
    maxHeapify(A, 1);
    return maxv;
}

void increaseKey(int i, int key) {
    if (key < A.at(i)) return;
    A.at(i) = key;
    while (i > 1 && A.at(i/2) < A.at(i)) {
        swap(A.at(i), A.at(i/2));
        i = i/2;
    }
}

void insert(int key) {
    H++;
    A.at(H) = -INFTY;
    increaseKey(H, key);
}

int main() {
    int key;
    char com[10];

    while (1) {
        cin >> com;
        if (com[0] == 'e' && com[1] == 'n') break;
        if (com[0] == 'i') {
            cin >> key;
            insert(key);
        } else {
            cout << extract() << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 10588
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void){
    char s[10];
    int min = 1000;
    scanf("%s", s);
    int i = 0;

    while(i < strlen(s) - 2) {
        int num = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0');
        if(abs(num - 753) < min){
            min = abs(num-753);
        }
        i++;
    }

    printf("%d\n", min);
    return 0; 
}

Measured memory_bytes: 128
#include<iostream>
#include<cmath>

constexpr bool is_prime(size_t x){
    for(size_t i = 2; i * i < x; i++){
        if(x % i == 0) return false;
    }

    return true;
}

int main(){

    size_t x;
    std::cin >> x;

    while(!is_prime(x)){
        x++;
    }

    std::cout << x << std::endl;

    return 0;
}


Measured memory_bytes: 256
from itertools import combinations

N, X, Y = map(int, input().split())

A = [0] * N
for i, j in combinations(range(1, N + 1), 2):
    A[min(abs(i - j), abs(X - i) + abs(Y - j) + 1, abs(X - j) + abs(Y - i) + 1)] += 1

print("\n".join(map(str, A[1:])))

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>
#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>
#include <math.h>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<llint, llint>Pii;

#define pi 3.141592653589793)
#define mod 1000000007

int main(){
	string s;
	cin >> s;
	vector<int>a(s.size());
	for (int i = 0; i < s.size(); i++)a[i] = atoi(s.substr(i, 1).c_str());
	int bit = pow(2, s.size() - 1);
	for (int i = 0; i < bit; i++) {
		int ans = 0;
		ans += a[0];
		for (int j = 1; j < s.size(); j++) {
			if (i & (1 << (j-1)))ans += a[j];
			else ans -= a[j];
		}
		if (ans == 7) {
			for (int j = 0; j < s.size() - 1; j++) {
				cout << a[j];
				if (i & (1 << j))cout << "+";
				else cout << "-";
			}
			cout << a[s.size()-1];
			cout << "=7" << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

int main(){
    int n,l;
    cin>>n>>l;
    int sum=0;
    for(int i=1;i<=n;++i)sum+=l+i-1;
    
    int app=300;
    int j=0;
    for(int i=1;i<=n;++i){
        if(app>abs(l+i-1)){
            app=abs(l+i-1);
            j=i;
        }
    }
    int temp=l+j-1;
    cout<<sum-temp<<endl;
}   


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

int main(){
        ll n; scanf("%lld", &n);
        vector<vector<P> > xy(n, vector<P>(0));

        for(ll i=0; i<n; i++){
                ll a; scanf("%lld", &a);
                for(ll j=0; j<a; j++){
                        ll x, y; scanf("%lld %lld", &x, &y);
                        xy[i].push_back(make_pair(x, y));
                }
        }


        ll ans = 0;
        for(ll i=0; i<(1<<n); i++){
                ll tmp = 0;
                bool hone[n], evil[n];
                memset(hone, 0, n); memset(evil, 0, n);
                for(ll j=0; j<n; j++){
                        if((i>>j)&1){
                                tmp++;
                                if(evil[j]) tmp=-1e11;
                                else hone[j]=true;
                                for(P p: xy[j]){
                                        ll x = p.first, y = p.second;
                                        if(y){
                                                if(evil[x-1]) tmp=-1e11;
                                                else hone[x-1]=true;
                                        }else{
                                                if(hone[x-1]) tmp=-1e11;
                                                else evil[x-1]=true;
                                        }
                                }
                        }else{
                                if(hone[j]) tmp=-1e11;
                                else evil[j]=true;
                        }
                }
                ans = max(ans, tmp);
        }
        printf("%lld\n", ans);
        return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	char s[51], t[51];
	int len_s, len_t;

	scanf("%s%n ", s, &len_s);
	scanf("%s%n", t, &len_t);

	for (int i = len_s - len_t; i >= 0; i--) {
		int ok = 1;
		for (int j = 0; j < len_t; j++)
			ok &= s[i + j] == t[j] || s[i + j] == '?';
		if (ok) {
			for (int j = 0; j < len_t; j++)
				s[i + j] = t[j];
			for (int j = 0; j < len_s; j++)
				if (s[j] == '?')
					s[j] = 'a';
			puts(s);
			return 0;
		}
	}

	puts("UNRESTORABLE");

	return 0;
}


Measured memory_bytes: 128
def isprime(n):
    if n < 2: return 0
    elif n == 2: return 1

    if n % 2 == 0: return 0

    for i in range(3, n, 2):
        if i > n/i: return 1
        if n % i == 0 : return 0

    return 1

N = int(input())
n = [int(input()) for i in range(N)]

a = [i for i in n if isprime(i)]

print(len(a))


Measured memory_bytes: 6000
n,m = map(int,input().split())
hl = list(map(int,input().split()))

from collections import defaultdict
G = defaultdict(list)

for _ in range(m):
    a,b = map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

ans = 0
for i in range(n):
    for j in G[i]:
        if hl[i] <= hl[j]:
            break
    else:
        ans += 1

print(ans)

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a!=b && b!=c && a!=c){
    cout << 3 << endl;
  }
  else if((a==b && b!=c) || (b==c && b!=a) || (a==c && b!=c)){
    cout << 2 << endl;
  }
  else{
    cout << 1 << endl;
  }
}
  


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

int main() {
  	int N, Y;
  	cin >> N >> Y;
  	int thousand;
  	bool flag = false;
  	int res, res2, res3;
  
  	for (int i = 0; i <= Y / 10000; i++){
      	for (int j = 0; j <= (Y - i * 10000) / 5000; j++){
          	thousand = N - (i + j);
          	if (thousand * 1000 + j * 5000 + i * 10000 == Y){
              	res = i;
              	res2 = j;
              	res3 = thousand;
              	flag = true;
              	break;
            }
        }
    }
  
  	if (flag == false) res = -1, res2 = -1, res3 = -1;
  
  	cout << res << ' ' << res2 << ' ' << res3 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#include<algorithm>
#include <cstring>
#define endl "\n"
#define SRK ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define EPS 1e-6
typedef long long ll;
using namespace std;



int main()
{
    SRK;
    int n,x,i;
    cin >> n;
    set <int> st;
    for (i = 0; i < n; i++)
    {
        cin >> x;
        st.insert(x);
    }
    if (st.size() == n)
    {
        cout << "YES\n";
    }
    else
    {
        cout << "NO\n";
    }



}


Measured memory_bytes: 12988