akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

class Main
{
    public static void main(String[] args)
    {
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	
	if (a < b) {
	    System.out.println("a < b");
	}
	else if (a > b) {
	    System.out.println("a > b");
	}
	else if (a == b) {
	    System.out.println("a == b");
	}
    }
}

Measured memory_bytes: 25956
#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
using namespace std;
const int M = 1e3;
char mmp[M][M], s[M][M];
int h, w, k, step[M][M], dr[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};
struct TnT
{
    int x, y, step, flag;
};
bool vis[M][M];
void bfs(TnT sta)
{
    memset(step, 0, sizeof(step));
    step[sta.x][sta.y] = 1;
    memset(vis, false, sizeof(vis));
    vis[sta.x][sta.y] = true;
    queue<TnT>q;
    q.push(sta);
    while (!q.empty())
    {
        TnT gg = q.front();
        q.pop();
        for (int i = 0 ; i < 4 ; i++)
        {
            TnT gl = gg;
            gl.x += dr[i][0];
            gl.y += dr[i][1];
            if (gl.x >= 0 && gl.x < h && gl.y >= 0 && gl.y < w && mmp[gl.x][gl.y] != '#' && !vis[gl.x][gl.y])
            {
                gl.step++;
                step[gl.x][gl.y] = gl.step;
                vis[gl.x][gl.y] = true;
                q.push(gl);
            }
        }
    }
}
int main()
{
    scanf("%d%d%d", &h, &w, &k);
    for (int i = 0 ; i < h ; i++)
        scanf("%s", mmp[i]);
    TnT sta;
    for (int i = 0 ; i < h ; i++)
    {
        for (int j = 0 ; j < w ; j++)
        {
            if (mmp[i][j] == 'S')
            {
                sta.x = i, sta.y = j;
                break;
            }
        }
    }
    sta.step = 0, sta.flag = k;
    bfs(sta);
    int ans = 1000000000;
    for (int i = 0 ; i < h ; i++)
    {
        for (int j = 0 ; j < w ; j++)
        {
            if (step[i][j] != 0)
            {
                if (i == 0 || i == h - 1 || j == 0 || j == w - 1)
                {
                    int gg = step[i][j];
                    ans = min(ans, gg / k + (gg % k != 0));
                }
                else
                {
                    int gg = step[i][j], gl = 0;
                    gl = gg / k + (gg % k != 0);
                    gg = i;
                    ans = min(ans, gl + gg / k + (gg % k != 0));
                    gg = j;
                    ans = min(ans, gl + gg / k + (gg % k != 0));
                    gg = h - 1 - i;
                    ans = min(ans, gl + gg / k + (gg % k != 0));
                    gg = w - 1 - j;
                    ans = min(ans, gl + gg / k + (gg % k != 0));
                }
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 6912
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();
		int A = scan.nextInt();
		if (X < A) {
			System.out.println(0);
			return;
		}
		System.out.println(10);
		return;
	}
}

Measured memory_bytes: 23124
/*
AUTHOR: Aman Raj
LANG: C++
*/

using namespace std;

typedef   long long  ll;
#include <bits/stdc++.h>


//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
#define fast  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
#define all(a) a.begin(),a.end()
#define mod 998244353
#define inf 1e9
//#define mod 3
#define flush fflush(stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<int, ll, hash<ll> > ht;

// find_by_order()  // order_of_key
typedef tree<
    int,
    null_type,
    less<long long int>,
    rb_tree_tag,
    tree_order_statistics_node_update>
    ordered_set;






ll power1(ll a, ll b)//a raised to power b
   {  if(b<=0) return 1; if(b==1) return a;
       ll c=power1(a,b/2);
        c*=c;c=c%mod;if(b%2==1) c*=a;c=c%mod;
        return c;
   }
  /* ll mi(ll a,ll m)
   { ll c= power1(a,m-2,mod);

     return c;
   }
*/


  int main()
{    fast;
    string s,t;cin>>s>>t;
      string ss=t.substr(0,s.size());
       cout<< (ss==s?"Yes":"No");
      return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n,m;
  while(cin >>n>>m,n||m){
    cin.ignore();
    int field[101][101] = {0},x = 0,y = 0;
    bool check[101][101] = {false};
    for(int i=0; i<n; i++){
      for(int j=0; j<m; j++){
	char c;
	scanf("%c",&c);
	if(c == '>'){field[j][i] = 1;}
	if(c == '<'){field[j][i] = 2;}
	if(c == '^'){field[j][i] = 3;}
	if(c == 'v'){field[j][i] = 4;}
      }
      scanf("%*c");
    }
    for(;;){
      if(check[x][y]){x = -1;cout <<"LOOP"<<endl;break;}
      check[x][y] = true;
      if(!field[x][y]){break;}
      else if(field[x][y] == 1){x++;}
      else if(field[x][y] == 2){x--;}
      else if(field[x][y] == 3){y--;}
      else if(field[x][y] == 4){y++;}
    }
    if(x>=0){cout <<x<<" "<<y<<endl;}
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
using namespace std;

#define ll long long

int main()
{
    ll N;
    scanf("%lld", &N);

    ll sum = 0;
    for (ll i = 1; i <= N; i++)
    {
        if (i % 3 != 0 && i % 5 != 0)
            sum += i;
    }

    printf("%lld", sum);
}


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

using namespace std;

using ll = long long;
using ld = long double;
using li = __int128;
using uli = unsigned __int128;

#define fi first
#define se second

template <typename T> void s_min(T& a, T b) {
	if (a > b) a = b;
}

template <typename T> void s_max(T& a, T b) {
	if (a < b) a = b;
}

int main() {
	ios_base::sync_with_stdio(0);

	string s, t;
	cin >> s >> t;
	int l1 = s.length(), l2 = t.length();
	vector<vector<int>> dp(l1 + 1, vector<int> (l2 + 1, 0));
	for (int i = 0; i <= l1; i++) {
		for (int j = 0; j <= l2; j++) {
			if (i == 0 || j == 0) continue;
			if (s[i - 1] == t[j - 1]) dp[i][j] = 1 + dp[i - 1][j - 1];
			else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
		}
	}
	string ans;
	while (l1 && l2) {
		if (s[l1 - 1] == t[l2 - 1]) {
			ans += s[l1 - 1];
			l1--, l2--;
		} else if (dp[l1 - 1][l2] > dp[l1][l2 - 1]) {
			l1--;
		} else l2--;
	}
	reverse(ans.begin(), ans.end());
	cout << ans;

	return 0;
}

Measured memory_bytes: 38632
#include <stdio.h>
    #include <bits/stdc++.h>
     
    #define endl "\n"
    #define si(a) scanf("%d ",&a);
    #define si2(a,b) scanf("%d %d ",&a,&b);
    #define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
    #define sll(a) scanf("%lld ",&a);
    #define sll2(a,b) scanf("%lld%lld",&a,&b)
    #define sll3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
    #define sf(a) scanf("%f ",&a);
    #define sd(a) scanf("%lf ",&a);
    #define sc(a) scanf("%c ",&a);
    #define ss(a) scanf("%s ",a);
    #define sf2(a,b) scanf("%f %f ",&a,&b);
    #define sd2(a,b) scanf("%lf %lf ",&a,&b);
    #define mp(a,b) make_pair(a,b)
    #define pb(x) push_back(x)
    #define all(a) a.begin(),a.end()
    #define forn(i,n) for(int i=0;i<n;i++)
    #define forq(i,q,n) for(int i=q;i<n;i++)
    #define form(i,n) for(int i=n;i>=0;i--)
    #define forp(i,q,n) for(int i=q;i>=n;i--)
    #define fi first
    #define se second
    #define INF 1000000010
    #define MOD 1000000007
    #define MAXN
    #define LL long long int
     
     
    using namespace std;
     
    int n;
    string s;
     
    void init(){
    	si(n);
    	cin >> s;
    	int in = 0, de = 0;
    	int a[1234];
    	if(s[0] == 'D') {
    		printf("0\n"); return;
    	}
    	for (int i = 0; i < n; ++i)
    	{
    		if(s[i] == 'I') {
    			in++;
    			a[i] = in;
    			//printf("%d\n", a[i]);
    		}
    		else if(s[i] == 'D') {
    			in--;
    			a[i] = in;	
    		}
    	}
    	int res = *max_element(a, a+n);
    	printf("%d\n", res);
    }
     
    int main(){
    	
    	init();
    	return 0;
    }

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 500005
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define mp make_pair
#define ll long long
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
ll n, m, k, top;
int num[SIZE];
struct UnionSet { //并查集
	int pa[SIZE];
	void init(int n) {
		for (int i = 1; i <= n; i++) pa[i] = i;
	}
	int find(int x) {
		return pa[x] == x ? x : pa[x] = find(pa[x]);
	}
	bool IsSame(int x, int y) { return find(x) == find(y); }
	int union_vertices(int x, int y) {
		int xr = find(x), yr = find(y);
		if (xr != yr) {
			pa[yr] = xr;
			return 1;
		}
		return 0;
	}
} U;

int main() {
	io(); cin >> n >> m >> k;
	U.init(n);
	rep(i, 1, m) {
		int x, y; cin >> x >> y;
		U.union_vertices(x, y);
		num[x]++, num[y]++;
	}
	map<int, int> MP;
	rep(i, 1, n) MP[U.find(i)]++;
	rep(i, 1, k) {
		int x, y; cin >> x >> y;
		if (U.IsSame(x, y)) num[x]++, num[y]++;
	}
	rep(i, 1, n) cout << MP[U.find(i)] - num[i] - 1 << ' ';
}

Measured memory_bytes: 5888
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//ここまでテンプレ
int main(){
	int D,N;
	cin>>D>>N;
	int M=1;
	for(int i=0;i<D;i++)
		M*=100;
	if(N==100)
		cout<<M*(N+1)<<endl;
	else
		cout<<N*M<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
	int n,p;
	while(cin>>n>>p){
		if(n==0 && p==0) break;
		int stone[51]={0};
		int wan=p,j=0,winner;
		while(1){
			if(wan>0){
				stone[j]++;
				wan--;
			}else{
				wan=stone[j];
				stone[j]=0;
			}
			if(wan==p){
				winner=j;
				break;
			}
			j++;
			if(j==n) j=0;
		}
		cout<<winner<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

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

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    ll s;
    cin >> s;
    const ll lim = 1000000000;
    ll y = s / lim + (s % lim > 0);
    ll x = y * lim - s;
    cout << "0 0 1000000000 1 " << x << ' ' << y << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
const long long INF = 1LL << 60;

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

  ll h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  ll time = h2 * 60 + m2 - (h1 * 60 + m1);
  cout << time - k << endl;

  return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
struct edge {int to,w,p;};
int n,m,k,used[202],a,b,c,cnt,A[202],B[202];
vector<edge> v[202];
int dfs(int s,int t,int r){
    if(s==t)return r;
    used[s]=1;
    for(int i=0;i<v[s].size();i++){
        edge &u=v[s][i];
        if(used[u.to]==0&&u.w>0){
            int F=dfs(u.to,t,min(r,u.w));
            if(F>0){
                u.w-=F;v[u.to][u.p].w+=F;return F;
            }
        }
    }
    return 0;
}
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A[i]>>B[i];
        a=200,b=i;
        edge p={b,1,(int)v[b].size()};v[a].push_back(p);
        edge q={a,0,(int)v[a].size()-1};v[b].push_back(q);
    }
    for(int i=100;i<100+n;i++){
        cin>>A[i]>>B[i];
        a=i,b=201;
        edge p={b,1,(int)v[b].size()};v[a].push_back(p);
        edge q={a,0,(int)v[a].size()-1};v[b].push_back(q);
    }
    for(int i=0;i<n;i++){
        for(int j=100;j<100+n;j++){
            if(A[i]<A[j]&&B[i]<B[j]){
                a=i,b=j;
                edge p={b,1,(int)v[b].size()};v[a].push_back(p);
                edge q={a,0,(int)v[a].size()-1};v[b].push_back(q);
            }
        }
    }
    int res=0;
    while(1){
        for(int i=0;i<202;i++)used[i]=0;
        int P=dfs(200,201,1e9);
        if(P==0)break;
        res++;
    }
    cout<<res<<endl;
}


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

#define M 1046527
#define NIL -1
#define L 14

char H[M][L];

int getChar(char ch){
  if(ch == 'A') return 1;
  else if(ch == 'C') return 2;
  else if(ch == 'G') return 3;
  else if(ch == 'T') return 4;
  else return 0;
}

long long getKey(char str[]){
  long long sum = 0,p = 1,i;
  for(i=0;i<strlen(str);i++){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){
  return key % M;
}
int h2(int key){
  return 1 + (key % (M - 1));
}

int find(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i=0;;i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i=0;;i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0){
      strcpy(H[h],str);
      return 0;
    }
  }
}

int main(){
  int i,n;
  char str[L],com[9];
  for(i=0;i<M;i++) H[i][0] = '\0';
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",com,str);
    
    if(com[0] == 'i'){
      insert(str);
    }
    else{
      if(find(str)){
	printf("yes\n");
      }
      else {
	printf("no\n");
      }
    }
  }
  return 0;
}



Measured memory_bytes: 16044
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

const bool ready = []() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);
    return true;
}();

