akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
using namespace std;
#define ll long long int

int main()
{
	int n;
	string s;
	int ans_ac = 0;
	int ans_wa = 0;
	int ans_tle = 0;
	int ans_re = 0;

	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> s;
		if (!s.compare("AC")) ans_ac++;
		if (!s.compare("WA")) ans_wa++;
		if (!s.compare("TLE")) ans_tle++;
		if (!s.compare("RE")) ans_re++;
	}

	cout << "AC x " << ans_ac << endl;
	cout << "WA x " << ans_wa << endl;
	cout << "TLE x " << ans_tle << endl;
	cout << "RE x " << ans_re << endl;
	return 0;
}


Measured memory_bytes: 3636
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
 
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; }
 
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  ll n;
  cin>>n;
  
  ll A[n];
  rep(i,n) cin>>A[i];
  
  map<ll,ll> l,r;
  rep(i,n){
    l[i-A[i]]++;
    r[i+A[i]]++;
  }
  
  ll ans=0;
  for (auto p : l) {
    auto a=p.first;
    auto b=p.second;
    ans+=b*r[a];
  }
  
  cout<<ans<<endl;
    
  return 0;
}

Measured memory_bytes: 39480
N=int(input())
#S = [[0 for j in range(3)] for i in range(2)]　2行3列の場合
S = [[0]*3 for i in range(100010)]
 
            
def chmax(a,b):
    if a>b:
        return a
    else:
        return b
 
for i in range(N):
    A,B,C=map(int,input().split())
    S[i+1][0]=A
    S[i+1][1]=B
    S[i+1][2]=C
 
DP=[[0 for j in range(3)] for i in range(100010)]
 
DP[0][0]=0
DP[0][1]=0
DP[0][2]=0
DP[1][0]=S[1][0]
DP[1][1]=S[1][1]
DP[1][2]=S[1][2]
 
if N==1:
    print(max(DP[1]))
    exit()
 
for k in range(2,N+1):
    for i in range(3):
        for j in range(3):
            if i!=j:
                DP[k][i]=chmax(DP[k-1][j]+S[k][i],DP[k][i])
                DP[k][j]=chmax(DP[k-1][i]+S[k][j],DP[k][j])
print(max(DP[N]))
 

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

#define long long long int

using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    long n;
    cin >> n;
    long res = LONG_MAX;
    for (long i = 1; i * i <= n; i++) {
        long j = n / i;
        if (i * j == n) {
            res = min(res, i + j - 2);
        }
    }
    cout << res;

    return 0;
}

Measured memory_bytes: 256
pos_black_mapping = {}
pos_num_mapping = {}
H, W, N = map(int, raw_input().split())
for i in range(N):
    a, b = map(int, raw_input().split())
    a, b = a-1, b-1
    if (a, b) in pos_black_mapping:
        continue
    pos_black_mapping[a, b] = 1
    for da in range(-1, 2):
        for db in range(-1, 2):
            na, nb = a+da, b+db
            if (0 < na < H-1) and (0 < nb < W-1):
                if not (na, nb) in pos_num_mapping:
                    pos_num_mapping[na, nb] = 0
                pos_num_mapping[na, nb] += 1

ans = [0 for _ in range(10)]
for a, b in pos_num_mapping.keys():
    ans[pos_num_mapping[a, b]] += 1
ans[0] = (W-2)*(H-2) - sum(ans[1:])
for v in ans:
    print v

Measured memory_bytes: 186780
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
typedef pair<int,int> P;

P f(int x) {
    int a = x % 10;
    int b = 0;
    while (x) {
        b = x;
        x /= 10;
    }
    return P(a,b);
}
int main(void){
    // Your code here!
    int n;
    cin >> n;
    map<P,int> freq;
    FOR(i,1,n) {
        P p = f(i);
        freq[p]++;
    }
    ll ans = 0;
    FOR(i,1,n) {
        P p = f(i);
        P q(p.second,p.first);
        ans += freq[q];
    }
    cout << ans << endl;
}

Measured memory_bytes: 764
// Itp1_5_c.java
import java.io.*;
import java.lang.Integer;
public class Main
{
	public static void main(String[] args) {
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
loop:		while(true) {
				String in  = br.readLine() ;
				String[] hw = in.split(" ");
				int height = Integer.parseInt(hw[0]);
				int width  = Integer.parseInt(hw[1]);
				if ( height == 0 || width == 0 ) {
					break;
				}
				for( int i = 1 ; i <= height ; i++ ) {
					for( int j = 1 ; j <= width ; j++ ) {
						if ( (i%2) == 1 ) {
							if ( (j%2) == 1 ) {
								System.out.print("#");
							} else {
								System.out.print(".");
							}
						} else {
							if ( (j%2)==1 ) {
								System.out.print(".");
							} else {
								System.out.print("#");
							}
						}
					}
					System.out.println("");
				}
				System.out.println("");
			}
		} catch ( IOException e ) {
			System.out.println("??¨??????????????????????????????");
		}
	}
}

