akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#ifdef LOCAL
#include<debug.h>
#else
#define db(...) 21
#endif
#define sz(a) (int)a.size()
#define found(m,x) ((m).find(x)!=(m).end())
#define uset unordered_set
#define umap unordered_map
#define a(x) x.begin(),x.end()
#define fo(i,n) for(int i=0;i<(int)n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<=(int)n:i>=(int)n;k<n?i++:i--)
#define input(v,n) fo(i,n)cin>>v[i]
using vi = vector<int>;
using vpi = vector<pair<int,int>>;
using pi = pair<int,int>;

const int nax = 1e5+7;
const int mod = 1e9+7; //1e9+2667 :: 0xcf : inf, 0xc0 -inf
const int inf = numeric_limits<int> :: max() - (int)9e6;
// ===================== MANASH =================== //

int n;

void test() {

      cin >> n;
      map<int,int> m;
      int sum = 0;
      fo(i,n) {
            int t;
            cin >> t;
            sum += t;
            m[t]++;
      }
      int q;
      cin >> q;
      fo(_,q) {
            int b,c;
            cin >> b >> c;
            int fre = m[b];
            sum -= b*fre;
            sum += c*fre;
            m.erase(b);
            m[c] += fre;
            cout << sum << '\n';
      }

}

signed main() {

      ios_base :: sync_with_stdio(false);
      cin.tie(NULL);

      #ifdef LOCAL
      freopen("input.txt","r",stdin);
      #endif

      int T = 1;
      //cin >> T;
      while(T--) {
            test();
            cout << "\n";
      }
      return 0;

}

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl '\n'

int main()
{
   
    string s,t;
    cin>>s>>t;
    ffor(i,0,sz(s))
    {
        if(s[i]!=t[i])
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    
    return 0;
}



Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	ll n;
	cin >> n;
	
	if(n % 2){
		cout << 0 << endl;
		return 0;
	}
	
	ll s1 = 0;
	
	ll p = 10;
	while(n / p >= 1){
		s1 += n / p;
		p *= 5;
	}
	
	cout << s1 << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

	    Scanner sc = new Scanner(System.in);
	    String S = sc.next();
	    char[] s = new char[3];

	    for (int i = 0; i < 3; i++) {
	    	s[i] = S.charAt(i);
	    }

	    if (s[0] == s[1] && s[0] == s[2]) {
	    	System.out.println("No");
	    } else {
	    	System.out.println("Yes");
	    }
	}
}

Measured memory_bytes: 22868
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Iterator;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		int[] a = new int[1000000];
		int end = 0;
		int findex=0;
		int m = 100000;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		a[0]=Integer.parseInt(str);
		
		
		for(int i=0; i<a.length-1 ;i++){
			if (a[i]==1){
				end += 1;
				if(end==2){
					findex=i;
					break;
				}
			}
			if (a[i]%2 == 0){
				a[i+1]=a[i]/2;
			}
			else {
				a[i+1]=a[i]*3+1;
			}
		}
		
		for(int i=0; i<m; i++){
			for(int j=i+1; j<m; j++){
				if (a[i]==a[j]){
					m = j;
				}
			}
		}
		System.out.println(m+1);
	}
}

Measured memory_bytes: 25812
#include <bits/stdc++.h>
#define int long long
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define per(i,r,l) for(int i=r;i>=l;i--)
#define IMAX 0x3f3f3f3f
#define LLMAX 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef double db;
inline int read() {
  int x=0,f=1;
  char c=getchar();
  while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
  while(isdigit(c)){x=x*10+c-'0';c=getchar();}
  return x*f;
}
ll n,k,ans;
signed main() {
  n=read(),k=read();
  ans=min(n%k,k-(n%k));
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pi;
int n;
long long mod = 998244353;
vector<pi>seg;
long long sum(vector<long long> &tree, int i) {
    long long ans = 0;
    while (i > 0) {
        ans += tree[i];
        i -= (i & -i);
    }
    return ans;
}
void update(vector<long long> &tree, int i, long long diff) {
    while (i < tree.size()) {
        tree[i] += diff;
        i += (i & -i);
    }
}
int main(){
	vector<long long>tree(600000,0);
	int k;
	cin>>n>>k;
	while(k--){
		int a,b;
		cin>>a>>b;
		seg.push_back(pi(a,b));
	}
	update(tree,n,1);
	for(int i=n-1; i>=1; i--){
		long long ret = 0;
		for(int j=0; j<seg.size(); j++){
			int start = i+seg[j].first;
			int fin = i+seg[j].second;
			ret+=sum(tree,fin)-sum(tree,start-1);
			ret%=mod;
		}
		update(tree,i,ret);
	}
	cout<<sum(tree,1);
}

Measured memory_bytes: 7824
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

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


  vector<int> a(n+1, 0);

  for(int i=0; i<n; i++) {
    if (s[i] == '<') {
      a[i+1] = max(a[i+1], a[i]+1);
    }
  }

  for(int i=n; i>=0; i--) {
    if (s[i] == '>') {
      a[i] = max(a[i], a[i+1]+1);
    }
  }

  // for(int i=0; i<n+1; i++) {
  //   cerr << a[i] << " ";
  // }
  // cerr << endl;

  long long sum = 0;
  for(int i=0; i<n+1; i++) sum += a[i];
  cout << sum << endl;

  return 0;
}

// EOF

Measured memory_bytes: 5876
use proconio::input;
     
fn main() {
    input! {
        n: i64,
    }
 
    let div = 1000000007;
    if n == 1 {
        println!("0");
    } else {
        println!("{}", expo(n, div));
    }
}
 
