akhauriyash/Code-Regression huggingface dataset:
// abc173_a
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int N;
  cin >> N;
  rep(i, 11) {
    if (i * 1000 - N >= 0) {
      cout << i * 1000 - N << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3628
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n-1)]

if n ==1:
    print(0)
    exit()

res = [0]
res.append(ab[n-2][0]+ab[n-2][1])

for i in range(n-3,-1,-1):
    temp = ab[i][0]+ab[i][1]
    if temp <= ab[i+1][1]:
        res.append(res[-1])
    else:
        for j in range(i,n-2):
            if temp <= ab[j+1][1]:
                temp = ab[j+1][1] + ab[j+1][0]
            else:
                if temp % ab[j+1][2] ==0:
                    temp += ab[j+1][0]
                else:
                    temp = ((temp//ab[j+1][2])+1) * ab[j+1][2] +ab[j+1][0]
        res.append(temp)

for l in range(n-1,-1,-1):
    print(res[l])

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

int main()
{
    int r;
    cin>>r;
    long double pi = 3.141592653589793238;
    cout<<setprecision(6)<<((long double)(((long double)2.000000000)*pi*((long double)r* 1.0000000)))<<endl;
    return 0;
}

Measured memory_bytes: 3788
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <cmath>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <unordered_map>
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define ll long long
#define INF ((1<<30)-1)
#define NEG (-1)
#define MOD 1000000007
#define MAXN 100100
#define EPS 1e-9
#define INFLL 1e18
using namespace std;
FILE *in,*out;

int N,M,K;
int dp[210];

int read()
{
    int i,j,k;
    fscanf(in,"%d",&N);
    dp[0]=1;
    for(i=0;i<=N;i++)
    {
        if(dp[i])
        {
            dp[i+4] = 1;
            dp[i+7] = 1;
        }
    }
    // for(i=0;i<N;i++)
    // {
    //     printf("%d %d\n",i,dp[i]);
    // }
    if(dp[N]) printf("Yes\n");
    else printf("No\n");
    return 0;
}

int main()
{
    // in = fopen("A.in","r");
    // out  = fopen("A.out","w");
    in = stdin;
    out = stdout;
    read();
    return 0;
}
//////////// Local Snippets
// forx
// fory
// vectorx
// pairx
// sizex

Measured memory_bytes: 256
matrix = []
while True:
    values = input()
    if '0 0' == values:
        break
    matrix.append([int(x) for x in values.split()])

for height, width in matrix:
    for i in range(height):
        if 0 == i or height - 1 == i:
            print('#' * width)
        else:
            print('{0}{1}{2}'.format('#', '.' * (width - 2), '#'))
    print()

Measured memory_bytes: 7616
#include <iostream>

using namespace std;

int main(void) {
	double a, b;

	cin >> a;
	cin >> b;

	if (a > b) {
		cout << "GREATER" << endl;
	}

	else if (a < b) {
		cout << "LESS" << endl;
	}

	else
		cout << "EQUAL" << endl;

	return 0;
}


Measured memory_bytes: 256
// C.

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
	int n, t = 0, f = 0, o = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		if ((a % 4) == 0) {
			++f;
		} else if ((a % 2) == 0) {
			++t;
		} else {
			++o;
		}
	}
	bool ans = true;
	if (f < o) {
		ans = f == o - 1 && t == 0;
	}
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
n=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(n):
    s=input()
    if s=="AC":
        ac=ac+1
    elif s=="WA":
        wa=wa+1
    elif s=="TLE":
        tle=tle+1
    else:
        re=re+1
print("AC x ",end="")
print(ac)
print("WA x ",end="")
print(wa)
print("TLE x ",end="")
print(tle)
print("RE x ",end="")
print(re)

Measured memory_bytes: 9220
import java.util.Scanner;
import java.math.BigInteger;

class Main {
    public static void main(String args[]) {
    int num = 0;
    BigInteger a, b;
    
    Scanner in = new Scanner(System.in);
    //System.out.println("Enter two number: ");
    a = in.nextBigInteger();
    b = in.nextBigInteger();
    
    int res = a.compareTo(b);
    if(res < 0) 
        System.out.println("LESS");
    else if (res == 0)
        System.out.println("EQUAL");
    else
        System.out.println("GREATER");
    }
}

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

struct UnionFind{
	vector<int> par;

	UnionFind(int N) : par(N,-1){ }

	int root(int x){
		if(par[x] < 0)return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y){
		int rx = root(x);
		int ry = root(y);
		if(rx==ry)return;
		if (par[rx] > par[ry]) swap(rx,ry);
    	par[rx] += par[ry];
   		par[ry] = rx;
	}

	bool same(int x, int y){
		int rx = root(x);
		int ry = root(y);
		return rx==ry;
	}

	int ConnectedComponentCount(int x){
		return -par[root(x)];
	}

};

int main(){
	int N,M,K;
	cin >> N >> M >> K;
	vector<int> c(N+1);
	vector<int> blk[N+1];
	UnionFind uf(N+1);
	rep(i,M){
		int a,b;
		cin >> a >> b;
		c[a]++;
		c[b]++;
		uf.unite(a,b);
	}
	rep(j,K){
		int a,b;
		cin >> a >> b;
		blk[a].push_back(b);
		blk[b].push_back(a);
	}

	rep(i,N){uf.root(i+1);}

	for(int i=1; i<=N; i++){
		int ans = uf.ConnectedComponentCount(i) - c[i] -1;
		for(int u : blk[i]){
			if(uf.same(i,u))ans--;
		}
		cout << ans << " ";
	}cout<< endl;
}


Measured memory_bytes: 6784
#include<iostream>
#include<vector>
#define MAX 100000
using namespace std;

int n,k,q;
vector<int> a(MAX);
vector<int> b(MAX);

int main(){
    cin >> n >> k >> q;
    for(int i = 0;i < q;i++){
        b.at(i) = 0;
    }
    for(int i = 0;i < q;i++){
        cin >> a.at(i);
        b.at(a.at(i) - 1)++;
    }
    /**/
    for(int i = 0;i < n;i++){
        if(k + b.at(i) - q > 0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }

    return 0;
}

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

using namespace std;
typedef long long ll;

#define LOOP(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) LOOP(i, 0, n)
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define MAX_N 20
#define MAX_M 30

int main(void) {
  while (true) {
    int n;
    cin >> n;
    if (n == 0)
      break;
    int x[MAX_N], y[MAX_M];
    REP(i, n) cin >> x[i] >> y[i];
    int m;
    cin >> m;
    bool cnt[MAX_N];
    memset(cnt, false, sizeof(cnt));
    int mx = 10, my = 10;
    REP(i, m) {
      string dir;
      int dist;
      cin >> dir >> dist;
      if (dir == "N") {
        REP(i, n) {
          if (x[i] == mx && my + dist >= y[i] && my <= y[i])
            cnt[i] = true;
        }
        my += dist;
      } else if (dir == "E") {
        REP(i, n) {
          if (y[i] == my && mx + dist >= x[i] && mx <= x[i])
            cnt[i] = true;
        }
        mx += dist;
      } else if (dir == "S") {
        REP(i, n) {
          if (x[i] == mx && my - dist <= y[i] && my >= y[i])
            cnt[i] = true;
        }
        my -= dist;
      } else if (dir == "W") {
        REP(i, n) {
          if (y[i] == my && mx - dist <= x[i] && mx >= x[i])
            cnt[i] = true;
        }
        mx -= dist;
      }
    }

    bool flag = true;
    REP(i, n) if (!cnt[i]) flag = false;
    if (flag)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 2988
#include <iostream>
#include <string>
#include <math.h>
#include <list>
#include <stack>
#include <set>
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <cstdlib>
#include <typeinfo>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
	ll ans = 0, p = 0;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++)if (s[i] == 'p')p++;
	ans = s.size() / 2 - p;
	cout << ans << endl;
}


Measured memory_bytes: 512
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))
L = [0] * 3
for p in P:
    if p<=A:
        L[0] += 1
    elif p<=B:
        L[1] += 1
    else:
        L[2] += 1
