akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using Graph = vector<vector<LL>>;

long long gcd(long long a, long long b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
long long chmax(long long a,long long b){
  a = max(a,b);
}
long long chmin(long long a, long long b){
  a = min(a,b);
}
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true;

    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v);
    }
}



int main() {
  LL n,k,sum=0,a=0,b=0,c=0,d=0,ans=0;
  LL MOD = 1000000007;
  LL INF = 1LL << 60;
  string S="";
  cin >> S;
  if(S=="ABC") S = "ARC";
  else S = "ABC";
  cout << S << endl;
}

Measured memory_bytes: 3640
#include<stdio.h>
int main()
{
int a,i,max,min;
scanf("%d",&a);
  min=1000;
  max=0;
int b[a];
  for(i=0;i<a;++i)
  {
  scanf("%d",&b[i]);
  if(b[i]<min) min=b[i];
  if(max<b[i]) max=b[i];
  }

printf("%d",max-min);

return 0;
}


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

vector<long> ans;

void dfs(long n, int d) {
  if (d == 10) {
    return;
  }
  int mi = max(0L, n % 10 - 1);
  int mx = min(9L, n % 10 + 1);
  for (int i = mi; i <= mx; i++) {
    ans.push_back(n * 10 + i);
    dfs(n * 10 + i, d + 1);
  }
}

int main() {
  int K;
  cin >> K;
  for (int i = 1; i <= 9; i++) {
    ans.push_back(i);
    dfs(i, 1);
  }
  sort(ans.begin(), ans.end());
  cout << ans.at(--K) << "\n";
}

Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include<map>
using namespace std;

int dp[90008];


int main() {
	int  H, W, D;
	cin >> H >> W >> D;

	int a;

	int A[90008], B[90008];


	for (int i = 1; i <= H; i++) {

		for (int k = 1; k <= W; k++) {
			cin >> a;

			A[a] = i;
			B[a] = k;
		}
	}
	
	for (int i = 1; i+D <= H*W; i++) {
		dp[i + D] = dp[i] + abs(A[i] - A[i + D]) + abs(B[i] - B[i + D]);
	}
	int Q;
	cin >> Q;
	vector<int> vec(Q);
	int b;
	for (int i = 0; i < Q; i++) {
		cin >> a >> b;
		vec[i] = dp[b] - dp[a];
	}
	for (int i = 0; i < Q; i++) {
		cout << vec[i] << endl;
	}


	return 0;
}



Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll INF = 1e14;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;

