akhauriyash/Code-Regression huggingface dataset:
n,m = map(int,input().split())

L = []
R = []
for i in range(m):
    li,mi = map(int,input().split())
    L.append(li)
    R.append(mi)

Lmax = L[0]
Rmin = R[0]
for i in range(m - 1):
    if Lmax < L[i + 1]:
        Lmax = L[i + 1]
    if Rmin > R[i + 1]:
        Rmin = R[i + 1]

if Lmax > n or Lmax > Rmin:
    print(0)
elif Rmin > n:
    print(n - Lmax + 1)
else:
    print(Rmin - Lmax + 1)


Measured memory_bytes: 11056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+7;
const int N=1e6+5;
typedef pair<int,int> pa;
char a[maxn];
int b[maxn];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    scanf("%s",a);
    int t=0;
    for(int i=n;i>0;){
        int k=m;
        if(k>i) k=i;
        for(;k>0;k--){
            if(a[i-k]=='0'){
                b[t++]=k,i-=k;
                break;
            }
        }
        if(k==0){
            puts("-1");
            return 0;
        }
    }
    for(t--;t>=0;t--){
        printf("%d ",b[t]);
    }
    return 0;
}


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

int main() {
  int N = 0, i, r, l, sum =0;
  cin >> N;

  for ( i=0; i<N; i++) {
    cin >> l >> r;
    sum += r - l + 1;    
  }
  cout << sum << 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 a = scanner.nextInt(), b = scanner.nextInt(), c = scanner.nextInt();
		int count = 0;
		if(a != b){
			count++;
		}
		if(b != c){
			count++;
		}
		if(c != a){
			count++;
		}
		if(count == 0){
			count++;
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 20820
#include <stdio.h>
    #include <stdlib.h>

    int main()
    {
        int a,b;
        scanf("%i",&a);
        scanf("%i",&b);
        int area=a*b;
        int perimetro=(a*2)+(b*2);
        printf("%i %i",area,perimetro);
        printf("\n");
        return 0;
    }



Measured memory_bytes: 2120
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    LL ans = 0;
    char prev = 0;
    rep(i, N) {
        if (prev != S[i]) {
            ++ans;
            prev = S[i];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
	
	public static int computePolish(String in) {
		Stack<Integer> polishStack= new Stack<Integer>();
		Scanner scan = new Scanner(in);
		
		while(scan.hasNext()) {
			String current = scan.next();
			
			switch(current) {
			case "*":
				
				int mult1 = polishStack.pop();
				int mult2 = polishStack.pop();
				polishStack.push(mult1*mult2);
				break;
			case "+":
				
				int plus1 = polishStack.pop();
				int plus2 = polishStack.pop();
				polishStack.push(plus1+plus2);
				break;
			case "-":
				
				int subt1 = polishStack.pop();
				int subt2 = polishStack.pop();
				polishStack.push(subt2-subt1);
				break;
			default:
				polishStack.push(Integer.parseInt(current));
				break;
			}
		}
		
		return polishStack.pop();
	}
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		System.out.println(computePolish(scan.nextLine()));
		
		
	}
}


Measured memory_bytes: 26188
// created_by  Rishi_Mohan

#include<bits/stdc++.h>

#define    ll           long long
#define    db1(x)       cout<<#x<<"="<<x<<'\n'
#define    db2(x,y)     cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define    db3(x,y,z)   cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define    rep(i,n)     for(int i=0;i<(n);++i)
#define    repA(i,a,n)  for(int i=a;i<=(n);++i)
#define    repD(i,a,n)  for(int i=a;i>=(n);--i)

using namespace std;

void solve()
{
 	int n;
   	cin >> n;
   	double ans = (double) ((float)(22*2*n)/7);
   	//double ans = (float)(3.14 * 2 * n);
   	cout << fixed << setprecision(6) << ans ;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
}

Measured memory_bytes: 3808
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
int i;
#define rep2(i, a, b) for(i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
using namespace std;
// _________コーディングはここから！！___________
template <const int sz = 5 * 10000000, typename T = long long> struct IO {
    char reader[sz], writer[sz];
    char *now, *now2 = writer;
    IO() {
        reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
        now = reader;
    }
    inline T read() {
        while(*now && *now <= 32) now++;
        if(*now == '-') {
            now++;
            T res = 0;
            while('0' <= *now and *now <= '9') { res = res * 10 + *now++ - '0'; }
            return -res;
        } else {
            T res = 0;
            while('0' <= *now and *now <= '9') { res = res * 10 + *now++ - '0'; }
            return res;
        }
    }
    inline string read_str() {
        string res;
        while(*now and *now != '\n' and *now != ' ') res += *now++;
        now++;
        return res;
    }
    inline void write(T x, char margin = ' ') {
        if(x == 0) {
            putchar('0');
            putchar(margin);
            return;
        }
        if(x < 0) {
            putchar('-');
            x = -x;
        }
        while(x) {
            *now2 = '0' + x % 10;
            now2++;
            x /= 10;
        }
        do {
            now2--;
            putchar(*now2);
        } while(now2 != writer);
        putchar(margin);
    }
    inline void write_str(string s, char margin = ' ') {
        for(auto c : s) putchar(c);
        putchar(margin);
    }
};
IO io;
inline int read() { return io.read(); }
inline void write(int x) { io.write(x); }
inline void write(int x, char c) { io.write(x, c); }
constexpr int N = 500003;
int c[N];
struct T {
    int l, r, idx;
    constexpr bool operator<(const T &rhs) const noexcept { return r < rhs.r; }
} q[N];
int ans[N], last[N], dat[N];

inline void dec(int k) {
    for(++k; k < N; k += k & -k) --dat[k];
}
inline int sum(int k) {
    int res = 0;
    for(++k; k > 0; k -= k & -k) res += dat[k];
    return res;
}
int n, Q, now = 1;

// 頑張れ！！
#pragma GCC target("avx2")
#pragma GCC optimize("unroll-loops")
// 頑張れ！！

// vector<int> l[N], idx[N];
vector<pair<int, int>> v[N];
int L, R;
main() {
    n = read(), Q = read();
    rep2(i, 1, n) c[i] = read();
    rep(i, Q) {
        L = read();
        v[read()].emplace_back(L, i);
    }
    rep2(i, 1, n) {
        if(last[c[i]]) dec(last[c[i]]);
        last[c[i]] = i;
        for(auto &[l, idx] : v[i]) ans[idx] = sum(i) - sum(l - 1) + i - l + 1;
    }
    // rep(i, Q) {
    //     for(; now < q[i].r; ++now) {
    //         if(last[c[now]]) dec(last[c[now]]);
    //         last[c[now]] = now;
    //     }
    //     ans[q[i].idx] = sum(q[i].r - 1) - sum(q[i].l - 1) + q[i].r - q[i].l;
    // }
    rep(i, Q) write(ans[i], '\n');
}


Measured memory_bytes: 42364
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

struct trojka {
    int rr;
    int gg;
    int bb;
};
int n;
vector<char> s;
vector<int> r, g, b;
vector<trojka> suf;
ll sol;
void solve(vector<int>& prvi, vector<int>& drugi, char znak) {
    for(auto p:prvi) {
        for(auto d:drugi) {
            if(d<p) continue;
            if(znak=='R') sol+=(d+1<n?(ll)(suf[d+1].rr):0LL);
            else if(znak=='G') sol+=(d+1<n?(ll)(suf[d+1].gg):0LL);
            else sol+=(d+1<n?(ll)(suf[d+1].bb):0LL);
            if(2*d-p<n && s[2*d-p]==znak) --sol;
        }
    }
}
int main() {
    IOS; cin >> n;
    s.resize(n);
    for(int i=0; i<n; ++i) {
        cin >> s[i];
        if(s[i]=='R') r.push_back(i);
        else if(s[i]=='G') g.push_back(i);
        else b.push_back(i);
    }
    suf.resize(n);
    for(int i=n-1; i>=0; --i) {
        if(i!=n-1) {
            suf[i].rr=suf[i+1].rr;
            suf[i].gg=suf[i+1].gg;
            suf[i].bb=suf[i+1].bb;
        }
        if(s[i]=='R') ++suf[i].rr;
        else if(s[i]=='G') ++suf[i].gg;
        else ++suf[i].bb;
    }
    solve(r, g, 'B');
    solve(g, r, 'B');
    solve(r, b, 'G');
    solve(b, r, 'G');
    solve(b, g, 'R');
    solve(g, b, 'R');
    cout << sol;
    return 0;
}


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

using namespace std;
using ll = long long;

using Graph = vector<vector<int>>;
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;}

vector<int> color;
bool dfs(const Graph &G, int v, int cur = 0){
    color[v] = cur;
    for(auto next_v : G[v]){
        if(color[next_v] != -1){
            if(color[next_v] == cur) return false;
            continue;
        }
        if(!dfs(G, next_v, 1-cur)) return false;
    }
    return true;
}

const ll INF = 1LL << 60;
int N;
vector<ll> h(1e5+10);

vector<ll> dp(1e5+10);

int main(){
    int N; cin >> N;
    rep(i, N) cin >> h[i];
    rep(i, 1e5+10) dp[i] = INF;

    dp[0] = 0;
    for(int i = 1; i < N; i++){
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if(i > 1) chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>

using namespace std;

int gcd(int x,int y){
  if(y == 0)return x;
  return gcd(y,x%y);
}

int lcm(int x,int y){
  return (x*y)/gcd(x,y);
}

string affine(string s,int a,int b){
  string news;
  news.clear();
  for(int i=0;i<s.length();i++){
    if(!('a'<= s[i] && s[i]<='z') ){
      news+=s[i];
      continue;
    }
    int y = s[i]-'a';
    news+= (char)((a*y+b)%26+'a');
  }
  
  return news;
}


int main(){

  int N;
  string s;
  cin >> N;
  cin.ignore();
  while(N-- > 0){
    getline(cin,s,'\n');
    bool fin = false;
    for(int a=0;a<=50;a++){
      if(gcd(a,26) == 1){
	for(int b=0;b<26;b++){
	  string Ns = affine(s,a,b);	  
	  if(Ns.find("that") != string::npos || Ns.find("this") != string::npos){
	    cout << Ns << endl;
	    fin = true;
	    break;
	  }
	}

	}
	if(fin)break;
    }
    if(!fin)cout << s << endl;


  }
  return 0;
}

Measured memory_bytes: 1216
import fractions
a, b, c, d = map(int, input().split())
cd_gcd = (c*d)//fractions.gcd(c, d)
print((b-a+1) - (b//c + b//d - b//(cd_gcd)) + ((a-1)//c + (a-1)//d - (a-1)//(cd_gcd)))

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

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

  int card[4][13] = {};
  for(int i=0;i<n;i++){
    string suit;
    int num;
    cin>>suit>>num;
    
    if(suit == "S") card[0][num-1] = 1;
    if(suit == "H") card[1][num-1] = 1;
    if(suit == "C") card[2][num-1] = 1;
    if(suit == "D") card[3][num-1] = 1;
  }

  string str[4] = {"S", "H", "C", "D"};
  for(int i=0;i<4;i++){
    for(int j=0;j<13;j++){
      if(card[i][j] == 1) continue;
      cout<<str[i]<<" "<<j+1<<endl;
    }
  }

  return 0;
}
		  
	


Measured memory_bytes: 3140
using System;

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

        bool ans = false;
        for (int i = 0; i < s.Length; i++)
        {
            ans = true;
            for (int j = 0; j < s.Length; j++)
            {
                int k = i + j;
                if (k >= s.Length)
                {
                    k -= s.Length;
                }

                if (s[j] != t[k])
                {
                    ans = false;
                    break;
                }
            }

            if (ans)
            {
                break;
            }
        }

        if (ans)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}


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

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if((a+b)<(c+d))
    {
        cout<<"Right"<<endl;
    }
    else if((a+b)==(c+d))
    {
        cout<<"Balanced"<<endl;
    }
    else if((a+b)>(c+d))
    {
        cout<<"Left"<<endl;
    }
    return 0;
}
/*
Left
Balanced
Right

*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    while (1)
    {
        string g;
        cin >> g;
        if (g == "#")
            break;
        int y, m, d;
        cin >> y >> m >> d;
        if (y > 31)
        {
            g = "?";
            y -= 30;
        }
        else if (y == 31 && m >= 5)
        {
            g = "?";
            y -= 30;
        }
        cout << g << " " << y << " " << m << " " << d << endl;
    }
}



Measured memory_bytes: 3176
#include <iostream>
#include <algorithm>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <string>

using namespace std;

int main()
{
    int x,a;
    cin >> x >> a;
    cout << (x < a ? 0 : 10) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int d, g;
    int p[20];
    int c[20];
    cin >> d >> g;
    imfor(i, d) {
        cin >> p[i] >> c[i];
    }
    int ans = 1<<30;
    for (int i = 0; i < (1<<d); i++) {
        bitset<10> bs(i);
        int tmpCount = 0;
        int tmpPoint = 0;
        for (int j = 0; j < d; j++) {
            if (bs[j]) {
                tmpCount += p[j];
                tmpPoint += (p[j] * (j+1)*100) + c[j];
            }
        }
        int addPoint, addPos = -1;
        for (int j = d-1; j >= 0; j--) {
            if (!bs[j]) {
                addPos = j;
                break;
            }
        }
        if (addPos != -1) {
            for (int j = 0; j < p[addPos] - 1; j++) {
                if (tmpPoint >= g) {
                    break;
                }
                tmpCount++;
                tmpPoint += (addPos+1) * 100;
            }
        }
        if (tmpPoint >= g) {
            ans = min(ans, tmpCount);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
x = 1
for _ in range(100000):
    if (x + 2) * (x + 1) // 2 > N:
        break
    x += 1

H = [i for i in range(x, 0, -1)]
dif = N - sum(H)

for i in range(dif):
    H[(i) % len(H)] += 1

print(*sorted(H), sep="\n")

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

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  bool ans = false;
  for (int i = a; i <= b; i++) {
	  if (i % k == 0) {
		  ans = true;
		}
	}
  if (ans) {
	  cout << "OK" << endl;
	} else {
	  cout << "NG" << endl;
	}
  return 0;
}


Measured memory_bytes: 3624
/*
 * @Author: BilyHurington
 * @Date: 2020-03-22 20:16:09
 * @LastEditors: BilyHurington
 * @LastEditTime: 2020-03-22 20:16:39
 */
#include<bits/stdc++.h>
using namespace std;
double x;
int main(){
    scanf("%lf",&x);
    printf("%.9lf",x*x*x/27.0);
    return 0;
}

Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int main(void) {

    int N; cin>>N;
    int BOX[N+1][3];
    for (int i = 0; i < N; ++i) {
        cin >> BOX[i][0] >> BOX[i][1] >> BOX[i][2];
    }

    int currentTime=0;
    int currentX = 0;
    int currentY = 0;
    for (int i = 0; i < N; ++i) {

        int Time = BOX[i][0]-currentTime;
        int Dist = abs(currentX-BOX[i][1])+abs(currentY-BOX[i][2]);

        if(((Dist > Time) || (Time%2!=Dist%2))){
            cout<<"No"<<endl;
            return 0;
        }

        currentTime = BOX[i][0];
        currentX = BOX[i][1];
        currentY = BOX[i][2];
    }

    cout<<"Yes"<<endl;

}


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

using namespace std;

const int P = 998244353;

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

	int n;
	cin >> n;

	string s;
	cin >> s;

	map<string, int> id;
	id["R"] = 0;
	id["G"] = 1;
	id["B"] = 2;
	id["RG"] = 3;
	id["GR"] = 4;
	id["GB"] = 5;
	id["BG"] = 6;
	id["RB"] = 7;
	id["BR"] = 8;

	long long ans = 1;
	vector<long long> cnt(9);

	for(char c : s) {
		if(c == 'R') {
			long long x = cnt[5] + cnt[6];
			long long y = cnt[1] + cnt[2];
			if(x > 0) {
				ans = ans * x % P;
				if(cnt[5] > 0) {
					cnt[5] -= 1;
				} else {
					cnt[6] -= 1;
				}
			} else if(y > 0) {
				ans = ans * y % P;
				if(cnt[1] > 0) {
					cnt[1] -= 1;
					cnt[4] += 1;
				} else {
					cnt[2] -= 1;
					cnt[8] += 1;
				}
			} else {
				cnt[0] += 1;
			}
		}
		if(c == 'G') {
			long long x = cnt[7] + cnt[8];
			long long y = cnt[0] + cnt[2];
			if(x > 0) {
				ans = ans * x % P;
				if(cnt[7] > 0) {
					cnt[7] -= 1;
				} else {
					cnt[8] -= 1;
				}
			} else if(y > 0) {
				ans = ans * y % P;
				if(cnt[0] > 0) {
					cnt[0] -= 1;
					cnt[3] += 1;
				} else {
					cnt[2] -= 1;
					cnt[6] += 1;
				}
			} else {
				cnt[1] += 1;
			}
		}
		if(c == 'B') {
			long long x = cnt[3] + cnt[4];
			long long y = cnt[0] + cnt[1];
			if(x > 0) {
				ans = ans * x % P;
				if(cnt[3] > 0) {
					cnt[3] -= 1;
				} else {
					cnt[4] -= 1;
				}
			} else if(y > 0) {
				ans = ans * y % P;
				if(cnt[0] > 0) {
					cnt[0] -= 1;
					cnt[7] += 1;
				} else {
					cnt[1] -= 1;
					cnt[5] += 1;
				}
			} else {
				cnt[2] += 1;
			}
		}
	}

	for(int i = 1; i <= n; ++i) {
		ans = ans * i % P;
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 720
package main

import (
	"fmt"
	"strings"
	"strconv"
)

func main() {
	var a string
	var b string
	fmt.Scan(&a,&b)
	var ans string
	lenA := len([]rune(a))
	lenB := len([]rune(b))
	if lenA > lenB {
		ans = "GREATER"
	} else if lenA < lenB {
		ans = "LESS"
	} else {
		for i := 0; i<lenA; i++ {
			aLst := strings.Split(a,"")
			bLst := strings.Split(b,"")
			tmpA,_ := strconv.Atoi(aLst[i])
			tmpB,_ := strconv.Atoi(bLst[i])
			if tmpA > tmpB {
				ans = "GREATER"
				break
			} else if tmpA < tmpB {
				ans = "LESS"
				break
			}
			ans = "EQUAL"
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 768
N, M = map(int, input().split())
k = [0] * M
s = [0] * M
for i in range(M):
    tmp_list = list(map(int, input().split()))
    k[i] = tmp_list[0]
    s[i] = tmp_list[1:]
p = list(map(int, input().split()))

ans = 0
for i in range(2 ** N):
    count = 0
    for m in range(M):
        tmp_str = str(bin(i))[2:].zfill(N)
        tmp_ones = 0
        for j in s[m]:
            tmp_ones += int(tmp_str[j - 1])
        if tmp_ones % 2 == p[m]:
            count += 1
            if count == M:
                ans += 1
        else:
            break

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
 #include<iostream>
using namespace std;
const int mod=1e9+7;
const int MAX=1e9+7;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[0]==a[1]&&a[1]!=a[2])
	cout<<"Yes";
	else if(a[0]!=a[1]&&a[1]==a[2]) 
	cout<<"Yes";
	else cout<<"No";
	
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

string s[3];
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    rep(i, 0, 3) cin >> s[i];
    rep(i, 0, 3) {
        cout << s[i][i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	if(a[0]%2==0||a[1]%2==0||a[2]%2==0){
		cout << 0 << endl;
	}else{
		sort(a,a+3);
		cout << (long long int)a[0]*a[1] << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<ll, ll>;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using Graph = VV;
int Inf = (1 << 30);
ll inf = (1LL << 60);
const int MOD = 1e9 + 7;
int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<char>> s(h, vector<char>(w));
	int i, j;
	for (i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> s[i][j];
		}
	}
	VVL dp(h, VL(w, 0));
	for (i = 0; i < h; i++) {
		if (s[i][0] == '#') break;
		dp[i][0] = 1;
	}
	for (j = 0; j < w; j++) {
		if (s[0][j] == '#') break;
		dp[0][j] = 1;
	}
	for (i = 1; i < h; i++) {
		for (j = 1; j < w; j++) {
			if (s[i][j] == '#') continue;
			dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
			dp[i][j] %= MOD;
		}
	}
	cout << dp[h - 1][w - 1];
	return 0;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int n,m,r;
    cin>>n>>m>>r;
    int town[r];
    for(int i=0;i<r;i++){
        cin>>town[i];
        town[i]--;
    }
    int a,b,c;
    int d[n][n] = {};
    for(int i=0;i<n;i++)for(int j=0;j<n;j++){
        if (i!=j) d[i][j] = 1e9;
    }
    for(int i=0;i<m;i++) {
        cin>>a>>b>>c;
        d[a-1][b-1]=c;
        d[b-1][a-1]=c;
    }
    for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++){
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    }

    int ans = 1e9;
    sort(town,town+r);
    while(next_permutation(town,town+r)){
        int ret=0;
        for(int i=0;i<r-1;i++){
            ret+=d[town[i]][town[i+1]];
        }
        ans=min(ans,ret);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <math.h> 
#include <iomanip>
#include <vector>
#include <map>
using namespace std;

std::map<unsigned long long,unsigned long long> m;
int answer = 0;
void cal(unsigned long long n){
    unsigned long long a = 2;

    while (n >= a * a) {
        if (n % a == 0) {
            if(m.count(a) >= 1){
                m[a] += 1; 
            }
            else{
                m[a] = 1;
            }
            n /= a;
        } 
        else {
            if(a==2){
                a++;
            }
            else{
                a+=2;
            }
        }
    }
    if(m.count(n) >= 1){
        m[n] += 1;
    }
    else{
        m[n] = 1;
    } 
}

int main(){
    unsigned long long N;
    cin >> N;
    int ans = 0;
    //soinsu bunkai
    if (N == 1){
        cout << 0 << endl;
        return 0;
    }
    cal(N);
    //cout << m[2] << endl;

    for(auto i = m.begin(); i != m.end() ; ++i ){
        unsigned long long dup = 1;
        unsigned long long omomi = 1;
        //cout << i->second << endl;
        while(i->second >= dup){
            ans+=1;
            ++omomi;
            dup = dup+omomi;
        }
    }

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

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int a[1010];
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a,a+n+1);
	int sum=0;
	for(int i=1;i<=m;i++)
		sum+=a[i];
	cout<<sum;
	return 0;
}


Measured memory_bytes: 3592
n=int(input());l=[list(map(int,input().split()))for i in[0]*n];a=[0 for i in[0]*n];d=1;k=n*(n-1)
while sum(a)<k and 0<d<9999:
 L=[0 for i in[0]*n];y=0;d+=1
 for i in range(n):
  if a[i]<n-1:
   x=l[i][a[i]]-1
   if l[x][a[x]]-1==i and L[x]+L[i]<1:
    a[i]+=1;a[x]+=1;L[i]=L[x]=y=1
 d*=y
print([k//2,d-1][d<9999])

Measured memory_bytes: 56156
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto P = new long[](N);
    foreach (i; 0 .. N)
        P[i] = lread();
    auto I = iota(N).array;
    zip(P, I).sort();
    long l = 1;
    long lm = 1;
    foreach (i; 1 .. N)
    {
        if (I[i - 1] < I[i])
        {
            l++;
        }
        else
        {
            lm = max(lm, l);
            l = 1;
        }
    }
    lm = max(lm, l);
    writeln(N - lm);
}


Measured memory_bytes: 5372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
ll a,b,c,d,inf=9223372036854775807;
vector<ll> v;
map<ll,ll> m;
ll gao(ll n){
	if(n==0)return 0;
	if(n==1)return d;
	ll u=inf;
	if(n<inf/d)u=n*d;
	if(m.find(n)!=m.end())
		return m[n];
	ll x;
	for(ll i=0;i<3;i++){
		if(i==0)x=a;
		if(i==1)x=b;
		if(i==2)x=c;
		if(n%v[i]==0)
			u=min(u,x+gao(n/v[i]));
		else{
			ll y=n/v[i]*v[i];
			u=min(u,d*(n-y)+x+gao(n/v[i]));
			ll z=y+v[i];
			u=min(u,d*(z-n)+x+gao(n/v[i]+1));
		}
	}
	return m[n]=u;
}
int main(){
	v.push_back(2);
	v.push_back(3);
	v.push_back(5);
	ll t=read();
	while(t--){
		ll n=read();
		a=read(),b=read(),c=read(),d=read();
		m.clear();
		printf("%lld\n",gao(n));
	}
	return 0;
}

Measured memory_bytes: 4540
x = int(input())

if x <= 6:
    ans = 1
elif 6 < x < 11:
    ans = 2
elif x%11 == 0:
    ans = (x//11)*2
else:
    ans = (x//11)*2
    x = x%11
    if x <= 6:
        ans += 1
    else:
        ans += 2

print (ans)


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

int main() {
  int w,a,b;
  cin>>w>>a>>b;
  int a_end=a+w,b_end=b+w;
  if ((a>=b && a<=b_end) || (a_end>=b && a_end<=b_end)) cout <<0<<endl;
  else if (b_end<a) cout <<a-b_end<<endl;
  else if (a_end<b) cout << b-a_end<<endl;
}

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

string temp,p,q;
bool vis[10];
int a,b,cnt;
void dfs(int t,int n){

    if(t==n) {
        cnt++;
        if(temp==p) a =cnt;
        if(temp==q) b =cnt;
        return ;
    }
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            temp +=to_string(i);
            vis[i] =1;
            dfs(t+1,n);
            temp.erase(t);
            vis[i] =0;
        }
    }
}
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        p +=to_string(x);
    }
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        q+=to_string(x);
    }
    cnt =0;
    dfs(0,n);
    cout<<abs(a-b)<<endl;
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int mi = INT_MAX;
    rep(i,s.size()-2) {
        int t = stoi(s.substr(i, 3));
        mi = min(mi, abs(753-t));
    }
    cout << mi << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(c)       int(c.size())
#define FOR(i,a,b)  for (int i=a; i<(b); ++i)
#define DOWN(i,a,b) for (int i=(a)-1; i>=(b); --i)
using namespace std;
using i64 = long long;



int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);

  i64 x,y;
  cin>>x>>y;
  int res=1;
  while (x*2<=y) {
    res+=1;
    x*=2;
  }
  cout<<res<<endl;

  return 0;
}


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

int dfs(int s,const int n,const vector<vector<int>> &t,vector<int> &dp){
    if(s==((1<<n)-1)){return 0;}
    if(dp[s]!= -1) return dp[s];
    int res=1e9;
    for(int i=0;i<n;i++){
        if(!(s & (1<<i))){
            int need=t[i][0];
            for(int j=0;j<n;j++){
                if(s & 1<<j){
                    need=min(need,t[i][j+1]);
                }
            }
            res=min(res,dfs(s+(1<<i),n,t,dp)+need);
        }

    }
    return (dp[s]=res);
}

int main(){
    int n;
    while(cin>>n,n){
        vector<vector<int>> t(n,vector<int>(n+1));
        for(int i=0;i<n;i++)
            for(int j=0;j<n+1;j++){
                cin>>t[i][j];
            }
        vector<int> dp(1<<n,-1);
        cout<<dfs(0,n,t,dp)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3360
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

typedef long long i64;

i64 MOD = 1e9 + 7;

// Eucli
i64 inv_mod(i64 a, i64 m = MOD) {
  i64 b, x, u, q, abs_m, tmp;

  abs_m = (m < 0) ? -m : m;
  b = m;
  x = 1;
  u = 0;
  while (b > 0) {
    q = a / b;
    tmp = u;
    u = x - q * u;
    x = tmp;
    tmp = b;
    b = a - q * b;
    a = tmp;
  }

  return (x < 0) ? abs_m + x : x;
}

i64 fact[202020];

i64 nCr(int n, int r) {
  return (fact[n] * inv_mod(fact[r]) % MOD * inv_mod(fact[n - r]) % MOD) % MOD;
}

//重複組み合わせ
i64 nHr(int n, int r) { return (nCr(n + r - 1, r)) % MOD; }

int main(){
  int h,w;
  cin >> h >> w;
  int a,b;
  cin >> a >> b;
  fact[0] = 1;
  rep(i,1,202020 - 1) {
    fact[i] = (fact[i - 1] * i) % MOD;
  }

  i64 ans = 0;
  rep(i,0,h - a - 1){
    (ans += nCr(i + b - 1,i) * nCr(h - i - 1 + w - b - 1,h - i - 1) % MOD) %= MOD;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1792
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left #bisect_left(list, value)
#from fractions import gcd
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N = int(input())

if N==3 or N==5 or N==7:
    print('YES')
else:
    print('NO')





Measured memory_bytes: 3440
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
#define x first
#define y second
#define mp make_pair
#define pb push_back
template <typename TYPE> inline void chkmax(TYPE &x,TYPE y){x<y?x=y:0;}
template <typename TYPE> inline void chkmin(TYPE &x,TYPE y){y<x?x=y:0;}
template <typename TYPE> void readint(TYPE &x)
{
    x=0;int f=1;char c;
    for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=x*10+c-'0';
    x*=f;
}
const int MAXN=305,MOD=998244353;
inline int dmy(int x){return x>=MOD?x-MOD:x;}
inline void inc(int &x,int y){x=dmy(x+y);}

int n;
char s[MAXN];
int f[MAXN][MAXN][MAXN],cnt[2];
bool g[MAXN][MAXN][MAXN];

int main()
{
	#ifdef LOCAL
	freopen("code.in","r",stdin);
//	freopen("code.out","w",stdout);
	#endif
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;++i)++cnt[s[i]-'0'];
	for(int j=0;j<=cnt[1];++j)f[n+1][0][j]=1;
	for(int i=1;i<=cnt[0];++i)
	{
		f[n+1][i][0]=1;
		for(int j=1;j<=cnt[1];++j)
			f[n+1][i][j]=dmy(f[n+1][i-1][j]+f[n+1][i][j-1]);
	}
	for(int k=n;k;--k)
		for(int i=0;i<=cnt[0];++i)
			for(int j=0;j<=cnt[1];++j)
			{
				if(i)inc(f[k][i][j],f[k+(s[k]=='0')][i-1][j]);
				if(j)inc(f[k][i][j],f[k+(s[k]=='1')][i][j-1]);
			}
	cnt[0]=cnt[1]=0;
	g[0][0][0]=1;
	for(int k=0;k<n;++k)
	{
		for(int i=0;i<=cnt[0];++i)
			for(int j=0;j<=cnt[1];++j)
			{
				if(!g[k][i][j])continue;
				if(s[k+1]=='0')
				{
					g[k+1][i+1][j]=1;
					if(j<cnt[1])g[k+1][i][j+1]=1;
					g[k+2][i+1][j]=1;
				}
				else
				{
					g[k+1][i][j+1]=1;
					if(i<cnt[0])g[k+1][i+1][j]=1;
					g[k+2][i][j+1]=1;
				}
				if(s[k+2]=='0')g[k+2][i+1][j]=1;
				else g[k+2][i][j+1]=1;
			}
		++cnt[s[k+1]-'0'];
	}
	int ans=0;
	for(int i=0;i<=cnt[0];++i)
		for(int j=0;j<=cnt[1];++j)
		{
			int pos=-1;
			for(int k=n;k>=0;--k)if(g[k][i][j]){pos=k;break;}
//cerr<<i<<" "<<j<<" "<<pos<<" : "<<f[pos+1][cnt[0]-i][cnt[1]-j]<<endl;
			if(pos<0)continue;
			inc(ans,f[pos+1][cnt[0]-i][cnt[1]-j]);
		}
	printf("%d\n",dmy(ans+MOD-1));
	return 0;
}

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

int main()
{
	string S;
	long long K,a=0;

	cin >> S >> K;

	int s = S.size();

	for (int i = 0; i < s; i++) {
		long long j = S[i] - '0';
		if(j==1){
			a++;
			if (K <= a) {
				cout << S[i] << endl;
				return 0;
			}
		}
		else {
			for (long long k = 0; k < 5000 * 1000000000000; k++) {
				a = (S[i] - '0')*j;
				j *= (S[i] - '0');
				if (K <= a) {
					cout << S[i] << endl;
					return 0;
				}
			}
		}
	}

	return 0;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<class T>
struct Point {
	typedef Point P;
	T x, y;
	explicit Point(T x=0, T y=0) : x(x), y(y) {}
	bool operator<(P p) const { return tie(x,y) < tie(p.x,p.y); }
	bool operator==(P p) const { return tie(x,y)==tie(p.x,p.y); }
	P operator+(P p) const { return P(x+p.x, y+p.y); }
	P operator-(P p) const { return P(x-p.x, y-p.y); }
	P operator*(T d) const { return P(x*d, y*d); }
	P operator/(T d) const { return P(x/d, y/d); }
	T dot(P p) const { return x*p.x + y*p.y; }
	T cross(P p) const { return x*p.y - y*p.x; }
	T cross(P a, P b) const { return (a-*this).cross(b-*this); }
	T dist2() const { return x*x + y*y; }
	double dist() const { return sqrt((double)dist2()); }
	// angle to x-axis in interval [-pi, pi]
	double angle() const { return atan2(y, x); }
	P unit() const { return *this/dist(); } // makes dist()=1
	P perp() const { return P(-y, x); } // rotates +90 degrees
	P normal() const { return perp().unit(); }
	// returns point rotated 'a' radians ccw around the origin
	P rotate(double a) const {
		return P(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a)); }
};

using P = Point<long long>;


template<class P>
bool onSegment(const P& s, const P& e, const P& p) {
	P ds = p-s, de = p-e;
	return ds.cross(de) == 0 && ds.dot(de) <= 0;
}


template<class It, class P>
int insidePolygon(It begin, It end, const P& p) {
	int n = 0; //number of isects with line from p to (inf,p.y)
	for (It i = begin, j = end-1; i != end; j = i++) {
		//if p is on edge of polygon
		if (onSegment(*i, *j, p)) return 1;
		//or: if (segDist(*i, *j, p) <= epsilon) return !strict;
		//increment n if segment intersects line from p
		n += (max(i->y,j->y) > p.y && min(i->y,j->y) <= p.y &&
				((*j-*i).cross(p-*i) > 0) == (i->y <= p.y));
	}
	return 2*(n&1); //inside if odd number of intersections
}

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cout << fixed << setprecision(15);
	int n;
	cin >> n;
	vector<P> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i].x >> a[i].y;
	}
	int q;
	cin >> q;
	for(int i = 0; i < q; i++){
		P p;
		cin >> p.x >> p.y;
		cout << insidePolygon(a.begin(), a.end(), p) << '\n';
	}
}



Measured memory_bytes: 3112
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include<vector>

using namespace std;
typedef long long ll;

ll ans,mx,sum,mn=1e18,cnt;
ll flag;

string t;
int main(){
	string s;
	cin>>s;
	for(ll i=0; i<s.size(); i++){
		if(s[i]=='B'){
			if(t.empty()==false)
				t.erase(t.size()-1,t.size());
		}
		else t+=s[i];
	}
	cout<<t;
}



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

const int MAXN = 200005;

int H, W, N, sr, sc;
char S[MAXN], T[MAXN];

bool calc(int s, int m){
	int L = 1, R = m;
	for(int i = N - 1; i >= 0; i--){
		if(S[i] == 'L' || S[i] == 'R'){
			if(T[i] == 'U'){
				R = min(m, R + 1);
			}else if(T[i] == 'D'){
				L = max(1, L - 1);
			}
		}else if(S[i] == 'U'){
			if(T[i] == 'D'){
				L = max(2, L);
			}else if(T[i] == 'U'){
				R = min(m, R + 1);
				L = L + 1;
			}else{
				L = L + 1;
			}
		}else{
			if(T[i] == 'U'){
				R = min(m - 1, R);
			}else if(T[i] == 'D'){
				L = max(1, L - 1);
				R = R - 1;
			}else{
				R = R - 1;
			}
		}
		
		if(L > R)return false;
	}
	if(s < L || s > R)return false;
	return true;
}
int main(){
	scanf("%d %d %d %d %d %s %s", &H, &W, &N, &sr, &sc, S, T);
	
	bool f1 = calc(sr, H);
	
	for(int i = 0; i < N; i++){
		if(S[i] == 'L')S[i] = 'U';
		else if(S[i] == 'R')S[i] = 'D';
		else if(S[i] == 'U')S[i] = 'L';
		else S[i] = 'R';
		
		if(T[i] == 'L')T[i] = 'U';
		else if(T[i] == 'R')T[i] = 'D';
		else if(T[i] == 'U')T[i] = 'L';
		else T[i] = 'R';
	}
	
	bool f2 = calc(sc, W);
	
	if(f1 && f2)printf("YES\n");
	else printf("NO\n");
	
	return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>

using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_buck(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
#define mod 1000000007


int main(){
	int N;
	cin>>N;
	ll x=1;
	rep(i,N){
		x *= (i+1);
		x %= mod;
	}
	cout<<x<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] s = new int[n];
		int sum = 0;
		int min = 101;
		int min2 = 101;
		int check = 0;

		for (int i=0; i<n; i++){
			s[i] = sc.nextInt();
			if (min > s[i]){
				min = s[i];
			}
		}

		for (int i=0; i<n; i++){
			sum += s[i];
		}

		if (sum%10 != 0){
			System.out.println(sum);
		}
		else if(min%10 != 0){
			System.out.println(sum-min);
		}
		else{
			for (int i=0; i<n; i++){
				if (min2 > s[i] && s[i]%10 != 0){
					min2 = s[i];
					check++;
				}
			}
			if (check == 0){
				System.out.println(0);
			}
			else{
				System.out.println(sum-min2);
			}

		}

	}
}

Measured memory_bytes: 21972
# define _CRT_SECUREj_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) (x).begin(),(x).end()
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<" :"<<x<<endl;
# define EPS 1e-12
template<class T> void debug(T a) { for (auto iiiiiiiiii : a)cout << iiiiiiiiii << endl; }
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };

int main()
{
	FOR(i, 7)
	{
		INT(a); INT(b);
		cout << a - b << endl;
	}
}

Measured memory_bytes: 3120
package main

import (
	"fmt"
)

var n int
var as []int

func main() {
	fmt.Scan(&n)
	as = make([]int, n)
	for i := range as {
		fmt.Scan(&as[i])
	}
	if zero() || three() {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func zero() bool {
	for i := range as {
		if as[i] != 0 {
			return false
		}
	}
	return true
}

func three() bool {
	if n%3 != 0 {
		return false
	}
	m := make(map[int]int)
	for i := range as {
		m[as[i]]++
	}
	//fmt.Println("n,m: ", n, m)
	rs := make([]int, 0)
	for k, v := range m {
		if v == n/3 {
			rs = append(rs, k)
		} else if v == n/3*2 {
			rs = append(rs, k, k)
		}
	}
	//fmt.Println("rs: ", rs)
	if len(rs) != 3 {
		return false
	}
	return rs[0]^rs[1] == rs[2]
}


Measured memory_bytes: 7040
#include<cstdio>
using namespace std;
#define N 53
#define mod 1000000007
int dp[N][N*4][N],fr[N],ifr[N],n;
int pw(int a,int p){int as=1;while(p){if(p&1)as=1ll*as*a%mod;a=1ll*a*a%mod;p>>=1;}return as;}
int main()
{
	scanf("%d",&n);
	fr[0]=ifr[0]=1;for(int i=1;i<=n;i++)fr[i]=1ll*fr[i-1]*i%mod,ifr[i]=pw(fr[i],mod-2);
	for(int i=n+1;i>=1;i--)dp[i][n][0]=1;
	for(int i=n;i>=0;i--)
	for(int j=0;j<=n*2;j++)
	for(int k=0;k<=n;k++)
	if(dp[i+1][j][k])
	{
		int st=(j-n)*2;
		if(st>n-k+1||st+n-k-1<0)continue;
		for(int s=0;s<=n-k;s++)
		for(int t=0;s+t<=n-k;t++)
		if(s+t)
		{
			int ns=n+st+s-t,nk=k+s+t;
			if(ns<0||ns>n*2)continue;
			if(j<n&&s<n-j)continue;
			if(j>n&&t<j-n)continue;
			if(!i&&s+t>1)continue;
			dp[i][ns][nk]=(dp[i][ns][nk]+1ll*dp[i+1][j][k]*ifr[s]%mod*ifr[t])%mod;
		}
	}
	printf("%d\n",1ll*dp[0][n+1][n]*fr[n]%mod);
}//

Measured memory_bytes: 1408
#include <iostream>
#include <queue>
#include <utility>

using namespace std;

int N;
int Ai;

struct cmp {
	bool operator()(pair<int,int> const& p1, pair<int,int >const& p2)
	{
		if (p1.second > p2.second) return true;
		return false;
	}
};

//pair<编号, 名次>
priority_queue<pair<int, int>, vector<pair<int, int>>, cmp> q;

void printQueue()
{
	while (!q.empty()) {
		pair<int, int> p = q.top();
		q.pop();
		cout << p.first << " " << p.second << endl;
	}
}

void printOrder()
{
	while (!q.empty()) {
		pair<int, int> p = q.top();
		q.pop();
		cout << p.first;
		if (!q.empty()) cout << " ";
	}
	cout << endl;
}

void test()
{
	for (int i = 10; i > 0; i--) {
		q.push(make_pair(1, i));
	}
	printQueue();
}

int main()
{
	cin >> N;

	for (int i = 1; i <= N; i++) {
		cin >> Ai;
		q.push(make_pair(i, Ai));
	}
	printOrder();

	return 0;
}





Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
#define inf 999999999
#define loop(i, a, b) for (int i = (a), i##len = (b); i < i##len; ++i)
#define rep(i, n) loop(i, 0, n)
#define lin long long
#define lfl long double

int main(void)
{
    string s;
    int n;
    cin >> n >> s;
    int r = 0;
    int b = 0;

    rep(i,n)
    {
        if(s[i] == 'R')
            r++;
        else
            b++;
    }

    if(r > b)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;

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

const ll INF = 1LL << 60;



signed main() {

	ll n;

	cin >> n;

	vector<ll> result;
	ll boundary = sqrt(n);

	for (ll i = 1; i <= boundary; i++) {
		if (n % i == 0) {
			result.push_back(i);
			if (i != (n / i) && i * i != n)
				result.push_back(n / i);
		}
	}

	sort(result.begin(), result.end());

	ll kosu = result.size();
	ll han = kosu / 2;
	ll ans;
	if (kosu % 2 == 0) {
		ans = result[han] + result[han - 1] - 2;
	}

	else {
		ans = result[han] * 2 - 2;
	}

	cout << ans;

}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<typename T> void chmax(T &a, T b) { a = max(a, b); }
template<typename T> void chmin(T &a, T b) { a = min(a, b); }

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i,n) cin >> s.at(i);
    map<char, int> mp;

    rep(i,n) {
        map<char, int> m;
        for (char c : s.at(i)) m[c]++;
        if (i == 0) {
            mp = m;
            continue;
        }
        for (auto p : mp) {
            if (m.count(p.first)) {
                mp.at(p.first) = min(p.second, m.at(p.first));
            }
            else mp.at(p.first) = 0;
        }
    }
    stringstream ss;
    for (auto p : mp) {
        rep(i, p.second) ss << p.first;
    }
    cout << ss.str() << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iostream>
#include<algorithm>//next_permutation
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << c << " " << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int h,m,s,nh,nm,ns;
  for(int i = 0 ; i < 3; i++){
    cin >> h >> m >> s;
    cin >> nh >> nm >> ns;
    s = h*3600 + m*60 + s;
    ns =  nh*3600 + nm*60 + ns;
    s = ns - s;
    h = s/3600;
    m = (s%3600)/60;
    s = (s%3600)%60;
    cout << h << " " << m << " " << s << endl;
    }
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>
struct Node{
	int key;
	struct Node *right, *left,*parent;
};

struct Node *root,*nil;



struct Node *find(struct Node *u,int k){
	while(u!=nil && k!=u->key){
		if(k<u->key){
			u=u->left;
		}
		else {
			u=u->right;
		}
	}
	return u;
}

void insert(int k){
	struct Node *y=nil;
	struct Node *x=root;
	struct Node *z;
	z=(struct Node*)malloc(sizeof(struct Node));
	z->key=k;
	z->left=nil;
	z->right=nil;
	
	while(x!=nil){
		y=x;
		if(z->key<x->key){
			x=x->left;
		}
		else{
			x=x->right;
		}
	}	
	
	z->parent=y;
	if(y==nil){
		root=z;
	}
	else{
		if(z->key<y->key){
			y->left=z;
		}
		else {
			y->right=z;
		}
	}
}

void inorder(struct Node *u){
	if(u==nil){
		return;
	}
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}

void preorder(struct Node *u){
	if(u==nil){
		return;
	}
	
	if(u==nil){
		return;
	}
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}

int main(void){
	int n,i,x;
	scanf("%d",&n);
	int d;
	char string[10];
	
	for(i=0;i<n;i++){
		scanf("%s %d",string,&d);
		if(string[0]=='i'){
			insert(d);
		}
		else if(string[0]=='p'){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
		else if(string[0]=='f'){
			struct Node *t=find(root,d);
			if(t!=nil){
				printf("yes\n");
			} 
			else{
				printf("no\n");
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 20608