print(min(L))

Measured memory_bytes: 3060
#include <stdio.h>

int main(void) {
    long long N, K, x, a, b, c, k, l, X, A[200005], B[200005], C[200005], i;
    scanf("%lld%lld", &N, &K);
    for (i=0; i<N; i++) {
        scanf("%lld", &A[i]);
        A[i]--;
    }
    for (i=0; i<N; i++) B[i]=-1;
    x=0; B[0]=0; C[0]=x; i=0;
    a=0; b=0;
    while (1) {
        i++;
        x=A[x];
        C[i]=x;
        if (i==K) {
            c=0;
            break;
        }
        if (B[x]!=-1) {
            a=B[x];
            b=i;
            c=1;
            break;
        }
        B[x]=i;
        // printf("%lld %lld\n", i, x);
    }
    if (c) {
        k=K-a;
        l=b-a;
        X=a+k%l;
        // printf("[%lld, %lld]", a, b);
        // printf("[%lld, %lld, %lld]", k, l, X);
        printf("%lld", C[X]+1);
    }
    else printf("%lld", x+1);
    return 0;
}


Measured memory_bytes: 6064
import scala.io.StdIn.readInt

object Main {
  def round(n:Double) = {
    val m = n % 1000
    if(m>0) n-m+1000 else n
  }