int main() {
    int N,M;
    cin >> N >> M;
    vector<int> S[20];
    for(int i = 0;i < M;i++) {
        int A;
        cin >> A;
        for(int j = 0;j < A;j++) {
            int B;
            cin >> B;
            S[B - 1].push_back(i);
        }
    }
    int ret = 0;
    vector<int> P(M);
    for(int i = 0;i < M;i++) {
        cin >> P.at(i);
    }
    for(int bit = 0;bit < (1 << N);bit++) {
        vector<int> cnt(N);
        for(int i = 0;i < N;i++) {
            if(bit & (1 << i)) {
                cnt.at(i) = 1;
            }
            else {
                cnt.at(i) = 0;
            }
        }
        vector<int> count(M);
        for(int i = 0;i < N;i++) {
            if(cnt.at(i) == 1) {
                for(int j = 0;j < S[i].size();j++) {
                    count.at(S[i].at(j))++;
                }
            }
        }
        int cnt2 = 0;
        for(int i = 0;i < M;i++) {
            if(count.at(i) % 2 == P.at(i)) {
                cnt2++;
            }
        }
        if(cnt2 == M) {
            ret++;
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int[][] students = new int[n][2];
		int[][] points = new int[m][2];
		for (int i = 0 ; i < n ; i++){
			students[i][0] = scanner.nextInt();
			students[i][1] = scanner.nextInt();
		}
		for (int i = 0 ; i < m ; i++){
			points[i][0] = scanner.nextInt();
			points[i][1] = scanner.nextInt();
		}
		
		int[] results = new int [n];
		for (int i = 0 ; i < n ; i++){
			int minIndex = 0;
			int minDist = Integer.MAX_VALUE;
			for (int j = 0 ; j < m ; j++){
				int dist = Math.abs(students[i][0] - points[j][0]) + Math.abs(students[i][1] - points[j][1]);
				if (dist < minDist){
					minDist = dist;
					minIndex = j;
				}			
			}
			results[i] = minIndex + 1;
		}
		for (int i = 0 ; i < n ; i++){
			System.out.println(results[i]);
		}
	}
} 

Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <algorithm>
#define llint long long

using namespace std;

llint n, m;
llint h[1505], w[1505];
llint sumh[1505], sumw[1505];
vector<llint> vech, vecw;

int main(void)
{
  while(1){
    cin >> n >> m;
    if(n == 0 && m == 0) break;

    for(int i = 1; i <= n; i++) cin >> h[i];
    for(int i = 1; i <= m; i++) cin >> w[i];

    vecw.clear(), vech.clear();

    for(int i = 1; i <= n; i++) sumh[i] = sumh[i-1] + h[i];
    for(int i = 1; i <= m; i++) sumw[i] = sumw[i-1] + w[i];

    for(int i = 1; i <= n; i++){
      for(int j = 1; j <= n; j++){
        if(i > j) continue;
        vech.push_back(sumh[j] - sumh[i-1]);
      }
    }
    for(int i = 1; i <= m; i++){
      for(int j = 1; j <= m; j++){
        if(i > j) continue;
        vecw.push_back(sumw[j] - sumw[i-1]);
      }
    }
    sort(vecw.begin(), vecw.end());

    llint ans = 0;
    for(int i = 0; i < vech.size(); i++){
      ans += upper_bound(vecw.begin(), vecw.end(), vech[i]) - lower_bound(vecw.begin(), vecw.end(), vech[i]);
    }
    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 28560
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
using namespace std;
#define INF 100000000

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

int main(){
    int N;cin>>N;
    vector<int> A(N);
    for(int i = 0; i < A.size(); i++)
    {
        cin>>A[i];
    }
    cout<<std::accumulate(A.begin()+1,A.end(),A[0],gcd)<<endl;
}

Measured memory_bytes: 640
#E_Picking Goods
R,C,K = map(int,input().split())
A =     [[0  for j in range(C)] for i in range(R)]
varr = [[[0  for j in range(C)] for i in range(R)] for k in range(4)]

for inputk in range(K):
    r,c,v = map(int,input().split())
    A[r-1][c-1] = v

for i in range(R):  
    for j in range(C):
        for k in range(2,-1,-1):
            if varr[k][i][j] >= 0:
                if  varr[k+1][i][j] < varr[k][i][j] + A[i][j]:
                    varr[k+1][i][j] = varr[k][i][j] + A[i][j]
        for kk in range(0,4):
            if varr[kk][i][j] >= 0:
                if i +1 < R :
                    if  varr[0][i + 1][j] < varr[kk][i][j]:
                        varr[0][i + 1][j] = varr[kk][i][j] 
                if j +1 < C :
                    if  varr[kk][i][j + 1] < varr[kk][i][j]:
                        varr[kk][i][j + 1] = varr[kk][i][j] 
ans = 0
for k in range (4):
    if ans < varr[k][R-1][C-1]:
        ans = varr[k][R-1][C-1]

print(ans)


Measured memory_bytes: 470208
#include <iostream>
using namespace std;
int main(){
    int n,m,c,ans=0,sum; cin >> n >> m >> c;
    int B[m]; for (int i=0;i<m; i++) cin >> B[i];
    int A[n][m];
    for (int i=0; i<n; i++){
        sum = 0;
        for (int j=0; j<m; j++){
            cin >> A[i][j];
            sum += A[i][j]*B[j]; 
        }
        if (sum + c > 0) ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

long long solve(const vector<vector<int>>& m){
	const int n = m.size();
	for(int k=0;k<n;k++){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(m[i][k]+m[k][j] < m[i][j]) return -1;
			}
		}
	}
	long long res = 0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			bool require = true;
			for(int k=0;k<n;k++){
				if(i==k || j==k) continue;
				if(m[i][j] == m[i][k]+m[k][j]) require = false;
			}			
			if(require) res += m[i][j];
		}
	}
	return res;
}

int main(){
	int n;
	while(cin >> n){
		vector<vector<int>> A(n, vector<int>(n));
		for(auto& v : A){
			for(auto& t : v) cin >> t;
		}
		cout << solve(A) << endl;
	}
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define sync()      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fileIO()    freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
#define F           first
#define S           second
#define ers         erase
#define ins         insert
#define db          pop_back
#define pb          push_back
#define df          pop_front
#define pf          push_front
#define SZ(x)       ((ll)x.size())
#define sqr(x)      (x)*(x)
#define Blz(x)      __builtin_clz(x)
#define Brz(x)      __builtin_ctz(x)
#define Bones(x)    __builtin_popcount(x)
#define all(x)      x.begin(),x.end()
#define kill(x)     return cout<<x,0
#define dbgp(x)     cerr<< #x << " = " << x.F << ", " << x.S << endl
#define dbg(x)      cerr<< #x << " = " << x << endl
#define ddbg(i,x)   cerr<< #i << " = " << i << " / ", dbg(x[i])
#define tdbg(i,E,x) cerr<< #i << " = " << i << " / ", ddbg(E,x[i])
typedef long long                                    ll;
typedef long double                                  ld;
typedef unsigned short int                           usi;
typedef pair<long long,bool>                         plb;
typedef pair<long long,long long>                    pll;
typedef pair<int,int>                                pii;
typedef string                                       str;
typedef priority_queue<ll>                           maxheap;
typedef priority_queue<ll,vector<ll>,greater<ll>>    minheap;
typedef priority_queue<pll,vector<pll>,greater<pll>> djq;
const ll maxn=2e5+10, wax=20, inf=4e18, mod=1e9+7; const ld pi=3.14159265359, eps=1e-9;
int main(){
    sync();
    ll n; cin>>n;

    ll jj=0,v;
    for(int i=1;i<=n;i++) cin>>v, jj=__gcd(jj,v);
    cout<<jj;
    return 0;
}
/**

 (                            )   (   )
 )\ )             (      )  ( /(  () /(
(()/(  (  (    (  )\  ( /(  )\()) )\ ())
 /(_))_)  )\   )\((_) )(_))(_)\) ((_)(_)
(_)) __| ((_) ((_)| |((_)_)| |(_)| |_| |
  | (_ |/ _ \/ _ \| |/ _` || / / |  _  |
   \___|\___/\___/|_|\__,_||_\_\ |_| |_|

I'm burning in rage and hatred...
**/


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };
int x[3];
signed main(){
	cin >> x[0] >> x[1] >> x[2];
	sort(x, x+3);
	if((x[0] == x[1] || x[1] == x[2]) && x[0] != x[2]) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  
  int a[3]= {1,0,0},t=0;
  char x,y,z,e;
  
  while(scanf("%c%c%c%c",&x,&y,&z,&e)!=EOF)
    {
      //printf("%c%c%c\n",x,y,z);
      // printf("aaaaaaaaaa\n");

      if(x=='A' && z=='B' || x=='B' && z=='A')
	{
	  t=a[0];
	  a[0]=a[1];
	  a[1]=t;
	}
      else if(x=='A' && z=='C' || x=='C' && z=='A')
	{
	  t=a[0];
	  a[0]=a[2];
	  a[2]=t;
	}
      else if(x=='B' && z=='C' || x=='C' && z=='B')
	{
	  t=a[1];
	  a[1]=a[2];
	  a[2]=t;
	}
      // if(a[0]==1)printf("A\n");
      // else if(a[1]==1)printf("B\n");
      //else if(a[2]==1)printf("C\n");
    }
  if(a[0]==1)printf("A\n");
  else if(a[1]==1)printf("B\n");
  else if(a[2]==1)printf("C\n");
  
  return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n; cin>>n;
    vector<ll> r(n);
    rep(i,n) cin>>r[i];
    ll maxi=-INF,mini=r[0];
    for(int i=1;i<n;i++){
        maxi=max(maxi,r[i]-mini);
        mini=min(mini,r[i]);
    }
    cout<<maxi<<endl;
    return 0;
}


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

int main() {
	string s;
    cin>>s;
  
  if(s.at(0)==s.at(1)){
  	if(s.at(0)!=s.at(2)&&s.at(2)==s.at(3)){
    	cout<<"Yes"<<endl;
    }
    else
      cout<<"No"<<endl;
  }
  else if(s.at(0)==s.at(2)){
  	if(s.at(0)!=s.at(1)&&s.at(1)==s.at(3)){
    	cout<<"Yes"<<endl;
    }
     else
      cout<<"No"<<endl;
  }
  else if(s.at(0)==s.at(3)){
  	if(s.at(0)!=s.at(1)&&s.at(1)==s.at(2)){
    	cout<<"Yes"<<endl;
    }
     else
      cout<<"No"<<endl;
  }
  else
    cout<<"No"<<endl;
    
    
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long ll;
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//const int dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

vector<ll> a, b;

int main()
{
	ll n,r;
	ll ans;
	cin >> n >> r;

	if (n >= 10) {
		ans = r;
	}
	else {
		ans = r + 100 * (10 - n);
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <cmath>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
typedef pair<ll, ll> p;
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 long long mod = 1e9 + 7;
ll dx[] = { 1,0 };
ll dy[] = { 0,1 };

bool judge(vector<string> A, vector<string> B, ll a, ll b);
ll N, M, x, y;

int main() {


    cin >> N >> M;

    vector<string>A(N), B(M);

    rep(i, N) {
        cin >> A[i];
    }

    rep(i, M) {
        cin >> B[i];
    }

    x = B.size();
    y = B[0].size();


    bool ans = false;

    rep(i, N - x + 1) {
        rep(j,  A[0].size() - y + 1) {
            if (A[i][j] == B[0][0] && A[i + x - 1][j + y - 1] == B[x - 1][y - 1]) {
                if (judge(A, B, i, j)) {
                    ans = true;
                    break;
                }
            }
        }
    }

    if (ans) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    return 0;
}

bool judge(vector<string> A, vector<string> B, ll a, ll b) {
    bool ans = true;
    rep(i, M) {
        rep(j, y) {
            if (A[i + a][j + b] != B[i][j]) {
                return false;
            }
        }
    }
    return true;
}

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


int main()
{
  string s;
  int c=0;
  
  cin >> s;
  for ( int i=0; i<s.length(); i++ ) {
    if ( s[i] == '1' ) c++;
  }
  cout << c << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int i,j;
  int y;
for(i=1;i<=9;i++){
for(j=1;j<=9;j++){
  y = 0;
  y = i * j;
 printf("%dx%d=%d", i , j ,y);
 printf("\n");
}
}
 return 0;
}

Measured memory_bytes: 524
#include <cstdio>
using namespace std;

int main(){
    int a, b, i, j, k;
    i = 1;
    j = 1;
    k = 1;
    while (k == 1){
        scanf("%d %d", &a, &b);
        if (a == 0 && b == 0){
            break;
        } else {
            while (i <= a){
                if (i % 2 == 1) {
                    while (j <= b){
                        if (j % 2 == 1){
                            printf("#");
                            
                        } else {
                            printf(".");
                        }
                        j += 1;
                    }
                } else {
                    while (j <= b){
                        if (j % 2 == 1){
                            printf(".");
                        } else {
                            printf("#");
                        }
                        j += 1;
                    }
                }
                j = 1;
                i += 1;
                printf("\n");
            }
            i = 1;
        }
        printf("\n");
        a = 0;
        b = 0;
    }
    return 0;
}


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

int main () {
  
  int A, B, C;
  cin >> A >> B >> C;
  
  int count = 0;
  int i;
  
  for (i = 0; i < C; i++) {
    
    B -= A;
    if (B < 0) break;
    
  }
  
  cout << i << endl;
  
}

Measured memory_bytes: 256
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let c: String = read_as_string();
    if c == c.to_lowercase() {
        println!("a");
    } else {
        println!("A");
    }
}


Measured memory_bytes: 2164
print([1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309, 3524578, 5702887, 9227465, 14930352, 24157817, 39088169, 63245986, 102334155, 165580141, 267914296, 433494437, 701408733, 1134903170][int(input())])

Measured memory_bytes: 7684
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
using namespace std;
int s,a[4];
int main()
{
  cin>>s;
  a[0]=s%10;
  a[1]=s%100/10;
  a[2]=s%1000/100;
  a[3]=s/1000;
  if(a[0]==a[1]&&a[1]==a[2]){cout<<"Yes"<<endl;return 0;}
  if(a[1]==a[2]&&a[2]==a[3]){cout<<"Yes"<<endl;return 0;}
  cout<<"No"<<endl;
  return 0;
}


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

using namespace std;

vector<int> h(100005);
vector<long long int> dp(100005, -1);

long long int solve(int n, int k)
{
    long long int least = LONG_LONG_MAX;
    if(dp[n] != -1)
        return(dp[n]);
    if(n <= k+1)
        return(dp[n] = abs(h[n]-h[1]));
    for(int i=1;i<=k;i++)
        least = min(least, solve(n-i, k) + abs(h[n]-h[n-i]));
    return(dp[n] = least);
}

int main()
{
    int n, k;
    long long int ans;
    cin >> n >> k;
    for(int i=1;i<=n;i++)
        cin >> h[i];
    ans = solve(n, k);
    cout << ans << endl;
    return(0);
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int N;cin>>N;
    if(N%2==0)cout<<N<<endl;
    else cout<<2*N<<endl;
}


Measured memory_bytes: 256
module Main where

import           Control.Monad

main :: IO ()
main = do
    [h, _] <- (map read . words) <$> getLine :: IO [Int]
    list   <- map (map read . words) <$> (replicateM h) getLine :: IO [[Int]]
    let res1 = (map goRight . enumerate2d) list
    let
        result = concat
            [(concatMap fst) res1, (fst . goRight . map (last . snd)) res1]

    putStr
        $ (unlines . (((show . length) result) :) . map
              ((unwords . map show) . (\((a, b), (c, d)) -> [a, b, c, d]))
          )
              result

    return ()
goRight
    :: [((Int, Int), Int)] -> ([((Int, Int), (Int, Int))], [((Int, Int), Int)])
goRight []  = ([], [])
goRight [x] = ([], [x])
goRight (a@(aPoint, aValue) : b@(bPoint, _) : xs) = if even aValue
    then mapSnd (a :) (goRight (b : xs))
    else
        let (resMove, resMap) = goRight (mapSnd (+ 1) b : xs)
        in  ((aPoint, bPoint) : resMove, mapSnd (subtract 1) a : resMap)

enumerate :: [a] -> [(Int, a)]
enumerate = zip [1 ..]

enumerate2d :: [[a]] -> [[((Int, Int), a)]]
enumerate2d =
    (map (\(y, a) -> (map (\(x, b) -> ((y, x), b)) . enumerate) a) . enumerate)

mapTuple :: (t1 -> a) -> (t2 -> b) -> (t1, t2) -> (a, b)
mapTuple f1 f2 (a, b) = (f1 a, f2 b)

mapFst :: (t1 -> a) -> (t1, b) -> (a, b)
mapFst = flip mapTuple id

mapSnd :: (t2 -> b) -> (a, t2) -> (a, b)
mapSnd = mapTuple id


Measured memory_bytes: 63228
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

MOD = 1000000007

def smax(a,b):
    if a>b:
        return a
    else:
        return b

def smin(a,b):
    if a<b:
        return a
    else:
        return b

def main():
    N = int(readline())
    s = 0
    for i in range(1,N+1):
        if i%5!=0 and i%3!=0:
            s += i
    print(s)

if __name__ == '__main__':
    main()

Measured memory_bytes: 67136
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    ll H;
    cin >> H;
    ll a = log2(H)+1;
    ll b = pow(2,a)-1;
    cout <<b<< "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int Res = 0;
    for (int n = 0; n < N; ++n) {
        int h;
        cin >> h;
        if (h >= K) ++Res;
    }
    cout << Res << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int i;
  int best[3]={0,0,0};
  int data[10];
  for(i=0;i<10;i++){
    scanf("%d",&data[i]);
  }
  for(i=0;i<10;i++){
    if(best[0]<=data[i]){
      best[2]=best[1];
      best[1]=best[0];
      best[0]=data[i];
    }
    else if(best[1]<=data[i]){
      best[2]=best[1];
      best[1]=data[i];
    }
    else if(best[2]<=data[i]){
      best[2]=data[i];
    }
  }
  printf("%d\n%d\n%d\n",best[0],best[1],best[2]);
  return(0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
map<pii, ll> dp, dpn;
int x[3], n;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, 3) cin >> x[i];
  dp[mp(0, 0)] = 1;
  x[1] += x[0];
  x[2] += x[1];
  ll ans = 0;
  FOR(i, 0, n){
    ans *= 10;
    each(itr, dpn) itr->se = 0;
    each(itr, dp){
      FOR(j, 1, 11){
        int f = itr->fi.fi, s = itr->fi.se;
        f += ((1<<(j-1))-1)<<(s+1);
        s += j;
        int _f = f, _s = s;
        while((f&1) || ((f>>x[0])&1) || ((f>>x[1])&1) || ((f>>x[2])&1)){
          f >>= 1;
          s--;
        }
        if(s == x[2]){
          ans += itr->se;
        }else{
          dpn[mp(f, s)] = (dpn[mp(f, s)] + itr->se) % mod;
        }
      }
    }
    swap(dp, dpn);
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2432
#include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl


int main(){
	li p;
	stack<li> stk;
	
	while(cin>>p){
		if(p>0)stk.push(p);
		else{
			cout<<stk.top()<<endl;
			stk.pop();
		}
	}
	
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
    
#define sz(x) (int) (x).size()
#define INF 0x3f3f3f3f
#define pb push_back
    
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
    
const int N = 3005;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s, t;
    cin >> s >> t;
    int n = sz(s), m = sz(t);
    vector<vector<int>> dp(n + 1, vector<int>(m + 1));
    for (int i = n - 1; i >= 0; i--) {
        for (int j = m - 1; j >= 0; j--) {
            if (s[i] == t[j]) dp[i][j] = 1 + dp[i + 1][j + 1];
            else dp[i][j] = max(dp[i + 1][j], dp[i][j + 1]);
        }
    }
    int res = dp[0][0] - 1;
    string ans = "";
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (dp[i][j] != dp[i + 1][j] && dp[i][j] != dp[i][j + 1] && dp[i + 1][j + 1] == res) {
                ans += s[i];
                res--;
                break;
            }
        }
    }
    cout << ans << "\n";

    //cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}

Measured memory_bytes: 38580
# coding: utf-8

num, mini, maxi = map(int, input().rstrip().split())
hani = range(mini,maxi+1)

atari = []

for i in range(1,num+1):
    num_list = list(map(int, str(i)))
    goukei = sum(num_list)
    if goukei in hani:
        atari.append(i)
    #print(atari)

print(sum(atari))


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

typedef long long ll;

const long long MOD = 1000000007;
long long modpow(long long a, long long n, long long m)
{
    long long ans = 1;
    while (n)
    {
        if (n & 1)
        {
            ans = (ans * a) % m;
        }
        a = (a * a) % m;
        n >>= 1;
    }
    return ans;
}
long long combi(long long n, long long a)
{
    long long ans = 1, ans1 = 1;
    for (long long i = n - a + 1; i <= n; i++)
    {
        ans *= i % MOD;
        ans %= MOD;
    }

    for (long long i = 2; i <= a; i++)
        ans1 = (ans1 * i) % MOD;
    ans1 = modpow(ans1, MOD - 2, MOD);
    return ((ans % MOD) * ans1) % MOD;
}

void dfs(string s, char mx, ll N)
{
    if (s.length() == N)
    {
        cout << s.c_str() << endl;
    }
    else
    {
        for (char c = 'a'; c <= mx; c++)
        {
            dfs(s + c, ((c == mx) ? (char)(mx + 1) : mx), N);
        }
    }
}

int bfs(int a, int b, int h, int w, char tmp[][101])
{
    int ans[101][101] = {0};
    char c[101][101] = {0};
    queue<pair<int, int>> s;

    for (int i = 0; i <= h; i++)
    {
        for (int j = 0; j <= w; j++)
        {
            c[i][j] = tmp[i][j];
        }
    }

    s.push(make_pair(a, b));

    while (s.size() > 0)
    {

        pair<int, int> tmp = s.front();
        s.pop();
        c[tmp.first][tmp.second] = '#';
        for (int i = -1; i <= 1; i++)
        {
            for (int j = -1; j <= 1; j++)
            {
                if (tmp.first + i < 1 || tmp.first + i > h)
                {
                    continue;
                }
                if (tmp.second + j < 1 || tmp.second + j > w)
                {
                    continue;
                }
                if (i != 0 && j != 0)
                {
                    continue;
                }
                if (i == 0 && j == 0)
                {
                    continue;
                }
                if (c[tmp.first + i][tmp.second + j] == '#')
                {
                    continue;
                }
                c[tmp.first + i][tmp.second + j] = '#';
                if (ans[tmp.first + i][tmp.second + j] == 0)
                {
                    ans[tmp.first + i][tmp.second + j] = ans[tmp.first][tmp.second] + 1;
                }
                else
                {
                    ans[tmp.first + i][tmp.second + j] = min(ans[tmp.first + i][tmp.second + j], ans[tmp.first][tmp.second] + 1);
                }
                s.push(make_pair(tmp.first + i, tmp.second + j));
            }
        }
    }

    int asd = 0;

    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            asd = max(a, ans[i][j]);
        }
    }

    return asd;
}

int main()
{
    ll n;
    string s, t;

    cin >> n >> s >> t;

    int tmp = n;
    for(int i=0; i<n; i++){
        string a = s.substr(i);
        string b = t.substr(0, n-i);
        if(a == b) break;
        tmp -= 1;
    }
    cout << 2*n-tmp << endl;
    return 0;
}

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

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

    ll ans = n * pow(100, d);
    if (n == 100) ans += pow(100, d);

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


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {


	final int MOD = 1000000007;


	public static void main(String[] args) {

		long ans = 0;
		Scanner sc = new Scanner(System.in);
		boolean f = false;

//		int n = sc.nextInt();
		int k = sc.nextInt();

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

		for(int i = 1; i <= k; i++) {
			for(int j = 1; j <= k; j++) {
				int tmpGcd = gcd(i, j);
				for(int l = 1; l <= k; l++) {
					ans += gcd(tmpGcd, l);
				}
			}
		}


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

//		if(f) {
//			System.out.println("Yes");
//		} else {
//			System.out.println("No");
//		}

		System.out.println(ans);

		sc.close();
	}

	static int gcd (int a, int b) {
		int temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
}

Measured memory_bytes: 35824
// 096 C Grid repainting
#include <bits/stdc++.h>
using namespace std;

int main(){

    int H, W;
    cin >> H >> W;
    string board[50];

    for (int i = 0; i < H; i++) 
    {
        cin >> board[i];
    }

    const int dx[4] = {0, -1, 1, 0};
    const int dy[4] = {-1, 0, 0, 1};


    bool ret = true;
    bool ret_temp = false;

    for (int i =0; i < H; i ++)    {
        for (int j = 0; j < W; j ++)    {
            ret_temp = false;    
            if (board[i][j] == '.')
                continue;
            for (int d = 0; d < 4; d ++){
                const int ni = i + dy[d];
                const int nj = j + dx[d];            

                if (ni < 0 or ni >= H) continue;
                if (nj < 0 or nj >= W) continue;
                if (board[ni][nj] == '#') 
                {
                    ret_temp = true;
                    break;
                }
            }
            if (ret_temp == false){
                cout << "No" << endl; 
                return 0;               
            }
        }
    }
    cout << "Yes" << endl;

}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <cstdint>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace std;

static ll dp[3001][3001][4];
static ll te[3001][3001];
int main(void){
    
    ll R, C, K;
    cin>>R>>C>>K;
    ll r, c, v;
    
    MEMSET(te, 0);
    MEMSET(dp, 0);
    rep(i, K){
        cin>>r>>c>>v;
        te[c-1][r-1]=v;
    }
    dp[0][0][1]=te[0][0];
    rep(j, R) rep(i, C){
        rep1(k, 3) dp[i+1][j][k]=max({dp[i+1][j][k], dp[i][j][k], dp[i][j][k-1]+te[i+1][j]});
        dp[i+1][j][0]=max({dp[i+1][j][0], dp[i][j][0]});
        rep(k, 4) dp[i][j+1][0]=max(dp[i][j][k], dp[i][j+1][0]);
        rep(k, 4) dp[i][j+1][1]=max(dp[i][j][k]+te[i][j+1], dp[i][j+1][1]);
    }
    ll Maxim=0;
    rep(i, 4){
        Maxim=max(Maxim, dp[C-1][R-1][i]);
    }
    cout<<Maxim<<endl;
    return 0;
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

bool ok[50][50][50][50];
int main(){
  while(1){
    int h,w;
    cin >> w >> h;
    if(h==0) return 0;
    vector<string> l(h),r(h);
    for(int i=0;i<h;i++) cin >> l[i] >> r[i];
    for(int i=0;i<h;i++) reverse(all(r[i]));
    int lsx,lsy,lgx,lgy,rsx,rsy,rgx,rgy;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(l[i][j]=='L'){
          lsy=i,lsx=j;
          l[i][j]='.';
        }else if(l[i][j]=='%'){
          lgy=i,lgx=j;
          l[i][j]='.';
        }
        if(r[i][j]=='R'){
          rsy=i,rsx=j;
          r[i][j]='.';
        }else if(r[i][j]=='%'){
          rgy=i,rgx=j;
          r[i][j]='.';
        }
      }
    }
    queue<pair<pair<int,int>,pair<int,int>>> bfs;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        for(int k=0;k<h;k++){
          for(int l=0;l<w;l++){
            ok[i][j][k][l]=false;
          }
        }
      }
    }
    bfs.push({{lsx,lsy},{rsx,rsy}});
    ok[lsy][lsx][rsy][rsx]=true;
    vector<int> vx={1,0,-1,0},vy={0,-1,0,1};
    int lnx,lny,rnx,rny;
    pair<pair<int,int>,pair<int,int>> now;
    while(!bfs.empty()){
      now=bfs.front();
      bfs.pop();
      // cout << now.first.first SP now.first.second SP now.second.first SP now.second.second << endl;
      for(int i=0;i<4;i++){
        lnx=now.first.first+vx[i];
        lny=now.first.second+vy[i];
        rnx=now.second.first+vx[i];
        rny=now.second.second+vy[i];
        if(0<=lnx&&lnx<w&&0<=lny&&lny<h){
          if(l[lny][lnx]=='#'){
            lnx=now.first.first;
            lny=now.first.second;
          }
        }else{
          lnx=now.first.first;
          lny=now.first.second;
        }
        if(0<=rnx&&rnx<w&&0<=rny&&rny<h){
          if(r[rny][rnx]=='#'){
            rnx=now.second.first;
            rny=now.second.second;
          }
        }else{
          rnx=now.second.first;
          rny=now.second.second;
        }
        if(!ok[lny][lnx][rny][rnx]){
          ok[lny][lnx][rny][rnx]=true;
          if((!(lnx==lgx&&lny==lgy))&&(!(rnx==rgx&&rny==rgy))) bfs.push({{lnx,lny},{rnx,rny}});
        }
      }
    }
    if(ok[lgy][lgx][rgy][rgx]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}



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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vll l(n), r(n);
  REP(i, q)
    cin >> l[i] >> r[i];

  vll aCount(n, 0);
  ll sum = 0;
  REP(i, n){
    aCount[i] = sum;
    if(s[i] == 'A' && s[i+1] == 'C' && i != n-1)
      sum++;
  }

  REP(i, q)
    cout << aCount[r[i]-1] - aCount[l[i]-1] << "\n";

  
  
}


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