fn expo(time: i64, div: i64) -> i64 {
    let mut ans10 = 1;
    let mut ans9  = 1;
    let mut ans8  = 1;
    for _ in 0..time {
        ans10 *= 10;
        ans10 %= div;
        ans9 *= 9;
        ans9 %= div;
        ans8 *= 8;
        ans8 %= div;
    }
    let mut ans = (ans10 - ans9 - ans9 + ans8) % div;
    if ans < 0 { ans += 1000000007; }
    ans
}


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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int d, n;
    cin >> d >> n;

    // 処理
    int base = pow(100, d);
    int ans  = base * n;

    // n=100の時だけn+1にする。n=100なので割り切れるため。
    if ((ans / (int)pow(100, d)) % 100 == 0) {
        ans = base * (n + 1);
    }

    // 出力
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
int n;
int main(){
	scanf("%d",&n);
	if(n==1<<(31-__builtin_clz(n)))return puts("No"),0;
	puts("Yes");
	printf("%d %d\n%d 3\n3 1\n1 2\n2 %d\n",1+n,2+n,2+n,3+n);
	for(int i=4;i+1<=n;i+=2)
	printf("%d %d\n%d 1\n1 %d\n%d %d\n",i+n,i+1,i+1,i,i,i+1+n);
	if(n%2==0){
		int x=__builtin_ctz(n);
		printf("%d %d\n%d %d\n",n,1<<x,n^1^(1<<x),2*n);
	}
	return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if (a>12) cout << b << endl;
    else if (a>5) cout << b/2 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t LL;
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int MOD=1e9+7;
int main()
{
  LL A=0,N,x;
  vector<LL> bit(60,0);
  cin>>N;
  while(cin>>x)rep(i,60)bit.at(i)+=x>>i&1;
  rep(i,60)A=fmod(A+fmod((N-bit.at(i))*bit.at(i)%MOD*pow(2,i),MOD),MOD);
  return cout<<A<<endl,0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n,m,g[101][101],w[1<<15],dp[1<<15][101];
int main()
{
	scanf("%d%d",&n,&m);int sum=0;for(int i=1;i<=m;++i){int a,b,c;scanf("%d%d%d",&a,&b,&c);g[a][b]=g[b][a]=c;sum+=c;}
	for(int i=0;i<(1<<n);++i)for(int j=1;j<=n;++j)if(i&(1<<j-1))for(int k=j+1;k<=n;++k)if(i&(1<<k-1))w[i]+=g[j][k];
	memset(dp,-1,sizeof(dp));for(int i=1;i<(1<<n);i+=2)dp[i][1]=w[i];
	for(int i=0;i<(1<<n);++i)
	{
		for(int j=1;j<=n;++j)if((i&(1<<j-1))&&~dp[i][j])
		{
			int tmp=(~i)&((1<<n)-1);
			for(int l=1;l<=n;++l)if((tmp&(1<<l-1))&&g[l][j])dp[i|(1<<l-1)][l]=max(dp[i|(1<<l-1)][l],dp[i][j]+g[l][j]);
			for(int k=tmp;k;k=(k-1)&tmp)dp[i|k][j]=max(dp[i|k][j],dp[i][j]+w[k|(1<<j-1)]);
		}
	}
	printf("%d\n",sum-dp[(1<<n)-1][n]);return 0;
}

Measured memory_bytes: 13184
#include<bits/stdc++.h>
using namespace std;
using Int = long long;


template<Int MOD = 1000000007>
struct Mod{
  Int prev=0;
  vector<Int> fact,inv,finv;
  Mod(){}
  Mod(Int n){init(n);}
  
  Int pow(Int x,Int n){
    Int res=1;
    while(n){
      if(n&1) (res*=x)%=MOD;
      (x*=x)%=MOD;
      n>>=1;
    }
    return res;
  }
  
  Int inverse(Int a){
    return pow(a,MOD-2);
  }
  
  void init(Int n){
    if(prev>=n) return;
    prev=n;
    fact=inv=finv=vector<Int>(n);
    
    fact[0]=1;
    for(Int i=1;i<n;i++)
      fact[i]=(fact[i-1]*i)%MOD;
    
    inv[1]=1;
    for(Int i=2;i<n;i++)
      inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD;
    
    finv[0]=1;
    for(Int i=1;i<n;i++)
      finv[i]=finv[i-1]*inv[i]%MOD;
  }
  
  Int comb(Int n,Int k){
    Int res=1;
    for(Int i=0;i<k;i++){
      res*=(n-i)%MOD;
      res%=MOD;
      res*=inverse(i+1);
      res%=MOD;
    }
    return res;
  }
  
  //only for prime MOD
  Int C(Int n,Int k){
    if(k<0||k>n) return 0;
    return fact[n]*finv[k]%MOD*finv[n-k]%MOD;
  }
  
  Int P(int n,int k){
    if(k<0||k>n) return 0;
    return fact[n]*finv[n-k]%MOD;    
  }

  Int H(Int n,Int k){
    return C(n+k-1,n);
  }

  Int S(Int n,Int k){
    Int res=0;
    for(Int i=1;i<=k;i++){
      Int tmp=C(k,i)*pow(i,n)%MOD;
      if((k-i)&1) res+=MOD-tmp;
      else res+=tmp;
      res%=MOD;
    }
    res=res*finv[k]%MOD;
    return res;
  }
  
  Int B(Int n,Int k){
    Int res=0;
    for(Int j=1;j<=k;j++){
      res+=S(n,j);
      res%=MOD;
    }
    return res;
  }
  
  Int montmort(Int n){
    Int res=0,rinv=1;
    for(Int k=2;k<=n;k++){
      rinv=rinv*inverse(k)%MOD;
      if(k%2) res+MOD-rinv;
      else res+=rinv;
      res%=MOD;
    }
    for(Int i=1;i<=n;i++) res=res*i%MOD;
    return res;
  }
  
  // calculate P(t) from given points in [0,N]
  Int LagrangePolynomial(vector<Int> &y,Int t){
    Int n=y.size()-1;
    init(n+1);
    Int num=1;
    for(Int i=0;i<=n;i++)
      num=num*((t-i)%MOD)%MOD;
    Int res=0;
    for(Int i=0;i<=n;i++){
      Int tmp=(y[i]*num%MOD)*inverse((t-i)%MOD)%MOD;
      tmp=tmp*finv[i]%MOD;
      tmp=tmp*finv[n-i]%MOD;
      if((n-i)&1) tmp=MOD-tmp;
      res=(res+tmp)%MOD;
    }
    return res;
  }
};


//INSERT ABOVE HERE
signed main(){
  const Int MOD = 1e9+7;
  Mod<MOD> mod(2e5);
  Int n,k;
  cin>>n>>k;
  cout<<mod.P(k,n)<<endl;
  return 0;
}



Measured memory_bytes: 7468
H,W = [int(x) for x in input().split()]

image = []
for i in range(H):
    image.append(input())

framed_image = []
for i in range(H+2):
    if i == 0 or i == H+1:
        framed_image.append("#"*(W+2))
    else:
        framed_image.append("#"+image[0]+"#")
        del image[0]

for line in framed_image:
    print(line)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
long int a[100],b[100],c[100],d[100],result[100];
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    
	int N,M;
	cin >> N;
    cin >> M;
    for(int i=0;i<N;i++){
        cin >> a[i];
        cin >> b[i];
    }
    for(int i=0;i<M;i++){
        cin >> c[i];
        cin >> d[i];
    }
    for(int i=0;i<N;i++){
        long int min=1000000000;
        for(int j=0;j<M;j++){
            long int dist=abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(min>dist){
                min=dist;
                result[i]=j+1;
            }
        }
    }
    for(int i=0;i<N;i++){
	    cout << result[i] << "\n";
    }
}

Measured memory_bytes: 256
var
	S:String;
	N,id:Longint;
	ans,L,R:int64;
begin
	readln(S);
	N:=length(S);
	id:=1;
	ans:=0;
	while id<=N do begin
		L:=0;
		R:=0;
		while(id<=N)and(S[id]='<')do begin
			inc(id);
			inc(L);
		end;
		while(id<=N)and(S[id]='>')do begin
			inc(id);
			inc(R);
		end;
		inc(ans,L*(L+1)div 2+R*(R+1)div 2);
		if L<R then dec(ans,L)else dec(ans,R);
	end;
	writeln(ans);
end.


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

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

void init() {}

void dfs(int i, int res, vector<int> v, const vector<int> &goal, int &ans) {
    if (i == v.size()) {
        ans = min(ans, res);
        return;
    }
    int n = v.size();
    int d = (goal[i] - v[i] + 10000) % 10;
    if (d == 0) {
        dfs(i + 1, res, v, goal, ans);
    } else {
        FOR(j, 1, n - i + 1) {
            vector<int> nxt = v;
            FOR(k, i, i + j) { nxt[k] += d; }
            dfs(i + 1, res + 1, nxt, goal, ans);
        }
    }
}

bool solve() {
    int N;
    cin >> N;
    if (N == 0) return false;
    string S, T;
    cin >> S >> T;
    vector<int> v(N);
    REP(i, N) {
        int d = T[i] - S[i] + 10;
        d %= 10;
        v[i] = d;
    }
    vector<int> ini(N, 0);
    int ans = N;
    dfs(0, 0, ini, v, ans);
    cout << ans << endl;

    return true;
}
signed main() {
    init();
    while (solve())
        ;
}


Measured memory_bytes: 3076
#include <iostream>

#define MOD 1000000007
#define NMAX 100005
using namespace std;

typedef long long ll;
ll p[2 * NMAX], inv[2 * NMAX];

ll _pow(ll baze, ll pw){
    ll rez = 1, im = baze;
    while(pw){
        if(pw & 1){
            rez *= im;
            rez %= MOD;
        }

        im *= im;
        im %= MOD;
        pw >>= 1;
    }

    return rez;
}

ll comb(ll n, ll m){
    return ((p[n] * inv[m]) % MOD * inv[n - m]) % MOD;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m, a, b;
    cin >> n >> m >> a >> b;

    p[0] = inv[0] = 1;
    for(int i = 1; i <= n + m; ++i){
        p[i] = 1LL * p[i - 1] * i % MOD;
        inv[i] = _pow(p[i], MOD - 2);
    }

    ll rez = 0;
    for(int j = b + 1; j <= m; ++j){
        long long prod = (comb(n - a + j - 2, n - a - 1) * comb(a + m - j - 1, a - 1)) % MOD;
        rez += prod;
        rez %= MOD;
    }

    cout << rez << '\n';
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    string s;
    cin>>s;
    int test=0;
    int i=0;
    while(i<n)
    {
        char c=s[i];
        while(i<n&&s[i]==c)
            i++;
        test++;
    }
    cout<<test<<endl;
    
    return 0;   
}


 
 


Measured memory_bytes: 512
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#define N 110000
using namespace std;
int n,a[N];
bool cmp(int x,int y)
{
	if(x>y) return 1;
	return 0;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++)
		if(a[i+1]<i+1)
		{
			int bo=0,j;
			if((a[i]-i)%2) bo=1;
			for(j=i;j;j++) if(a[j+1]!=i) break;
			if((j-i)%2) bo=1;
			if(bo) printf("First\n");
			else printf("Second\n");
			return 0;
		}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int a,b,c,d,e,f;
    vector<int> w(1,0),s(1,0);
    cin>>a>>b>>c>>d>>e>>f;
    for(int i=0;a*i*100<=f;i++){
        for(int j=0;a*i*100+b*j*100<=f;j++){
            w.push_back(a*i*100+b*j*100);
        }
    }
    for(int i=0;c*i<=f;i++){
        for(int j=0;c*i+d*j<=f;j++){
            s.push_back(c*i+d*j);
        }
    }
    float m=-1;
    int rsw=0,rs=0;
    for(auto i : w){
        for(auto j : s){
            if(j*100.0f/(j+i)>m && i+j<=f && i*e/100>=j){
                m=j*100.0f/(j+i);
                rsw=i+j;
                rs=j;
            }
        }
    }
    cout<<rsw<<" "<<rs;
}