  def getDebt(n:Int,m:Double):Int = if(n==0) m.toInt else getDebt(n-1,round(m*1.05))

  def main(args:Array[String]) = {
    val n = readInt
    println(getDebt(n,100000))
  }
}

Measured memory_bytes: 43376
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M,V,P;
    cin >> N >> M >> V >> P;
    ll A[100010];
    rep(i,0,N) cin >> A[i];
    sort(A, A+N);
    ll lv = -1, rv = N+1;
    while(rv - lv > 1){
        bool ok = true;
        ll mid = (rv + lv) / 2;
        ll b[100010];
        rep(i,0,N) b[i] = A[i];
        ll idx = 0;
        rrep(i,mid,0){
            if(idx < V){
                b[i] += M;
            }else{
                break;
            }
            idx++;
        }
        rep(i,0,P-1){
            if(idx < V){
                b[N-1-i] += M;
            }else{
                break;
            }
            idx++;
        }
        ll val = b[mid];
        ll amari = (V - idx) * M;
        if(amari != 0){
            rep(i,mid+1, N-P+1){
                ll v = max(0LL, val - b[i]);
                if(amari >= v){
                    amari -= v;
                    b[i] += v;
                }else{
                    amari = 0;
                    b[i] += amari;
                }
            }
        }
        if(amari > 0) b[mid+1] += amari;
        sort(b, b+N, greater<ll>());
        ll pos = -1;
        rep(i,0,N){
            if(b[i] == val){
                pos = i+1;
                break;
            }
        }
        if(pos <= P){
            ok = true;
        }else{
            ok = false;
        }
        // print(mid, ok);

        if(ok){
            rv = mid;
        }else{
            lv = mid;
        }
    }
    print(N - rv);


    

}

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

int main() {
    long long int n, m, x, y, z, sum, ans = 0;
    cin >> n >> m;
    long long int xyz[n][3] = {0};
    for(int i = 0; i < n; ++i) cin >> xyz[i][0] >> xyz[i][1] >> xyz[i][2];
    
    for(int bit = 0; bit < (1<<8); ++bit) {
        long long int sum = 0, xyz_sum[n] = {0};
        int fx = (bit & 0x1)?-1:1;
        int fy = (bit & 0x2)?-1:1;
        int fz = (bit & 0x4)?-1:1;
        for(int i = 0; i < n; ++i) {
            xyz_sum[i] = fx*xyz[i][0] + fy*xyz[i][1] + fz*xyz[i][2];
        }
        sort(xyz_sum, xyz_sum + n);
        for(int i = 0; i < m; ++i) {
            sum += xyz_sum[i];
        }
        sum = abs(sum);
        if(sum > ans) ans = sum;
    }

    cout << ans << '\n';
}


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

const int INF = 1'000'000'000;
struct Edge { int to, cost; };
using P=pair<int, int>;

int V, E;
vector<vector<Edge>> graph;
vector<int> dist;


void Dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P>> pq;
	pq.push({ 0,s });
	dist[s] = 0;

	while (!pq.empty()) {
		P p = pq.top(); pq.pop();
		int v = p.second;
		if (dist[v] < p.first)continue;
		for (auto e : graph[v]) {
			if (dist[e.to] > dist[v] + e.cost) {
				dist[e.to] = dist[v] + e.cost;
				pq.push({ dist[e.to],e.to });
			}
		}
	}
}

int main() {
	int r;
	cin >> V >> E >> r;
	graph = vector<vector<Edge>>(V);
	dist = vector<int>(V, INF);
	for (int i = 0; i < E; i++) {
		int s, t, d;
		cin >> s >> t >> d;
		graph[s].push_back({ t,d });
	}

	Dijkstra(r);
	for (auto d : dist) {
		if (d == INF)puts("INF");
		else cout << d << endl;
	}
}


