akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  vector<int> color(n, -1);
  for (int x : a) {
    auto it = lower_bound(color.begin(), color.end(), x);
    assert(it != color.begin());
    it = prev(it, 1);
    *it = x;
  }
  auto it = upper_bound(color.begin(), color.end(), -1);
  cout << color.end() - it << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007 //998244353
typedef vector<ll> vl;
typedef vector<vl> matrix;//A(n, vl(m)); //n*m行列
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
typedef vector<bool> vb;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Sortup(V) sort(V.begin(), V.end())
#define Sortdown(V) sort(V.rbegin(), V.rend())
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;}
void CumuSum(vl &A){rep(i,A.size())if(i)A[i]+=A[i-1];}
ll llpow(ll e,ll x){ll res=1LL;while(x){if(x&1)res*=e;e*=e;x/=2;}return res;}
ll llpowMOD(ll e,ll x){ll res=1LL;while(x){if(x&1)res*=e;e*=e;x/=2;res%=MOD;e%=MOD;}return res;}
bool bit(ll subset, ll Rsift){ return ((subset)>>(Rsift))&1; }

ll gcd(ll A, ll B){
    if(A<B) swap(A,B);
    while(B){
        ll w = A%B;
        A = B;
        B = w;
    }
    return A;
}

ll lcm(ll A, ll B){return A/gcd(A,B)*B;}

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

    // solution comes here

    ll A, B;
    cin >> A >> B;
    cout << lcm(A, B) << nl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main(){
    string o, e;
    cin >> o;
    cin >> e;
    int n, m;
    n = o.size();
    m = e.size();
    for(int i = 0; i < n + m; i++){
        if(i % 2 == 0)//奇数文字目
        cout << o.at(i / 2);
        else
        cout << e.at(i / 2);
    }
    cout << endl;
    return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 
//#define SIZE (10)
#define SIZE (10000)

using namespace std;

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

    ll N, W;
    cin >> N >> W;
    vector<ll> v(N+10), w(SIZE+10);

    rep(i,1,N+1) cin >> v[i] >> w[i];

    vector<vector<ll>> dp(N+10, vector<ll>(SIZE+10, -1));

    rep(i,0,W+1) dp[0][i] = 0;

    rep(i,1,N+1)
    {
        rep(j,0,W+1)
        {
            if (j-w[i]>=0 && j-w[i]<=W) 
                dp[i][j] = max(dp[i-1][j], dp[i][j-w[i]] + v[i]);
            else
                dp[i][j] = dp[i-1][j];

            //for (auto l: dp)
            //{
            //    for (auto k: l)
            //        cout << ' ' << k;
            //    cout << endl;
            //}
        }
    }

    cout << dp[N][W] << endl;

    return 0;
}



Measured memory_bytes: 11544
v,e = map(int, input().split())
G = [[float('inf')] * v for i in range(v)]
for i in range(v):
    G[i][i] = 0
for i in range(e):
    s,t,d = map(int, input().split())
    G[s][t] = d

for i in range(v):
    for j in range(v):
        for k in range(v):
            G[j][k] = min(G[j][k], G[j][i]+G[i][k])

for i in range(v):
    if G[i][i] < 0:
        print('NEGATIVE CYCLE')
        exit()

for row in G:
    row = map(lambda x: 'INF' if x == float('inf') else str(x),row)
    print(' '.join(row))

Measured memory_bytes: 8124
#include <stdio.h>

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

