akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>PP;
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
char mp[22][22];

int bit[]={1,2,4,8,16,32,64,128,256,512,1024};
int W,H,X[11],Y[11],cnt,cst[11][11];

void cst_cal(){
	for(int i=0;i<=cnt;i++){
		int tmp[22][22];
		for(int j=0;j<22*22;j++)tmp[j/22][j%22]=-1;
		queue<P>Q;
		Q.push(P(X[i],Y[i]));
		tmp[X[i]][Y[i]]=0;
		while(!Q.empty()){
			P p=Q.front();Q.pop();
			int x=p.first,y=p.second;
			if('.'!=mp[x][y])cst[i][mp[x][y]-'0']=tmp[x][y];
			for(int j=0;j<4;j++){
				if(mp[x+dx[j]][y+dy[j]]!='x' && tmp[x+dx[j]][y+dy[j]]<0){
					tmp[x+dx[j]][y+dy[j]]=tmp[x][y]+1;
					Q.push(P(x+dx[j],y+dy[j]));
				}
			}
		}
	}
}


int main(){
	
	while(cin>>W>>H,W){
		cnt=0;
		for(int i=0;i<11*11;i++)cst[i/11][i%11]=114514;
		for(int i=0;i<22*22;i++)mp[i/22][i%22]='x';
		for(int i=1;i<=H;i++){
			for(int j=1;j<=W;j++){
				cin>>mp[j][i];
				if(mp[j][i]=='o'){
					X[0]=j;
					Y[0]=i;
					mp[j][i]='0';
				}
				if(mp[j][i]=='*'){
					cnt++;
					X[cnt]=j;
					Y[cnt]=i;
					mp[j][i]='0'+cnt;
				}
			}
		}
		cst_cal();
		
		map<P,int>M;
		priority_queue<PP, vector<PP>,greater<PP> >Q;
		Q.push(PP(1,P(1,0)));//スコア/ビット/場所
		int ans=0;
		while(!Q.empty()){
			PP p=Q.top();Q.pop();
			if(M[p.second]!=0)continue;
			M[p.second]=p.first;
			if(p.second.first==bit[cnt]*2-1){
				ans=p.first;
				break;
			}
			for(int i=0;i<=cnt;i++){
				if(M[P(bit[i]|p.second.first,i)]==0 && cst[p.second.second][i]!=114514){
					Q.push(PP(p.first+cst[p.second.second][i],P(bit[i]|p.second.first,i)));
				}
			}
		}
		cout<<ans-1<<endl;
	}
	
	return 0;
}


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

BASYO = [int(i) for i in input().split()]

M = int(input())

KOMA = [int(i) for i in input().split()]

for i in range(M):
    
    X = KOMA[i] - 1
    
    if (N != X + 1 and 1 == BASYO[X+1] - BASYO[X]) or BASYO[X] == 2019:
        pass
    
    else:
        BASYO[X] += 1
for i in range(N):
    print(BASYO[i])


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

using namespace std;

bool is[1000010];
vector<int> p;

void build() {
    for (int i = 2; i < 1000010; ++i)  
        for (int j = i + i; j < 1000010; j += i)
            is[j] = 1;
    for (int i = 2; i < 1000010; ++i)
        if(!is[i]) p.push_back(i);
}
long long ans;
void f(long long n) {
    long long id = 0, pf = p[id];
    while(pf * pf <= n) {
        bool flag = 0;
        while(n % pf == 0) {
            n /= pf;
            flag = 1;
        }
        ans += flag;
        pf = p[++id];
    }
    ans += n != 1;
}
int main() {
    build();
    ans = 1;
    long long a,b;
    cin >> a >> b;
    long long g = __gcd(a,b);
    f(g);
    cout << ans << "\n";
    return 0;
}


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

int main() {
  int N, M, P, X, Y=0;
  cin >> N;
  vector<int> T(N);
  for (int i=0; i<N; i++){
    cin >> T.at(i);
    Y=Y+T.at(i);
  }
  cin >> M;
  for (int j=0; j<M; j++){
    cin >> P >> X;
    cout << Y-T.at(P-1)+X << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  long n = sc.nextLong();
	  int m = sc.nextInt();
	  for(int i = 0; i < m; i++) {
		  n -= sc.nextLong();
		  if(n < 0) {
			  n = -1;
			  break;
		  }
	  }
	  System.out.println(n);
	}
}