Measured memory_bytes: 12876
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<stack>
#include<cstdlib>
#include<deque>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>P;
const int len=2e5+5;
const ll mod=998244353;
const ull seed=131;
int main()
{	
	int n,a,b;
	cin>>n>>a>>b;
	int x=0,y=0,z=0;
	for(int i=0;i<n;++i)
	{
		int t;
		cin>>t;
		if(t<=a)x++;
		if(a+1<=t&&t<=b)y++;
		if(t>=b+1)z++;
	}
	cout<<min(x,min(y,z))<<endl;
}




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

int main(){
	string s;
	cin >> s;
	if (s.length() % 2 != 0) {
		cout << "No" << endl;
		return 0;
	}
	int cut = 0;
	string ans, a = s;
	for (char c : s) {
		cut++;
		ans.push_back(c);
		a.erase(0,1);
		if (cut % 2 == 0) {
			if (ans != "hi") {
				cout << "No" << endl;
				return 0;
			} else {
				ans.erase(0);
			}
		}
	}
	if (!a.empty()) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int r, D, x[11];
	cin >> r >> D >> x[0];
	for (int i = 0; i<10; i++) {
		x[i + 1] = r * x[i] - D;
		cout << x[i + 1] << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){
  int a, b, c;
  cin >>a >> b>> c;
  cout <<(a+b)*c/2 fin;
  
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



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

const ll INF = 1e17;
const ll MOD = 1e9+7;

int main() {
    // input, ready
    int N,M;
    cin >> N >> M;

    // output
    if(N==M) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, N) for (int i = 0; i < (N); ++i)
#define rep2(i, a, b) for (ll i = a; i <= b; ++i)
#define rep3(i, a, b) for (ll i = a; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(c) begin(c), end(c)
#define ok() puts(ok ? "Yes" : "No");
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll, ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
// clang++ -std=c++11 -stdlib=libc++

int main() {
  int N;
  cin >> N;
  int T;
  double A;
  cin >> T >> A;
  vi H(N);
  rep(i, N) cin >> H[i];

  double mn = INF;
  int ans = 0;
  rep(i, N) {
    double now = abs(A - (T - H[i] * 0.006));
    if (chmin(mn, now))
      ans = i + 1;
  }
  cout << ans << endl;
  return 0;
}


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

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

  int k = N.size();
  char m =N.at(k-1);

   if (m=='2'||m=='4'||m=='5'||m=='7'||m=='9'){
    cout<<"hon"<<endl;
  }
  else if(m=='0'||m=='1'||m=='6'||m=='8'){
    cout<<"pon"<<endl;
  }
  else if(m=='3'){
    cout<<"bon"<< endl;
  }
  return 0;

 cout<<m<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef int64_t i64;

int main()
{
  string s;
  cin >> s ;

  bool ans = false;

  sort(s.begin(),s.end());
  if(s.at(0) == s.at(1) && s.at(2) == s.at(3) && s.at(0) != s.at(2)) ans = true;
  if(ans) puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n;
  cin >> n;
  vector<int> v(n);
  int sum = 0;
  rep(i,n) {
    cin >> v[i];
    sum += v[i];
  }
  sort(ALL(v));
  if (sum % 10 != 0) {
    cout << sum << endl;
    return;
  }
  rep(i,n) {
    if ((sum - v[i]) % 10 == 0) continue;
    cout << sum - v[i] << endl;
    return;
  }
  cout << 0 << endl;
}

int main() {
  solve();
  return 0;
}

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

vector<vector<ll> > a = {{0, 1, 1}, {1, 0, 1}, {1, 1, 0}}, i1 = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}} ;
int flag = 0;
vector<vector<ll> > mul(vector<vector<ll> > a1, vector<vector<ll> >a2){
	vector<vector<ll> > tmp = a1;
	for(int i=0; i<3; i++){
		for(int j=0; j<3; j++){
			ll sum = 0;
			for(int k=0; k<3; k++){
				if(log(a1[i][k])+log(a2[k][j]) > log(1e18)){
					flag = 1;
				}
				sum += a1[i][k]*a2[k][j];
			}
			tmp[i][j] = sum;
		}
	}
	return tmp;
}
vector<vector<ll> > matexpo(ll k){
	vector<vector<ll> > res = i1;
	while(k){
		if(k%2 == 1){
			res = mul(res, a);
		}
		a = mul(a, a);
		k/=2;
	}
	return res;
}


int main(void){
	ll a, b, c, k;
	cin>>a>>b>>c>>k;
	if(k%2==0){
		cout<<a-b<<endl;
	}else{
		cout<<b-a<<endl;
	}
	
	
}

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