Measured memory_bytes: 1400
import math
import heapq
from bisect import bisect_right, bisect_left
from collections import defaultdict, Counter
import itertools
import sys
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7
INF = float("inf")


def main():
    n = int(input())
    print(math.ceil(n/2)/n)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static char[][] f;
	static int H, W;
	static char FILL = '!';

	public static void main(String[] args) {
		int N = sc.nextInt();
		for (int i = 0; i < N; ++i) {
			H = sc.nextInt();
			W = sc.nextInt();
			f = new char[H][W];
			for (int j = 0; j < H; ++j) {
				f[j] = sc.next().toCharArray();
			}
			System.out.println(solve() ? "SUSPICIOUS" : "SAFE");
		}
	}

	static boolean solve() {
		int[] t = new int[26];
		int[] b = new int[26];
		int[] l = new int[26];
		int[] r = new int[26];
		boolean[] exist = new boolean[26];
		Arrays.fill(t, 99);
		Arrays.fill(b, -1);
		Arrays.fill(l, 99);
		Arrays.fill(r, -1);
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				if (Character.isUpperCase(f[i][j])) {
					int pos = f[i][j] - 'A';
					t[pos] = Math.min(t[pos], i);
					b[pos] = Math.max(b[pos], i);
					l[pos] = Math.min(l[pos], j);
					r[pos] = Math.max(r[pos], j);
					exist[pos] = true;
				}
			}
		}
		for (int i = 0; i < 8; ++i) {
			for (int j = 0; j < 26; ++j) {
				if (!exist[j]) continue;
				boolean ok = true;
				for (int row = t[j]; row <= b[j]; ++row) {
					for (int col = l[j]; col <= r[j]; ++col) {
						if (f[row][col] != (char) (j + 'A') && f[row][col] != FILL) ok = false;
					}
				}
				if (ok) {
					for (int row = t[j]; row <= b[j]; ++row) {
						for (int col = l[j]; col <= r[j]; ++col) {
							f[row][col] = FILL;
						}
					}
					exist[j] = false;
				}
			}
		}
		for (int i = 0; i < 26; ++i) {
			if (exist[i]) return true;
		}
		return false;
	}
}