int n, arr[100010], maks, ans;
int main()
{
    cin>>n;
    for (int i = 1; i <=n; i++) cin>>arr[i];
    for (int i = 1; i <=n; i++)
    {
        if (arr[i]>=arr[i+1] && i!=n) ans++;
        else ans=0;
        if (ans>maks) maks=ans;
    }
    cout<<maks<<endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

int main(){
  int n;
  int a[100001];

  cin>>n;
  rep(i,1,n) cin>>a[i];
  a[0]=0;

  bool flag=true;
  rep(i,1,n){
    if(a[i]>a[i-1]) a[i]--;
    else if(a[i]<a[i-1]){
      flag=false;
      break;
    }
  }

  if(flag) cout<<"Yes";
  else cout<<"No";
  cout<<endl;
}

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

res = [[0 for i in range(10)] for j in range(10)]

for i in range(N):
	a = i + 1
	b = a % 10
	while a > 0:
		if a < 10:
			break
		a = a // 10
	res[a][b] = res[a][b] + 1

ans = 0
for i in range(10):
	for j in range(10):
		ans += res[i][j] * res[j][i]

print(ans)

Measured memory_bytes: 40428
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;

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

int l[1000005];

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    bool pairwise=1;
    bool setwise=1;
    ll now=1;
    rep(i,n){
        cin >> a[i];
        
        if(i==0){
            now=a[i];
        }else{
            now=gcd(now,a[i]);
        }
        
        int b=a[i];
        int temp=0;
        
        int d=2;
        while(b%d==0){
            temp++;
            b/=d;
        }
        if(l[d]>0&&temp>0)pairwise=0;
        l[d]+=temp;
        temp=0;
        for(d=3;d<=b&&b>1&&d<=sqrt(a[i])+1;d+=2){
            while(b%d==0){
                temp++;
                b/=d;
            }
            if(l[d]>0&&temp>0)pairwise=0;
            l[d]+=temp;
            temp=0;
        }
        if(b>1){
            if(l[b]>0)pairwise=0;
            l[b]++;
        }
    }
    if(now>1){
        setwise=0;
    }
    if(pairwise){
        cout<<"pairwise coprime"<<endl;
    }else if(setwise){
        cout<<"setwise coprime"<<endl;
    }else{
        cout<<"not coprime"<<endl;
    }
    return 0;
}