int main(){
  int N;
  cin >> N;
  
  int l, r;
  int ans;
  for(int i = 0; i < N; i++){
    cin >> l >> r;
    ans += (r - l + 1);
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;
using static System.Math;

class MainClass
{

    public static void Main(string[] args)
    {
        var _ = LnLngs();
        var N = _[0];var K = _[1];
        var n =N%K;
        Console.WriteLine(Min(n,Abs(n-K)));
    }


    public static long Gcd(long a, long b) { if (a > b) { var r = a % b; if (r == 0) return b; else return Gcd(b, r); } else { var r = b % a; if (r == 0) return a; else return Gcd(a, r); } }
    public static int Gcd(int a, int b){if (a > b){var r = a % b;if (r == 0) return b; else return Gcd(b, r);}else{ var r = b % a; if (r == 0) return a; else return Gcd(a, r); }}
public static int[] LnInts(){var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);var ins = new int[vs.Length];for (int i = 0; i < vs.Length; i++) ins[i] = int.Parse(vs[i]);return ins;}public static int LnInt(){var vs = Console.ReadLine().Trim();return int.Parse(vs);}public static long[] LnLngs(){var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);var ins = new long[vs.Length];for (int i = 0; i < vs.Length; i++) ins[i] = long.Parse(vs[i]);return ins;}public static long LnLng(){var vs = Console.ReadLine().Trim();return long.Parse(vs);}public static string[] LnStrs(){var vs = Console.ReadLine().Trim().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);return vs;}public static string LnStr(){var vs = Console.ReadLine().Trim();return vs;}}



Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {

	public static void main(String args[]){
		
		Scanner sc = new Scanner(System.in);
		
		int number = Integer.parseInt(sc.next());
		
		for(int i = 1;i<= number;i++){
			
			int x = i;
			
			if(x % 3 == 0){
				System.out.print(" " + i);
				continue;
			}
			
			while(x > 0){
				
				if(x%10 == 3){
					System.out.print(" " + i);
					break;
				}
				
				x /= 10;
			}
			
		}
		System.out.println();
		sc.close();
	}

}



Measured memory_bytes: 28876
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
int main(){
  int n,m;cin >> n >> m;
  vector<int> a(n,0);
  rep(i,m){
    int s,t;cin >> s >> t;
    a[s-1]++;
    a[t-1]++;
  }
  for(auto &i:a) cout << i << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "./libb/lib.hpp"

using namespace std;
const uint64_t MOD = 1000000007;
const double PI = acos(-1);

int main()
{
    uint64_t aa;
    uint64_t bb;
    uint64_t cc;
    uint64_t kk;
    int64_t sum = 0;

    cin >> aa >> bb >> cc >> kk;

    if(aa >= kk){
        cout << kk << endl;
        //cout << "aa out " << endl;
        return 0;
    }

    //cout << "sum" << sum << endl;
    sum = aa;
    kk -= aa;

    if(bb >= kk){
        cout << sum << endl;
        //cout << "bb out " << endl;
        return 0;
    }

   // cout  << "sum" << sum << endl;
    kk -= bb;

    sum -= kk;
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 3584
#include "bits/stdc++.h"
#include <numeric>

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define vi vector<int>

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cerr << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define debug(...) CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) (__VA_ARGS__)

using namespace std;
using ll = long long;
using P = pair<int, int>;

void Main() {
  int n;
  cin >> n;
  string s;
  cin >> s;

  ll ans = 0;
  ll R, G, B;
  R = G = B = 0;
  rep(i, s.size()) {
    if (s[i]=='R') {
      R++;
    } else if (s[i]=='G') {
      G++;
    } else {
      B++;
    }
  }
  ans += R*G*B;
  rep(i, s.size()) {
    for(int j=i+2; j<s.size(); j+=2) {
      char a=s[i];
      char b=s[(i+j)/2];
      char c=s[j];
      if (a!=b&&b!=c&&c!=a) ans--;
    }
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 3660
n=int(input())
a=list(map(int,input().split()))
b=[i for i in a if i<1]
ans=0;k=0
if len(b)%2==0:
    for i in a:ans+=abs(i)
else:
  c=sorted([abs(i) for i in a]);l=c[0]
  for i in a:
    if (i==l or i==-l) and k==0:
      ans=ans+l if l<0 else ans-l
      k+=1
    else:
      ans+=abs(i)
print(ans)

Measured memory_bytes: 14464
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
        int N,M; cin >> N >> M;
        if(N == 0 && M == 0) break;

        VI h(N), w(M);
        REP(i,N) cin >> h[i];
        REP(i,M) cin >> w[i];

        VI acch(N+1), accw(M+1);
        REP(i,N) acch[i+1] = acch[i] + h[i];
        REP(i,M) accw[i+1] = accw[i] + w[i];

        VI hlist, wlist;
        FOR(i,0,N+1) FOR(j,i+1,N+1){
            int tmp = acch[j] - acch[i];
            hlist.eb(tmp);
        }
        FOR(i,0,M+1) FOR(j,i+1,M+1){
            int tmp = accw[j] - accw[i];
            wlist.eb(tmp);
        }

        sort(hlist.begin(), hlist.end());
        sort(wlist.begin(), wlist.end());

        LL ans = 0;

        for(int h : hlist){
            LL cnt = lower_bound(wlist.begin(),wlist.end(),h) - lower_bound(wlist.begin(),wlist.end(), h+1);
            ans -= cnt;
        }
        cout << ans << endl;


    }

}


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

int n, k, a[5000], dp[5001][5000];

void init() {
	for (int i = 0; i < 5001; i++) {
		for (int j = 0; j < 5000; j++) {
			dp[i][j] = false;
		}
	}
	dp[0][0] = true;
}

bool fundp(int x) {//x番目を抜いたdp
	//cout << "a" << endl;
	bool res = false;
	init();
	//cout << "start" << endl;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < k; j++) {
			if (dp[i][j] && j+a[i] < k && i != x)dp[i + 1][j + a[i]] = true;
			dp[i + 1][j] = dp[i + 1][j] || dp[i][j];
		}
	}
	//cout << "midle" << endl;
	for (int i = k-a[x]; i < k; i++) {
		if (i < 0 || dp[n][i]) {
			res = true;
			break;
		}
	}
	return res;
}