const double PI = acos(-1);
using ll= long long;
#define int ll
#define fori(n) for(int i=0; i<int(n); i++)

#define cini(i) int i; cin>>i;
#define cins(s) string s; cin>>s;
#define cind(d) double d; cin>>d;
#define cinai(a,n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s,n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a,n) vd a(n); fori(n) { cin>>a[i]; }

using pii= pair<int, int>;
using pdd= pair<double, double>;
using vd= vector<double>;
using vb= vector<bool>;
using vvb= vector<vb>;
using vi= vector<int>;
using vvi= vector<vi>;
using vs= vector<string>;

/* How does dp change if one goes out?
 * All with a shortest path over that one have
 * a shortest path one smaller.
 * Which ones are these?
 * Can we do updates?
 * Try.
 */
void solve() {
    cini(n);
    cinai(p,n*n);

    vvi dp(n, vi(n)); /* dp[i][j]==number of haters if u use that path */
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
            dp[i][j]=min(i, min(j, min(n-1-i, n-1-j)));

    vvi notvis(n, vi(n,1));

    const vector<pii> d= { { -1, 0}, {1,0}, {0,-1}, {0,1}};
    int ans=0;
    for(int i=0; i<n*n; i++) {
        int r=(p[i]-1)/n;
        int c=(p[i]-1)%n;

        int mi=1e9;
        for(auto d1 : d) {
            int rr=r+d1.first;
            int cc=c+d1.second;
            if(rr>=0 && rr<n && cc>=0 && cc<n)
                mi=min(mi, dp[rr][cc]+notvis[rr][cc]);
            else
                mi=0;
        }
        ans+=mi;
        dp[r][c]=mi;
        notvis[r][c]=0;
//cerr<<"i="<<i<<" r="<<r<<" c="<<c<<" mi="<<mi<<endl;

        queue<pii> q;
        q.emplace(r,c);
        while(q.size()) {
            auto [r0,c0]=q.front();
            q.pop();
            for(auto d1 : d) {
                int rr=r0+d1.first;
                int cc=c0+d1.second;
                if(rr>=0 && rr<n && cc>=0 && cc<n && dp[rr][cc]>dp[r0][c0]+notvis[r0][c0]) {
                    dp[rr][cc]=dp[r0][c0]+notvis[r0][c0];
                    q.emplace(rr,cc);
                }
            }
        }
    }

    cout<<ans<<endl;
}