Measured memory_bytes: 46008
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=100000+19;

char opt[N],s[5];
ll pre[N],suf[N],ans;
int A[N];
int n,las;

int main(){
	n=IN();
	A[1]=IN();
	opt[1]='+';
	For(i,2,n+1){
		scanf("%s",s);
		opt[i]=s[0];
		A[i]=IN();
	}
	opt[++n]='-';A[n]=0;
	opt[++n]='-';A[n]=0;
	For(i,1,n+1){
		if (opt[i]=='+') pre[i]=pre[i-1]+A[i];else pre[i]=pre[i-1]-A[i];
	}
	for (int i=n;i;i--) suf[i]=suf[i+1]+A[i];
	ans=pre[n];
	For(i,1,n+1) if (opt[i]=='-'){
		if (las){
			ans=max(ans,pre[las-1]-(suf[las]-suf[i])+suf[i]);
		}
		las=i;
	}
	cout<<ans<<endl;
}

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

 



int main() {
	int N ;
	string S;
	cin >> N >> S;
	int ans = 0;
	string tmp;
	rep(2, N) {
		tmp.push_back(S[i - 2]);
		tmp.push_back(S[i - 1]);
		tmp.push_back(S[i]);
		if (tmp == "ABC") {
			ans++;
		}
		tmp.clear();
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

// {a, {b, c}} : a = gcd(p, q) = bp + cq
pair<ll,pair<ll,ll>> ext_gcd(ll p, ll q) {
  if (q == 0) return {p, {1, 0}};
  auto r = ext_gcd(q, p%q);
  return {r.first, {r.second.second, r.second.first - p/q*r.second.second}};
}



int main(){
  int a, b;

  cin >> a >> b;

  auto res = ext_gcd(a, b);
  
  cout << res.second.first << " " << res.second.second << endl;
    
  
  return 0;
}





Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define VI vector<int>
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60 ; const ll mod=1e9+7 ;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------

int main(){
	ll n,a,b;
	cin  >> a >> b;
	ll k = 0;
	k = (a+b);
	if(k%2==0) cout << k/2 << endl;
	else cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 256
N, *A = STDIN.each_line.map(&:to_i)

pair = A.reduce({ pair: 0, carry: 0 }) { |memo, item|
  pair, mod = (item + memo[:carry]).divmod(2)
  carry = item.nonzero? ? mod : 0

  { pair: memo[:pair] + pair, carry: carry }
}[:pair]

puts pair


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s, t;
    cin >> s;
    t = s;
    reverse(t.begin(), t.end());
    int cnt = 0;
    for (int i = 0; i < s.length(); ++i)
        cnt += s[i] != t[i];
    cout << cnt / 2 << endl;
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    const int p = 2019;

    vector<int> modcnt(p, 0);
    int cur = 0, coef = 1;
    modcnt[cur]++;
    for (int i = 0; i < n; i++) {
        cur = (cur + coef * (s[n - i - 1] - '0') % p) % p;
        coef = coef * 10 % p;
        modcnt[cur]++;
    }

    int ans = 0;
    for (int i = 0; i < p; i++) {
        ans += modcnt[i] * (modcnt[i] - 1) / 2;
    }
    cout << ans << endl;
}


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

using namespace std;

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

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

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

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

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    double T,X;
    cin >> T >> X;
    cout << T / X << endl;



}


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

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;

void solve(){
    int n;
    cin>>n;
    cout<<n*n<<endl;
    
    return;
}

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
#ifndef ONLINE_JUDGE
   // printf("%.10f\n",1.0*clock()/CLOCKS_PER_SEC);
#endif
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = y.pow(y, n);
  Mint pow(Mint a, long long n) const {
    Mint y(1);
    Mint b(a);
    while (n > 0) {
      if (n & 1) y *= b;
      b *= b;
      n >>= 1;
    }
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return pow(a, mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= i;
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

Mint dp[3004][3004];
int main(){
  mod = 998244353;
  int N, S;
  std::cin >> N >> S;
  std::vector<int > A(N);
  for (int i=0; i<N; i++){
    std::cin >> A[i];
  }
  dp[0][0] = 1;
  for (int i=0; i<N; i++){
    for (int j=0; j<=3000; j++){
      dp[i+1][j] += Mint(2) * dp[i][j];
      //if (j==0) printf("dp[%d][%d]=%lld\n", i+1, j, dp[i+1][j].x);
      if (j+A[i]<=3000){
        dp[i+1][j+A[i]] += dp[i][j];
        //if (i+1==3 && j+A[i]==4) printf("dp[%d][%d]=%lld\n", i+1, j+A[i], dp[i+1][j+A[i]].x);
        //if (dp[i+1][j+A[i]].x>0) printf("dp[%d][%d]=%lld\n", i, j+A[i], dp[i+1][j+A[i]].x);
      }
    }
  }
  //dp[N][S]-=1;
  //printf("output dp[%d][%d]\n", N, S);
  std::cout << dp[N][S].x << std::endl;
  return 0;
}

Measured memory_bytes: 73576
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"RUDLUDR"# => "Yes",
r#"DULL"# => "No",
r#"UUUUUUUU"# => "Yes",
r#"ULURU"# => "No",
r#"RDULULDURURLRDULRLR"# => "Yes",
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        s: chars,
    }
    // println!("=--------------------");
    let even_s = (0..s.len()).filter(|i| i % 2 == 0).map(|i| s[i]).filter(|&c| c != 'R' && c != 'U' && c != 'D').collect::<Vec<char>>();
    // println!("{:?}", (0..s.len()).filter(|i| i % 2 == 0).map(|i| s[i]).collect::<Vec<char>>());
    let odd_s = (0..s.len()).filter(|i| i % 2 != 0).map(|i| s[i]).filter(|&c| c != 'L' && c != 'U' && c != 'D').collect::<Vec<char>>();
    // println!("{:?}", (0..s.len()).filter(|i| i % 2 != 0).map(|i| s[i]).collect::<Vec<char>>());

    if even_s.len() == 0 && odd_s.len() == 0 {
        "Yes"
    } else {
        "No"
    }.to_string()
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <map>
#include <cstring>
#include <algorithm>
#include <string>
#include <set>
#include <sstream>
#include <vector>
#include <queue>
#include <cmath>
using namespace std;
#define maxn 100005
int main()
{
	int x;
	cin >> x;
	if (x>=400 && x<=599) cout << "8" << endl;
	if (x>=600 && x<=799) cout << "7" << endl;
	if (x>=800 && x<=999) cout << "6" << endl;
	if (x>=1000 && x<=1199) cout << "5" << endl;
	if (x>=1200 && x<=1399) cout << "4" << endl;
	if (x>=1400 && x<=1599) cout << "3" << endl;
	if (x>=1600 && x<=1799) cout << "2" << endl;
	if (x>=1800 && x<=1999) cout << "1" << endl;
}

Measured memory_bytes: 3628
s = str(input())

if(s.count("RRR") == 1):
    print(3)
elif(s.count("RR") == 1):
    print(2)
elif(s.count("R") == 1 or s.count("RSR") == 1):
    print(1)
elif(s.count("SSS") == 1):
    print(0)


Measured memory_bytes: 80336
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define db long double
  #define PB push_back
  int32_t main()
  {         
    
    
    IOS
   
    
    int n;
    cin>>n;
    vector<int> v;
    int k=-1;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        k=max(k,x);
        v.PB(x);
    }
    
    sort(v.begin(),v.end());
    int ans=0;
    for(int i=1;i<=k;i++)
    {
        int l=upper_bound(v.begin(),v.end(),i)-v.begin();
        int g=n-l;
        
        //cout<<l<<" "<<g<<endl;
        if(l==g)
        {   
            ans++;
        }
        else if(l>g)
        {
            break;
        }
    }
    cout<<ans;
    return 0;
  }           

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  string S;
  cin >> S;
  vector<pair<char, int>> stone_count;
  stone_count.push_back(make_pair(S[0], 1));
  rep(i, S.size() - 1)
  {
    if (stone_count.back().first == S[i + 1])
      stone_count.back().second++;
    else
      stone_count.push_back(make_pair(S[i + 1], 1));
  }
  int ans = stone_count.size() - 1;
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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

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

int lcm(int a, int b)
{return a * b / gcd(a, b);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll ans = n * (n-1) /2;
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3612
import collections
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table
a = list(map(int,input().split()))

b = []
co = 0
su = 1
s = prime_decomposition(a[1])
c = collections.Counter(s)
ss = c.most_common()
i = 0
for i in range(len(ss)):
    if ss[i][1] >= a[0]:
        su *= int(ss[i][0])**(ss[i][1]//a[0])

print(su)


Measured memory_bytes: 3436
import java.util.*;
public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();
        int cnt = 0;
        while(x <= y) {
        	cnt++;
        	x = x * 2;
        }
        System.out.println(cnt);
    }

}


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

void solve()
{
    int a, b;
    cin >> a >> b;
    int ans = a + b;
    if (ans >= 24)
        ans -= 24;
    cout << ans << endl;
}

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

Measured memory_bytes: 3632
import math

def isPrime(x) :
    if x == 2 :
        return True

    if x < 2 or x % 2 == 0 :
        return False

    i = 3
    while i <= math.sqrt(x) :
        if x % i == 0 :
            return False
        i += 2

    return True


def main() :
    n = int(input())
    nums = []
    for i in range(n) :
        x = int(input())
        nums.append(x)

    print(sum(map(isPrime, nums)))


if __name__ == '__main__' :
    main()

Measured memory_bytes: 8108
#include <iostream>
#include <string>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

string s;
int cnt[26];

int main() {
	int i;
	
	cin >> s;
	rep(i, s.length()) cnt[s[i] - 'a']++;
	rep(i, 26) if (cnt[i] == 0) break;
	if (i == 26) cout << "None" << endl;
	else cout << (char)(i + 'a') << endl;
	return 0;
}

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

int main(void)
{
    int r;
    cin >> r;
    pr(r*r);
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;

signed main() {
	int N, K;
	cin >> N >> K;
	int a, b;
	vector<P>v(N);
	rep(i, N)cin >> v[i].first >> v[i].second;
	sort(v.begin(), v.end());
	int cnt = 0;
	int num;
	int i = 0;
	while (cnt < K) {
		num = v[i].first;
		cnt += v[i].second;
		i++;
	}
	cout << num;
}

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

#define maxn 63
#define maxm 63
int N, M;
char field[maxn][maxn];
char pattern[maxm][maxm];
ll rhash[maxn][maxn];
ll tmp[maxn][maxn];

void cp_hash(char a[maxn][maxn], int n){
    const ll b1 = 53;
    const ll b2 = 2503;

    ll t1 = 1;

    for(int j=0; j<M; j++) t1 *= b1;
    for(int i=0; i<n; i++){
        ll e=0;
        for(int j=0; j<M; j++) e = e*b1+a[i][j];

        for(int j=0; j+M<=n; j++){
            tmp[i][j] = e;

            if(j+M<n) e=e*b1-t1*a[i][j]+a[i][j+M];
        }
    }
    ll t2 =1;
    for(int i=0; i<M; i++) t2*=b2;
    for(int j=0; j+M<=n; j++){
        ll e=0;
        for(int i=0; i<M; i++) e=e*b2+tmp[i][j];
        for(int i=0; i+M<=n; i++){
            rhash[i][j] = e;
            if(i+M<n) e=e*b2-t2*tmp[i][j] +tmp[i+M][j];
        }
    }
}
int main(){
    scanf("%d%d", &N, &M);
    for(int i=0; i<N; i++){
        scanf("%s", field[i]);
    }
    for(int i=0; i<M; i++){
        scanf("%s", pattern[i]);
    }
    set<ll> tmplate;
    cp_hash(pattern, M);
    tmplate.insert(rhash[0][0]);
    cp_hash(field, N);
    for(int i=0; i+M<=N; i++){
        for(int j=0; j+M<=N; j++){
            tmplate.erase(rhash[i][j]);
        }
    }
    if(!tmplate.size()) printf("Yes\n");
    else printf("No\n");
    return 0;
}






Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return i
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func scanInts64(n int) []int64 {
	res := make([]int64, n)
	for i := range res {
		res[i] = scanInt64()
	}
	return res
}

func scanText() string {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Scan()
	return sc.Text()
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	a := scanInt()
	fmt.Println(a + a*a + a*a*a)
}


Measured memory_bytes: 1768
#include <iostream>
#include <vector>
#include <algorithm>

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    int N, W, H;
    cin >> N >> W >> H;
    vector<int> width(W + 1, 0);
    vector<int> height(H + 1, 0);
    REP (i, 0, N) {
        int x, y, w;
        cin >> x >> y >> w;
        int lw = max(0, x - w);
        int rw = min(W, x + w);
        int lh = max(0, y - w);
        int rh = min(H, y + w);
        width[lw]++;
        width[rw]--;
        height[lh]++;
        height[rh]--;
    }
    REP (i, 0, W) width[i + 1] += width[i];
    REP (i, 0, H) height[i + 1] += height[i];
    bool w = true, h = true;
    REP (i, 0, W) if (width[i] == 0) w = false;
    REP (i, 0, H) if (height[i] == 0) h = false;
    cout << (w || h ? "Yes" : "No") << endl;

    return 0;
}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  int a, b, n, x, y;
  string s, t, u;
  char c;
  cin >> a >> c >> b;
  if (c == '+')
    pr(a + b);
  else if (c == '-')
    pr(a - b);
  else if (c == '*')
    pr(a * b);
  else
    pr(a / b);
  return 0;
}