int binary() {
	int left = -1, right = n, mid, i = 0;
	while (left+1 != right) {
		mid = (left + right) / 2;
		//cout << ++i << "回目" << endl;
		/*cout << "left:" << left << " right:" << right << endl;
		cout << "mid:" << mid << endl;*/
		if (fundp(mid)) {//fundp(mid)
			right = mid;
		}
		else {
			left = mid;
		}
	}
	return right;
}

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	cout << binary() << endl;
}

Measured memory_bytes: 98048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[5];
int ans;
int main(){
	for(int i=0;i<3;i++){
		cin>>a[i];
	}
	sort(a,a+3);
	
	for(int i=0;i<2;i++){
		ans+=abs(a[i]-a[i+1]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
  	cin >> N;
  	if(N/10%111 == 0 || (N-N/1000)%111 == 0){
    	cout << "Yes" << endl;
    }
  	else cout << "No" << endl;	
  	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp) for(auto& i:mp)

int main() {
  ll a, b, c, k;
  cin >> a>> b>>c>>k;
  ll ans = 0;
  rep(i, k){
    if (a > 0) {
      ans += 1;
      a--;
    }
    else if (b > 0) {
      // ans += 0;
      b--;
    }
    else if(c > 0){
      ans -= 1;
      c--;
    }
  }

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


Measured memory_bytes: 3632
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>
#include <cstdio>

using namespace std;

using ll = long long;

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

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

    ll ans = 1LL;

    for(int i = 0; i < N; i++){
        ll T;
        cin >> T;
        ans = lcm(ans, T);
    }

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


Measured memory_bytes: 256
b=int(input())
a=[]
aa=[]
n=0
i=0
while i<b:
    for x in input().split(" "):
        aa.append(float(x))
    a.append(aa)
    aa=[]
    i+=1
i=0
while i<b:
    j=0
    while j<b:
        if j!=i:
            n+=((a[i][0]-a[j][0])**2+(a[i][1]-a[j][1])**2)**0.5
        j+=1
    i+=1
print(n/b)

Measured memory_bytes: 3064
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let vals = get!([usize]);
    let mut n = 4*get!(usize);
    
    let mut val = 0;
    let vec = vec![8,4,2,1];
    let mut vq = vals.into_iter().rev().zip(vec.into_iter()).collect::<Vec<_>>();
    vq.sort_by(|&(v1,q1), &(v2,q2)| (v1*q2).cmp(&(v2*q1)));
    for (v,q) in vq {
        val += v*(n/q);
        n %= q;
    }
    println!("{}", val);

}


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


int main() {
  int p[10];
  int N; cin >> N;
  for ( int i = 0; i < N; i++ ) cin >> p[i];
  sort(p,p+N,greater<int>());
  int sum = p[0]/2;
  for ( int i = 1; i < N; i++ ) sum += p[i];
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 200005
#define fi(a, b, c, d) for(int a = b; i < c; i += d)
#define fl(a, b, c, d) for(ll a = b; i < c; i += d)
#define quit exit(0)

ll N, K, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;
ll mp[MAX_INT];
ll ncrs[MAX_INT];

int main() {
	scanf("%lld", &N);
	for(int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
		mp[arr[i]]++;
	}	
	ll sum = 0;
	for(int i = 0; i <= N; i++) {
		ncrs[i] = (mp[i] * (mp[i] - 1)) / 2;
		sum += ncrs[i];
	}
	ll temp;
	for(int i = 0; i < N; i++) {
		temp = sum;
		temp -= ncrs[arr[i]];
		temp += ((mp[arr[i]] - 1) * (mp[arr[i]] - 2)) / 2; 
		cout << temp << " \n";
	}

	return 0;
}
/*
	Powered by Buggy Plugin
*/




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

int main(){
    int n,d,x[20][20],ans=0;
    cin>>n>>d;
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin>>x[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int sum=0;
            for(int k=0;k<d;k++){
                sum+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            if(sqrt(sum)==(int)sqrt(sum)) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

const double PI = 3.1415926535897932384626433832795;

struct Player {
  LL place;
  LL point;
};

int main() {
  LL n;
  cin >> n;
  vector<Player> v(n);
  REP(i, n) {
    cin >> v[i].place >> v[i].point;
  }
  sort(ALL(v),
      [](Player &lhs, Player &rhs) -> int {
        return lhs.place < rhs.place;
      });
  LL minpoint = v.back().point;
  LL ans = v.back().place + minpoint;
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(void){
  ll n;
  cin>>n;
  ll j=1,ans=0;
  for(int i=1;i<=n/i;i++){
    if(n%i==0){
      j=i;
    }
  }
  ans=j+n/j-2;
  cout<<ans<<endl;
  return 0;
}

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

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


Measured memory_bytes: 3652
while True:
    n, r = [int(s) for s in input().strip().split()]

    if n == 0 and r == 0:
        break

    cards = list(range(1, n+1))
    cards.reverse()

    for _ in range(r):
        p, c = [int(s) for s in input().strip().split()]

        part1 = cards[0:p-1]
        part2 = cards[p-1:p-1+c]

        cards[0:c] = part2
        cards[c:c+p-1] = part1

    print(cards[0])




Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0);
	//freopen("in.txt", "r", stdin);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ret = 0;
	rep(i,0,n-2) {
		if(s.substr(i,3) == "ABC") {
			ret++;
		}
	}
	cout << ret << '\n';
	return 0;
}

Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll x, y;
  cin >> x >> y;
  if(x%y==0){
    print(-1);
    return 0;
  }
  for(ll i = x; ; i += x){
    if(i%y!=0){
      print(i);
      return 0;
    }
  }
}


Measured memory_bytes: 3644
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = null;
		try{
			List<Integer> dataset = new ArrayList<Integer>();
			scan = new Scanner(new InputStreamReader(System.in));
			while(scan.hasNext()){
				for(int i = 0; i < 8;i++){
					dataset.add(scan.nextInt());
				}
				int hit = 0 , blow = 0;

				for(int i = 0; i < 4;i++){
					for(int j = 4; j <8;j++){
						if(i == (j-4)){
							if(dataset.get(i) == dataset.get(j))hit++;
						}else{
							if(dataset.get(i) == dataset.get(j))blow++;
						}
					}
				}
				System.out.println(hit +" "+blow);
				dataset.clear();
			}
		}finally{
			scan.close();
		}
	}
}

Measured memory_bytes: 18140
import sys
six = [6,36,216,1296,7776,46656]
nine = [9,81,729,6561,59049]

def dfs(n):
    if n < 6:
        return n
    six_max, nine_max = (1, 1)

    for i in six:
        if n < i:
            break
        six_max = i
    
    for i in nine:
        if n < i:
            break
        nine_max = i
    
    ans = 123
    
    if nine_max != 1:
        ans = dfs(n - nine_max) + 1
    if six_max != 1:
        ans = min(ans, dfs(n - six_max) + 1)
    return ans

print(dfs(int(input())))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)

/*
bool isprime(int x){
	for(int i = 2;i*i<=x;i++){
		if(x%i == 0)return false;
	}
	return x!=1;
}
int gcd(int a, int b) 
{ 
    if (a == 0) 
       return b; 
    if (b == 0) 
       return a; 
   
    if (a == b) 
        return a; 
   
    if (a > b) 
        return gcd(a-b, b); 
    return gcd(a, b-a); 
} 
void dfs(int x,int y){
		if(x == n+1){
			int tmp = 0;
			FOR(i,0,k){
				if(tmp1[mortyy[i]]-tmp1[morty[i]] == mortyyy[i])tmp+=mortyyyy[i];
			}
			rick = max(rick,tmp);
			return ;
		}
		int i;
		for(i = y;i<=n1;i++){
			tmp1[x] = i;
			dfs(x+1,i);
		}
	}
*/


//3111111111111111111111111111111




	void solve(){
		ini(n);
		ini(n1);
		string morty[n];
		FOR(i,0,n){
			in(morty[i]);
		}
		int morty1[n][n1][4];
		FOR(i,0,n)FOR(i1,0,n1)FOR(i2,0,4)morty1[i][i1][i2] = 0;
		FOR(i,0,n1){
			int tmp = 0;
			FOR(i1,0,n){
				if(morty[i1][i] == '.'){tmp++;morty1[i1][i][0] = tmp;}
				else tmp = 0;
			}
			tmp = 0;
			for(int i1 = n-1;i1>=0;i1--){
				if(morty[i1][i] == '.'){tmp++;morty1[i1][i][1] = tmp;}
				else tmp = 0;
			}
		}
		FOR(i,0,n){
			int tmp = 0;
			FOR(i1,0,n1){
				if(morty[i][i1] == '.'){tmp++;morty1[i][i1][2] = tmp;}
				else tmp = 0;
			}
			tmp = 0;
			for(int i1 = n1-1;i1>=0;i1--){
				if(morty[i][i1] == '.'){tmp++;morty1[i][i1][3] = tmp;}
				else tmp = 0;
			}
		}
		int rick = 0;
		FOR(i,0,n){
			FOR(i1,0,n1){
				rick = max(rick,morty1[i][i1][0]+morty1[i][i1][1]+morty1[i][i1][2]+morty1[i][i1][3]-3);
			}
		}
		out(rick);







	}









































int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}