signed main() {
    solve();
}



Measured memory_bytes: 9276
n = int(input())
nums = list(map(int, input().split()))

ans = pow(200, 2) * 100
for y in range(min(nums), max(nums) + 1):
    cost = 0
    for x in nums:
        cost += pow(x - y, 2)
    ans = min(ans, cost)
print(ans)


Measured memory_bytes: 2940
#include "bits/stdc++.h"

using namespace std;

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

    // 左にあるblackの個数
    int lBlack = 0;
    // 右にあるwhiteの個数
    int rWhite = count(S.begin(), S.end(), '.');

    int ans = lBlack + rWhite;
    for (int i = 0; i < N; ++i) {
        if (S[i] == '#')
            lBlack += 1;
        else
            rWhite -= 1;
        ans = min(ans, lBlack + rWhite);
    }
    cout << ans << endl;
}

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

using namespace std;

int prime(long long n){
	for(long long i=2;i<=sqrt(n);i++){
    	if(n%i==0){
    	    return 0;
    	}
	}
	return 1;
}
	
int main(){
	long long n,m;
	cin>>n>>m;
	long long maxn=1;
	if(n==1){
		cout<<m<<endl;
		return 0;
	}
	double ff=m,fff=n;
	double f=pow(ff,1.0/fff);
	
	for(long long i=f+1;i>=2;i--){
		long long sum=1;
		for(long long j=0;j<n;j++){
			sum*=i;
			if(sum>m)
				break;
			}
		if(m%sum==0){
			maxn=i;
			break;
		}
	}
	cout<<maxn<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(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 = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;cin >> a >> b;
    if(abs(a-b)<=1){
        cout << "Yay!" << endl;
    }
    else{
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 3628
n = gets.chomp.to_i
a = []
b = []
n.times do |i|
  a[i] = gets.chomp.to_i
end
b = a.dup
m = a.max
if a.count(m) == 1
  b.delete(m)
  n.times do |i|
    if a[i] == m
      puts b.max
    else
      puts m
    end
  end
else
  n.times do
    puts m
  end
end


Measured memory_bytes: 6856
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <queue>
using namespace std;

const int MAXN = 1e5 + 10;
int n, m, first[MAXN], tot, d[MAXN], s, t;

struct edge { int from, v, w; } e[20 * MAXN];
struct Node
{
	int x, d;
	bool operator <(const Node &b)const
	{
		return d > b.d;
	}
}cyc;
priority_queue<Node> q;
inline void insert(int u, int v, int w)
{
	tot++; e[tot].v = v; e[tot].w = w; e[tot].from = first[u]; first[u] = tot;
}
int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (register int i = 1; i <= n; i++)
		for (register int j = 0; j <= 9; j++)insert(i, ((i - 1) * 10 + j) % n + 1, j);
	for (register int j = 1; j <= 9; j++) insert(0, j + 1, j);
	s = 0; t = 1;
	memset(d, 0x3f, sizeof d);
	d[s] = 0; q.push((Node) { s, d[s] });
	while (!q.empty())
	{
		cyc = q.top(); q.pop();
		if (cyc.d != d[cyc.x])continue;
		register int x = cyc.x;
		for (int i = first[x]; i; i = e[i].from)
			if (d[e[i].v] > d[x] + e[i].w)
			{
				d[e[i].v] = d[x] + e[i].w;
				q.push((Node) { e[i].v, d[e[i].v] });
			}
	}
	return cout << d[t], 0;
}

Measured memory_bytes: 15476
import java.util.Scanner;
public class Main {
    static int[] treasureV, treasureW;
    public static void main (String[] args) {
	Scanner scan = new Scanner (System.in);
	int cnt = 1;
	String[] input;
	while (true) {
	    int capacity = Integer.parseInt(scan.nextLine());
	    if (capacity == 0) {
		break;
	    }
	    int n = Integer.parseInt(scan.nextLine());
	    treasureV = new int[n];
	    treasureW = new int[n];
	    for (int i = 0; i < n; i++) {
		input = scan.nextLine().split(",");
		treasureV[i] = Integer.parseInt(input[0]);
		treasureW[i] = Integer.parseInt(input[1]);
	    }
	    System.out.println("Case " + cnt++ + ":");
	    solve(n, capacity);
	} 
    }
    
    public static void solve (int n, int w) {
	int[][] dp = new int[n+1][w+1];
	int maxvalue = Integer.MIN_VALUE;
	int minweight = Integer.MAX_VALUE;
	for (int i = n - 1; i >= 0; i--) {
	    for (int j = 0; j <=w; j++) {
		if (j < treasureW[i]) {
		    dp[i][j] = dp[i+1][j];
		} else {
		    dp[i][j] = Math.max(dp[i+1][j], dp[i+1][j-treasureW[i]] + treasureV[i]);
		    if (maxvalue < dp[i][j]) {
			maxvalue = dp[i][j];
			minweight = j;
		    } else if (maxvalue == dp[i][j] && minweight > j){
			minweight = j;
		    }
		}
	    }
	}
	System.out.println(maxvalue);
	System.out.println(minweight);
    }
}

Measured memory_bytes: 36580
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,i,k,p;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&k,&p);
		if(k%p==0)	printf("%d\n",p);
		else	printf("%d\n",k%p);
	}
	return 0;
}