Measured memory_bytes: 38584
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long long ll;
int main()
{
  ll k;
  cin >> k;
  ll t = 7, res = 0;
  for (int i = 0; i < k; ++i)
  {
    res += t%k;
    t = t*10%k;
    res = res % k;
    if (res == 0)
    {
      cout << i+1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

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

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

int main()
{
  int n;
  cin >> n;
  while(n--){
    int y, m, d, ans = 0;
    cin >> y >> m >> d;
    
    for(int i = m ; i <= 10 ; i++){
      if(i == m){
	if(y%3 == 0 || i%2 == 1){
	  ans += 20 - d + 1;
	}else{
	  ans += 19 - d + 1;
	}
      }else{
	if(y%3 == 0 || i%2 == 1){
	  ans += 20;
	}else{
	  ans += 19;
	}
      }
    }
    
    for(int i = y+1 ; i < 1000 ; i++){
      if(i%3==0){
	ans += 20*10;
      }else{
	ans += 19*5 + 20*5;
      }
    }
    cout << ans << '\n';
  }
}

Measured memory_bytes: 1160
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Security.Cryptography;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var n = long.Parse(spl[0]);
        var a = long.Parse(spl[1]);
        var b = long.Parse(spl[2]);

        var aa = Math.Min(a,b);
        var bb = Math.Max(a,b);
        
        if((bb-aa) %2 == 0) return (bb-aa) / 2;

        var ue = aa - 1 <= n - bb;
        long c = 0;
        if (ue) {
            c += aa - 1;
            c++;
            bb -= c + 1;
            aa -= c;
            return c + (bb - aa) / 2;
        } else {
            c += n - bb;
            c++;
            aa += c + 1;
            bb += c;
            return c + (bb - aa) / 2;
        }
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

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

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#include <complex>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

// 許容する誤差ε
#define EPS (1e-10)
// 2つのスカラーが等しいかどうか
#define EQ(a,b) (abs((a)-(b)) < EPS)
// 2つのベクトルが等しいかどうか
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )

using namespace std;

typedef complex<double> P;
typedef pair<double,double> PP;
// 反時計順にソート
bool cmp (P a, P b )
{
	double arga = arg (a );
	double argb = arg (b );
	if (!EQ (arga, argb ) ){
		return arga < argb;
	} // end if

	return abs (a ) > abs (b );
}
/*
bool cmp (P a, P b )
{
	double cosa = a.real()/abs (a );		
	double sina = a.imag()/abs (a );
	double cosb = b.real()/abs (b );
	double sinb = b.imag()/abs (b );
	if (sina >= 0. && sinb >= 0. ){
		return cosa > cosb;
	}else
	if (sina < 0. && sinb < 0. ){
		return cosa < cosb;
	}else
	if (sina >= 0. && sinb < 0. ){
		return sina > sinb;
	}else
	if (sina < 0. && sinb >= 0. ){
		return sina < sinb;
	} // end if

	return abs (a ) > abs (b );
}
*/
// 外積 (cross product) : a×b = |a||b|sinΘ
double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.EPRB", "r", stdin );
	int n;
	while (scanf ("%d", &n ), n ){
		vector<P> p (n );
		rep (i, n ){
			double x, y;
			scanf ("%lf,%lf", &x, &y );
			p[i].real() = x; p[i].imag() = y;
		} // end rep
										
		// 原点回りに反時計回りにソート
		sort (ALL (p ), cmp );
/*
		rep (i, n ){
			cerr << '(' << p[i].real() << ',' << p[i].imag() << ')' << endl;
		} // end rep
*/
		set<PP> convex_hull; convex_hull.clear();
		for (int i = 0; i < n; i++ ){
			for (int j = i+1; j < n; j++ ){
				bool ok = true;
				rep (k, n ){
					if (k == i || k == j ) continue;
					if (cross (p[j] - p[i], p[k] - p[i] ) > 0. ) continue;
					ok = false;
					break;
				} // end rep
				if (ok ){
					convex_hull.insert (PP (p[i].real(), p[i].imag() ) );
					convex_hull.insert (PP (p[j].real(), p[j].imag() ) );
				} // end if
			} // end for
		} // end for
		printf ("%d\n", n - (int)convex_hull.size() );
/*
		set<PP>::iterator it = convex_hull.begin();
		for (; it != convex_hull.end(); it++ ){
			cerr << '(' << (*it).first << ',' << (*it).second << ')' << endl;
		} // end for
*/		
	} // end loop

		
	return 0;
}

Measured memory_bytes: 1296
#include <iostream>
#include <cmath>

constexpr double PI = 3.14159265;

int main()
{
    int side1, side2, deg;
    std::cin >> side1 >> side2 >> deg;

    double rad = deg * PI / 180;

    double area = side1 * side2 * sin(rad) / 2;
    double side3 = sqrt(pow(side1, 2) + pow(side2, 2)
                        - 2 * side1 * side2 * cos(rad));
    double round = side1 + side2 + side3;
    double height = side2 * sin(rad);

    std::cout << std::fixed << area << " "
              << round << " "
              << height << std::endl;

    return 0;
}

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

const double pi = 3.14159265358979323846;
const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n, k; cin >> n >> k;
	ll ans = 0;
	ll tmp = n/k;
	ans += tmp * tmp * tmp;
	if(k % 2 == 0){
		vector<ll> res(k, 0);
		for(int i = 1; i <= n; i++){
			res.at(i % k)++;
		}
		for(int i = 1; i < k; i++){ //一つの数のあまりがiの時
			if(k - 2 * i == 0){
				ans += res.at(i) * res.at(k-i) * res.at(k-i);
			}
		}
	}
	cout << ans << endl;
} 