Measured memory_bytes: 3628
import sys
H,W=map(int,input().split())
listA=[list(input()) for i in range(H)]
start=[0,0]
while 1:  
  if start[0]!=H-1 and start[1]!=W-1 and listA[start[0]+1][start[1]]=="#" and listA[start[0]][start[1]+1]=="#":
    print("Impossible")
    sys.exit()
  if start[0]!=0 and start[1]!=0 and listA[start[0]-1][start[1]]=="#" and listA[start[0]][start[1]-1]=="#":
    print("Impossible")
    sys.exit()
  if start==[H-1,W-1]:
    print("Possible")
    sys.exit()  
  if start[0]!=H-1 and listA[start[0]+1][start[1]]=="#":
    start=[start[0]+1,start[1]]
    continue  
  if start[1]!=W-1 and listA[start[0]][start[1]+1]=="#":
    start=[start[0],start[1]+1]    
  else:
    print("Impossible")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<ll, ll, ll> T;

string s;
ll K;

int main(void){
    
    cin >> s;
    scanf("%lld", &K);
    
    int cnt = 0;
    char num = 0;
    for(int i = 0; i < s.size(); ++i){
        if(s[i] == '1') ++cnt;
        if(s[i] != '1') { num = s[i]; break; }
    }
    
    if(K <= cnt) printf("1\n");
    else printf("%c\n", num);
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define int long long

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

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

LL _pow(LL x, LL n)
{
  LL ret = 1;
  while(n > 0) {
    if(n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
}

string f(LL mask){
    string ret = "";
    bool flag = false;
    REP(i, 16){
        if(mask & (1 << i)) ret = "1" + ret;
        else ret = "0" + ret;
    }
    return ret;
}

string g(string x, string y){
    string ret = "";
    bool flag = false;
    REP(i, 16){
        if(!flag && y[i] == '1'){
            ret = ret + y[i] + x[i];
            flag = true;
        }else if(!flag && x[i] == '1'){
            ret = ret + x[i];
            flag = true;
        }else if(flag){
            ret = ret + y[i] + x[i];
        }
    }
    return (ret == "" ? "0" : ret);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    LL n;
    cin >> n;
    
    vector<LL> plus4, minus4;
    REP(i, 32){
        LL x = _pow(-2, i);
        if(x > 0) plus4.pb(x);
        else minus4.pb(-x);
    }
    
    vector<LL> mp1, mp2;
    vector<string> mpp1, mpp2;
    for(int mask = 0; mask < (1 << 16); mask++){
        LL sum = 0;
        REP(i, 16){
            if(mask & (1 << i)) sum += plus4[i];
        }
        mp1.push_back(sum);
        mpp1.push_back(f(mask));
    
        sum = 0;
        REP(i, 16){
            if(mask & (1 << i)) sum += minus4[i];
        }
        mp2.push_back(sum);
        mpp2.push_back(f(mask));
    
    }
    
    if(n >= 0){
        for(int i = 0; i < mp1.size(); i++){
            LL x = mp1[i];
            if(n > x) continue;
            auto y = lower_bound(all(mp2), (x - n));
            if(x - n != *y) continue;
            
            cout << g(mpp1[i], mpp2[y - mp2.begin()]) << endl;
            return 0;
        }
    }else{
        for(int i = 0; i < mp2.size(); i++){
            LL x = mp2[i];
            if((-n) > x) continue;
            auto y = lower_bound(all(mp1), (x - (-n)));
            if(x - (-n) != *y) continue;
            
            cout << g(mpp1[y - mp1.begin()], mpp2[i]) << endl;
            return 0;
        }
    }
}


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

int main() {
    std::string s, ret;
    int w;
    std::cin >> s >> w;

    for (int i = 0; i < s.size() / w + ((s.size() % w == 0)?0:1); i++) {
        ret += s[w*i];
    }

    std::cout << ret << std::endl;

    return 0;
}

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

int main() {
  int A, B, K;
  cin >> A >> B >> K;

  int ans = 0, cnt = 0;
  for (int i = min(A, B); i >= 1; i--) {
    if (A % i == 0 && B % i == 0) {
      cnt++;
    }
    if (cnt == K) {
      ans = i;
      break;
    }
  }

  cout << ans << endl;
}

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

typedef struct card{
    char state;
    int num;
}Card;

int my_partition(Card A[], int p, int r){
    int x = A[r].num;
    int i  = p-1;
    for(int j = p; j < r; j++){
        if(A[j].num <= x){
            i++;
            Card tmp = A[i];
            A[i] = A[j];
            A[j] = tmp;
        }
    }
    Card tmp = A[i+1];
    A[i+1] = A[r];
    A[r] = tmp;

    return i+1;
}

void quickSort(Card A[], int p, int r){
    if(p < r){
        int q = my_partition(A, p, r);
        quickSort(A, p, q-1);
        quickSort(A, q+1, r);
    }
}


void merge(Card A[], int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    vector<Card> L(n1+1), R(n2+1);   //新しく配列分の領域が必要
                                    //他のソートアルゴリズムに比べメモリが必要になる
                                    //番兵分に一つ多くの配列が必要
    rep(i, n1)
        L[i] = A[left + i];
    rep(i, n2)
        R[i] = A[mid + i];
    
    L[n1].num = INT_MAX;    //番兵
    R[n2].num = INT_MAX;    //番兵
    int i = 0;
    int j = 0;
    for(int k = left; k < right; k++){
        if(L[i].num <= R[j].num){
            A[k] = L[i];
            i++;
        }
        else{
            A[k] = R[j];
            j++;
        }
    }
}

void mergeSort(Card A[], int left, int right){
    if(left+1 < right){             //1つになるまで分割
        int mid = (left + right)/2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main()
{
    int n;
    cin >> n;
    Card quick[100000];
    Card merge[100000];
    rep(i, n){
        cin >> quick[i].state >> quick[i].num;
        merge[i] = quick[i];
    }

    quickSort(quick, 0, n-1);
    mergeSort(merge, 0, n);

    bool check = true;
    rep(i, n){
        if(merge[i].state != quick[i].state){
            check = false;
            break;
        }
    }
    if(check){
        cout << "Stable" << endl;
    }
    else{
        cout << "Not stable" << endl;
    }
    rep(i, n){
        cout << quick[i].state << " " << quick[i].num << endl;
    }

    return 0;
}


Measured memory_bytes: 5052
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793

/*ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}*/
int main (){
    int n;
    cin >> n;
    map<int,int>odds;
    map<int,int>even;
    rep(i,n){
        int v;
        cin >> v;
        if(i%2==0) odds[v]++;
        else even[v]++;
    }
    int sum=0;
    int odds_max1=0,odds_max2=0;
    int even_max1=0,even_max2=0;
    int odds_most,even_most;
    for(auto p:odds){
        sum+=p.second;
        if(p.second>odds_max1) odds_most=p.first;
        odds_max1=max(odds_max1,p.second);
    }
    for(auto p:even){
        sum+=p.second;
        if(p.second>even_max1) even_most=p.first;
        even_max1=max(even_max1,p.second);
    }
    for(auto p:odds){
        if(p.first!=odds_most) odds_max2=max(odds_max2,p.second);
    }
    for(auto p:even){
        if(p.first!=even_most) even_max2=max(even_max2,p.second);
    }
    if(odds_most!=even_most) cout << sum-odds_max1-even_max1 <<endl;
    else cout << min(sum-odds_max1-even_max2,sum-odds_max2-even_max1) <<endl;
    return 0;
}



Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>

int main() {
  size_t N, A, B;

  std::cin >> N >> A >> B;

  size_t P1=0;
  size_t P2=0;
  size_t P3=0;

  for (size_t i=0; i<N; i++) {
    size_t p;
    std::cin >> p;

    if (p > B)
      P3++;
    else if (p > A)
      P2++;
    else
      P1++;
  }

  size_t ans = std::min({P1, P2, P3});

  std::cout << ans << std::endl;

  return 0;
}


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

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    sort(a.begin(), a.end());
    auto b = a;
    b.erase(unique(b.begin(), b.end()), b.end());
    if (a == b)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 1792
N=int(input())
num=0
flag=0
for i in range(2,1000):
    if 2*N==i*(i-1):
        num=i
        flag=1
        break
if flag==0:
    print("No")
else:
    l=[[] for _ in range(num)]
    cnt=1
    for i in range(num):
        for j in range(i+1,num):
            l[i].append(cnt)
            l[j].append(cnt)
            cnt=cnt+1
    print("Yes")
    print(num)
    for i in range(num):
        print(num-1,*l[i],sep=" ")

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

int main() {
	int N, X, T, ans = 1000000;
	cin >> N >> X >> T;

	for (int i = 1; i < 1000000; i++) {
		if (X * i >= N) {
			ans = i * T;
			break;
		}
	}

	cout << ans;

	return 0;
}


//made by myself

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define mod 1000000007
ll int dp[1000][1000];
ll int sum(ll int st,ll int en,ll int *a)
{ll int d=0;
	for(ll int i=st;i<=en;i++)
		d+=a[i];
	return d;

}
ll int ans(ll int s,ll int e,ll int *a)
{if(s>=e)
	return 0;
	if(dp[s][e]!=-1)
	return dp[s][e];
dp[s][e]==INT_MAX;
for(ll int i=s;i<e;i++)
{
dp[s][e]=min(dp[s][e],ans(s,i,a)+ans(i+1,e,a)+sum(s,i,a)+sum(i+1,e,a));

}
return dp[s][e];

}
int main()
{
	
memset(dp,-1,sizeof dp);
   ll int n;
   cin>>n;
   ll int a[n];
   for(ll int i=0;i<n;i++)
   	cin>>a[i];
  ll int d=ans(0,n-1,a);
cout<<d<<endl;
}

Measured memory_bytes: 8064
#include <iostream>
#include <algorithm>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); ++i)

int s[11][10001];
int c[11][10001];
int main(void){
    int R, C;
    while(cin >> R >> C, R!=0) {
        rep(i, R) {
            rep(j, C) {
                cin >> s[i][j];
            }
        }
        int ans = 0;
        for(int bit=0; bit<(1<<(R+1)); bit++){
            rep(i, R){
                rep(j, C) {
                    c[i][j] = s[i][j];
                }
            }
            rep(i, R) {
                if(bit&(1<<i)){
                    rep(j, C) {
                        if(c[i][j]==1) c[i][j] = 0;
                        else c[i][j]=1;
                    }
                }
            }
            int sum = 0;
            rep(i, C) {
                int count = 0;
                rep(j, R) {
                    if(c[j][i]==1) count++;
                }
                sum += max(count, R-count);
            }
            ans = max(sum, ans);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1948
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int odd = 0;
        for(int i = 0; i < n; i++){
            int a = sc.nextInt();
            if(a % 2 != 0){
                odd++;
            }
        }
        System.out.println(odd%2 == 0 ? "YES" : "NO");
    }
}


class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 35540
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _
        int a,b,c; cin >> a >> b >> c;
        for(int i=1;i<b+1;i++){
        if((a*i)%b==c){
            cout << "YES" << endl;
              return 0;
            }
        }
        cout << "NO" << endl;


return 0;
}



Measured memory_bytes: 3600
n,m=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(n)]
move=[]
cnt=0
for i in range(n):
  for j in range(m):
    if arr[i][j]%2==0:
      continue
    else:
      if j!=m-1:
        arr[i][j]-=1
        arr[i][j+1]+=1
        move.append([i+1,j+1,i+1,j+1+1])
        cnt+=1
      else:
        if i!=n-1:
          arr[i][j]-=1
          arr[i+1][j]+=1
          move.append([i+1,j+1,i+1+1,j+1])
          cnt+=1
print(cnt)
for i1,j1,i2,j2 in move:
  print(i1,j1,i2,j2)

Measured memory_bytes: 30368
n, k = map(int, input().split())
a = [0 for _ in range(n)]

for i in range(k):
  j = int(input())
  b = list(map(int, input().split()))
  for k in b:
    a[k-1] = 1

cnt = 0
for k in a:
  if k == 0:
    cnt += 1

print(cnt)

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

#define pb            push_back
#define mp            make_pair
#define all(x)        x.begin(),x.end()
#define debug(X)      { cerr<<'\n'<<(#X)<<" = "<<(X)<<'\n'; }
//#define cerr if(0)cerr

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    double r;
    cin>>r;
    cout<<(double)(2*r*M_PI)<<'\n';
}



Measured memory_bytes: 3804
N = int(input())
H = list(map(int, input().split()))
I = [H[i + 1] - H[i] for i in range(N - 1)]
N = len(I)
for i in range(N):
    if I[i] >= 0:
        continue
    elif I[i] < -1:
        print('No')
        quit()
    else:
        if i == N - 1:
            continue
        for j in range(i + 1, N):
            if I[j] >= 1:
                break
            elif I[j] <= -1:
                print('No')
                quit()
            else:
                continue
print('Yes')

Measured memory_bytes: 20700
n, k = list(map(int, input().split(" ")))
x = list(map(int, input().split(" ")))

if((0 in x) == True):
    state = x.index(0)
    k -= 1
else:
    x.append(0)
    x = sorted(x)
    state = x.index(0)

ans = int(1e10)
for left in range(k+1):
    right = k - left
    if(((state - left) >= 0) and ((state + right) <= (len(x) - 1))):
        if(right > 0): tmp = -2 * x[state-left]
        else: tmp = -1 * x[state-left]
        tmp += x[state+right]
        if(ans > tmp): ans = tmp

        tmp = -1 * x[state-left]
        if(left > 0): tmp += 2 * x[state+right]
        else: tmp += x[state+right]
        if(ans > tmp): ans = tmp

print(ans)

Measured memory_bytes: 14480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll a[100005];
ll SUM = 0;
ll basis[60];
int main(){
    scanf("%d",&n);
    for (int i = 0; i < n; i++){
        scanf("%lld",&a[i]);
        SUM ^= a[i];
    }
    ll ans = 0;
    for (int i = 0; i < n; i++){
        a[i] &= (~SUM);
        for (int j = 59; j >= 0; j--){
            if ((a[i] & (1ll<<j)) == 0) continue;
            if (basis[j] == 0){
                basis[j] = a[i];
                break;
            }
            a[i] ^= basis[j];
        }
    }
    for (int i = 59; i >= 0; i--){
        if (basis[i] != 0){
            if ((ans & (1ll<<i)) == 0){
                ans ^= basis[i];
            }
        }
    }
    ans <<= 1;
    ans += SUM;
    printf("%lld",ans);
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}
 
int main() {
  ll a,b,c,k ; 
  cin >> a >> b >> c >> k;
  if(k%2==0)cout<<a-b<<endl;
  else cout<<b-a<<endl;
}
  



Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
 
#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define rep(i, x, n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define eb emplace_back
#define trav(a, x) for(auto& a: x)
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define MOD 1000000007
#define endl '\n'
#define MAX 100002
#define pii pair<int, int>
#define pll pair<long long, long long>


typedef long long int ll;
typedef unsigned long long ull;
typedef vector<int> vec;

int main(){
    fast_cin();
    ll a, b, c, k;cin>>a>>b>>c>>k;
    ll ans = 0;
    ll x=0;
    x=k;
    k-=a;
    if(k>=0){
        ans+=a;
        k-=b;
        if(k>=0){
            ans-=k;
        }
    }
    else
        ans=x;
    cout<<ans<<endl;
}

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

using namespace std;

int main(){
  int n;
  cin >> n;
  string s1;
  cin >> s1;
  string s2;
  cin >> s2;
  bool a[52];
  int size = 0;
  for(int i=0,idx=0;i<n;){
    if(s1[i]==s2[i]){
      a[size++] = true;
      i++;
    }else{
      a[size++] = false;
      i+=2;
    }
  }

  unsigned long pat = 0;
  bool pre = a[0];
  if(a[0]) pat = 3;
  else pat = 6;

  for(int i=1;i<size;++i){
    bool cur = a[i];
    if((pre&&!cur)||(pre&&cur)){
      pat = (pat*2)%1000000007;
    }else if(!pre&&!cur){
      pat = (pat*3)%1000000007;
    }
    pre = a[i];
  }
  
  cout << pat << endl;
  return 0;
}

Measured memory_bytes: 256