Measured memory_bytes: 2760
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main() {
    int n, a, b;
    string s;
    cin >> n >> a >> b >> s;

    int tot_a = 0;
    int tot_b = 0;
    REP(i, n) {
        switch (s[i])
        {
        case 'a':
            if (tot_a + tot_b < a + b) {
                cout << "Yes" << endl;
                tot_a++;
            } else {
                cout << "No" << endl;
            }
            break;
        case 'b':
            if ((tot_a + tot_b < a + b) && (tot_b < b)) {
                cout << "Yes" << endl;
                tot_b++;
            } else {
                cout << "No" << endl;
            }
            break;
        case 'c':
            cout << "No" << endl;
            break;
        default:
            return 1;
        }
    }
    return 0;
}

Measured memory_bytes: 896
import java.util.Scanner

object Main extends App { 
  val sc = new Scanner(System.in)
  val N, W = sc.nextInt()
  val items = (for (i <- 1 to N) yield (sc.nextInt, sc.nextInt)).toArray

  class DP(n:Int, w:Int, items:Array[(Int,Int)]) {
    val memo = Array.fill(n+1)(Array.fill(w+1)(0))
    def solver():Int = {
      for (i <- 1 to n; j <- 1 to w) {
        val (v, w) = items(i-1)
        val v0 = memo(i-1)(j)
        val v1 = if (j < w) 0 else memo(i)(j-w) + v
        memo(i)(j)= if (v0 > v1) v0 else v1
      }
        // for (r <- 0 to n) println(memo(r).mkString(" "))
      memo(n)(w)
    }
  }
  