int main(){
	int a, b;
	
	while(scanf("%d %d", &a, &b)!=EOF)
	printf("%d\n", gcd(a, b));
	
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<complex>
using namespace std;
typedef long long int llint;
int main() {
	int a, b;
	cin >> a >> b;
	if (a%b == 0) {
		cout << -1 << endl;
	}
	else {
		int cnt = 2 * a;
		while (cnt%b == 0) {
			cnt += a;
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class UNKO
{

    static void Main()
    {
        List<int> Ans = new List<int>();


        while (true)
        {

            int x = dateinput();

            if (x == -1)
            {
                break;
            }

            else
            {
                Ans.Add(x);
            }

        }

        for (int i = 0; i < Ans.Count; i++)
        {
            Console.WriteLine(Ans[i]);
        }

    }



    static int dateinput()
    {
        List<int> nums = new List<int>();
        string str = Console.ReadLine();
        char[] chaan = new char[str.Length];
        chaan = str.ToCharArray();

        if ((chaan.GetLength(0) == 1) && (chaan[0] == '0'))
            return -1;

        else
        {
            for (int i = 0; i < chaan.GetLength(0); i++)
            {
                nums.Add(chaan[i] - '0');
            }

            int digitsum = 0;


            for (int i = 0; i < nums.Count; i++)
            {
                digitsum += nums[i];
            }

            return digitsum;

        }
    }


    }

Measured memory_bytes: 9152
#include <bits/stdc++.h>
using namespace std;
const int M = 100001;
int n, m, i, u, v, ans, in[M], dis[M];
bool vis[M];
vector < int > adj[M];
void dfs(int s)
{
    vis[s] = true;
    for(auto it : adj[s])
    {
        dis[it] = max(dis[it], dis[s] + 1);
        if(--in[it] == 0) dfs(it);
    }
    ans = max(ans, dis[s]);
}

int main ()
{
    cin >> n >> m;
    for(i = 1; i <= m; i++)
    {
        cin >> u >> v;
        adj[u].push_back(v);
        ++in[v];
    }
    memset(vis, false, sizeof(vis));
    for(i = 1; i <= n; i++)
    {
        if(!vis[i] and !in[i]) dfs(i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 14624
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int n, m, p;
  vector<int>d;
  scanf("%d%d%d", &n, &m, &p);
  for(int i=0;i<m;i++){
    int x;
    scanf("%d", &x);
    d.push_back(x);
  }

  sort(d.begin(), d.end());
  int ds = d.size();
  int res = 1<<30;
  for(int i=0;i<m;i++){
    if(d[i] < p){
      int l = 0;
      if(i)
	l = n - d[i] + d[i-1];
      else
	l = d[(i+ds-1)%ds] - d[i] ;
      res = min(res, (p - d[i]) + l);

      if(i == m-1)
	l = d[i] - d[(i+ds+1)%ds];
      else
	l = n - d[i+1] + d[i];
      res = min(res, (n - p + d[i]) + l);
    }else{
      int l = 0;
      if(i == m-1)
	l = d[i] - d[(i+ds+1)%ds]; 
      else
	l = n - d[i+1] + d[i];
      res = min(res, (d[i] - p) + l);

      if(i == 0)
	l = d[(i+ds-1)%ds] - d[i];
      else
	l = n - d[i] + d[i-1];
      res = min(res, ((n - d[i] + p) + l));
    }
  }

  int j = 0;
  while(d[j] < p && j < m) j++;
  if(j == 0){
    res = min(res, min(n - (d[j] - p),n - (n - d[(j+ds-1)%ds] + p)));
  }else if(j == m){
    res = min(res, min(n - (p - d[j-1]),n - (n - p + d[0])));
  }else{
    res = min(res, min(n - (p - d[j-1]), n - (d[j] - p)));
  }
  printf("%d\n", res*100);  
  return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  if (s.size() == 2) {
    if (s[0] == s[1]) cout << "1 2" << endl;
    else cout << "-1 -1" << endl;
  }
  else {
    for (int i = 0; i + 2 < n; i++) {
      char a = s[i], b = s[i + 1], c = s[i + 2];
      if (a == b || b == c || c == a) {
        cout << i + 1 << ' ' << i + 3 << endl;
        return 0;
      }
    }
    cout << "-1 -1" << endl;
  }
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int n, q;
string s;
vector<char> t, d;

int check(int mid){
    int res = mid;
    rep(i, q){
        if(t[i] == s[res]){
            if(d[i] == 'L'){
                --res;
            }else{
                ++res;
            }
        }
    }

    return res;
}

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

    cin >> n >> q;

    cin >> s;
    s.insert(s.begin(), '0');
    s.push_back('0');

    t.resize(q);
    d.resize(q);
    rep(i, q){
        cin >> t[i] >> d[i];
    }

    int ok = 0, ng = n + 1;
    while(abs(ok - ng) > 1){
        int mid = (ok + ng) / 2;
        if(check(mid) == 0){
            ok = mid;
        }else{
            ng = mid;
        }
    }

    int left = ok;

    ok = n + 1;
    ng = 0;
    while(abs(ok - ng) > 1){
        int mid = (ok + ng) / 2;
        if(check(mid) == n + 1){
            ok = mid;
        }else{
            ng = mid;
        }
    }

    int right = ok;

    cout << right - left - 1 << endl;

    return 0;
}

Measured memory_bytes: 976
#include<iostream>
#define MAX 1<<30
using namespace std;

int main(){
  long long int sum = 0;
  long long int max = -MAX;
  long long int min = MAX;
  int n;
  cin>>n;
  while(n--){
    long long int num;
    cin>>num;
    sum += num;
    if(max < num) max = num;
    if(min > num) min = num;
  }
  cout<<min<<' '<<max<<' '<<sum<<endl;
  return 0;
}

Measured memory_bytes: 1168
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int& x : a) cin >> x;
	int ans = 0;
	for(int i = 0; i < n; i += 2){
		if (a[i] % 2 == 1) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
  int a;
  int b;
  int c;
  int d;
  
  cin >> a >> b >> c >> d;
  
  if (a + b > c + d)
    cout << "Left" << endl;
  else if (a + b == c + d)
    cout << "Balanced" << endl;
  else 
    cout << "Right" << endl;
  
  return (0);
}

Measured memory_bytes: 256
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define dloop(i,n) for(int i=n-1;i>=0;i--)
#define iii tuple<int,int,int>
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define int long long
#define ld long double
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

const int mxn = 1e5+10;
int dp[102][mxn];
int v[102],w[102];
int n;
int W;



int32_t main(){
	NINJA;
	cin >> n >> W;
	fo(i,n) cin >> w[i] >> v[i];
	fo(i,102) fo(j,mxn) dp[i][j] = inf;
	dp[0][0] = 0;
	for1(i,n){
		fo(j,mxn){
			dp[i][j] = min(dp[i][j],dp[i-1][j]);
			if(j>=v[i-1]){
				dp[i][j] = min(dp[i][j],dp[i-1][j-v[i-1]]+w[i-1]);
			}
		}
	}
	int ans = -1;
	fo(i,mxn) if(dp[n][i]<=W) ans = i;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 83324
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).expect("stdin read error");
    let mut num: i32 = buf.trim().parse().expect("parse error");

    let ans = loop {
        let end: i32 = (num as f64).sqrt() as i32;
        let mut is_prime = true;
        for i in 2..end {
            if num % i == 0 {
                is_prime = false;
            }
        }
        if is_prime {
            break num
        }
        num += 1;
    };
    println!("{}", ans);
}

Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
const int N = 3919;
#define int long long
const int mod = 998244353;
int n,s;
int a[N];
int f[N];
signed main(){
	scanf("%lld%lld",&n,&s);
	for(int i = 1;i<=n;i++) scanf("%lld",&a[i]);
	f[0] = 1;
	for(int i = 1;i<=n;i++)
		for(int j = s;j>=0;j--){
			f[j]*=2;
			if(j>=a[i]) f[j] += f[j-a[i]];
			f[j]%=mod;
		}
	printf("%lld",f[s]);
	return 0;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
long long a,b,c;
int main() 
{
    cin>>a>>b>>c;
    if(a%2==0||b%2==0||c%2==0) {
        cout<<0;
        return 0;
    }
    cout<<min(min(a*b,a*c),b*c);
    return 0;
}

Measured memory_bytes: 256
s = input()

s1 = s[0:(len(s) - 1) // 2]
s2 = s[(len(s) + 1) // 2 : len(s)]

if s == s[::-1] and s1 == s1[::-1] and s2 == s2[::-1]:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, k;
    cin >> n >> k;
    map<int, ll> mp;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        mp[a] += b;
    }
    int ans = 0;
    for (auto&& p : mp) {
        k -= p.se;
        if (k <= 0) {
            ans = p.fi;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4224
#include <stdio.h>
 
int main() {
 
  int n,i,j;
  int card[4][13];
  int num;
  long long moji;
 
  scanf("%d", &n);
 
  for(j=0; j<4; j++) {
  for(i=0; i<13 ;i++){
    card[j][i] = 0;
  }
  }
 
  for(i=0; i<2*n ; i++) {
    scanf("%c ",&moji);
    scanf("%d",&num);
    if(moji == 'S') {
      card[0][num-1] = 1;
    } else if(moji == 'H') {
      card[1][num-1] = 1;
    } else if(moji == 'C') {
      card[2][num-1] = 1;
    } else if(moji =='D') {
      card[3][num-1] = 1;
    }
  }
 
  for(j=1;j<=13;j++) {
    if(card[0][j-1] != 1) {
      printf("S %d\n",j);
    }
  }
  for(j=1;j<=13;j++) {
    if(card[1][j-1] != 1) {
      printf("H %d\n",j);
    }
  }
  for(j=1;j<=13;j++) {
    if(card[2][j-1] != 1) {
      printf("C %d\n",j);
    }
  }
  for(j=1;j<=13;j++) {
    if(card[3][j-1] != 1) {
      printf("D %d\n",j);
    }
  }
   return 0;
}


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

using namespace std;

int main() {
  // input
  vector <int> a(3);
  for (int i=0; i<3; i++){
    cin >> a[i];
  }

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

  int ans = a[2]*10 + a[1] +a[0];

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
 size_t strlen(const char *s);
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::vector<int> graph[10050];//graph頂点数のsize
const int N=100010;
const int P=1000000007;
long long int compare_int(const void *a, const void *b)
{
    return *(long long int*)a - *(long long int*)b;//a-b昇順
}
//絶対値
int ze(int a, int b){
	if(a>b){
		return a-b;
	}else{
		return b-a;
	}
}
// a^n mod 
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

//mod掛け算
long long mt(long long a, long long b, long long mod){
	return (a*b)%mod;
}

//メモ
//	cout<<(n-2)*180<<endl;
//	string s="hoge";
//	cout<<ans<<endl;
//	int  n  ,a  ,b  ,c  ,d  ,e  ,f  ;
//	cin  >>n  >>a  >>b  >>c  >>d  >>e  >>f  ;

/*
	memset(b, '\0', sizeof(b));
初期化*/


/*
	len = strlen(s);
文字列長さ*/


/*
	string s;
	s.size()
*/


/*ソート
	qsort(b, 10, sizeof(int), compare_int);
*/


/*
	char s[N];
	strlen(s)
/*
	if(  <  )puts("Yes");
	else puts("No");
*/
/*
	graph[a].push_back(b);//graph[a][i番目に入れた]==b
	graph[j].size()	//forで回すときとか

*/

int main(){
	long long int n,ans;
	cin>>n;
	ans=2*n;
	for(long long int i=1;i<1000010;i++){
		if(n%i==0){
			if(i+n/i-2<ans){
				ans=i+n/i-2;
			}
			
		}
	} 
	cout<<ans<<endl;



}

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

#define INF INT_MAX

using namespace std;

typedef long long ll;
typedef pair<string,int> pii;

int main(void){
 	cin.tie(0);
    ios::sync_with_stdio(false);
	
	int N;
	cin >> N;
	vector<int> w(N);
	for(int i = 0;i < N;i++){
		cin >> w[i];
	}

	int ans = INF;
	int asum = 0;
	int bsum = 0;
	for(int i = 0;i < N;i++){
		asum += w[i];
		bsum = 0;
		for(int j = i+1;j < N;j++){
			bsum += w[j];
		}
		if(ans > abs(bsum-asum)){
			ans = abs(bsum-asum);
		}
	}

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

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include<iomanip>
#include <fstream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <assert.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(s) (s).begin(),(s).end()
#define ITE(c) typeof((c).begin())

#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define MP(a,b) make_pair((a),(b))

using namespace std;

int  vis[128][128]; 
char dat[128][128];


int main(){
	int w, h;
	while(cin>>h>>w,w||h){
		rep(i,128){
			rep(j,128){
				vis[j][i]=0;
				dat[j][i]=0;
			}
		}
		
		rep(i,h){
			rep(j,w){
				cin>>dat[j][i];
			}
		}
		int px=0, py=0;
		while(dat[px][py]!='.'){
			if(vis[px][py]) break;
			vis[px][py]=1;
			switch(dat[px][py]){
				case '>':px++;break;
				case '<':px--;break;
				case '^':py--;break;
				case 'v':py++;break;
			}
		}
		if(vis[px][py]){
			cout<<"LOOP"<<endl;
		}else{
			cout<<px<<" "<<py<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1240
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;



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

  string s;
  int ans = 0;

  cin >> s;

  if(s[0] != 'A'){
    ans = 1;
  } 
  
  int f = 1;
  for(int i=1;i<s.size();i++){
    if(f == 0 && s[i] == 'C')ans = 1;
    if(1 < i && i+1 < s.size() && s[i] == 'C')f = 0;
    if(s[i] != 'C' && 'A' <= s[i] && s[i] <= 'Z')ans = 1;
  }

  if(f)ans = 1;

  if(ans){
    cout << "WA" << endl;
  } else {
    cout << "AC" << endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/
 
int main() {
    int N;
    cin >> N;
    char S[N];
    ll nums[N];
    FOR(i, 0, N) {
        char c;
        cin >> c;
        S[i] = c;
        nums[i] = 0;
    }
    ll ws = 0;
    ll es = 0;
    FOR (i, 0, N) {
        nums[i] += ws;
        nums[N - i - 1] += es;
        if (S[i] == 'W') ws++;
        if (S[N - i - 1] == 'E') es++; 
    }
    ans = N;
    FOR(i, 0, N) {
        ans = min(ans, nums[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T> >;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Kunitaka{
    template<
        typename TYPE,
        std::size_t SIZE
    >
    std::size_t array_length(const TYPE (&array)[SIZE])
    {
        return SIZE;
    }

    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; }
}
using namespace Kunitaka;
namespace Printer{
    void br(){
        cout << endl;
    }

    void loop_cnt(int i){
        cout << "i = " << i << endl;
    }

    void loop_cnt(int i, int j){
        cout << "i = " << i << ", " << "j = " << j << endl;
    }

    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T, class S>
    void print(T x, S y){
        cout << x << "," << y << endl;
    }

    template<class T, class S, class U>
    void print(T x, S y, U z){
        cout << x << "," << y << "," << z << endl;
    }

    template<class T, class S>
    void print(pair<T, S> p){
        cout << p.first << ", " << p.second << endl;
    }

    template<
        typename TYPE,
        std::size_t SIZE
    >
    void print(const TYPE (&array)[SIZE]){
        int lim = array_length(array);
        for(int i=0; i<lim; i++){
            if(i) cout << " ";
            cout << array[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<S> v){
        for(int i=0; i<v.size(); i++){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<vector<S> > vv){
        for(int i=0; i<vv.size(); i++){
            for(int j=0; j<vv[i].size(); j++){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void yesno(bool x){
        if(x) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
};
using namespace Printer;

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//


    // input
    cout << fixed << setprecision(10);

    ll K; cin >> K;
    vector<ll> ans(50);
    rep(i, 50){
        ans[i] = i;
    }
    reverse(ALL(ans));

    ll avg = K / 50;
    ll plus_one = K % 50;
    rep(i, 50){
        ans[i] += avg;
    }
    rep(i, plus_one){
        ans[i]++;
    }
    print(50);
    print(ans);
    
    return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d %d', $n, $k);
$pp = [];
for ($i = 0; $i < $n; $i++) {
	fscanf(STDIN, '%s', $p);
	$key = substr($p, 0, 1);
	if (!isset($pp[$key])) $pp[$key] = 0;
	$pp[$key]++;
}

arsort($pp);
$pp = array_values($pp);
$res = 0;
$len = count($pp);
$result = true;
while ($result) {
	arsort($pp);
	$pp = array_values($pp);
	$idx = 0;
	for ($i = 0; $i < $k; $i++) {
		$result = false;
		while ($idx < $len) {
			if ($pp[$idx] > 0) {
				$pp[$idx]--;
				$result = true;
				$idx++;
				break;
			}
			$idx++;
		}
	}
	if ($result) $res++;
}
echo $res.PHP_EOL;

Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>

int main()
{
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  for (int i = 0; i < N; i++) std::cin >> A.at(i);
  sort(A.begin(), A.end());
  int ans1 = 0, ans2 = 0;
  ans1 = A.at(N-1);
  double half = A.at(N-1)/2.0;
  for (int i = 0; i < N; i++)
  {
    if (abs(ans2 - half) > abs(A.at(i) - half))
      ans2 = A.at(i);
  }
  std::cout << ans1 << " " << ans2 << std::endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cerr<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}

int main(){
    int x,y,z,k;cin >> x >> y >> z >> k;
    vl a(x), b(y), c(z);
    rep(i,x) cin >> a[i];
    rep(i,y) cin >> b[i];
    rep(i,z) cin >> c[i];

    sort(a.begin(), a.begin() + x, greater<ll>());
    sort(b.begin(), b.begin() + y, greater<ll>());
    sort(c.begin(), c.begin() + z, greater<ll>());

    vl ans;
    rep(i,x){
        rep(j,y){
            rep(l,z){
                if((i+1)*(j+1)*(l+1) <= k) ans.emplace_back(a[i] + b[j] + c[l]);
                else break;
            }
        }
    }
    sort(ans.begin(), ans.end(), greater<ll>());
    rep(i,k) cout << ans[i] << "\n";
}

Measured memory_bytes: 1404
#include <stdio.h>
int main(){
  int t,m,f,r;
  while(1){
    scanf("%d %d %d",&m,&f,&r);
    if(m!=-1&&f!=-1){
      t=m+f;
      if(t>=80){
	printf("A\n");
      }
      if(t>=65&&t<80){
	printf("B\n");
      }
      if(t>=50&&t<65){
	printf("C\n");
      }
      if(t<50&&t>=30){
	if(r>=50){
	  printf("C\n");
	}
	else{
	  printf("D\n");
	}
}
      if(t<30){
	printf("F\n");
      }}
    else{      
if(m==-1&&f==-1&&r==-1){
	break;
 }
 else{
   printf("F\n");
 }
    }
  }      
return 0;
  
}

Measured memory_bytes: 1012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
ll facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main(){
  int n;
  cin >> n;
  int a[n];
  int p[n],q[n];
  for(int i = 0;i<n;++i) a[i] = 1;
  for(int i = 0;i<n;++i) cin >> p[i];
  for(int i = 0;i<n;++i) cin >> q[i];
  
  int sum = 0;
  ll pp = 0,pq = 0;
  ll ans = 0;
  for(int i = 0;i<n-1;++i){
    sum = 0;
    for(int j = 0;j<p[i];++j) sum += a[j];
    a[p[i]-1]--;
    pp += (sum-1)*facctorialMethod(n-1-i);
  }
  
  for(int i = 0;i<n;++i) a[i] = 1;
  for(int i = 0;i<n-1;++i){
    sum = 0;
    for(int j = 0;j<q[i];++j) sum += a[j];
    a[q[i]-1]--;
    pq += (sum-1)*facctorialMethod(n-1-i);
  }
  
  ans = abs(pp - pq);
  cout << ans << endl;  
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input!{c:[chars; 2]};
    //debug!(c);

    if c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0] {
        println!("YES");
    } else {
        println!("NO");
    }

}

Measured memory_bytes: 4352
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#define ll long long
using namespace std;

const ll mod=1e9+7;

ll ksm(ll b,ll p)
{
	ll ans=1;
	while(p>0)
    {
        if(p%2==1)
            ans=(ans*b)%mod;
        b=(b*b)%mod;
        p/=2;
    }
    return ans;
}

ll f[500010],anss;

int main()
{
	int n,k;
	cin>>n>>k;
	for(ll i=k;i>=1;i--)
	{
		ll cnt=k/i;
		f[i]=ksm(cnt,n);
		for(ll j=2*i;j<=k;j+=i)
		{
			f[i]=(f[i]+mod-f[j])%mod;
		}
	}
	for(ll i=1;i<=k;i++)
	{
		anss+=f[i]*i;
		anss%=mod;
	}
	cout<<anss;
        return 0;
}

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

int main()
{
	int n = 0;
	std::cin >> n;

	std::vector<unsigned long long> list;
	unsigned long long input = 0;
	for (int i = 0; i < n; ++i) {
		std::cin >> input;
		list.push_back(input);
	}
	int li = 0, ri = n-1;
	unsigned long long lt = 0, rt = 0;
	while (li <= ri) {
		if (lt <= rt) {
			lt += list[li++];
		}
		else {
			rt += list[ri--];
		}
	}
	unsigned long long sa = (rt >= lt) ? rt - lt : lt - rt;
	std::cout << sa;
	return 0;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
#define For(i, a, b)  for(int i = a, _b = b; i <= _b; ++i)
#define Ford(i, a, b) for(int i = a, _b = b; i >= _b; --i)
#define FileName      "test"
#define ll            long long
#define ld            long double
#define ull           unsigned long long
#define Print(x)      cerr << #x << "is " << x << '\n';
#define pb            push_back
#define X             first
#define Y             second
//#define Karma

using namespace std;

template<typename T> inline void Cin(T &x)
{
    char c;
    T sign = 1;
    x = 0;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        if (c == '-') sign = -1;
    for (; c >= '0' && c <= '9'; c = getchar())
        x = x * 10 + c - '0';
    x *= sign;
}
template <typename T> inline void Out(T x) {if(x > 9) Out(x / 10); putchar(x % 10 + '0');}
template <typename T> inline void Cout(T x, char c) {if(x < 0) putchar('-'); x = abs(x); Out(x); putchar(c);}
template <typename T, typename... Args> inline void Cin(T& a, Args&... args) {Cin(a);Cin(args...);}
template <typename T, typename... Args> inline void Cout(T a, char c, Args... args) {Cout(a, c);Cout(args...);}

typedef pair<int, int> pii;
typedef pair<ll, int> plli;
const int N = 1e6 + 7;
const int M = 1e5 + 7;
const ld pi = 3.1415926535897;

ll h[N], f[N], n;

void Enter()
{
     Cin(n);
     For(i, 1, n) Cin(h[i]);
}

void Solve()
{
     f[1] = 0;
     f[2] = abs(h[2] - h[1]);
     For(i, 3, n)
     {
         f[i] = min(f[i - 1] + abs(h[i] - h[i - 1]), f[i - 2] + abs(h[i] - h[i - 2]));
     }
     cout << f[n];
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef Karma
    freopen(FileName".inp", "r", stdin);
    freopen(FileName".out", "w", stdout);
#endif // Karma

    Enter();
    Solve();

    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i=0;i<N;i++)cin >> S.at(i);

    int cnt_ac=0, cnt_wa=0, cnt_tle=0, cnt_re=0;
    for(int i=0;i<N;i++){
        if(S.at(i)=="AC"){
            cnt_ac++;
        }
        else if(S.at(i)=="WA"){
            cnt_wa++;
        }
        else if(S.at(i)=="TLE"){
            cnt_tle++;
        }
        else if(S.at(i)=="RE"){
            cnt_re++;
        }
    }

    cout << "AC x " << cnt_ac << endl;
    cout << "WA x " << cnt_wa << endl;
    cout << "TLE x " << cnt_tle << endl;
    cout << "RE x " << cnt_re << endl;
}

Measured memory_bytes: 6420
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(args...) do { cout << "DEBUG: " << #args << " -> "; err(args); } while (0)
#else
#define dbg(...)
#endif
void err() { cout << endl; }
template<template<typename...> class T, typename t, typename... Args>
void err(T<t> a, Args... args) { for (auto x: a) cout << x << ' '; err(args...); }
template<typename T, typename... Args>
void err(T a, Args... args) { cout << a << ' '; err(args...); }
// -----------------------------------------------------------------------------

const int N = 200;
int n, a[N];

int main() {
    cin >> n;
    FOR (i, 0, n) cin >> a[i];
    int s = accumulate(a, a + n, 0);
    int idx = 0;
    FOR (i, 0, n) {
        if (abs(a[i] * n - s) < abs(a[idx] * n - s))
            idx = i;
    }
    cout << idx << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <math.h>
#include <unordered_map>
#include <numeric>
#include <sstream>
using namespace std;

int main()
{
	int a,b;

	cin >> a >> b;

	if(b%a==0){
		cout << a+b << endl;
	}else{
		cout << b-a << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>
#include <iostream>
#include <set> 
void lookvec(std::vector<int> v);
void dim2vec(std::vector<std::vector<int> > G);
void lookset(std::set<int> s);
void sortvec(std::vector<int> &v);
void reversevec(std::vector<int> &v);

int main(){

	int i, j, m, spe, start, end, centor;//speは初項+末項の意,start,endは初項と末項の意味
	//printf("input a positive integer:");
	m = 1;
	while (m!=0){
		scanf("%d", &m);
		if (m == 0) break;
		int count = 0;


		for (i = m; i > 1; i--){
			if (i % 2 == 1){
				if (m%i == 0) {
					centor = m / i;
					start = centor - (i / 2);
					end = centor + (i / 2);
					if (start > 0)count++;
				}
			}
			else {
				if (m % (i / 2) == 0 && m%i != 0){//m%(i/2)は割り切れないといけないが、m%iは割り切れてはいけない。
					centor = m / i;//小数点は切り捨てられて中心のうち小さい方になります
					start = centor - (i / 2) + 1;
					end = centor + (i / 2);

					if (start > 0)count++;
				}
			}
			/*
			for(j=i+1;j<=m+1;j++){
			if (m==sum_mid(i, j))printf("%d..%d=%d\n",i,j,sum_mid(i, j));
			//mとsumの値が等しい時のみ出力するように変更した

			}*/


		}
		printf("%d\n", count);
	}
	return 0;
}
	

//vectorの中身をみる関数
void lookvec(std::vector<int> v){
	printf("{");
	{for (int i = 0; i<v.size(); i++) printf("%d,", v[i]); }
	printf("}\n");
}

//二次元vectorの中身をみる関数
void dim2vec(std::vector<std::vector<int> > G){
	int i, j;
	for (i = 0; i < G.size(); i++){
		printf("{");
		for (j = 0; j < G[i].size(); j++){
			printf("%d", G[i][j]);
			if (j != G[i].size() - 1) printf(",");
		}
		printf("}\n");
	}
}

//setの中身を見る関数
void lookset(std::set<int> s){
	std::set< int >::iterator pos = s.begin();//先頭の要素を取得する
	while (pos != s.end()){//最後の要素に達するまでループ
		printf("%d,", *pos);//値を表示

		pos++;//一つ進める
	}
	printf("\n");
}
void sortvec(std::vector<int> &v){
	std::sort(v.begin(), v.end());
}
void reversevec(std::vector<int> &v){
	std::sort(v.begin(), v.end(), std::greater<int>());//降順ソート
}


Measured memory_bytes: 1192
#include <iostream>

using namespace std;

int digit(int n){
    int keta = 0;

    while(n > 0){
        n /= 10;
        keta++;
    }

    return keta;

}

int main(){
    int n,count = 0;

    cin >> n;

    for(int i = 1;i <= n;i++){
        if(digit(i) % 2 != 0)
            count++;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	String str;
	int pos;
	
	private TreeSet<Integer> solve(List<TreeSet<Integer>> list , List<Character> oplist){
		TreeSet<Integer> res = new TreeSet<Integer>();
		int len = list.size();
		if( len <= 1){
			return list.get(0);
		}
		for(int i = 1; i < len; i++){
			//(list) 0 to i , i to len 
			
			TreeSet<Integer> left = solve(list.subList(0, i), oplist.subList(0, i-1));
			TreeSet<Integer> right = solve(list.subList(i, len), oplist.subList(i, len-1));
			char nowOp = oplist.get(i-1);
			for(int l: left){
				for(int r: right){
					switch(nowOp){
					case '+':
						res.add(l + r);
						break;
					case '-':
						res.add(l - r);
						break;
					case '*':
						res.add(l * r);
						break;
					case '/':
						if(r != 0) {
							res.add(l / r);
						}
						break;
					default :
						//error
						int temp = 1/0;
					}
				}
			}
		}
		return res;
	}
		
	
	private TreeSet<Integer> exp() {
		//System.out.println(str);
		//char first = str.charAt(0);
		//int len = str.length();
//		if(first == '('){
//			String temp = str.substring(1,len-1);
//			return exp(temp);
//		}
		ArrayList<TreeSet<Integer>> al = new ArrayList<TreeSet<Integer>>();
		ArrayList<Character> oplist = new ArrayList<Character>();
		TreeSet<Integer> res = fact();
		al.add(res);
		while(true){
			char op = str.charAt(pos);
			if(op == '+'|| op == '-' ||op == '*'|| op == '/'){
				TreeSet<Integer> old = res;
				pos++;
				res = fact();
				al.add(res);
				oplist.add(op);
			}
			else break;
		}
		//calc

		return solve(al, oplist);
	}
	
	private TreeSet<Integer> fact() {
		TreeSet<Integer> res = new TreeSet<Integer>();
		if(Character.isDigit(str.charAt(pos))){
			int t = str.charAt(pos) - '0';
			pos++;
			while(Character.isDigit(str.charAt(pos))){
				t = t * 10 + (str.charAt(pos) - '0');
				pos++;
			}
			
			res.add(t);
			return res;
		}
		else if(str.charAt(pos) =='('){
			pos++;
			res = exp();
			pos++;
			return res;
		}
		return res;
	}

	private void doit() {
		Scanner sc = new Scanner(System.in);
		while(true){
			str = sc.next() + "#";
			if(str.equals("##")) break;
			pos = 0;
			TreeSet<Integer> res = exp();
			//System.out.println(res);
			System.out.println(res.size());
		}
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 13000
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

a = int(arr_data[0][0])
b = int(arr_data[0][1])
c = int(arr_data[0][2])

if a==b and a==c:
    
    print(1)
    
elif a==b or a==c or b==c:
    
    print(2)
    
else:

    print(3)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;
vector<int> check;
int main() {
    int n,m;
    cin >> n >> m;
    if(n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a+b==c||a+c==b||b+c==a){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

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

int main(){
	long long int N,A,B,n,a;
	cin >> N >> A >> B;
	n=N/(A+B);
	a=N%(A+B);

	if(a>=A){
		cout << (n*A+A) << endl;
	}else{
		cout << (n*A+a) << endl;
	}

	return 0;
}


Measured memory_bytes: 384
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val N = scanner.nextLong()
    val dList = arrayListOf<Long>()
    (1..N).forEach {
        dList.add(scanner.nextLong())
    }
    dList.sort()
    dList.reverse()
  //  println(dList)
    var cur = dList[0]
    var count = 1
    for (d in dList){
        if(cur>d){
            count++
            cur=d
        }
    }
    println(count)

}

Measured memory_bytes: 29600
#include<iostream>
#include<fstream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<math.h>

#define FIO ios_base::sync_with_stdio(0);  cin.tie(0);
#define PI 3.14159265358979323846
#define mod 1000000007
#define ll long long
#define vll vector<long long>  

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

// Used to traverse in any STL container with iterators
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

// Find whether element is present in given container or not
#define present(container, element) (container.find(element) != container.end())

// Finds whether element in present container is present in vector or not
#define cpresent(container, element) (find(all(container),element) != container.end())

using namespace std;

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    FIO
    
    int n,k;
    cin>>n>>k;
    int arr[n];
    int dp[n], count, tmp;
    for(int i=0;i<n;i++)cin>>arr[i];
    dp[0]=0;
    for(int i=1;i<n;i++){
        count = k;
        tmp = INT_MAX;
        for(int j=i-1;j>=0 && count>0;j--){
            tmp = min(tmp, dp[j]+ abs(arr[i] - arr[j]));
            count--;
        }
        dp[i]= tmp;
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std;
main(){
int i,j,k,l,n;
char s1[10000],s2[10000];
while(cin>>s1>>s2){
  k=strlen(s1);
  j=strlen(s2);
  for(i=0;i<j;i++){
  cout<<s1[i]<<s2[i];
  }
if(k>j) cout<<s1[k-1];
cout<<endl;
} return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n,i,j,cnt,m;
    scanf("%d",&n);
    int a[n],b[n];
    for(i=1; i<=n; i++){
        scanf("%d",&a[i]);
        b[i] = 0;
    }

    cnt = 0, m = 0;

    for(i = n; i >= 1; i--){
        for(j = 2; i * j <= n; j++){
            if(b[i*j] == 1 ){
            cnt++;
            }
        }
        if(cnt % 2 == a[i]){
            b[i] = 0;
        }else{
            b[i] = 1;
            m++;
        }
        cnt = 0;
    }


    printf("%d\n",m);
    for(i=1; i<=n; i++){
    if(b[i] == 1)    printf("%d ",i);
        }

    return 0;
}

Measured memory_bytes: 2432
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<Integer, Integer> even = new HashMap<>();
		Map<Integer, Integer> odd = new HashMap<>();
		for(int i = 0; i < N; i++) {
			int num = sc.nextInt();
			Map<Integer, Integer> mp = null;
			if(i % 2 == 0) {
				mp = even;
			}else {
				mp = odd;
			}
			if(mp.containsKey(num)) {
				mp.put(num, mp.get(num) + 1);
			}else {
				mp.put(num, 1);
			}
		}
		int even_g_num = 0;
		int even_g_cnt = 0;
		int even_g_sec_num = 0;
		int even_g_sec_cnt = 0;
		int odd_g_num = 0;
		int odd_g_cnt = 0;
		int odd_g_sec_num = 0;
		int odd_g_sec_cnt = 0;
		for(int i : even.keySet()) {
			int cnt = even.get(i);
			if(cnt > even_g_cnt) {
				even_g_sec_num = even_g_num;
				even_g_sec_cnt = even_g_cnt;
				even_g_num = i;
				even_g_cnt = cnt;
			}else if(even_g_sec_cnt < cnt) {
				even_g_sec_num = i;
				even_g_sec_cnt = cnt;
			}
		}
		for(int i : odd.keySet()) {
			int cnt = odd.get(i);
			if(cnt > odd_g_cnt) {
				odd_g_sec_num = odd_g_num;
				odd_g_sec_cnt = odd_g_cnt;
				odd_g_num = i;
				odd_g_cnt = cnt;

			}else if(odd_g_sec_cnt < cnt) {
				odd_g_sec_num = i;
				odd_g_sec_cnt = cnt;
			}
		}
		if(even_g_num == odd_g_num) {
			System.out.println(Math.min(N -(even_g_cnt + odd_g_sec_cnt), N - (odd_g_cnt + even_g_sec_cnt)));
		}else {
			System.out.println(N - (even_g_cnt + odd_g_cnt));
		}

	}

}


Measured memory_bytes: 63200
#include <stdio.h>
#include <string.h>
#include <ctype.h>

#define WSIZE 32
#define TSIZE 1024

int main(void) {
  int i, cnt = 0;
  char W[WSIZE] = {0}, T[TSIZE] = {0};

  scanf("%s", W);
  // change to upper case
  for (i = 0; W[i] != '\0'; i++)
    W[i] = toupper(W[i]);

  for (;;) {
    scanf("%s", T);
    if (!strcmp(T, "END_OF_TEXT"))
      break;
    // change to upper case
    for (i = 0; T[i] != '\0'; i++)
      T[i] = toupper(T[i]);
    // compare T with W
    if (strcmp(T, W) == 0)
      cnt++;
  }

  printf("%d\n", cnt);
  return 0;
}

Measured memory_bytes: 548