Measured memory_bytes: 1792
import java.util.*;
import java.io.*;
import java.math.*;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();


        if (X == 2) {
            System.out.println(2);
            return;
        }
        if (X % 2 == 0) X += 1;

        int num = 1000000;
        boolean isPrime = false;
        for (int i = X; i <= num; i += 2) {
            for (int j = 2; j * j <= i; j++) {
                if (i % j == 0) {
                    isPrime = false;
                    break;
                }
                isPrime = true;
            }
            if (isPrime) {
                System.out.println(i);
                break;
            }
        }

    }

}


Measured memory_bytes: 22228
#include <stdio.h>

int main() {
	int x,y,tmp;

	scanf("%d %d", &x, &y);
	if(x < y) {
		tmp = x;
		x = y;
		y = tmp;
	 }

	while (y != 0) {
		tmp = y;
		y = x % y;
		x = tmp;
	}
	printf("%d\n", x);

	return 0;
}

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

int main() {
	int n;
	cin >> n;
	int a[n], b[n];
	for (int i = 0; i < n; i++) cin >> a[i];
	bool bo = true;
	for (int i = 0; i < n; i++) {
		cin >> b[i];
		bo &= (a[i] == b[i]);
	}
	if (bo) {
		cout << 0 << endl;
		return 0;
	}
	vector<vector<ll> > dp(50, vector<ll>(51, 0));
	for (int i = 0; i <= 50; i++) {
		dp[0][i] = 1ll << i;
	}
	for (int i = 1; i < 50; i++) {
		for (int j = 0; j < 51; j++) {
			dp[i][j] = dp[i - 1][j] | dp[i][j%i];
		}
		bo = true;
		for (int j = 0; j < n; j++) bo &= (bool) (dp[i][a[j]] & (1ll << b[j]));
		if (bo) {
			vector<int> pre;
			pre.push_back(i);
			ll ans = 1ll << i;
			for (int k = i - 1; k >= 0; k--) {
				for (int j = 0; j < 51; j++) {
					for (int l = 0; l < pre.size(); l++)
						dp[k][j] |= dp[k][j%pre[l]];
				}
				bo = true;
				for (int j = 0; j < n; j++) bo &= (bool) (dp[k][a[j]] & (1ll << b[j]));
				if (!bo) {
					pre.push_back(++k);
					//cout << pre.size() << " " << k << endl;
					ans += 1ll << k;
				}
			}
			cout << ans << endl; 
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string S;
    cin>>S;
    int N=S.size();
    if(N%2!=0){
        cout<<"No"<<endl;
        return 0;
    }
    for(int i=0;i<N;++i){
         if(i%2==0&&S[i]!='h'){
             cout<<"No"<<endl;
             return 0;
         }
         if(i%2!=0&&S[i]!='i'){
             cout<<"No"<<endl;
             return 0;
         }
    }
    cout<<"Yes"<<endl;
}


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

struct edge{int to, cost;};
typedef pair<int, int> P;

const int MAX_N = 100001;
vector<edge> G[MAX_N];
int n;
ll d[MAX_N];

void dijkstra(int s){
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d+n, INF);
	d[s] = 0;
	que.push(P(0, s));

	while(!que.empty()){
		P p = que.top(); que.pop();
		int v = p.second;
		if(d[v] < p.first) continue;
		for(int i=0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > d[v] + e.cost){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main(void) {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n;

	for(int i=0; i<n-1; i++){
		int a, b, c;
		cin >> a >> b >> c;

		a--;
		b--;
		G[a].pb(edge{b, c});
		G[b].pb(edge{a, c});
	}

	int q, k;
	cin >> q >> k;
	k--;

	dijkstra(k);


	for(int i=0; i<q; i++){
		int x, y;
		cin >> x >> y;
		x--;
		y--;

		cout << d[x] + d[y] << endl;
	}


	
	return 0;
}


Measured memory_bytes: 8820
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<long long, long long>
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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 std;
using ll = long long;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);

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

  int n; cin >> n;

  int all = 1;
  int odd = 1;
  rep(i, n) {
    int a; cin >> a;
    if (a%2 == 0 && a > 0) {
      odd *= 2;
    }
    if (a > 0) {
      all *= 3;
    } else {
      all *= 2;
    }
  }

  cout << all-odd << endl;
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<int> vec[10];
  rep(i, n) vec[s[i]-'0'].push_back(i);
  int ans = 0;
  rep(i, 10) {
    if (vec[i].begin() == vec[i].end()) continue;
    int idi = vec[i][0];
    rep(j, 10) {
      auto itr = upper_bound(vec[j].begin(), vec[j].end(), idi);
      if (itr == vec[j].end()) continue;
      int idj = vec[j][distance(vec[j].begin(), itr)];
      rep(k, 10) {
        if(upper_bound(vec[k].begin(), vec[k].end(), idj) != vec[k].end()) ++ans;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(void){
    int H, W, h, w;
    scanf("%d %d", &H, &W);
    h=2;
    w=0;
    while(H!=0 || W!=0){
        while(w<W){
            printf("#");
            w++;
        }
        printf("\n");
        w=2;
        while(h<H){
            printf("#");
            while(w<W){
                printf(".");
                w++;
            }
            printf("#\n");
            w=2;
            h++;
        }
        w=0;
        while(w<W){
            printf("#");
            w++;
        }
        printf("\n\n");
        scanf("%d %d", &H, &W);
        w=0;
        h=2;
    }
    return 0;  
}



Measured memory_bytes: 2036
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Applicative
import Control.Monad.Fix
import Control.Monad.ST
import Data.Int
import Data.Foldable
import Data.List
import Data.Graph
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Data.ByteString.Internal (accursedUnutterablePerformIO)
import qualified Data.ByteString.Char8 as B
import Debug.Trace

solve :: Int -> Int -> VU.Vector Int -> VU.Vector (Int, Int) -> Int
solve !n !m !pn !xys = length
  $ filter (\(!i) -> findUF ufTree i == findUF ufTree (pn VU.! i)) [0 .. n - 1]
  where ufTree = VU.foldl' (\(!uf) (!x, !y) -> unionUF uf x y) (new n) xys

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  (n, m) <-
    (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> B.getLine
  pn  <- VU.map (\n -> n - 1) . VU.unfoldrN n readInt <$> B.getLine
  xys <-
    VU.replicateM m
    $   (\vec -> (vec VU.! 0 - 1, vec VU.! 1 - 1))
    .   VU.unfoldrN 2 readInt
    <$> B.getLine
  print $ solve n m pn xys


----------------
-- Union-Find
----------------

uread :: VUM.Unbox a => Int -> VUM.IOVector a -> a
uread !i !v = accursedUnutterablePerformIO $ VUM.unsafeRead v i

uwrite :: VUM.Unbox a => Int -> a -> VUM.IOVector a -> VUM.IOVector a
uwrite !i !a !v =
  accursedUnutterablePerformIO $ VUM.unsafeWrite v i a >> return v

uswap :: VUM.Unbox a => Int -> Int -> VUM.IOVector a -> VUM.IOVector a
uswap !i !j !v =
  accursedUnutterablePerformIO $ VUM.unsafeSwap v i j >> return v

ufreeze :: VUM.Unbox a => VUM.IOVector a -> VU.Vector a
ufreeze !v = accursedUnutterablePerformIO $ VU.unsafeFreeze v

uthaw :: VUM.Unbox a => VU.Vector a -> VUM.IOVector a
uthaw !v = accursedUnutterablePerformIO $ VU.unsafeThaw v

data Pair a b = Pair !a !b
data UnionFind = UnionFind (Pair (VUM.IOVector Int) (VUM.IOVector Int))

new :: Int -> UnionFind
new !n = UnionFind $ Pair (uthaw $ VU.fromList [0 .. n - 1])
                          (accursedUnutterablePerformIO $ VUM.replicate n 1)

findUF :: UnionFind -> Int -> Int
findUF !(UnionFind (Pair elems _)) !k = fix
  (\f (!elems, !k, !path) -> case uread k elems of
    n | n == k -> foldl' (\(!acc) !p -> uwrite p n acc) elems path `seq` n
    n          -> f (elems, n, n : path)
  )
  (elems, k, [k])

sizeUF :: UnionFind -> Int -> Int
sizeUF !uf@(UnionFind (Pair _ sizes)) !i =
  let j = findUF uf i in j `seq` uread j sizes

unionUF :: UnionFind -> Int -> Int -> UnionFind
unionUF !uf@(UnionFind (Pair elem sizes)) !i !j =
  let pi = findUF uf i
      pj = findUF uf j
      si = uread pi sizes
      sj = uread pj sizes
  in  if pi == pj
        then uf
        else
          let (t1, t2) = if si < sj then (pi, pj) else (pj, pi)
          in  UnionFind $ Pair (uwrite t1 t2 elem) (uwrite t2 (si + sj) sizes)


Measured memory_bytes: 7804
#include<iostream>
#include<string>
#include <cmath>
#define MOD 1e9+7
using namespace std;
typedef long long ll;

int main(){

int sx,sy,tx,ty;

cin >> sx >> sy >> tx >> ty;

int x = tx - sx;
int y = ty - sy;

for(int i = 0; i < x; i++) cout << "R";
for(int i = 0; i < y; i++) cout << "U";
for(int i = 0; i < x; i++) cout << "L";
for(int i = 0; i <= y; i++) cout << "D";

for(int i = 0; i <= x; i++) cout << "R";
for(int i = 0; i <= y; i++) cout << "U";

cout << "LU";

for(int i = 0; i <= x; i++) cout << "L";
for(int i = 0; i <= y; i++) cout << "D";

cout << "R" << endl;

return 0;
}

Measured memory_bytes: 256
// E - Double Factorial
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
	ll N; cin>>N;
	ll n = N/2, m = log(n)/log(5), ans = 0;
	if(N%2) ans = 0;
	else for(ll w=5, i=0; i<m; ++i, w*=5) ans += n/w;
	cout<< ans <<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  	cin.tie(0);
  	ios::sync_with_stdio(false);
  	int n, m;
  	cin >> n >> m;
  	if (m <= n) {
      	cout << 0 << endl;
      	return 0;
    }
  	vector<int> x(m);
  	for (int i = 0; i < m; i++) cin >> x[i];
  	sort(x.begin(), x.end());
  	vector<long long> d(m-1);
  	for (int i = 1; i < m; i++) d[i-1] = x[i]-x[i-1];
  	sort(d.begin(), d.end());
  	long long ans = 0;
  	for (int i = 0; i < m-1-(n-1); i++) ans += d[i];
  	cout << ans << endl;
  	return 0;
}

Measured memory_bytes: 1408
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str1 = sc.next();
    String str2 = sc.next();
    StringBuilder sb = new StringBuilder();
    for(int i = 0; i < str1.length()+str2.length(); i++){
      if(i % 2 == 0){
        System.out.print(str1.charAt(i/2));
      }else{
        System.out.print(str2.charAt(i/2));
      }
    }
    System.out.println();
  }
}

Measured memory_bytes: 21716
var
    s:longint;
    ch:char;
begin
    while not eoln do
        begin
            read(ch);
            if ch='C' then s:=1;
            if (s=1)and(ch='F') then 
                begin
                    writeln('Yes');
                    halt;
                end;
        end;
    writeln('No');
end.

Measured memory_bytes: 128
def solve():
    N,M=map(int,input().split())
    ans=[0]*N
    for i in range(M):
        a,b=map(int,input().split())
        ans[a-1]+=1
        ans[b-1]+=1
    for i in range(N):
        print(ans[i])

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3060
/*
By Snickeen
*/
#include<bits/stdc++.h>
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <limits.h>
#include <math.h>
#include <algorithm>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <string>
#include <vector>
#include <bitset>
#include <functional>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double db;
typedef long double ldb;
#define rep(i,a,b) for(i=a;i<b;i++)
#define repu(i,a,b) for(i=a;i<=b;i++)
#define repd(i,a,b) for(i=a;i>=b;i--)
#define repc(i,a,b,c) for(i=a;i<b;i+=c)
#define repcu(i,a,b,c) for(i=a;i<=b;i+=c)
#define repcd(i,a,b,c) for(i=a;i>=b;i-=c)
#define FIN freopen("input.in","r",stdin)
#define FOUT freopen("output.out","w",stdout)
#define CC(a) memset(a,0,sizeof(a))
#define MST(a,b) memset(a,b,sizeof(a))
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define VI vector<int>
#define VL vector<LL>
#define VII vector<PII >
#define VLL vector<PLL >
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define FF first
#define SS second

template<typename T>inline void gn(T &x){
	x=0;T f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
template<typename T>inline void gt(T x){
	if(!x)return;
	gt(x/10);putchar(x%10+'0');
}
 
const LL MAXN=1e5+10;
LL t,n,m,ans;
LL MOD=1e9+7,inf=0x1f1f1f1f;
db eps=1e-5;

LL u,v;
char a[MAXN];

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	LL i,j,k,l,ca=0;
	cin>>a;
	l=strlen(a);
	rep(i,0,l)u+=a[i]=='g';
	v=l-u;
	ans=(u-v)/2;
	cout<<ans<<endl; 
	return 0;
}

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

void printArray(int A[], int N) {
    for (int i = 0; i < N; i++) {
        if (i != 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

void selectionSort(int A[], int N) {
    int n_swaps = 0;
    for (int i = 0; i <= N - 1; i++) {
        int min_j = i;
        for (int j = i; j <= N - 1; j++) {
            if (A[j] < A[min_j]) min_j = j;
        }
        swap(A[i], A[min_j]);
        if (i != min_j) n_swaps++;
    }
    printArray(A, N);
    cout << n_swaps << endl;
}

int main() {
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++) cin >> A[i];

    selectionSort(A, N);
}



Measured memory_bytes: 3104
#include <iostream>
#include <string.h>
#include <algorithm>
#define MAX 50000
using namespace std;

int dp[MAX + 1];
int prm[MAX + 1];

int main()
{
    for (int i = 2; i <= MAX; i++) prm[i] = 1;
    for	(int i = 2; i <= MAX; i++)
        for (int j = 2;	j * i <= MAX; j++)
            prm[i * j] = 0;
    int n;
    for (int i = 0; i <= MAX; i++)
        for (int j = i; j + i<= MAX; j++)
            if (prm[i] == 1 && prm[j] == 1) dp[i + j]++;
    while (cin >> n, n > 0) {
        cout << dp[n] << endl;
    }

    return 0;
}

Measured memory_bytes: 1548
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int Dmax = D.Max();
		int[][] Mp = new int[Dmax + 1][];
		for(int i=0;i<=Dmax;i++){
			Mp[i] = new int[N];
		}
		
		for(int i=0;i<Q;i++){
			Mp[D[i]][V[i]] = Math.Max(Mp[D[i]][V[i]],i + 1);
		}
		
		int[] newest = new int[N];
		for(int i=0;i<N;i++){
			for(int j=0;j<=Dmax;j++) newest[i] = Math.Max(newest[i],Mp[j][i]);
		}
		
		for(int t=1;t<=Dmax;t++){
			for(int tt=t;tt<=Dmax;tt++){
				int[] nxt = new int[N];
				for(int i=0;i<M;i++){
					int a = A[i];
					int b = B[i];
					nxt[a] = Math.Max(nxt[a],Mp[tt][b]);
					nxt[b] = Math.Max(nxt[b],Mp[tt][a]);
				}
				Mp[tt] = nxt;
			}
			for(int i=0;i<N;i++){
				for(int j=0;j<=Dmax;j++) newest[i] = Math.Max(newest[i],Mp[j][i]);
			}
		}
		
		int[] ans = new int[N];
		for(int i=0;i<N;i++){
			ans[i] = newest[i] == 0 ? 0 : C[newest[i] - 1];
		}
		
		Console.WriteLine(String.Join("\n",ans));
		
		
	}
	int N,M,Q;
	int[] A,B;
	int[] V,D,C;
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1];
		A = new int[M];
		B = new int[M];
		for(int i=0;i<M;i++){
			d = ria();
			A[i] = d[0] - 1;
			B[i] = d[1] - 1;
		}
		Q = ri();
		V = new int[Q];
		D = new int[Q];
		C = new int[Q];
		for(int i=0;i<Q;i++){
			d = ria();
			V[i] = d[0] - 1;
			D[i] = d[1];
			C[i] = d[2];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 37392
import java.util.*;
import java.math.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(Math.max(a*b,Math.max(a+b,a-b)));
    }
}


Measured memory_bytes: 22864
#include<iostream>
#include<cstdio>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
int main(){
    double r;
    cin >>r;
    
    double area;
    double length;
    
    area = M_PI * r *r;
    length = M_PI * r * 2;
    
    printf("%f %f", area, length);
    
    return 0;
}


Measured memory_bytes: 3192
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    int n;
    while(cin >> n,n){
        vector<int> len(n);
        rep(i,n){
            string s;cin >> s;
            len[i]=s.size();
        }
        for(int i=0;i<n;i++){
            int now = i;
            int sum=0;
            while(sum<5){
                if(now==n)break;
                sum+=len[now];
                now++;
            }
            if(now==n||sum!=5)continue;
            
            sum=0;
            while(sum<7){
                if(now==n)break;
                sum+=len[now];
                now++;
            }
            if(now==n||sum!=7)continue;
            
            sum=0;
            while(sum<5){
                if(now==n)break;
                sum+=len[now];
                now++;
            }
            if(now==n||sum!=5)continue;
            
            sum=0;
            while(sum<7){
                if(now==n)break;
                sum+=len[now];
                now++;
            }
            if(now==n||sum!=7)continue;

            sum=0;
            while(sum<7){
                if(now==n)break;
                sum+=len[now];
                now++;
            }
            if(sum!=7)continue;
            cout << i+1 << endl;
            break;
        }

    }
    return 0;
}


Measured memory_bytes: 3008
def abc092_c():
    n = int(input())
    a = [0] + list(map(int, input().split())) + [0]
    money = 0
    for i in range(n + 1):
        money += abs(a[i] - a[i + 1])
    for i in range(1, n+1):
        print(money - abs(a[i] - a[i - 1]) - abs(a[i] - a[i + 1]) + abs(a[i + 1] - a[i - 1]))


abc092_c()

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

int main(){
    int k,n,t, gap=0;
    std::vector<int> a;
    std::cin>>k>>n>>t;
    a.push_back(t);
    for(int i=1;i<n;++i){
        std::cin>>t;
        gap=std::max(gap, std::abs(a.back()-t));
        a.push_back(t);
    }

    std::cout<<k-std::max(gap, (k-a.back()+a[0]));
    return 0;
}

Measured memory_bytes: 1400