  val dp = new DP(N, W, items)

  println(dp.solver())
}


Measured memory_bytes: 53924
#include <bits/stdc++.h>
using namespace std;
int ans[100001];
bool prime(int p){
    if(p==1)return false;
    for(int i=2;i<=sqrt(p);i++){
        if(p%i==0)return false;
    }
    return true;
}
int main(){
	int q,l,r;
	cin>>q;
	ans[1]=0;
	for(int i=2;i<=100000;i++){
	    ans[i]=ans[i-1];
	    if(prime(i)&&prime((i+1)/2))ans[i]++;
	}
	for(int i=0;i<q;i++){
	    cin>>l>>r;
		cout<<ans[r]-ans[l-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
def bbq():
    n = int(input())
    a = input()
    tmp = a.split()
    l = [int(x) for x in tmp]
    l.sort()
    n = 0
    i = 0
    while(i<len(l)):
        n += l[i]
        i += 2
    print (n)

if __name__ == "__main__":
    bbq()

Measured memory_bytes: 7272
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    int n,q;
    string s;
    cin >> n >> q >> s;
    vector<int> z(n);
        for (int i = 0; i < n-1; i++) {
            int g = 0;
            if (s.at(i) == 'A' && s.at(i + 1) == 'C') {
                g = 1;
            }
            z.at(i + 1) = z.at(i) + g;
        }
        for (int i = 0; i < q; i++) {
            int a, b;
            cin >> a >> b;
            cout << z.at(b-1) - z.at(a-1) << endl;
        }
}

Measured memory_bytes: 1536
#[allow(unused_imports)]
use std::cmp::Reverse;

#[allow(unused_imports)]
use proconio::{fastout, input, marker::Chars};

#[allow(unused_imports)]
use itertools::Itertools;

#[fastout]
pub fn main() {
    input! {
        s: Chars,
        t: Chars,
    }

    let mut dp = vec![vec![0; t.len() + 1]; s.len() + 1];
    for i in 0..s.len() {
        for j in 0..t.len() {
            if s[i] == t[j] {
                dp[i + 1][j + 1] = dp[i + 1][j + 1].max(dp[i][j] + 1);
            }
            dp[i + 1][j + 1] = dp[i + 1][j + 1].max(dp[i + 1][j].max(dp[i][j + 1]));
        }
    }

    let mut i = s.len();
    let mut j = t.len();
    let mut result = String::new();
    while i > 0 && j > 0 {
        if dp[i][j] == dp[i - 1][j] {
            i -= 1;
        } else if dp[i][j] == dp[i][j - 1] {
            j -= 1;
        } else {
            result.push(s[i - 1]);
            i -= 1;
            j -= 1;
        }
    }
    println!("{}", result.chars().rev().collect::<String>());
}


Measured memory_bytes: 37360
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Queue;

public class Main {
    static final int MAX = Integer.MAX_VALUE;
    
    public static void main(String[] args) throws Exception{
//        Scanner sc = new Scanner(System.in);
        BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
        String[] s;
        s = sc.readLine().split(" ");
        int n = Integer.parseInt(s[0]);
        int m = Integer.parseInt(s[1]);
        HashMap<Integer, Integer>[] d = new HashMap[n+1];
        for (int i = 0; i <= n; i++) {
            d[i] = new HashMap<Integer, Integer>();
        }
        
        for (int i = 0; i < m; i++) {
            s = sc.readLine().split(" ");
            int xLi = Integer.parseInt(s[0]);
            int xRi = Integer.parseInt(s[1]);
            int xDi = Integer.parseInt(s[2]);
            d[xLi].put(xRi, xDi);
            d[xRi].put(xLi, -xDi);
        }

        Queue<Integer> q = new LinkedList<Integer>();
        int[] pos = new int[n+1];
        Arrays.fill(pos, MAX);
        
        for (int i = 1; i <= n; i++) {
            if (pos[i] != MAX) continue;
            
            q.add(i);
            pos[i] = 0;
            while (!q.isEmpty()) {
                int f = q.poll();
                for (Integer k : d[f].keySet()) {
                    Integer vFK = d[f].get(k);
                    
                    if (pos[k] != MAX) {
                        if (pos[k] != pos[f] + vFK) {
                            System.out.println("No");
                            return;
                        }
                    } else {
                        q.add(k);
                        pos[k] = pos[f] + vFK;
                    }
                }
            }
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 95272
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;

ll add(ll a, ll b){
    return (a + b) % mod;
}

ll mul(ll a, ll b){
    a = (a + mod) % mod;
    b = (b + mod) % mod;
    return 1ll * a * b % mod;
}

ll a[N];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    ll cum = 0, ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        cum += a[i];
    }
    for(int i = 0; i < n; i++){
        cum -= a[i];
        ans = add(ans, mul(a[i], cum));
    }
    cout << ans;

    return 0;
}


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

using namespace std;

const int inf = (int) (2e9);

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    vector<int> dp(n);
    for (int i = 1; i < n; ++i) {
        dp[i] = inf;
        for (int j = max(0, i - k); j < i; ++j) {
            dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]));
        }
    }
    cout << dp.back() << '\n';
    return 0;
}

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