Measured memory_bytes: 31416
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n,K; cin >> n >> K;
  vector<ll> a(n);
  ll sum=0;
  rep(i,n){
    cin >> a[i];
    sum+=a[i];
  }
  ll ans=0;
  for(int i=1;i<=sqrt(sum);i++){
    if(sum%i!=0) continue;
    vector<ll> p={i,sum/i};
    rep(k,2){
      vector<ll> b=a;
      rep(j,n){
        b[j]%=p[k];
      }
      sort(all(b));
      vector<ll> s(n+1);
      s[0]=0;
      rep(j,n){
        s[j+1]=s[j]+b[j];
      }
      
      rep(j,n+1){
        ll mns=s[j];
        ll pls=p[k]*(n-j)-(s[n]-s[j]);
        if(mns==pls&&pls<=K) chmax(ans,p[k]);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>

using namespace std;

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

    cout << N*(N-1)/2 + M*(M-1)/2 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	long t1,t2,a1,a2,b1,b2;
	long result1,result2;
	long mod;
	scanf("%ld %ld", &t1,&t2);
	scanf("%ld %ld", &a1,&a2);
	scanf("%ld %ld", &b1,&b2);
	
	result1=(a1-b1)*t1;
	result2=result1+(a2-b2)*t2;
	if(result2==0) {
		printf("infinity");
		return 0;
	}
	if(result1>0) {
		if(result2>0) {
			printf("0");
			return 0;
		} else {
			if(result1%(-result2)==0) {
				mod=0;
			} else {
				mod=1;
			}
			printf("%ld", result1/(-result2)*2+mod);
		}
	} else {
		if(result2<0) {
			printf("0");
			return 0;
		} else {
			if((-result1)%(result2)==0) {
				mod=0;
			} else {
				mod=1;
			}
			printf("%ld", result1/(-result2)*2+mod);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main()
{
    int c[10],i,m[4],n[4],o[4];
    char ans[4];
    
    for(i=0;i<9;i++)
    scanf("%d", &c[i]);
    ans[0] = 'N';
    ans[1] = 'o';
    ans[2] = '\0';
    i = 0;
    m[0] = c[1] - c[0];
    m[1] = c[4] - c[3];
    m[2] = c[7] - c[6];
    n[0] = c[2] - c[1];
    n[1] = c[5] - c[4];
    n[2] = c[8] - c[7];
    o[0] = c[2] - c[0];
    o[1] = c[5] - c[3];
    o[2] = c[8] - c[6];
    if (m[0] == m[1] && m[1] == m[2] && n[0] == n[1] && n[1] == n[2] && o[0] == o[1] && o[1] == o[2])
        i++;
    m[0] = c[3] - c[0];
    m[1] = c[4] - c[1];
    m[2] = c[5] - c[2];
    n[0] = c[6] - c[3];
    n[1] = c[7] - c[4];
    n[2] = c[8] - c[5];
    o[0] = c[6] - c[0];
    o[1] = c[7] - c[1];
    o[2] = c[8] - c[2];
    if (m[0] == m[1] && m[1] == m[2] && n[0] == n[1] && n[1] == n[2] && o[0] == o[1] && o[1] == o[2])
        i++;
    if (i == 2)
    {
        ans[0] = 'Y';
        ans[1] = 'e';
        ans[2] = 's';
        ans[3] = '\0';
    }
    printf("%s", ans);
    return 0;
}

Measured memory_bytes: 128
package main

import (
        "bufio"
        "fmt"
        "os"
        "strconv"
)

var si = bufio.NewScanner(os.Stdin)

func readInt() int {
        si.Scan()
        r, _ := strconv.Atoi(si.Text())
        return r

}

func main() {
        si.Split(bufio.ScanWords)
        si.Buffer(make([]byte, 0), 10000000)
        N, M, Q := readInt(), readInt(), readInt()
        m := [501][501]int{}
        for i := 0; i < M; i++ {
                l, r := readInt(), readInt()
                m[l][r] += 1
        }
        n := [501]int{}
        for i := 1; i <= N; i++ {
                for j := 1; j <= N; j++ {
                        n[j] = n[j] + m[i][j]
                        m[i][j] = m[i][j-1] + n[j]
                }
        }
        for i := 0; i < Q; i++ {
                l, r := readInt(), readInt()
                fmt.Println(m[r][r] - m[l-1][r] - m[r][l-1] + m[l-1][l-1])
        }
}

Measured memory_bytes: 6144
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <stdio.h>

using namespace std;

#define fo(i,n) for(int i=0; i<(int)n; i++)
#define rep(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define pii pair<int,int>

typedef long double Double;

const Double eps = 1.0e-12;

struct point{
	Double x,y,z;
	point(){}
	point(Double x, Double y,Double z):x(x),y(y),z(z){}
};
struct circle{
	point c;
	Double r;
	circle(){};
	circle(point p, Double r):c(p),r(r){}
};

point operator-(const point &a, const point &b) {
	return point(a.x-b.x,a.y-b.y,a.z-b.z);
}
point operator+(const point &a, const point &b) {
	return point(a.x+b.x,a.y+b.y,a.z+b.z);
}
Double operator*(const point &a, const point &b) {
	return a.x*b.x + a.y*b.y + a.z*b.z;
}
point operator*(const Double &t, const point &a) {
	return point(t*a.x,t*a.y,t*a.z);
}

int n;
point u;
circle v[110];
point O;

Double dist(point a, point b) {
	point c = a-b;
	return sqrt(c.x*c.x+c.y*c.y+c.z*c.z);
}

bool intersect(point p, circle c) {
	Double A = p*p;
	Double B = 2.0*(O*p) - 2.0*(c.c*p);
	Double C = O*O + c.c*c.c - 2.0*(O*c.c) - c.r*c.r;
	
	Double delta = B*B - 4.0*A*C;
	
	return delta > eps;
}

point intersection(point p, circle c) {
	p = (1.0/(p*p))*p;
	
	Double A = p*p;
	Double B = 2.0*(O*p) - 2.0*(c.c*p);
	Double C = O*O + c.c*c.c - 2.0*(O*c.c) - c.r*c.r;
	
	Double delta = B*B - 4.0*A*C;
	if (abs(delta)<eps) {
		Double m = -B/(2.0*A);
		return point(O+m*p);
	}
	else {
		if (delta<eps) return O;
		Double m = (-B + sqrtl(delta)) / (2.0*A); 
		point a1 = O + m*p;
		m = (-B - sqrtl(delta)) / (2.0*A);
		point a2 = O + m*p;
		if (dist(O,a1)<dist(O,a2)) return a1;
		else return a2;
	}
	
	return point(0,0,0);
}

point reflexion(point dir, circle c, point q) {
	
	point n = q - c.c;
	
	n = (1.0 / sqrtl(n*n))*n;
	dir = (-1.0 / sqrtl(dir*dir))*dir;
	
	point b = (2.0*(dir*n))*n - dir;
	
	return b;
}

int main() {

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

	while (scanf("%d",&n) && n!=0) {
		int x,y,z,r;
		scanf("%d%d%d",&x,&y,&z);
		u = point(x,y,z);
		O = point(0,0,0);
		for (int i=0; i<n; i++) {
			scanf("%d%d%d%d",&x,&y,&z,&r);
			v[i] = circle(point(x,y,z),r);
		}
		int last = -1;
		for (int i=0; i<10; i++) {
			bool exist = 0;
			point next;
			point dir;
			for (int j=0; j<n; j++) if (j!=last) {
				if (intersect(u,v[j])) {
					point p = intersection(u,v[j]);
					if ((p-O)*u<eps) continue;
					
					if (!exist || dist(O,p)<dist(O,next)) {
						exist = 1;
						next = p;
						dir = reflexion(u,v[j],p);
						last = j;
					}
				}
			}
			if (!exist) break;
			u = dir;
			O = next;
		}
		printf("%.4lf %.4lf %.4lf\n",(double)O.x, (double)O.y, (double)O.z);
	}

    return 0;

}

Measured memory_bytes: 1228
#include <stdio.h>
#include <set>

int main(void) {
  int n, a, i;
  scanf("%d", &n);
  std::set<int> s;
  for(i = 0; i < n; ++i) {
    scanf("%d", &a);
    if(s.find(a) != s.end()) s.erase(s.find(a));
    else s.insert(a);
  }
  printf("%d", s.size());
  return 0;
}

Measured memory_bytes: 4864
#include <iostream>

using namespace std;


void solve(long long N){
    long long result = 0;
    for(long long i = 1; i <= N; i++) {
        if(i % 3 == 0 && i % 5 == 0) {
            continue;
        }else if(i % 3 == 0)  {
            continue;
        }else if(i % 5 == 0) {
            continue;
        }else {
            result += i;
        }
    }
    cout << result << endl;
    return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

int main()
{
  long N;
  std::cin >> N;
  long long A[N];

  for ( long i = 0; i < N; i++ ) std::cin >> A[i];

  long how_many = 1;
  long index = 1;

  while ( true ) {
    long temp_i = index;
    while (temp_i < N && A[temp_i] - A[temp_i-1] >= 0) {
      temp_i++;
    }
    
    long temp_j = index;
    while (temp_j < N && A[temp_j] - A[temp_j-1] <= 0) {
      temp_j++;
    }
    index = std::max(temp_i, temp_j) + 1;
    if ( index > N ) break;
    how_many++;
  }

  std::cout << how_many << "\n";
  return 0;
}


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

int main() {
    //初期設定
    int book_num, alg_num, skill_value;
    cin >> book_num >> alg_num >> skill_value;
    vector<int> book_money(book_num);
    vector<vector<int>> book_skill(book_num, vector<int>(alg_num));
    rep(i,book_num) {
        cin >> book_money[i];
        rep(j, alg_num) {
            cin >> book_skill[i][j];
        }
    }

    //すべての本の組み合わせを考える
    const int book_max = 12;
    vector<int> all_money(1 << book_max, 0);
    vector<vector<int>> all_skill(1 << book_max, vector<int>(alg_num, 0));

    for (int tmp = 1; tmp < (1 << book_max); tmp++) {
        bitset<book_max> s(tmp);

        rep(i, book_num) {
            if (s.test(i)) {
                all_money[tmp] += book_money[i];
                rep(j, alg_num) { 
                    all_skill[tmp][j] += book_skill[i][j];
                }
            }
        }
    }

    //すべての組み合わせから条件にあう最も安い組を見つける
    int min_money = 1e9;
    for (int tmp = 1; tmp < (1 << book_max); tmp++) {
        bitset<book_max> s(tmp);
        bool ng = false;
        
        rep(j, alg_num) {
            if (all_skill[tmp][j] < skill_value) {
                ng = true;
                break;
            }
        }
        if (ng) continue;
        else min_money = min(min_money, all_money[tmp]);
    }

    //目標達成できるかどうか
    if (min_money == 1e9) cout << "-1" << endl;
    else                  cout << min_money <<endl;
    
    return 0;
}

Measured memory_bytes: 3964
g = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]
a,b = map(int,raw_input().split(' '))
flag = False
for i in g:
    if (a in i) and (b in i):
        flag = True
        break
if flag:
    print "Yes"
else:
    print "No"

Measured memory_bytes: 2568
#include<cmath>
#include<fstream>
#include<iostream>

using namespace std;

int main(){
	string S;
	cin >> S;
	if(S[0]=='Y' && S[1]=='A' && S[2]=='K' && S[3]=='I') cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s = br.readLine();

		if (s.equals("RRR")) {
			System.out.println("3");
		} else if (s.equals("RRS")) {
			System.out.println("2");
		} else if (s.equals("SRR")) {
			System.out.println("2");
		} else if (s.equals("RSS")) {
			System.out.println("1");
		} else if (s.equals("SRS")) {
			System.out.println("1");
		} else if (s.equals("SSR")) {
			System.out.println("1");
		} else if (s.equals("SSS")) {
			System.out.println("0");
		} else if (s.equals("RSR")) {
			System.out.println("1");
		}
	}
}


Measured memory_bytes: 32624
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val a1, a2 = sc.nextLong()
  val s = a1 + a2
  var x = List.fill(n-2)(sc.nextLong()).foldLeft(0L)(_ ^ _)

  if (x > s || ((s - x) & 1) == 1) {
    println(-1)
  } else {
    var d = (s - x) >> 1
    if (d > a1 || (0 to 40).indexWhere(i => ((d >> i) & 1) == 1 && ((x >> i) & 1) == 1) != -1) {
      println(-1)
    } else {
      for (i <- 40 to 0 by -1 if ((x >> i) & 1) == 1 && d + (1L << i) <= a1) {
        d += 1L << i
      }
      if (d == 0) println(-1) else println(a1 - d)
    }
  }
}


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

int n;
vector<pair<int,int> > G[100001];
bool visited[100001];
long long int d[100001];

const long long int INF = 1000000000000;

long long int  prim(){

    priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > que;

    long long int res = 0;

    fill(d,d+n,INF);
    fill(visited,visited+n,false);

    que.push(make_pair(0,0));

    while(!que.empty()){
        pair<int,int> p = que.top(); que.pop();

        int v = p.second, cst = p.first;
        if(visited[v]){
            continue;
        }
        visited[v] = true;
        res += cst;
        for(int i=0; i<G[v].size(); i++){
            que.push(make_pair(G[v][i].first, G[v][i].second));
        }

    }

    return res;

}

inline int my_abs(int a){
    if(a<0){
        a *= -1;
    }
    return a;
}

int x[100001],y[100001];
pair<pair<int,int>,int> px[100001],py[100001];

int main() {

    cin >> n;

    for(int i=0; i<n; i++){
        scanf(" %d %d",&x[i],&y[i]);
        px[i] = make_pair(make_pair(x[i],y[i]),i);
        py[i] = make_pair(make_pair(y[i],x[i]),i);
    }

    sort(px,px+n);
    sort(py,py+n);



    int a, b, c;

    for (int i = 0; i < n-1; i++) {
        int from = px[i].second;
        pair<int,int> e;
        e.second = px[i+1].second; //to
        e.first = min(my_abs(px[i+1].first.first - px[i].first.first),my_abs(px[i+1].first.second - px[i].first.second)); //cost
        G[from].push_back(e);
        swap(from,e.second);
        G[from].push_back(e);

        from = py[i].second;
        e.second = py[i+1].second; //to
        e.first = min(my_abs(py[i+1].first.first - py[i].first.first),my_abs(py[i+1].first.second - py[i].first.second)); //cost
        G[from].push_back(e);
        swap(from,e.second);
        G[from].push_back(e);
    }

    cout << prim() << endl;

    return 0;
}

Measured memory_bytes: 14448
import numpy as np

N, W = map(int, input().split())

dp = np.full(N * 1000 + 1, W + 1, dtype=np.int64)
dp[0] = 0

for _ in range(N):
    w, v = map(int, input().split())
    np.minimum(dp[:-v] + w, dp[v:], out=dp[v:])

print(((dp <= W) * np.arange(N * 1000 + 1)).max())



Measured memory_bytes: 14904
n = int(input())

def dfs(N, s, c):
    if N == n:
        s = "".join([chr(int(i) + 97) for i in s])
        print(s)

    else:
        for i in range(c+1):
            dfs(N + 1, s+str(i), c+1 if i == c else c)

dfs(0, "", 0)

Measured memory_bytes: 61528
import sys
import copy
import  math
import bisect
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

li = input().split()
print('YES' if int("".join(li)) % 4 == 0 else 'NO')

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;
typedef vector<map<lli,lli>> graph;

lli n,m;
vll can1;
vll cann;

int main(){
	cin >> n >> m;
	can1 = vll(n+1);
	cann = vll(n+1);
	for(lli i = 0;i < m;i++){
		lli a,b;
		cin >> a >> b;
		if(a == 1){
			can1[b]++;
		}
		if(b == n){
			cann[a]++;
		}
	}
	for(lli i = 0;i < n;i++){
		if(can1[i] && cann[i]){
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 3328
n=int(input())
yaku=set()
mod=7+10**9

#まず2~1000までの素数のリスト作る
primes=[]
for i in range(2,1001):
  flag=0
  for j in range(2,i):
    if j!=i and i%j==0:
      flag=1
      break 
  if flag==0:
    primes.append(i)

#1000!に、それぞれの因数が何個あるか記録するリスト
insu=[0]*len(primes)

#1~1000まで素因数分解して、それぞれの因数の個数分記録する処理
for i in range(2,n+1):
  n=0
  while i!=1:
    if i%primes[n]==0:
      insu[n]+=1
      i=i//primes[n]
    else:
      n+=1
#print(insu)
ans=1
for i in insu:
  ans*=(i+1)
  ans%=mod
print(ans)

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

int main(){
    int n; cin >> n;
    vector<long long> s(n);
    for (int i = 0; i < n; i++) cin >> s[i];
    vector<long long> l[n], r[n];
    for (int i = 1; i < n; i++) {
        int t = i;
        l[i].emplace_back(0);
        r[i].emplace_back(0);
        while (t < n) {
            l[i].emplace_back(l[i].back() + s[t]);
            t += i;
        }
        int q = n-1-i;
        while (q >= 0) {
            r[i].emplace_back(r[i].back() + s[q]);
            q -= i;
        }
    }
    long long ans = 0;
    for (int i = 1; i < n; i++) {
        for (int j = 1; j * i < n; j++) {
            int d = n-1 - j * i;
            if (d == 0) continue;
            int a = d; int b = a-i;
            if (b <= 0) continue;
            if (a % i == 0 && a / i <= j) continue;
            ans = max(ans, l[i][j] + r[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 33268
#include <iostream>
#include <bits/stdc++.h>
#define mod 1000000007
#define point complex<long long>
#define pi acos(-1)
#define pb push_back


typedef long long ll;

using namespace std;

void Fastio(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int n, m, s, e;
vector<int>arr[100005];
int bfs(){
    queue<pair<int,int> >q;
    q.push({s, 0});
    int vis[n+1][3]={0};
    while(!q.empty()){
        int cur=q.front().first, d=q.front().second;
        q.pop();
        if(cur==e && d%3==0)
            return d/3;
            vis[cur][d%3]=1;
        for(auto i: arr[cur]){
            if(vis[i][(d+1)%3])continue;
            vis[i][(d+1)%3]=1;
            q.push({i, d+1});
        }
    }
    return -1;
}
int main()
{
    Fastio();
    int ttt=1; //cin>>ttt;
    while(ttt--){
        cin>>n>>m;
        for(int i=0; i<m; i++){
            int u, v; cin>>u>>v;
            arr[u].pb(v);
        }
        cin>>s>>e;
        cout<<bfs()<<'\n';
    }

    return 0;
}


Measured memory_bytes: 10264
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N; cin >> N;
	rep1(i,9) rep1(j,9) if(N==i*j){
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
n = int(input())

t = []

for i in range(n):
    t.append(int(input()))

buy = t[0]
val = t[-1] - buy

for i in range(1, n):
    if t[i] - buy > val:
        val = t[i] - buy
    if t[i] < buy:
        buy = t[i]

print(val)



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

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

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

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


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


int main(){
  int n, t, sn = 0;
  cin >> n;
  t = n;
  
  while(t){
    sn += t%10;
    t/=10;
  }

  puts(n%sn == 0 ? "Yes" : "No");
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,ans=0;
int main(){
	
string s;
cin>>s;
for(int i=0;i<s.size();i++)
{
	
	if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')n++,ans=max(ans,n);
	else   n=0;
}
cout<<ans;
	return 0;
}


Measured memory_bytes: 256
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
// #include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(double);
		void decrement(void);
		void decrement(double);
		double getResult(void);
	private:
		double result;
	};
	void Ans::showResult(void) {
		printf("%.0lf\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(double value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(double value) {
		this->result -= value;
	}
	double AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void input(Str* str) {
		str->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				str->push_back(row);
				row = "";
			} else {
				row += buf[i];
			}
		}
		str->push_back(row);
	}
	void input(Num* num) {
		num->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				num->push_back(std::atoi(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		num->push_back(std::atoi(row.c_str()));
	}
	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
	const char rep(int s, std::string* str) {
		if ((str->c_str()[0] + s) < 91) {
			const char buf = (str->c_str()[0] + s);
			return buf;
		} else {
			const char buf = (str->c_str()[0] + s - 26);
			return buf;
		}	
	}
}

int main(void) {

	AtCoder::Num n;
	AtCoder::Str s;

	AtCoder::input(&n);

	const int sn = n[0];

	AtCoder::input(&s);
	AtCoder::exp(&s[0], &s);

	for (std::string str : s) {
		 const char buf = AtCoder::rep(sn, &str);
		 printf("%c", buf);
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 836
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    string s;cin>>s;
    int r=0,l=0;
    bool f=0;
  if(s[0]==s[1]){
    f=1;l=1,r=2;
  }else{
    rep(i,s.size()-2){
        if(s[i]==s[i+1]){
            f=1;
            l=i+1,r=i+2;
            break;
        }
        if(s[i]==s[i+2]){
            f=1;
            l=i+1,r=i+3;
            break;
        }
    }
  }
    if(f)cout<<l<<' '<<r<<endl;
    else cout<<"-1 -1"<<endl;
}


Measured memory_bytes: 512
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define msi map<string,int>
#define mii map<int,int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define po pop_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int a[3];
	rep(i,3){
		cin>>a[i];
	}		
	sort(a,a+3);
	if((a[0] == a[1] || a[1] == a[2]) && a[0]!=a[2]){
		cout<<"Yes";
		return 0;
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;
const string nyan("(=^・ω・^=)");

int N;
ll A[100000], DP[100000][2];

int main() {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	DP[0][0] = A[0];
	DP[0][1] = -A[0];
	for (int i = 1; i < N - 1; ++i) {
		DP[i][0] = max(DP[i - 1][0] + A[i], DP[i - 1][1] - A[i]);
		DP[i][1] = max(DP[i - 1][0] - A[i], DP[i - 1][1] + A[i]);
	}
	cout << max(DP[N - 2][0] + A[N - 1], DP[N - 2][1] - A[N - 1]) << endl;
}


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

int main() {
    int N,X;
    cin >> N >> X;
    int Y=X,mn=1000;
    int m[101];
    for(int j=0;j<N;j++){
        cin >> m[j];
        Y -= m[j];
        mn = min(mn,m[j]);
    }

    int n = Y / mn ;

    cout << n+N << endl;
    
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int x[10000], i;

	for (i = 1;; i++) {
		scanf("%d", &x[i]);
		if (x[i] == 0) {
			break;
		}
		printf("Case %d: %d\n", i, x[i]);
	}


	return 0;
}



Measured memory_bytes: 2756
#include <stdio.h>

int main(void){
	
	int  a, b ,c ;
	
	scanf("%d %d %d",&a ,&b ,&c);
	
	if(a < b && b < c)
     {
     	printf("Yes\n");
	 }
 	else
	{
		printf("No\n");
	}

}


Measured memory_bytes: 2620
MOD=10**9+7
n,a,b=map(int,input().split())
s=pow(2,n,MOD)-1
comba=1
combb=1
a=min(a,n-a)
b=min(b,n-b)
for i in range(1,a+1):
    comba*=(n-i+1)*(pow(i,MOD-2,MOD))
    comba=comba%MOD
comba=comba%MOD
for i in range(1,b+1):
    combb*=(n-i+1)*(pow(i,MOD-2,MOD))
    combb=combb%MOD
combb=combb%MOD
print((s-comba-combb)%MOD)

Measured memory_bytes: 3064
K = int(input())

from math import gcd
   
ans = 0
dic = {}
for i in range(1, K+1):
    for j in range(i, K+1):
        for k in range(j, K+1):
            time = len(set([i, j, k]))
            if time==3:
                t=6
            elif time==2:
                t=3
            else:
                t=1
            s = tuple(sorted([i, j, k]))
            if s in dic:
                ans += dic[s]
            else:
                a = gcd(gcd(i, j), k)
                ans += a*t
                dic[s] = a*t
                
print(ans)

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

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
const int INF = 1e9;
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");
#define FOR(i, l, r) for (int i = int(l); i < int(r); ++i)
#define print(a)       for(auto x : a) cout << x << " "; cout << "\n"
#define print1(a)      for(auto x : a) cout << x.ff << " " << x.ss << "\n"
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << "\n"


ll fast_exp(ll base, ll exp) {ll res=1;while(exp>0) {if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return res%MOD;}
int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
int val(char c){if (c >= '0' && c <= '9')return (int)c - '0';else return (int)c - 'A' + 10;}
ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll divisibles(ll a, ll b, ll m){if(a%m==0)return (b/m)-(a/m)+1;else return (b/m)-(a/m);}// in [a,b]
string bitstring(int n, int size){string s;while(n){s+=(n%2)+'0';n/=2;}while(s.size()<size){s+='0';}reverse(all(s));return s;}
// dsu start

vi root(200001,0);
vi size(200001,1);
int find(int x){while(x!=root[x])x = root[x];return x;}
bool same(int a,int b){return find(a)==find(b);}
void unite(int a, int b){a = find(a);b = find(b);if(size[a]<size[b])swap(a,b);size[a] += size[b];root[b] = a;}

// dsu end
vi vis(200001,0);
vi adj[200001];

int main()
{	
    std::ios::sync_with_stdio(false);
    //string bitstring = std::bitset< 3 >( 7 ).to_string(); <bits> (num)
    //srand(time(0));
    //cin.tie(NULL);
    //cout.tie(NULL);
 	ll n,m;
 	cin>>n>>m;
 	ll c = 0;
 	int flag = 0;
 	ll cc = m/2;
 	if(m%2)
 		++c;
 	ll sum  = 0;
 	//cout<<cc<<"\n";
 	if(n>=cc)
 	{
 		sum+=cc;
 		cout<<sum<<"\n";
 	}
 	else
 	{
 		sum+=n;
 		//cout<<sum<<"\n";
 		cc -= n;
 		sum+=cc/2;
 		if(cc%2)
 			++flag;
 		if(flag==2)
 			cout<<sum;
 		else
 			cout<<sum;
 	}
}

Measured memory_bytes: 7296
# abc 045 c
from itertools import zip_longest

s = input()

sum_num = 0
for i in range(0, 2**(len(s)-1)):
	sings = bin(i)[2:].zfill(len(s)-1).replace("1", "+").replace("0", " ")
	formula = ("".join("".join(t) for t in zip_longest(s, sings, fillvalue=" "))).replace(" ", "")
	sum_num += eval(formula)

print(sum_num)

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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)

// policy-based
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;	


using namespace std;


typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

/*
typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
 
const ll MAX = 2e5;
const ll inf = 1e12;
const ll mod = 1e9+7;

ll a[MAX];

int main(){
	fastio;
	ll k,n,x = 0, p = inf ;
	cin >> n;
	f(i,0,n) cin >> a[i];
	ll ans = 1000;
	f(i,0,n){
		if(p>a[i]) ans += x*p, x = ans/a[i], p= a[i],ans-=x*p;
		else{
			p = a[i];
		}
	}
	cout << ans + p*x << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using uint = unsigned int;
using ll = long long;
 
int main() {
	int N;
	cin >> N;
	
	vector<pair<ll, ll>> XL(N, pair<ll, ll>());
	
	for(uint i=0; i<N; i++) {
		ll X, L;
		cin >> X >> L;
		XL[i] = make_pair(X - L, X + L);
	}
	
	sort(XL.begin(), XL.end());
		
	ll front = XL[0].first;
	uint findx = 0;
	uint ans = 0;
	
	for(uint i=0; i<N; i++) {
		ll le = XL[i].first;
		ll re = XL[i].second;
		
		//cout << front << " ";
		if(front <= le) {
			ans++;
			front = re;
			findx = i + 1;
		} else if(re <= front) {
			front = re;
			findx = i + 1;
		}
		
		//cout << le << " " << re << " " << ans[i+1] << " " << front << endl;
	}
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long ll;

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;

struct node {
	int t,a,id;
	bool operator < (const node &rhs) const {
		return t < rhs.t;
	}
} Query[N];
int ans[N],r[N];

inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

int main() {
	int X = read(),n = read();
	For(i,1,n) r[i] = read();
	int q = read();
	For(i,1,q) {
		int t = read(),a = read();
		Query[i] = (node){t,a,i};
	}
	sort(Query + 1,Query + q + 1);
	int DivPosl = 0,DivPosr = X,Sign = -1,val = 0,id = 0,Delta = 0;
	bool flag = 0;
	r[++n] = INF;
	For(i,1,n) {
		while(Query[id + 1].t <= r[i] && id < q) {
			node cur = Query[++id];
			int T = cur.t - r[i - 1];
			if(!flag)
				ans[cur.id] = val + min(max(DivPosl,cur.a),DivPosr) + Sign * T;
			else ans[cur.id] = val + Sign * T;
			chkmax(ans[cur.id],0),chkmin(ans[cur.id],X);
		}
		Delta += Sign * (r[i] - r[i - 1]);
		if(Sign == -1) chkmax(DivPosl,-Delta);
		if(Sign == 1) chkmin(DivPosr,X - Delta);
		if(DivPosl > DivPosr) {
			if(flag) val = min(max(0,val + Sign * (r[i] - r[i - 1])),X);
			else {
				if(Sign == -1) val = DivPosr + val - (r[i] - r[i - 1]);
				else val = DivPosl + val + (r[i] - r[i - 1]);
				chkmax(val,0),chkmin(val,X);
			}
			flag = true;
		}
		else val += Sign * (r[i] - r[i - 1]);
		Sign = -Sign;
	}

	For(i,1,q) printf("%d\n",ans[i]);

	return 0;
}

Measured memory_bytes: 3200
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    sort(A.begin(),A.end());
    vector<int> era(1000005,1);
    int ans = 0;
    for(int i=0; i<N; i++){
        if(era[A[i]] == 0) continue;
        for(int j=A[i]; j<1000005; j+=A[i]){
            era[j] = 0;
        }
        if(i){
            if(A[i] == A[i-1]) continue;
        }
        if(i<N-1){
            if(A[i] == A[i+1]) continue;
        }
        ans++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 7948
import sys

def isin(y, x):
  flag = True
  for i in range(m):
    for j in range(m):
      if image_n[y + i][x + j] != image_m[i][j]:
        flag = False
        
  return flag 

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

image_n = []

for i in range(n):
  image_n.append(input())

image_m = []

for j in range(m):
  image_m.append(input())


for i in range(n - m + 1):
  for j in range(n - m + 1):
    if isin(i, j):
      print("Yes")
      sys.exit()

print("No")


Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	vs := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&vs[i])
	}
	cs := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&cs[i])
	}

	ans := 0
	for i := 0; i < N; i++ {
		if val := vs[i] - cs[i]; val > 0 {
			ans += val
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {FIN
    
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if (x - r >= 0 and x + r <= w and y - r >= 0 and y + r <= h)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 3224
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

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

int main(){
  ll n,k;cin>>n>>k;
  vector<ll> x(n);
  rep(i,n){
    cin>>x[i];
  }
  vector<ll> xright(n);
  vector<ll> xleft(n);
  rep(i,k){
    xright[i]=INF;
    xleft[i]=INF;
  }
  int index_right=0;
  int index_left=0;
  rep(i,n){
    if(x[i]>=0){
      xright[index_right]=x[i];
      index_right++;
    }
    if(x[n-1-i]<0){
      xleft[index_left]=-x[n-1-i];
      index_left++;
    }
  }

  ll ans=INF;
  ans=min(ans,min(xleft[k-1],xright[k-1]));

  rep(i,k-1){
    ans= min(ans,2*xleft[i]+xright[k-2-i]);
    ans= min(ans,xleft[i]+2*xright[k-2-i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 2688
N = int(input())

l = len(bin(N))-2

ans = [[0]*N for _ in range(N)]
for i in range(l):
    for j in range(N-1):
        for k in range(j+1,N):
            if (j&(1<<i)) == (k&(1<<i)): continue
            if ans[j][k]: continue
            ans[j][k] = ans[k][j] = i+1

for i,row in enumerate(ans[:-1]):
    print(*(row[i+1:]))

Measured memory_bytes: 11280
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>

using namespace std;

int cut_man(int b_count, int num, int a[], int b[], int M){
    int n_count = 0;
    int index = -1;
    for(int j=0; j < M; j++){
        if (a[j] == num or b[j] == num){
            n_count++;
            index = j;
        }
    }
    if(n_count == 1){
        if(a[index]==num){
            num = b[index];
        }else{
            num = a[index];
        }
        a[index] = 0;
        b[index] = 0;
        b_count++;
        b_count = cut_man(b_count, num, a, b, M);
        //printf("num:%d\n",num);
    }
    return b_count;
}

int main(){
    int N,M;
    cin >> N >> M;
    int a[M],b[M];
    for(int i = 0; i < M; i++){
        cin >> a[i] >> b[i];
    }

    int b_count = 0;
    int n_count = 0;
    int index = -1;

    for(int num = 1; num <= N; num++){
        b_count = cut_man(b_count, num, a, b, M);
        //n_count = 0;

        //printf("num:%d\n",num);
    }

    cout << b_count << endl;

    return 0;
}


Measured memory_bytes: 256
import sys

s = input()
t = input()


if s == t:
    print("Yes")
    sys.exit(0)

ls = list(s)
for i in range(0,len(s)):
    tmp = ls.pop(-1)
    ls.insert(0,tmp)

    sls = ''.join(ls)
    #print(t, sls)

    if t == str(sls):
        print("Yes")
        sys,exit(0)
    else:
        continue

print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

//-------------------------------------//
// 素数の判定
//-------------------------------------//


int main(){
  int x;
  cin >> x;
  while(1){
    bool flg = true;  //素数かどうかの判定
    for (int i = 2; i < x; ++i){
      if (x%i == 0){
        flg = false;  //割り切れたら素数ではない
        break;
      }
    }
    if(flg) break;
    ++x;
  }

  cout << x << endl;

  return 0;
}

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

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

	string S; ll K;
	cin >> S >> K;
	int to_a;
	rep(i, S.size()) {
		to_a = ('z'-S[i]+1) % 26;
		// cout << S[i] << " " << to_a << endl;
		if (K >= to_a) {
			S[i] = 'a';
			K -= ll(to_a);
		}
	}
	if (K) {
		S.back() += (K%26);
	}
	cout << S << endl;
}

Measured memory_bytes: 592
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        for(int i = 1; i <= n; i++) {
            if(i%3!=0 && i%5!=0) {
                ans += i;
            }
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 35772
#include <algorithm>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  string S, T;
  while (cin >> S >> T) {
    vector<int> P(26, -1), Q(26, 0);
    bool res = true;
    for (int i = 0; i < S.size(); i++) {
      int s = S[i] - 'a', t = T[i] - 'a';
      if (P[s] == -1) {
        if (Q[t]) {
          res = false;
          break;
        }
        P[s] = t;
        Q[t] = 1;
      } else if (P[s] != t) {
        res = false;
        break;
      }
    }
    cout << (res ? "Yes" : "No") << endl;
  }
  return 0;
}


Measured memory_bytes: 776
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine();

        if(s == "ABC")
        {
            Console.WriteLine("ARC");
        }
        else
        {
            Console.WriteLine("ABC");
        }

        
    }
}

Measured memory_bytes: 25676