Measured memory_bytes: 129536
N, M = map(int,input().split())

list_a = []
list_b = []
count = 0

for i in range(N):
    a = [int(i) for i in input().split()]
    list_a.append(a)
    
for i in range(M):
    b = [int(i) for i in input().split()]
    list_b.append(b)
    
for i in range(N):
    ans_x = 10**18
    for j in range(M):
        x = abs(list_a[i][0]-list_b[j][0])
        y = abs(list_a[i][1]-list_b[j][1])
        xxx = x + y
        if xxx < ans_x:
            ans_x = xxx
            count = j+1
    print(count)


    

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

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

#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ll long long
#define ld long double
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)

#define xx first
#define yy second
#define mp make_pair
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define pdd pair<double,double>
#define ALL(v) (v).begin(), (v).end()

const ll MOD=1e9+7; ;
const ll inf=1e10;

#define MODSET(d) if ((d) >= MOD) d %= MOD;
#define MODNEGSET(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;
#define put(x) cout<<#x<<" = "<<x<<endl;

ll power(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a);
        n>>=1;
        a=(a*a);
    }
    return ans;
}


ll powerMod(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%MOD;
        n/=2;
        a=(a*a)%MOD;
    }
    return ans;
}

ll powerMod1(ll a,ll n,ll mod){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%mod;
        n>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

ll lcm(ll a,ll b){
    return a*(b/__gcd(a,b));
}

ll sumdigit(ll n){
    ll sum=0;
    while(n){
        sum+=n%10;
        n=n/10;
    }
    return sum;
}

ll countSetBit(ll a){
    return __builtin_popcount(a);
}
ll countBit(ll a){
    ll sum=0;
    while(a){
        sum++;
        a>>=1;
    }
    return sum;
}

ll length(ll a){
    ll ans=0;
    while(a){
        ans++;
        a=a/10;
    }
    return ans;
}

bool isVowel(char c){
	if(c=='a' or c=='e' or c=='i' or c=='o' or c=='u')
		return true;
	return false;
}


int main()
{
    fast;
    ll t;
    
    //~ cin>>t;
    t=1;
    while(t--){
			ll a,b;
			cin>>a>>b;
			if(a>b)
				swap(a,b);
			if(a==1){
				if(b==2)
					cout<<3;
				else cout<<2<<endl;
			}else{
				cout<<1;
			}
    }
    return 0;
}


Measured memory_bytes: 256