int main() {
    string S;
    cin>>S;
    long ans = 0;
    long tmp = 0;
    for(int i=0;i<S.size();++i){
        if(S[i] == 'B')tmp++;
        else ans += tmp;
    }
    cout<<ans<<endl;
}


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

int main()
{
    int a,b,c;
    cin >> a >> b >>c;
    if(a+b+c>=22)
        cout << "bust" << endl;
    else
        cout << "win" << endl;
    return 0;
}


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

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

    vector<vector<int> > c(n, vector<int>(n));
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            cin >> c[i][j];
        }
    }

    vector<int> tmp(n);
    for(int i=0; i<n; ++i)
        tmp[i] = i;
    map<vector<int>, int> history;
    multimap<int, vector<int> > mm;
    history[tmp] = 0;
    mm.insert(make_pair(0, tmp));

    int ret = 0;
    while(!mm.empty()){
        int curr = mm.begin()->first;
        vector<int> a = mm.begin()->second;
        mm.erase(mm.begin());

        if(curr > history[a])
            continue;
        ret = curr;

        for(int i=0; i<n; ++i){
            for(int j=0; j<i; ++j){
                swap(a[i], a[j]);

                int next = curr + c[a[i]][a[j]];
                if(history.find(a) == history.end() || next < history[a]){
                    history[a] = next;
                    mm.insert(make_pair(next, a));
                }

                swap(a[i], a[j]);
            }
        }
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 13564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(5e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

map<int, int> prime;
void prime_factor(int n) {
    for (int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ++prime[i];
            n /= i;
        }
    }
    if (n != 1) prime[n]++;
    return;
}

int main() {
    int n, p2=0, p4=0, p14=0, p24=0, p74=0, ans = 0;
    cin >> n;
    REP(i,n+1){
        prime_factor(i);
    }
    for(auto p : prime){
        if(p.second>=74) p74++;
        if(p.second>=24) p24++;
        if(p.second>=14) p14++;
        if(p.second>=4) p4++;
        if(p.second>=2) p2++;
    }

    ans += p4*(p4-1)*(p4-2)/2;
    ans += (p2-p4)*p4*(p4-1)/2;
    ans += p14*(p4-1);
    ans += p24*(p2-1);
    ans += p74;

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


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


int* mallocint(int si)
{
    return (int*) malloc(si * sizeof(int));
}

int* inputint(int n)
{
    int *ans = mallocint(n);
    for( int i = 0; i < n; i++ ) cin >> ans[i];
    return ans;
}

#define AMAX 1000000

int main()
{
    int n;
    cin >> n;
    int *a = inputint(n);
    int *map = new int[AMAX + 1];
    for( int i = 0; i <= AMAX; i++ ) map[i] = 0;
    for( int i = 0; i < n; i++ )
    {
        map[a[i]]++;
    }

    int ans = n;
    for( int i = 0; i < n; i++ )
    {
        if( map[a[i]] > 1 || map[1] > 1)
        {
            ans--;
            continue;
        }

        if( map[1] == 1 )
        {
            if( a[i] != 1 )
            {
                ans--;
                continue;
            }
        }


        for(int n = 2; n * n <= a[i]; n++ )
        {
            if( a[i] % n == 0 )
            {
                if( map[n] > 0 || map [a[i] / n] > 0 )
                {
                    ans--;
                    break;
                }
            }
        }
    }
    cout << ans;
    return 0;    
}

Measured memory_bytes: 8280
//#pragma GCC optimize("O2147483647")
//#pragma GCC optimize("inline")
//#pragma GCC optimize("-ffast-math")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("inline-small-functions")
//#pragma GCC optimize("-finline-small-functions")
//#pragma GCC optimize("-fexpensive-optimizations")
//#pragma GCC optimize("-funsafe-loop-optimizations")
//#pragma GCC optimize("inline-functions-called-once")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx,avx")
//#pragma GCC optimze("fast-math")
//#define GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include "testlib.h"
#define rep(i, j, k) for (int i = (int)(j); i<(int)(k); i++)
#define per(i, j, k) for (int i = (int)(k); i>=(int)(j); i--)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)((x).size())
#define fprd fprintf(stderr,
#define fi first
#define se second
#define endl '\n'
using namespace std;
typedef long long ll;
//#define int ll
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

const int N=1e5+5;
int h,n;

int main() {
    scanf("%d%d",&h,&n);
    int sum=0;
    rep(i,0,n) {
        int x;
        scanf("%d",&x);
        sum+=x;
    }
    puts((sum>=h)?"Yes":"No");
}

Measured memory_bytes: 256
/*

Author : AllKilled
Date   : 202001197 19:50:00 UTC+8

Website: https://atcoder.jp/contests/abc152
Contest: AtCoder Beginner Contest 152
Problem: Task B.
Result :

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

typedef long long LL;
typedef pair<LL, LL> PLL;

const int inf = 0x3f3f3f3f;
const int N = 18;
const LL MAXN = (1 << N) + 3;

///--------------------------------------------///



int main()
{
    int a, b;
    cin >> a >> b;
    string A(a, '0'+b), B(b, '0'+a);
    if (A > B) swap(A, B);
    cout << A << endl;
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
//#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)
bool is[100000];
int main()
{
	ll a,b;
	cin>>a>>b;
	ll m;
	m=b;
	rep(i,1000){
		if(i*i>=100000) break;
		is[i*i]=1;
	}
	while(m>0){
		m/=10;
		a*=10;
	}
	if(is[a+b]) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 384
/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0000
 */
#include<iostream>
#define B 9
using namespace std;
int main(){
  for(int i=0;i<B*B;cout<<(i/B+1)<<'x'<<(i%B+1)<<'='<<(i/B+1)*(i%B+1)<<endl,i++){}
  return 0;
}

Measured memory_bytes: 3040
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll n,sum=0;
  cin>>n;
  ll a[n];
  for(ll i=0;i<n;i++){
    	cin>>a[i];
    	sum+=a[i];
  }
  cout<<sum-n;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
    cin >> s;
    if (s[0] == s[1] && s[1] == s[2]) {
        cout << "Yes";
        return 0;
    }
    if (s[1] == s[2] && s[2] == s[3]) {
        cout << "Yes";
        return 0;
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
#define fst first
#define snd second

bool pairwise(VI a) {
  const int N = 1e6 + 10;
  vector<int> pr(N);
  for (int i = 2; i < N; i++) {
    if (pr[i] == 0) {
      for (int j = i; j < N; j += i) {
        pr[j] = i;
      }
    }
  }
  vector<bool> seen(N);
  for (int x: a) {
    while (x > 1) {
      int p = pr[x];
      if (seen[p]) return false;
      seen[p] = true;
      while (x % p == 0) x /= p;
    }
  }
  return true;
}
bool setwise(VI a) {
  int g = a[0];
  for (int x: a) g = gcd(g, x);
  return g == 1;
}

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n; cin >> n;
  vector<int> a(n);
  for (int& x: a) cin >> x;

  if (pairwise(a)) {
    cout << "pairwise coprime" << endl;
  } else if (setwise(a)) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }

  return 0;
}


Measured memory_bytes: 15212
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int[] a = sc.IntArray();

        int ans = 0;
        for (int i = 0; i < n; i++)
        {
            if (i % 2 == 0 && a[i] % 2 == 1) ans++;
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 28028
#include <bits/stdc++.h>
#define int long long
#define range(i,x,y) i=(x);i<(y);i++
#define all(x) begin(x),end(x)
#define lim(x,r,l) (r<=x&&x<l)
typedef long long ll;
typedef long double ld;
using namespace std;

signed main(){
  int n;
  while(cin >> n, n != 0){
    vector<int> p(n), j(n-1);
    int ps = 0;
    for(int range(i,0,n)){
      cin >> p[i];
      ps += p[i];
    }
    for(int range(i,0,n-1)){
      cin >> j[i];
    }
    sort(all(j));
    int res = ps * n;
    int js = 0;
    for(int i = n; i >= 2; i--){
      res = max(res, (ps + js)*i);
      js += j[i-2];
    }
    res = max(res, (ps + js));
    cout << res << endl;
  }
}

/*
1 2 3 4 5
 4 3 2 1

1,1->6,1->12,1
        ->9,2
   ->3,2->9,2
        ->6,3

(S + a + b) * m

(S + a + j + b)* m-1

1 1 1 3*3
5 * 2
*/

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

int main() {
    int t, d, l, x[100005];
    while(cin >> t >> d >> l, t){
        for(int i=0;i<t;i++){
            cin >> x[i];
        }
        int ans = 0, r = 0;
        for(int i=0;i<t;i++,r--){
            if(r > 0) ans++;
            if(x[i] >= l){
                r = d+1;
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3468
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
int N;
std::vector<int> v(1000000,LINF),w(1000000);
int dp[201][100005];
int f(int i,int x){
  //cout<<i<<" "<<x<<endl;
  if(dp[i][x]!=-1)return dp[i][x];
  if(i==0)return dp[i][x]=x%v[0];
  int res=0;
  res+=f(i-1,x%v[i]);
  res+=f(i-1,x)*i;
  res%=MOD;
  return dp[i][x]=res;
}

//main
signed main(){
  int X;cin>>N>>X;
  w[0]=1;for(int i=1;i<1000000;i++)w[i]=w[i-1]*i%MOD;
  memset(dp,-1,sizeof(dp));
  for(int i=0;i<N;i++)cin>>v[i];
  sort(v.begin(),v.end());
  cout<<f(N-1,X)<<endl;
  /*
  for(int i=0;i<5;i++){
    for(int j=0;j<20;j++)cout<<dp[i][j]<<" ";cout<<endl;
  }
  */
  //for(int i=0;i<10;i++)cout<<v[i]<<" ";cout<<endl;
}


Measured memory_bytes: 173056
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>

using namespace std;
typedef long long ll;
double EPS=1e-10;
typedef pair<int,int> pii;
bool EQ(double a,double b){
	return abs(a-b)<EPS;
}

typedef pair<pii,pii> ppii;

int W,H;
int field[101][101];
const int dy[]={-1,0,1,0};
const int dx[]={0,1,0,-1};
int cc[101];
int d[101][101][4];
const int INF=1000000000;

int dijkstra(){
	for(int i=0;i<101;i++)
		for(int j=0;j<101;j++)
			for(int k=0;k<4;k++)
				d[i][j][k]=INF;
	priority_queue<ppii,vector<ppii>,greater<ppii> > pq;
	pq.push(make_pair(pii(0,1),pii(0,0)));
	d[0][0][1]=0;
	while(pq.size()){
		ppii p=pq.top();pq.pop();
		int cy=p.second.first;
		int cx=p.second.second;
		int cang=p.first.second;
		int ccost=p.first.first;
		if(d[cy][cx][cang]<ccost)continue;
		for(int i=0;i<4;i++){
			int nadd=cc[i];
			if(i==field[cy][cx])nadd=0;
			if(i==0){
				int nang=cang;
				int ny=cy+dy[cang];
				int nx=cx+dx[cang];
				if(ny>=0&&nx>=0&&ny<H&&nx<W){
					int ncost=d[cy][cx][cang]+nadd;
					if(ny>=0&&nx>=0&&ny<H&&nx<W&&d[ny][nx][nang]>ncost){
						d[ny][nx][nang]=ncost;
						pq.push(make_pair(pii(ncost,nang),pii(ny,nx)));
					}
				}
			}
			else if(i==1){
				int nang=(cang+1)%4;
				int ny=cy+dy[nang];
				int nx=cx+dx[nang];
				int ncost=d[cy][cx][cang]+nadd;
				if(ny>=0&&nx>=0&&ny<H&&nx<W){
					if(ny>=0&&nx>=0&&ny<H&&nx<W&&d[ny][nx][nang]>ncost){
						d[ny][nx][nang]=ncost;
						pq.push(make_pair(pii(ncost,nang),pii(ny,nx)));
					}
				}
			}
			else if(i==2){
				int nang=(cang+2)%4;
				int ny=cy+dy[nang];
				int nx=cx+dx[nang];
				int ncost=d[cy][cx][cang]+nadd;
				if(ny>=0&&nx>=0&&ny<H&&nx<W){
					if(ny>=0&&nx>=0&&ny<H&&nx<W&&d[ny][nx][nang]>ncost){
						d[ny][nx][nang]=ncost;
						pq.push(make_pair(pii(ncost,nang),pii(ny,nx)));
					}
				}
			}
			else if(i==3){
				int nang=(cang+3)%4;
				int ny=cy+dy[nang];
				int nx=cx+dx[nang];
				int ncost=d[cy][cx][cang]+nadd;
				if(ny>=0&&nx>=0&&ny<H&&nx<W){
					if(ny>=0&&nx>=0&&ny<H&&nx<W&&d[ny][nx][nang]>ncost){
						d[ny][nx][nang]=ncost;
						pq.push(make_pair(pii(ncost,nang),pii(ny,nx)));
					}
				}
			}
		}
	}
	int res=INF;
	for(int i=0;i<4;i++)
		res=min(res,d[H-1][W-1][i]);
	return res;
}

void solve(){
	while(cin>>W>>H&&(W|H)){
		for(int i=0;i<H;i++)
			for(int j=0;j<W;j++)
				cin>>field[i][j];
		for(int i=0;i<4;i++)
			cin>>cc[i];
		cout<<dijkstra()<<endl;
	}
}
int main(){

	solve();

	return 0;
}

Measured memory_bytes: 1192