Measured memory_bytes: 14900
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
using namespace std;
int main(){
    set<int> st;
    int n,x;
    scanf("%d",&n);
    while(n--){
        scanf("%d",&x);
        if(st.count(x)==0)
            st.insert(x);
        else st.erase(x);
    }
    printf("%d\n",st.size());
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define B begin()
#define E end()
#define F first
#define S second
#define pub push_back
#define mkp make_pair
#define migmig ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long double ld;
typedef long long ll; 
typedef vector<ll> vll;
typedef map<ll,ll> mll;
const ll N=1e5+5;
ll k;
int main(){
	cin>> k;
	for(ll i=0; i<k; i++){
		cout<<"ACL";
	}
	return 0;
}










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

int main(){
    long double a,b;
    cin >> a >> b;
    long double c = a * b;
    long d = floor(c);

    cout << d << endl;
}

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

int main() {
  ll n; cin >> n;
  vector<ll> A(n,0),K(n);
  
  rep(i,n){
    cin >> K[i];
    A[K[i]-1]++;
  }
  ll cnt = 0;
  vector<ll> B(n);
  rep(i,n){
    B[i] = A[i]*(A[i]-1)/2;
    cnt += B[i];
  }
  // cntは全ての組み合わせの総和
  
  
  rep(i,n){
    if(A[K[i]-1] != 0)
      cnt += - B[K[i]-1] + (A[K[i]-1]-1)*(A[K[i]-1]-2) / 2;
    cout << cnt << endl;
    if(A[K[i]-1] != 0)
      cnt +=  B[K[i]-1] - (A[K[i]-1]-1)*(A[K[i]-1]-2) / 2;
  }
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int fac(int n) {
    int res = 1;
    for (int i = 0; i < n; ++i) {
        res *= (i+1);
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i] >> y[i];
    }

    double res = 0;
    for (int i = 0; i < n-1; ++i) {
        for (int j = i+1; j < n; ++j) {
            res += (double)fac(n-1) * 2 * sqrt((x[j] - x[i]) * (x[j] - x[i]) + (y[j] - y[i]) * (y[j] - y[i]));
        }
    }
    cout << fixed << setprecision(10) << res / (double)fac(n) << endl;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N,M;
    cin >> N >> M;
    Yes(N==M);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
int N;
cin >> N;
int A[N];
for(int i=0; i<N; i++) cin >> A[i];

long int min = 1000000000;
long int max = -10;

for(int i=0; i<N; i++){
    if(A[i] < min) min = A[i];
    if(A[i] > max) max = A[i];
}

cout << max - min;
 return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String arg[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();
		int ans = 0;
		
		for(int i = 1; i <= N; i++) {
			if(splitN(i) >= A && splitN(i) <= B) {
				ans += i;
			}
		}
		System.out.println(ans);
	}
	
	public static int splitN(int n) {
		int sum = 0;
		String str = Integer.toString(n);
		String[] S = str.split("");
		
		for(int i = 0; i < S.length; i++) {
			sum += Integer.parseInt(S[i]); 
		}
		return sum;
	}
}

Measured memory_bytes: 39648
N = int(input())
a = list(map(int,input().split()))
ans = 0
count = 1
for i in range(len(a)-1):
  if a[i] == a[i+1]:
    count+=1
  else:
    ans+=int(count/2)
    count=1
if count != 1:
  ans+=int(count/2)
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
int nx[4]={0,-1,0,1};
int ny[4]={-1,0,1,0};

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

int main(){
    ll a,b,c,x,y;
    ll ans =1001001001001000100;
    ll zero=0;
    cin >> a >> b >> c >> x >> y;
    for(int i=0;i<=2*max(x,y);i++){
        if(i%2==1) continue;
        ll price=a*max(zero,x-i/2)+b*max(zero,y-i/2)+c*i;
        ans=min(ans,price);
    }
    cout << ans <<endl;

    return 0;
}


Measured memory_bytes: 256
h,w = map(int,input().split())
graph = [input() for _ in range(h)]
y = [ 0, 0, 1,-1]
x = [-1, 1, 0, 0]
for i in range(h):
    for j in range(w):
        if graph[i][j] == "#":
            for k in range(4):
                nh = i + y[k]
                nw = j + x[k]
                if nh < 0 or nh >= h or nw < 0 or nw >= w:continue
                if graph[nh][nw] == "#":break
            else:print("No");exit()
print("Yes")

Measured memory_bytes: 3064